00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef SELDON_FILE_MATRIX_SPARSE_HXX
00023
00024 #include "../Common/Common.hxx"
00025 #include "../Common/Properties.hxx"
00026 #include "../Common/Storage.hxx"
00027 #include "../Common/Errors.cxx"
00028 #include "../Common/Allocator.hxx"
00029
00030 namespace Seldon
00031 {
00032
00033
00035
00042 template <class T, class Prop, class Storage,
00043 class Allocator = SELDON_DEFAULT_ALLOCATOR<T> >
00044 class Matrix_Sparse: public Spacetown, public Matrix_Base<T, Allocator>
00045 {
00046
00047 public:
00048 typedef typename Allocator::value_type value_type;
00049 typedef typename Allocator::pointer pointer;
00050 typedef typename Allocator::const_pointer const_pointer;
00051 typedef typename Allocator::reference reference;
00052 typedef typename Allocator::const_reference const_reference;
00053
00054
00055 protected:
00056
00057 int nz_;
00058
00059 int* ptr_;
00060
00061 int* ind_;
00062
00063
00064 public:
00065
00066 Matrix_Sparse();
00067 Matrix_Sparse(int i, int j);
00068 Matrix_Sparse(int i, int j, int nz);
00069 template <class Storage0, class Allocator0,
00070 class Storage1, class Allocator1,
00071 class Storage2, class Allocator2>
00072 Matrix_Sparse(int i, int j, Vector<T, Storage0, Allocator0>& values,
00073 Vector<int, Storage1, Allocator1>& ptr,
00074 Vector<int, Storage2, Allocator2>& ind);
00075
00076
00077 ~Matrix_Sparse();
00078 void Clear();
00079
00080
00081 template <class Storage0, class Allocator0,
00082 class Storage1, class Allocator1,
00083 class Storage2, class Allocator2>
00084 void SetData(int i, int j,
00085 Vector<T, Storage0, Allocator0>& values,
00086 Vector<int, Storage1, Allocator1>& ptr,
00087 Vector<int, Storage2, Allocator2>& ind);
00088 void SetData(int i, int j, int nz, pointer values, int* ptr, int* ind);
00089
00090
00091 int GetNonZeros() const;
00092 int GetDataSize() const;
00093 int* GetPtr() const;
00094 int* GetInd() const;
00095 int GetPtrSize() const;
00096 int GetIndSize() const;
00097
00098
00099 value_type operator() (int i, int j) const;
00100
00101
00102 void Print() const;
00103 void SetDiags();
00104 };
00105
00106
00108 template <class T, class Prop, class Allocator>
00109 class Matrix<T, Prop, ColSparse, Allocator>:
00110 public Matrix_Sparse<T, Prop, ColSparse, Allocator>
00111 {
00112 public:
00113 Matrix() throw();
00114 Matrix(int i, int j);
00115 Matrix(int i, int j, int nz);
00116 template <class Storage0, class Allocator0,
00117 class Storage1, class Allocator1,
00118 class Storage2, class Allocator2>
00119 Matrix(int i, int j,
00120 Vector<T, Storage0, Allocator0>& values,
00121 Vector<int, Storage1, Allocator1>& ptr,
00122 Vector<int, Storage2, Allocator2>& ind);
00123 };
00124
00125
00127 template <class T, class Prop, class Allocator>
00128 class Matrix<T, Prop, RowSparse, Allocator>:
00129 public Matrix_Sparse<T, Prop, RowSparse, Allocator>
00130 {
00131 public:
00132 Matrix() throw();
00133 Matrix(int i, int j);
00134 Matrix(int i, int j, int nz);
00135 template <class Storage0, class Allocator0,
00136 class Storage1, class Allocator1,
00137 class Storage2, class Allocator2>
00138 Matrix(int i, int j,
00139 Vector<T, Storage0, Allocator0>& values,
00140 Vector<int, Storage1, Allocator1>& ptr,
00141 Vector<int, Storage2, Allocator2>& ind);
00142 };
00143
00144
00145 }
00146
00147 #define SELDON_FILE_MATRIX_SPARSE_HXX
00148 #endif