1 #ifndef MSP_LINAL_SQUAREMATRIX_H_
2 #define MSP_LINAL_SQUAREMATRIX_H_
12 A mathematical matrix with S rows and columns. Some operations are provided
13 here that are only possible for square matrices.
15 template<typename T, unsigned S>
16 class SquareMatrix: public Matrix<T, S, S>
20 SquareMatrix(const T *d): Matrix<T, S, S>(d) { }
22 SquareMatrix(const Matrix<U, S, S> &m): Matrix<T, S, S>(m) { }
24 static SquareMatrix identity();
26 SquareMatrix &operator*=(const SquareMatrix &);
28 SquareMatrix &invert();
31 template<typename T, unsigned S>
32 inline SquareMatrix<T, S> SquareMatrix<T, S>::identity()
35 for(unsigned i=0; i<S; ++i)
40 template<typename T, unsigned S>
41 SquareMatrix<T, S> &SquareMatrix<T, S>::operator*=(const SquareMatrix<T, S> &m)
43 return *this = *this*m;
46 template<typename T, unsigned S>
47 SquareMatrix<T, S> &SquareMatrix<T, S>::invert()
49 SquareMatrix<T, S> r = identity();
50 return invert_matrix(*this, r);
53 template<typename T, unsigned S>
54 inline SquareMatrix<T, S> invert(const SquareMatrix<T, S> &m)
56 SquareMatrix<T, S> r = m;