X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Ffull-storage.cc;h=987a98ec042b147508a50ca8d272d39109638034;hb=f56e1381aaa6edc69dfc36dcba16777fe83f3631;hp=34dcdad1b8ceb1bed7e181dbf5bd2fedc43ecc0d;hpb=1a66290a98e7de8d6d41485b5b71a9f7e1fe35c7;p=lilypond.git diff --git a/flower/full-storage.cc b/flower/full-storage.cc index 34dcdad1b8..987a98ec04 100644 --- a/flower/full-storage.cc +++ b/flower/full-storage.cc @@ -3,7 +3,7 @@ source file of the Flower Library - (c) 1996,1997 Han-Wen Nienhuys + (c) 1996, 1997--1998 Han-Wen Nienhuys */ #include "full-storage.hh" @@ -12,12 +12,12 @@ void Full_storage::operator=(Full_storage const &fs) { - resize (fs.height_i_, fs.width_i_); - OK(); - fs.OK(); - for (int i=0; i= height_i_ && max_width_i_ >= width_i_); - assert (height_i_ >= 0 && width_i_ >= 0); - assert (els_p_p_||!max_height_i_); + assert (max_height_i_ >= height_i_ && max_width_i_ >= width_i_); + assert (height_i_ >= 0 && width_i_ >= 0); + assert (els_p_p_||!max_height_i_); #endif } @@ -37,169 +36,127 @@ Full_storage::OK() const Full_storage::~Full_storage() { - for (int i=0; i < max_height_i_; i++) - delete [] els_p_p_[i]; - delete[] els_p_p_; + for (int i=0; i < max_height_i_; i++) + delete [] els_p_p_[i]; + delete[] els_p_p_; } void - Full_storage::resize (int rows, int cols) { - OK(); - resize_cols (rows); - resize_rows (cols); + OK(); + resize_cols (rows); + resize_rows (cols); + band_i_ = rows >? cols; } - - -bool -Full_storage::mult_ok (int i, int) const +void +Full_storage::delete_column (int k) { - return i < height_i_; + assert (0 <= k &&k= height_i_) { - i=0; - j ++; - } -} + assert (0 <= k&& k <=height_i_); + resize_cols (height_i_+1); + for (int i=height_i_-1; i > k ; i--) + for (int j=0; j +Full_storage::row (int n) const { - assert (mult_ok (i,j)); - j++; - if (j >= width_i_) { - j=0; - i++; - } + Array r; + for (int j = 0; j < cols(); j++) + r.push (elem (n,j)); + return r; } - -void -Full_storage::delete_column (int k) +Array +Full_storage::column (int n) const { - assert (0 <= k &&k r; + for (int i = 0; i < rows(); i++) + r.push (elem (i,n)); + return r; } - void -Full_storage::delete_row (int k) +Full_storage::set_size (int rows, int cols) { - assert (0 <= k &&k k ; i--) - for (int j=0; j name() != Full_storage::static_name () || - right->name() != Full_storage::static_name ()) - return false; - - Full_storage *d_l = (Full_storage*)dest; - Full_storage *r_l = (Full_storage*)right; - - d_l->set_size (height_i_, r_l->width_i_); - for (int i=0; i < d_l->height_i_; i++) - for (int j = 0; j < d_l->width_i_; j++) { - Real &r (d_l->els_p_p_[i][j]); - r=0.0; - for (int k = 0; k < width_i_; k++) - r += els_p_p_[i][k] * r_l->els_p_p_[k][j]; - - } - return true; - - -} -IMPLEMENT_IS_TYPE_B1(Full_storage,Matrix_storage); void Full_storage::resize_cols (int newh) { - if (newh <= max_height_i_) { - height_i_=newh; - return; + if (newh <= max_height_i_) + { + height_i_=newh; + return; } - Real ** newa=new Real*[newh]; - int j=0; - for (; j < height_i_; j++) - newa[j] = els_p_p_[j]; - for (; j < newh; j++) - newa[j] = new Real[max_width_i_]; - delete[] els_p_p_; - els_p_p_=newa; - - height_i_ = max_height_i_ = newh; + Real ** newa=new Real*[newh]; + int j=0; + for (; j < height_i_; j++) + newa[j] = els_p_p_[j]; + for (; j < newh; j++) + newa[j] = new Real[max_width_i_]; + delete[] els_p_p_; + els_p_p_=newa; + + height_i_ = max_height_i_ = newh; } -Full_storage::Full_storage (Matrix_storage*m) -{ - set_size (m->rows(), m->cols ()); - if ( !m->is_type_b ( Full_storage::static_name())) - for (int i=0; imult_ok (i,j); m->mult_next (i,j)) - els_p_p_[i][j] = m->elem (i,j); -} - - void Full_storage::resize_rows (int neww) { - if (neww <= max_width_i_) { - width_i_=neww; - return; + if (neww <= max_width_i_) + { + width_i_=neww; + return; } - for (int i=0; i < max_height_i_ ; i++) { - Real* newa = new Real[neww]; - for (int k=0; k < width_i_; k++) - newa[k] = els_p_p_[i][k]; - - delete[] els_p_p_[i]; - els_p_p_[i] = newa; + for (int i=0; i < max_height_i_ ; i++) + { + Real* newa = new Real[neww]; + for (int k=0; k < width_i_; k++) + newa[k] = els_p_p_[i][k]; + + delete[] els_p_p_[i]; + els_p_p_[i] = newa; } - width_i_ = max_width_i_ = neww; + width_i_ = max_width_i_ = neww; } #ifdef INLINE @@ -207,4 +164,5 @@ Full_storage::resize_rows (int neww) #endif #define INLINE + #include "full-storage.icc"