2 matrix-storage.hh -- declare Matrix_storage
4 source file of the Flower Library
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
10 #ifndef MATRIX_STORAGE_HH
11 #define MATRIX_STORAGE_HH
15 #include "class-name.hh"
19 base class for interface with matrix storageclasses. There are no
20 iterators for matrixclasses, since matrices are (like arrays)
21 explicitly int-indexed.
23 Iteration is provided by *_next, *_ok, which update and check both
24 index variables simultaneously.
27 determine type of product matrix.
30 class Matrix_storage {
35 virtual void OK() const=0;
38 virtual int rows() const = 0;
41 virtual int cols() const = 0;
44 /** set the size. contents lost.
48 virtual void set_size(int rows, int cols) = 0;
50 /**set the size to square dimen. contents lost
54 virtual void set_size(int i) = 0;
57 keep contents. If enlarged contents unspecified
63 virtual void resize(int rows, int cols ) = 0;
66 set the size to square dimen. contents kept
67 Keep contents. If enlarged contents are unspecified
72 virtual void resize(int i) = 0;
78 Generate an errormessage, if this happens
79 in the 0-part of a sparse matrix.
82 virtual Real& elem(int i,int j) = 0;
84 /// access a element, no modify
85 virtual Real const & elem(int i, int j) const = 0;
87 virtual Array<Real> row(int i) const = 0;
88 virtual Array<Real> column(int j) const = 0;
92 add a row to the matrix before row k. Contents
93 of added row are unspecified
97 virtual void insert_row(int k)=0;
101 delete a row from this matrix.
106 virtual void delete_row(int k)=0;
107 virtual void delete_column(int k)=0;
108 virtual ~Matrix_storage() { }
109 virtual Matrix_storage *clone()=0;
114 at end of matrix?. when doing loop
121 virtual bool mult_ok(int i, int j) const=0;
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 virtual void mult_next(int &i, int &j) const = 0;
134 valid matrix entry. return false if at end of row
136 virtual bool trans_ok(int i, int j) const=0;
139 walk through matrix (transposed multiply).
140 Get next i (for column j)
146 virtual void trans_next(int &i, int &j) const = 0;
147 /// generate a "Full_storage" matrix
148 static Matrix_storage *get_full(int n, int m);
151 virtual bool try_right_multiply(Matrix_storage *dest,
152 const Matrix_storage *fact) ;
156 NAME_MEMBERS(Matrix_storage);
162 Matrix_storage::try_right_multiply(Matrix_storage *,
163 const Matrix_storage *)
167 #endif // MATRIX_STORAGE_HH