23 #ifndef SELDON_FILE_MATRIX_COMPLEXSPARSE_HXX
35 ::allocator allocator;
43 SeldonDefaultAllocator<VectFull, float>::allocator allocator;
51 SeldonDefaultAllocator<VectFull, double>::allocator allocator;
59 SeldonDefaultAllocator<VectFull, long double>::allocator allocator;
70 ::allocator allocator;
78 SeldonDefaultAllocator<VectFull, float>::allocator allocator;
86 SeldonDefaultAllocator<VectFull, double>::allocator allocator;
94 SeldonDefaultAllocator<VectFull, long double>::allocator allocator;
110 template <
class T,
class Prop,
class Storage,
class Allocator
111 =
typename SeldonDefaultAllocator<Storage, T>::allocator>
116 typedef typename Allocator::value_type value_type;
117 typedef typename Allocator::pointer pointer;
118 typedef typename Allocator::const_pointer const_pointer;
119 typedef typename Allocator::reference reference;
120 typedef typename Allocator::const_reference const_reference;
121 typedef typename SeldonDefaultAllocator<VectFull, int>::allocator AllocatorInt;
122 typedef typename SeldonDefaultAllocator<VectFull, long>::allocator AllocatorLong;
123 typedef complex<value_type> entry_type;
124 typedef complex<value_type> access_type;
125 typedef complex<value_type> const_access_type;
140 value_type* real_data_;
141 value_type* imag_data_;
150 template <
class Storage0,
class Allocator0,
151 class Storage1,
class Allocator1,
152 class Storage2,
class Allocator2>
162 Storage, Allocator>& A);
169 template <
class Storage0,
class Allocator0,
170 class Storage1,
class Allocator1,
171 class Storage2,
class Allocator2>
181 long real_nz, pointer real_values,
long* real_ptr,
183 long imag_nz, pointer imag_values,
long* imag_ptr,
187 void Reallocate(
int i,
int j,
long real_nz,
long imag_nz);
188 void Resize(
int i,
int j);
189 void Resize(
int i,
int j,
long real_nz,
long imag_nz);
210 const entry_type
operator() (
int i,
int j)
const;
211 value_type&
ValReal(
int i,
int j);
212 const value_type&
ValReal(
int i,
int j)
const;
213 value_type&
ValImag(
int i,
int j);
214 const value_type&
ValImag(
int i,
int j)
const;
215 value_type&
GetReal(
int i,
int j);
216 const value_type&
GetReal(
int i,
int j)
const;
217 value_type&
GetImag(
int i,
int j);
218 const value_type&
GetImag(
int i,
int j)
const;
219 void Set(
int i,
int j,
const entry_type& x);
224 bool sorted =
false);
233 void Fill(
const entry_type& x);
237 void Write(
string FileName)
const;
238 void Write(ostream& FileStream)
const;
239 void WriteText(
string FileName,
bool cplx =
false)
const;
240 void WriteText(ostream& FileStream,
bool cplx =
false)
const;
241 void Read(
string FileName);
242 void Read(istream& FileStream);
243 void ReadText(
string FileName,
bool cplx =
false);
244 void ReadText(istream& FileStream,
bool cplx =
false);
246 #ifdef SELDON_WITH_VIRTUAL
247 typedef typename ClassComplexType<T>::Treal Treal;
248 typedef typename ClassComplexType<T>::Tcplx Tcplx;
251 const typename ClassComplexType<T>::Treal& omega,
252 int nb_iter,
int stage_ssor)
const;
255 const typename ClassComplexType<T>::Treal& omega,
256 int nb_iter,
int stage_ssor)
const;
258 virtual void MltAddVector(
const Treal& alpha,
const Vector<Treal>& x,
261 virtual void MltAddVector(
const Tcplx& alpha,
const Vector<Tcplx>& x,
281 virtual bool IsSymmetric()
const;
288 template <
class T,
class Prop,
class Allocator>
294 typedef typename Allocator::value_type value_type;
295 typedef Prop property;
297 typedef Allocator allocator;
301 explicit Matrix(
int i,
int j);
302 Matrix(
int i,
int j,
long real_nz,
long imag_nz);
304 template <
class Storage0,
class Allocator0,
305 class Storage1,
class Allocator1,
306 class Storage2,
class Allocator2>
318 template <
class T,
class Prop,
class Allocator>
324 typedef typename Allocator::value_type value_type;
325 typedef Prop property;
327 typedef Allocator allocator;
331 explicit Matrix(
int i,
int j);
332 Matrix(
int i,
int j,
long real_nz,
long imag_nz);
333 template <
class Storage0,
class Allocator0,
334 class Storage1,
class Allocator1,
335 class Storage2,
class Allocator2>
347 #define SELDON_FILE_MATRIX_COMPLEXSPARSE_HXX
void FillRand()
Fills the non-zero entries randomly.
value_type & GetImag(int i, int j)
Access method.
long GetRealIndSize() const
Returns the length of the array of (column or row) indices for the real part.
Selection of default allocator depending on storage and value type.
Complex sparse-matrix class.
void Zero()
Resets all non-zero entries to 0-value.
~Matrix_ComplexSparse()
Destructor.
Base class for all matrices.
int GetRealPtrSize() const
Returns the length of the array of start indices for the real part.
void SetIdentity()
Sets the matrix to identity.
void Reallocate(int i, int j)
Initialization of an empty matrix i x j.
int * GetImagInd() const
Returns (row or column) indices of non-zero entries for the imaginary part.
void Nullify()
Clears the matrix without releasing memory.
value_type & ValReal(int i, int j)
Access method.
value_type * GetImagData() const
Returns the array of values of the imaginary part.
size_t GetMemorySize() const
returns size of A in bytes used to store the matrix
void Set(int i, int j, const entry_type &x)
Sets an element (i, j) to a value.
void ReadText(string FileName, bool cplx=false)
Reads the matrix from a file.
void WriteText(string FileName, bool cplx=false) const
Writes the matrix in a file.
long * GetImagPtr() const
Returns (row or column) start indices for the imaginary part.
void Fill()
Fills the non-zero entries with 0, 1, 2, ...
long GetDataSize() const
Returns the number of elements stored in memory.
long GetRealDataSize() const
Returns the length of the array of (column or row) indices for the real part.
const entry_type operator()(int i, int j) const
Access operator.
long GetNonZeros() const
Returns the number of elements stored in memory.
void Resize(int i, int j)
Changing the number of rows and columns.
value_type & ValImag(int i, int j)
Access method.
Matrix_ComplexSparse()
Default constructor.
int GetImagPtrSize() const
Returns the length of the array of start indices for the imaginary part.
void Clear()
Clears the matrix.
void AddInteraction(int i, int j, const entry_type &x)
Add a value to a non-zero entry.
long GetImagIndSize() const
Returns the length of the array of (column or row) indices for the imaginary part.
void Copy(const Matrix_ComplexSparse< T, Prop, Storage, Allocator > &A)
Copies a matrix.
value_type * GetRealData() const
Returns the array of values of the real part.
long * GetRealPtr() const
Returns (row or column) start indices for the real part.
void Write(string FileName) const
Writes the matrix in a file.
void Print() const
Displays the matrix on the standard output.
value_type & GetReal(int i, int j)
Access method.
void Read(string FileName)
Reads the matrix from a file.
int * GetRealInd() const
Returns (row or column) indices of non-zero entries for the real part.
Matrix_ComplexSparse< T, Prop, Storage, Allocator > & operator=(const Matrix_ComplexSparse< T, Prop, Storage, Allocator > &A)
Duplicates a matrix (assignment operator).
long GetImagDataSize() const
Returns the length of the array of (column or row) indices for the imaginary part.
void SetData(int i, int j, Vector< value_type, Storage0, Allocator0 > &real_values, Vector< long, Storage1, Allocator1 > &real_ptr, Vector< int, Storage2, Allocator2 > &real_ind, Vector< value_type, Storage0, Allocator0 > &imag_values, Vector< long, Storage1, Allocator1 > &imag_ptr, Vector< int, Storage2, Allocator2 > &imag_ind)
Redefines the matrix.
void AddInteractionRow(int i, int nb, const IVect &col, const Vector< entry_type > &val, bool sorted=false)
Adds values to several non-zero entries on a given row.