00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef __GNUC__
00029 #pragma interface
00030 #endif
00031
00032 #ifndef _math_scmat_dim_h
00033 #define _math_scmat_dim_h
00034
00035 #include <util/keyval/keyval.h>
00036 #include <util/state/state.h>
00037
00038 class RefSCDimension;
00048 class SCBlockInfo: public SavableState {
00049 protected:
00050 int n_;
00051 int nblocks_;
00052 int *start_;
00053 int *size_;
00054 RefSCDimension *subdims_;
00055 void init_start();
00056 public:
00058 SCBlockInfo(int n, int nblocks = 0, const int *blocksizes = 0);
00059 SCBlockInfo(StateIn&);
00072 SCBlockInfo(const Ref<KeyVal>& keyval);
00073
00074 ~SCBlockInfo();
00075 void save_data_state(StateOut&);
00076
00078 int equiv(SCBlockInfo *bi);
00080 int nelem() const { return n_; }
00082 int nblock() const { return nblocks_; }
00084 int start(int i) const { return start_[i]; }
00086 int size(int i) const { return size_[i]; }
00088 int fence(int i) const { return start_[i] + size_[i]; }
00089
00090 void elem_to_block(int i, int &block, int &offset);
00091
00093 RefSCDimension subdim(int i);
00097 void set_subdim(int i, const RefSCDimension &dim);
00098
00100 void print(std::ostream&o=ExEnv::out()) const;
00101 };
00102
00103
00107 class SCDimension: public SavableState {
00108 protected:
00109 char *name_;
00110 int n_;
00111 Ref<SCBlockInfo> blocks_;
00112 SCDimension(const char* name = 0);
00113 public:
00116 SCDimension(int n, const char* name = 0);
00117 SCDimension(const Ref<SCBlockInfo>&, const char *name = 0);
00118 SCDimension(int n, int nblocks, const int *blocksizes = 0,
00119 const char* name = 0);
00130 SCDimension(const Ref<KeyVal>&);
00131 SCDimension(StateIn&s);
00132
00133 ~SCDimension();
00134 void save_data_state(StateOut&);
00135
00137 int equiv(const SCDimension*) const;
00138
00140 int n() const { return n_; }
00143 const char* name() const { return name_; }
00144
00146 Ref<SCBlockInfo> blocks() { return blocks_; }
00147
00149 void print(std::ostream&o=ExEnv::out()) const;
00150 };
00151
00154 class RefSCDimension: public Ref<SCDimension> {
00155
00156 public:
00159 RefSCDimension();
00161 RefSCDimension(const RefSCDimension& d);
00163 RefSCDimension(SCDimension *d);
00164
00165 ~RefSCDimension();
00167 RefSCDimension& operator=(SCDimension* d);
00168
00169 RefSCDimension& operator<<(RefCount*);
00170 RefSCDimension& operator<<(const RefBase &);
00172 RefSCDimension& operator=(const RefSCDimension & d);
00173
00174
00175 public:
00177 operator int() const;
00178 int n() const;
00179
00180 void print(std::ostream&o=ExEnv::out()) const;
00181 };
00182
00183 #endif
00184
00185
00186
00187
00188