]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/full-storage.hh
8fec189c735925c1ecbcd5dde21bb1cb61c4ad27
[lilypond.git] / flower / include / full-storage.hh
1 /*
2   full-storage.hh -- declare Full_storage
3
4   source file of the Flower Library
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9
10 #ifndef FULL_STORAGE_HH
11 #define FULL_STORAGE_HH
12
13 #include "varray.hh"
14 #include "real.hh"
15
16 /// simplest matrix storage. refer to its baseclass for the doco.
17 class Full_storage 
18 {
19   /// height, width
20   int height_i_;
21   int width_i_;
22   /// maxima.
23   int max_height_i_;
24   int max_width_i_;
25     
26   /// the storage
27   Real** els_p_p_;
28
29   void init() ;
30      
31   bool valid (int i, int j) const ; 
32
33   void resize_rows (int);
34   void resize_cols (int);
35
36 public:
37   int band_i_;                  // ugh
38
39   /// check invariants
40   void OK() const;
41     
42     /// height of matrix
43   int rows() const;
44
45   /// width of matrix
46   int cols() const;
47
48   /// size if square
49   int dim() const;
50       
51   /**  set the size. contents lost.       
52       PRE
53       i >=0, j>=0
54     */
55   void set_size (int rows, int cols) ;
56
57  
58   /**set the size to square dimen. contents lost
59       PRE
60       i>=0
61     */
62   void set_size (int i) ;
63   /**set the size to i.
64
65       keep contents. If enlarged contents unspecified
66         
67       PRE
68       i>=0, j>=0
69     
70     */
71   void resize (int rows, int cols);
72  
73   /**    
74     set the size to square dimen. contents kept
75     Keep contents. If enlarged contents are unspecified
76     
77     PRE
78     i>=0  
79     */
80   void resize (int i);
81   
82     
83   /**
84     access an element.
85
86     Generate an errormessage, if this happens
87     in the 0-part of a sparse matrix.
88     */
89
90   Real& elem (int i,int j);
91
92   /// access a element, no modify
93   Real elem (int i, int j) const;
94
95   Array<Real> row (int i) const ;
96   Array<Real> column (int j) const;
97
98     
99   /**
100     add a row to the matrix before  row k. Contents
101     of added row are unspecified
102
103       0 <= k <= rows()
104     */
105   void insert_row (int k);
106
107     
108   /**
109       delete a row from this matrix.
110
111       PRE
112       0 <= k < rows();
113     */
114   void delete_row (int k);
115   void delete_column (int k);
116
117
118     
119     /**
120       at end of matrix?. when doing loop
121
122       for (i=0; i<h; i++)
123         for (j=0; j<w; j++)
124           ..
125
126     */
127   bool mult_ok (int i, int j) const;
128
129   /**
130       walk through matrix (regular multiply).
131       get next j for row i, or get next row i and reset j.
132       this will make sparse matrix implementation easy.
133     
134       PRE
135       mult_ok (i,j)
136      */
137   void mult_next (int &i, int &j) const;
138
139   /**
140       valid matrix entry. return false if at end of row
141     */
142   bool trans_ok (int i, int j) const;
143
144   /**
145       walk through matrix (transposed multiply).
146       Get next i (for column j)
147     
148       PRE
149       ver_ok (i,j)
150      */
151
152   void trans_next (int &i, int &j) const;
153
154   Full_storage();
155   Full_storage (int i, int j);
156   Full_storage (Full_storage const&);
157   Full_storage (int i);
158   void operator=(Full_storage const &);
159     
160     
161   ~Full_storage();
162 };
163
164 #ifndef INLINE
165 #define INLINE inline
166 #endif
167
168 #include "full-storage.icc"
169
170
171 #endif // FULL_STORAGE_HH