]> git.tdb.fi Git - libs/math.git/blobdiff - source/linal/squarematrix.h
Math function usage fixes
[libs/math.git] / source / linal / squarematrix.h
index 94157b0f3b92f2e2de9ebbf49e927d17bf8a9ae8..1cdc56726455f9ab2b97589b1b93bacbad702eac 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MSP_LINAL_SQUAREMATRIX_H_
 #define MSP_LINAL_SQUAREMATRIX_H_
 
+#include <cmath>
 #include <stdexcept>
 #include "matrix.h"
 
@@ -14,6 +15,10 @@ public:
        virtual ~not_invertible() throw() { }
 };
 
+/**
+A mathematical matrix with S rows and columns.  Some operations are provided
+here that are only possible for square matrices.
+*/
 template<typename T, unsigned S>
 class SquareMatrix: public Matrix<T, S, S>
 {
@@ -42,13 +47,14 @@ inline SquareMatrix<T, S> SquareMatrix<T, S>::identity()
 template<typename T, unsigned S>
 SquareMatrix<T, S> &SquareMatrix<T, S>::operator*=(const SquareMatrix<T, S> &m)
 {
-       Matrix<T, S, S>::operator*=(m);
-       return *this;
+       return *this = *this*m;
 }
 
 template<typename T, unsigned S>
 SquareMatrix<T, S> &SquareMatrix<T, S>::invert()
 {
+       using std::abs;
+
        SquareMatrix<T, S> r = identity();
        for(unsigned i=0; i<S; ++i)
        {