Jump to content
  • Advertisement
Sign in to follow this  
Storyyeller

Is there a good matrix class?

This topic is 3308 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently trying to implement a version of Whole History Rating (http://remi.coulom.free.fr/WHR/WHR.pdf), although my version will be slightly different because it is designed for a team game. Anyway, I'm not sure what to do for the matrices and vectors. Are there existing classes that are suitable, or should I attempt to write my own? All of the matrices will by tridiagonal, so ideally, the class should be able to take advantage of that and optimize it. One other question I had thought of is, if a class has an object as a member variable, for example, a std::map, can I safely assume that it has been initialized with the default constructor? My code seems to be working so far, but I don't want to accidenttally invoke undefined behavior.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Storyyeller
One other question I had thought of is, if a class has an object as a member variable, for example, a std::map, can I safely assume that it has been initialized with the default constructor?

No. Inside the body of the constructor, the member initializers for any members declared after that variable or any member functions you can assume that it's been properly constructed, but you can't assume that the constructor used was the default constructor.

Share this post


Link to post
Share on other sites
You know, when I punch "C++ matrix class" into Google I get a lot more than just Sparselib++ back.

Share this post


Link to post
Share on other sites
A matrix? Uh... try an array, it's literally what I computer matrix is.

You can have single or multi-dimensional arrays in which you can place any kind of data type in. Examples:

1D Array (1x4)
[Integer] [Integer] [Integer] [Integer]

2D Array (3x4)
[Object] [Object] [Object] [Object]
[Object] [Object] [Object] [Object]
[Object] [Object] [Object] [Object]

Maybe you get the point. ? I also assume you're using C++, here's a clicky link. And another. And yet another.

Hope I was a help, otherwise, sorry for wasting your time! :D

Share this post


Link to post
Share on other sites
Quote:
Original post by mntlinstituteflr
A matrix? Uh... try an array, it's literally what I computer matrix is.

You can have single or multi-dimensional arrays in which you can place any kind of data type in. Examples:

1D Array (1x4)
[Integer] [Integer] [Integer] [Integer]

2D Array (3x4)
[Object] [Object] [Object] [Object]
[Object] [Object] [Object] [Object]
[Object] [Object] [Object] [Object]

Maybe you get the point. ? I also assume you're using C++, here's a clicky link. And another. And yet another.

Hope I was a help, otherwise, sorry for wasting your time! :D
I'm not sure how relevant any of the above is to the stated problem. A proper matrix class is very different than a simple 1-d or 2-d array, and can include a more or less arbitrary amount of functionality (either directly or indirectly) beyond that provided by a simple array. (I'm assuming this is what the OP is looking for - a linear algebra library that includes classes for matrices and vectors, and is specifically suited to a particular application or set of applications.)

Share this post


Link to post
Share on other sites
There are a TON of C++ matrix libraries, and which one to use depends on your needs. Some of the following come to mind uBLAS, newmat, blitz++ (full fledged array library), SparseLib++ (as you found), MTL, eigen ... I'm getting tired already. What are your requirements (dense/sparse) what operations do you need? You need to give us more info if you want a thorough answer.

Share this post


Link to post
Share on other sites
The problem with an array is you can't perform many operations on it. So that's why you have matrix classes, so you can for example do things as:

m1(2,2) = 4; // Assign value to position (2,2)
m3 = m1 * m2; // Multiply matrices
m2 = -m1; // Invert matrix

I'm sure there are tons of classes available, otherwise you can easily make one yourself as the information on how to perform these operations can easily be found.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!