5 #include "matrix-storage.hh"
8 /** a Real matrix. This is a class for a nonsquare block of #Real#s. The
9 implementation of sparse matrices is done in the appropriate #smat#
10 class. Matrix only does the mathematical actions (adding,
15 implement ref counting? */
22 void OK() const { dat->OK(); }
23 int cols() const { return dat->cols(); }
24 int rows() const { return dat->rows(); }
26 /** return the size of a matrix.
28 the matrix needs to be square.
32 // Matrix() { dat = 0; }
33 ~Matrix() { delete dat; }
39 void set_diag(Real d);
41 void set_diag(Vector d);
43 void unit() { set_diag(1.0); }
45 void operator+=(Matrix const &m);
46 void operator-=(Matrix const &m);
47 void operator*=(Real a);
48 void operator/=(Real a) { (*this) *= 1/a; }
51 add a row to the matrix before row k
57 void insert_row(Vector v,int k);
59 delete a row from this matrix.
64 void delete_row(int k) { dat->delete_row(k); }
65 void delete_column(int k) { dat->delete_column(k); }
68 square n matrix, initialised to null
73 n x m matrix, init to 0
76 Matrix(Matrix const &m);
78 /// dyadic product: v * w.transpose
79 Matrix(Vector v, Vector w);
80 void operator=(Matrix const &m);
83 Real operator()(int i,int j) const { return dat->elem(i,j); }
86 Real &operator()(int i, int j) { return dat->elem(i,j); }
88 /// Matrix multiply with vec (from right)
89 Vector operator *(Vector const &v) const;
91 /// set this to m1*m2.
92 void set_product(Matrix const &m1, Matrix const &m2);
95 Vector left_multiply(Vector const &) const;
97 Matrix operator-() const;
102 /// return a transposed copy.
103 Matrix transposed() const ;
110 void swap_columns(int c1, int c2);
116 void swap_rows(int c1, int c2);
119 Vector row(int ) const;
120 Vector col(int) const;
122 operator String() const;
127 operator *(Vector &v, Matrix const & m) { return m.left_multiply(v); }
128 Matrix operator *(Matrix const & m1,Matrix const &m2);
129 Matrix operator /(Matrix const &m1,Real a);
130 inline Matrix operator -(Matrix m1,const Matrix m2)