   Is there a good matrix class?
  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.   
Quote:Original post by StoryyellerOne 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.;  bump   ;  Have you searched Google for such classes? If you found some, why are they unsuitable?   ;  The only thing I could find was Sparselib++, but I can't find anything that explains how to use it.   ;  You know, when I punch "C++ matrix class" into Google I get a lot more than just Sparselib++ back.   ;  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   ;Quote:Original post by mntlinstituteflrA 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!  :DI'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.)   ;  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.   ;  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 matricesm2 = -m1; // Invert matrixI'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.   