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_COMPLEXSPARSE_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
00046 template <class T, class Prop, class Storage,
00047 class Allocator = SELDON_DEFAULT_ALLOCATOR<T> >
00048 class Matrix_ComplexSparse: public Matrix_Base<T, Allocator>
00049 {
00050
00051 public:
00052 typedef typename Allocator::value_type value_type;
00053 typedef typename Allocator::pointer pointer;
00054 typedef typename Allocator::const_pointer const_pointer;
00055 typedef typename Allocator::reference reference;
00056 typedef typename Allocator::const_reference const_reference;
00057 typedef complex<value_type> entry_type;
00058 typedef complex<value_type> access_type;
00059 typedef complex<value_type> const_access_type;
00060
00061
00062 protected:
00063
00064 int real_nz_;
00065 int imag_nz_;
00066
00067 int* real_ptr_;
00068 int* imag_ptr_;
00069
00070 int* real_ind_;
00071 int* imag_ind_;
00072
00073
00074 T* real_data_;
00075 T* imag_data_;
00076
00077
00078 public:
00079
00080 Matrix_ComplexSparse();
00081 Matrix_ComplexSparse(int i, int j);
00082 Matrix_ComplexSparse(int i, int j, int real_nz, int imag_nz);
00083 template <class Storage0, class Allocator0,
00084 class Storage1, class Allocator1,
00085 class Storage2, class Allocator2>
00086 Matrix_ComplexSparse(int i, int j,
00087 Vector<T, Storage0, Allocator0>& real_values,
00088 Vector<int, Storage1, Allocator1>& real_ptr,
00089 Vector<int, Storage2, Allocator2>& real_ind,
00090 Vector<T, Storage0, Allocator0>& imag_values,
00091 Vector<int, Storage1, Allocator1>& imag_ptr,
00092 Vector<int, Storage2, Allocator2>& imag_ind);
00093 Matrix_ComplexSparse(const Matrix_ComplexSparse<T, Prop,
00094 Storage, Allocator>& A);
00095
00096
00097 ~Matrix_ComplexSparse();
00098 void Clear();
00099
00100
00101 template <class Storage0, class Allocator0,
00102 class Storage1, class Allocator1,
00103 class Storage2, class Allocator2>
00104 void SetData(int i, int j,
00105 Vector<T, Storage0, Allocator0>& real_values,
00106 Vector<int, Storage1, Allocator1>& real_ptr,
00107 Vector<int, Storage2, Allocator2>& real_ind,
00108 Vector<T, Storage0, Allocator0>& imag_values,
00109 Vector<int, Storage1, Allocator1>& imag_ptr,
00110 Vector<int, Storage2, Allocator2>& imag_ind);
00111 void SetData(int i, int j,
00112 int real_nz, pointer real_values, int* real_ptr,
00113 int* real_ind,
00114 int imag_nz, pointer imag_values, int* imag_ptr,
00115 int* imag_ind);
00116 void Nullify();
00117 void Copy(const Matrix_ComplexSparse<T, Prop, Storage, Allocator>& A);
00118
00119
00120 int GetNonZeros() const;
00121 int GetDataSize() const;
00122 int* GetRealPtr() const;
00123 int* GetImagPtr() const;
00124 int* GetRealInd() const;
00125 int* GetImagInd() const;
00126 int GetRealPtrSize() const;
00127 int GetImagPtrSize() const;
00128 int GetRealIndSize() const;
00129 int GetImagIndSize() const;
00130 T* GetRealData() const;
00131 T* GetImagData() const;
00132
00133
00134 complex<value_type> operator() (int i, int j) const;
00135 complex<value_type>& Val(int i, int j);
00136 const complex<value_type>& Val(int i, int j) const;
00137 Matrix_ComplexSparse<T, Prop, Storage, Allocator>&
00138 operator= (const Matrix_ComplexSparse<T, Prop, Storage, Allocator>& A);
00139
00140
00141 void Print() const;
00142 };
00143
00144
00146 template <class T, class Prop, class Allocator>
00147 class Matrix<T, Prop, ColComplexSparse, Allocator>:
00148 public Matrix_ComplexSparse<T, Prop, ColComplexSparse, Allocator>
00149 {
00150
00151 public:
00152 typedef typename Allocator::value_type value_type;
00153 typedef Prop property;
00154 typedef ColComplexSparse storage;
00155 typedef Allocator allocator;
00156
00157 public:
00158 Matrix() throw();
00159 Matrix(int i, int j);
00160 Matrix(int i, int j, int real_nz, int imag_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>& real_values,
00166 Vector<int, Storage1, Allocator1>& real_ptr,
00167 Vector<int, Storage2, Allocator2>& real_ind,
00168 Vector<T, Storage0, Allocator0>& imag_values,
00169 Vector<int, Storage1, Allocator1>& imag_ptr,
00170 Vector<int, Storage2, Allocator2>& imag_ind);
00171 };
00172
00173
00175 template <class T, class Prop, class Allocator>
00176 class Matrix<T, Prop, RowComplexSparse, Allocator>:
00177 public Matrix_ComplexSparse<T, Prop, RowComplexSparse, Allocator>
00178 {
00179
00180 public:
00181 typedef typename Allocator::value_type value_type;
00182 typedef Prop property;
00183 typedef RowComplexSparse storage;
00184 typedef Allocator allocator;
00185
00186 public:
00187 Matrix() throw();
00188 Matrix(int i, int j);
00189 Matrix(int i, int j, int real_nz, int imag_nz);
00190 template <class Storage0, class Allocator0,
00191 class Storage1, class Allocator1,
00192 class Storage2, class Allocator2>
00193 Matrix(int i, int j,
00194 Vector<T, Storage0, Allocator0>& values,
00195 Vector<int, Storage1, Allocator1>& ptr,
00196 Vector<int, Storage2, Allocator2>& ind,
00197 Vector<T, Storage0, Allocator0>& imag_values,
00198 Vector<int, Storage1, Allocator1>& imag_ptr,
00199 Vector<int, Storage2, Allocator2>& imag_ind);
00200 };
00201
00202
00203 }
00204
00205 #define SELDON_FILE_MATRIX_COMPLEXSPARSE_HXX
00206 #endif