X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flinal%2Fmatrix.h;h=bf21184092046c71bc1973ae1575deff51406fb7;hb=ff8619c1c440fd1a7c8deaca763a33b8e1d53b5e;hp=daf9cb898e04393f2fc2d0f4d75b52d69bca4b94;hpb=2feea51b078cc53663e411bf80e35044c1ef4a07;p=libs%2Fmath.git diff --git a/source/linal/matrix.h b/source/linal/matrix.h index daf9cb8..bf21184 100644 --- a/source/linal/matrix.h +++ b/source/linal/matrix.h @@ -2,6 +2,7 @@ #define MSP_LINAL_MATRIX_H_ #include +#include #include "vector.h" namespace Msp { @@ -50,9 +51,9 @@ public: Matrix &operator+=(const Matrix &); Matrix &operator-=(const Matrix &); - Matrix &exchange_rows(unsigned, unsigned); - Matrix &multiply_row(unsigned, T); - Matrix &add_row(unsigned, unsigned, T); + Matrix &exchange_columns(unsigned, unsigned); + Matrix &multiply_column(unsigned, T); + Matrix &add_column(unsigned, unsigned, T); }; template @@ -226,27 +227,27 @@ inline bool operator==(const Matrix &a, const Matrix &b) } template -inline Matrix &Matrix::exchange_rows(unsigned i, unsigned j) +inline Matrix &Matrix::exchange_columns(unsigned i, unsigned j) { using std::swap; - for(unsigned k=0; k -inline Matrix &Matrix::multiply_row(unsigned i, T s) +inline Matrix &Matrix::multiply_column(unsigned i, T s) { - for(unsigned k=0; k -inline Matrix &Matrix::add_row(unsigned i, unsigned j, T s) +inline Matrix &Matrix::add_column(unsigned i, unsigned j, T s) { - for(unsigned k=0; k transpose(const Matrix &m) return r; } +template +inline std::ostream &operator<<(std::ostream &s, const Matrix &m) +{ + s << "Matrix" << M << 'x' << N << '('; + for(unsigned i=0; i