From 5eac29b9dc345f3435079cca41ac9ece03522586 Mon Sep 17 00:00:00 2001 From: fred Date: Sat, 31 Aug 1996 13:44:25 +0000 Subject: [PATCH] flower-1.0.18 --- flower/tsmat.tcc | 151 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 flower/tsmat.tcc diff --git a/flower/tsmat.tcc b/flower/tsmat.tcc new file mode 100644 index 0000000000..0e5407ae70 --- /dev/null +++ b/flower/tsmat.tcc @@ -0,0 +1,151 @@ +#include "smat.hh" + +template +void +Full_storage::operator=(Full_storage const &fs) +{ + resize(fs.h, fs.w); + for (int i=0; i +void +Full_storage::OK() const +{ + assert(maxh >= h && maxw >= w); + assert(h >= 0 && w >= 0); +} +template +void +Full_storage::resize_cols(int newh) +{ + if (newh <= maxh) { + h=newh; + return; + } + + T** newa=new T*[newh]; + int j=0; + for (; j < h; j++) + newa[j] = els[j]; + for (; j < newh; j++) + newa[j] = new T[w]; + delete[] els; + els=newa; + maxh = newh; +} + +template +void +Full_storage::resize_rows(int neww) +{ + if (neww <= maxw) { + w=neww; + return; + } + for (int i=0; i < h ; i++) { + T* newa=new T[neww]; + for (int k=0; k < w; k++) + newa[k] = els[i][k]; + + delete[] els[i]; + els[i] = newa; + maxw = neww; + } +} + +template +Full_storage::~Full_storage() { + for (int i=0; i < maxh; i++) + delete [] els[i]; + delete[] els; +} + +template +void +Full_storage::resize(int i, int j) +{ + resize_cols(i); + resize_rows(j); +} + +template +void +Full_storage::set_size(int i, int j) +{ + resize(i,j) +} + +template +bool +Full_storage::mult_ok(int i, int j) const +{ + return valid(i,j); +} + +template +bool +Full_storage::trans_ok(int i, int j) const +{ + return valid(i,j); +} + + +template +void +Full_storage::trans_next(int &i, int &j) const +{ + assert(trans_ok(i,j)); + i++; + if (i >= h) { + i=0; + j ++; + } +} + +template +void +Full_storage::mult_next(int &i, int &j) const +{ + assert(mult_ok(i,j)); + j++; + if (j >= w) { + j=0; + i++; + } +} + +template +void +Full_storage::delete_row(int k) +{ + assert(0 <= k k ; i++) + for (int j=0; j < w; j++) + els[i-1][j]=els[i][j]; +} + +template +void +Full_storage::insert_row(int k) +{ + assert(0 <= k <=h); + resize_cols(h+1); + for (int i=h-1; i > k ; i++) + for (int j=0; j +virtual_smat * +virtual_smat::get_full(int n, int m) +{ + return new Full_storage(n,m); +} +#include "real.hh" + +template Full_storage; -- 2.39.5