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_SYMSPARSE_HXX
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
00043 template <class T, class Prop, class Storage,
00044 class Allocator = SELDON_DEFAULT_ALLOCATOR<T> >
00045 class Matrix_SymSparse: public Matrix_Base<T, Allocator>
00046 {
00047
00048 public:
00049 typedef typename Allocator::value_type value_type;
00050 typedef typename Allocator::pointer pointer;
00051 typedef typename Allocator::const_pointer const_pointer;
00052 typedef typename Allocator::reference reference;
00053 typedef typename Allocator::const_reference const_reference;
00054 typedef typename Allocator::value_type entry_type;
00055 typedef typename Allocator::value_type access_type;
00056 typedef typename Allocator::value_type const_access_type;
00057
00058
00059 protected:
00060
00061 int nz_;
00062
00063 int* ptr_;
00064
00065 int* ind_;
00066
00067
00068 public:
00069
00070 Matrix_SymSparse();
00071 Matrix_SymSparse(int i, int j);
00072 Matrix_SymSparse(int i, int j, int nz);
00073 template <class Storage0, class Allocator0,
00074 class Storage1, class Allocator1,
00075 class Storage2, class Allocator2>
00076 Matrix_SymSparse(int i, int j, Vector<T, Storage0, Allocator0>& values,
00077 Vector<int, Storage1, Allocator1>& ptr,
00078 Vector<int, Storage2, Allocator2>& ind);
00079 Matrix_SymSparse(const Matrix_SymSparse<T, Prop, Storage, Allocator>& A);
00080
00081
00082 ~Matrix_SymSparse();
00083 void Clear();
00084
00085
00086 template <class Storage0, class Allocator0,
00087 class Storage1, class Allocator1,
00088 class Storage2, class Allocator2>
00089 void SetData(int i, int j,
00090 Vector<T, Storage0, Allocator0>& values,
00091 Vector<int, Storage1, Allocator1>& ptr,
00092 Vector<int, Storage2, Allocator2>& ind);
00093 void SetData(int i, int j, int nz, pointer values, int* ptr, int* ind);
00094 void Nullify();
00095 void Copy(const Matrix_SymSparse<T, Prop, Storage, Allocator>& A);
00096
00097
00098 int GetNonZeros() const;
00099 int GetDataSize() const;
00100 int* GetPtr() const;
00101 int* GetInd() const;
00102 int GetPtrSize() const;
00103 int GetIndSize() const;
00104
00105
00106 value_type operator() (int i, int j) const;
00107 value_type& Val(int i, int j);
00108 const value_type& Val(int i, int j) const;
00109 Matrix_SymSparse<T, Prop, Storage, Allocator>&
00110 operator= (const Matrix_SymSparse<T, Prop, Storage, Allocator>& A);
00111
00112
00113 void Print() const;
00114 void WriteText(string FileName) const;
00115 void WriteText(ostream& FileStream) const;
00116 };
00117
00118
00120 template <class T, class Prop, class Allocator>
00121 class Matrix<T, Prop, ColSymSparse, Allocator>:
00122 public Matrix_SymSparse<T, Prop, ColSymSparse, Allocator>
00123 {
00124
00125 public:
00126 typedef typename Allocator::value_type value_type;
00127 typedef Prop property;
00128 typedef ColSymSparse storage;
00129 typedef Allocator 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
00146 template <class T, class Prop, class Allocator>
00147 class Matrix<T, Prop, RowSymSparse, Allocator>:
00148 public Matrix_SymSparse<T, Prop, RowSymSparse, Allocator>
00149 {
00150
00151 public:
00152 typedef typename Allocator::value_type value_type;
00153 typedef Prop property;
00154 typedef RowSymSparse storage;
00155 typedef Allocator allocator;
00156
00157 public:
00158 Matrix() throw();
00159 Matrix(int i, int j);
00160 Matrix(int i, int j, int nz);
00161 template <class Storage0, class Allocator0,
00162 class Storage1, class Allocator1,
00163 class Storage2, class Allocator2>
00164 Matrix(int i, int j,
00165 Vector<T, Storage0, Allocator0>& values,
00166 Vector<int, Storage1, Allocator1>& ptr,
00167 Vector<int, Storage2, Allocator2>& ind);
00168 };
00169
00170
00171 }
00172
00173 #define SELDON_FILE_MATRIX_SYMSPARSE_HXX
00174 #endif