2 matrix-storage.hh -- declare Matrix_storage
4 source file of the Flower Library
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #ifndef MATRIX_STORAGE_HH
11 #define MATRIX_STORAGE_HH
18 base class for interface with matrix storageclasses. There are no
19 iterators for matrixclasses, since matrices are (like arrays)
20 explicitly int-indexed.
22 Iteration is provided by *_next, *_ok, which update and check both
23 index variables simultaneously.
26 determine type of product matrix.
29 class Matrix_storage {
45 /** set the size. contents lost.
49 void set_size (int rows, int cols) ;
52 /**set the size to square dimen. contents lost
56 void set_size (int i) ;
59 keep contents. If enlarged contents unspecified
65 void resize (int rows, int cols);
68 set the size to square dimen. contents kept
69 Keep contents. If enlarged contents are unspecified
80 Generate an errormessage, if this happens
81 in the 0-part of a sparse matrix.
84 Real& elem (int i,int j);
86 /// access a element, no modify
87 Real elem (int i, int j) const;
89 Array<Real> row (int i) const ;
90 Array<Real> column (int j) const;
94 add a row to the matrix before row k. Contents
95 of added row are unspecified
99 void insert_row (int k);
103 delete a row from this matrix.
108 void delete_row (int k);
109 void delete_column (int k);
110 ~Matrix_storage() { }
114 at end of matrix?. when doing loop
121 bool mult_ok (int i, int j) const;
124 walk through matrix (regular multiply).
125 get next j for row i, or get next row i and reset j.
126 this will make sparse matrix implementation easy.
131 void mult_next (int &i, int &j) const;
134 valid matrix entry. return false if at end of row
136 bool trans_ok (int i, int j) const;
139 walk through matrix (transposed multiply).
140 Get next i (for column j)
146 void trans_next (int &i, int &j) const;
148 /// generate a "Full_storage" matrix
149 static void set_band (Matrix_storage*&, int band);
152 #endif // MATRIX_STORAGE_HH