00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SELDON_FILE_HETEROGENEOUS_MATRIX_COLLECTION_HXX
00022
00023
00024 #include "../share/Common.hxx"
00025 #include "../share/Properties.hxx"
00026 #include "../share/Storage.hxx"
00027 #include "../share/Errors.hxx"
00028 #include "../share/Allocator.hxx"
00029
00030 namespace Seldon
00031 {
00032
00033
00035
00039 template <class Prop0, class Storage0,
00040 class Prop1, class Storage1,
00041 template <class U> class Allocator>
00042 class HeterogeneousMatrixCollection:
00043 public Matrix_Base<double, Allocator<double> >
00044 {
00045
00046
00047 public:
00048 typedef Matrix<float, Prop0, Storage0, Allocator<float> > float_dense_m;
00049 typedef Matrix<float, Prop1, Storage1, Allocator<float> > float_sparse_m;
00050 typedef Matrix<double, Prop0, Storage0, Allocator<double> >
00051 double_dense_m;
00052 typedef Matrix<double, Prop1, Storage1, Allocator<double> >
00053 double_sparse_m;
00054
00055 typedef Matrix<float_dense_m, General, RowMajorCollection,
00056 NewAlloc<float_dense_m> > float_dense_c;
00057 typedef Matrix<float_sparse_m, General, RowMajorCollection,
00058 NewAlloc<float_sparse_m> > float_sparse_c;
00059 typedef Matrix<double_dense_m, General, RowMajorCollection,
00060 NewAlloc<double_dense_m> > double_dense_c;
00061 typedef Matrix<double_sparse_m, General, RowMajorCollection,
00062 NewAlloc<double_sparse_m> > double_sparse_c;
00063
00064
00065 protected:
00067 int nz_;
00069 int Mmatrix_;
00071 int Nmatrix_;
00073 Vector<int, VectFull, CallocAlloc<int> > Mlocal_;
00075 Vector<int, VectFull, CallocAlloc<int> > Mlocal_sum_;
00077 Vector<int, VectFull, CallocAlloc<int> > Nlocal_;
00079 Vector<int, VectFull, CallocAlloc<int> > Nlocal_sum_;
00080
00082
00088 Matrix<int, General, RowMajor, CallocAlloc<int> > collection_;
00089
00091 float_dense_c float_dense_c_;
00093 float_sparse_c float_sparse_c_;
00095 double_dense_c double_dense_c_;
00097 double_sparse_c double_sparse_c_;
00098
00099
00100
00101 public:
00102
00103 HeterogeneousMatrixCollection();
00104 HeterogeneousMatrixCollection(int i, int j);
00105 HeterogeneousMatrixCollection
00106 (const HeterogeneousMatrixCollection<Prop0, Storage0, Prop1,
00107 Storage1, Allocator>& A);
00108
00109
00110 ~HeterogeneousMatrixCollection();
00111 void Clear();
00112 void Nullify();
00113 void Nullify(int i, int j);
00114 void Deallocate();
00115
00116
00117 int GetM() const;
00118 int GetMmatrix() const;
00119 int GetM(int i) const;
00120 int GetN() const;
00121 int GetNmatrix() const;
00122 int GetN(int j) const;
00123 int GetSize() const;
00124 int GetDataSize() const;
00125 int GetType(int i, int j) const;
00126
00127 float_dense_c& GetFloatDense();
00128 const float_dense_c& GetFloatDense() const;
00129 float_sparse_c& GetFloatSparse();
00130 const float_sparse_c& GetFloatSparse() const;
00131 double_dense_c& GetDoubleDense();
00132 const double_dense_c& GetDoubleDense() const;
00133 double_sparse_c& GetDoubleSparse();
00134 const double_sparse_c& GetDoubleSparse() const;
00135
00136
00137 void Reallocate(int i, int j);
00138
00139
00140 void SetMatrix(int m, int n, const float_dense_m&);
00141 void SetMatrix(int m, int n, const float_sparse_m&);
00142 void SetMatrix(int m, int n, const double_dense_m&);
00143 void SetMatrix(int m, int n, const double_sparse_m&);
00144
00145
00146 void GetMatrix(int m, int n, float_dense_m&) const;
00147 void GetMatrix(int m, int n, float_sparse_m&) const;
00148 void GetMatrix(int m, int n, double_dense_m&) const;
00149 void GetMatrix(int m, int n, double_sparse_m&) const;
00150
00151
00152 double operator() (int i, int j) const;
00153
00154 HeterogeneousMatrixCollection<Prop0, Storage0, Prop1,
00155 Storage1, Allocator>&
00156 operator= (const HeterogeneousMatrixCollection<Prop0, Storage0,
00157 Prop1, Storage1, Allocator>& A);
00158
00159 void Copy(const HeterogeneousMatrixCollection<Prop0, Storage0,
00160 Prop1, Storage1, Allocator>& A);
00161
00162
00163 void Print() const;
00164
00165
00166 void Write(string FileName, bool with_size) const;
00167 void Write(ostream& FileStream, bool with_size) const;
00168 void WriteText(string FileName) const;
00169 void WriteText(ostream& FileStream) const;
00170
00171 void Read(string FileName);
00172 void Read(istream& FileStream);
00173
00174 };
00175
00176
00178 template <template <class U> class Allocator>
00179 class Matrix<FloatDouble, General,
00180 DenseSparseCollection, Allocator<double> >:
00181 public HeterogeneousMatrixCollection<General, RowMajor, General,
00182 RowSparse, Allocator >
00183 {
00184
00185 public:
00186 typedef General property;
00187 typedef DenseSparseCollection storage;
00188 typedef Allocator<double> allocator;
00189
00190 public:
00191 Matrix();
00192 Matrix(int i, int j);
00193 };
00194
00195
00196 }
00197
00198
00199 #define SELDON_FILE_HETEROGENEOUS_MATRIX_COLLECTION_HXX
00200 #endif