22 #ifndef SELDON_FILE_MATRIX_ARRAY_COMPLEX_SPARSE_HXX
34 ::allocator allocator;
42 SeldonDefaultAllocator<VectFull, float>::allocator allocator;
50 SeldonDefaultAllocator<VectFull, double>::allocator allocator;
58 SeldonDefaultAllocator<VectFull, long double>::allocator allocator;
68 ::allocator allocator;
76 SeldonDefaultAllocator<VectFull, float>::allocator allocator;
84 SeldonDefaultAllocator<VectFull, double>::allocator allocator;
92 SeldonDefaultAllocator<VectFull, long double>::allocator allocator;
103 ::allocator allocator;
111 SeldonDefaultAllocator<VectFull, float>::allocator allocator;
119 SeldonDefaultAllocator<VectFull, double>::allocator allocator;
127 SeldonDefaultAllocator<VectFull, long double>::allocator allocator;
138 ::allocator allocator;
146 SeldonDefaultAllocator<VectFull, float>::allocator allocator;
154 SeldonDefaultAllocator<VectFull, double>::allocator allocator;
162 SeldonDefaultAllocator<VectFull, long double>::allocator allocator;
174 template <
class T,
class Prop,
class Storage,
class Allocator
175 =
typename SeldonDefaultAllocator<Storage, T>::allocator>
180 typedef typename Allocator::value_type value_type;
181 typedef typename Allocator::pointer pointer;
182 typedef typename Allocator::const_pointer const_pointer;
183 typedef typename Allocator::reference reference;
184 typedef typename Allocator::const_reference const_reference;
185 typedef complex<value_type> entry_type;
186 typedef complex<value_type> access_type;
187 typedef complex<value_type> const_access_type;
210 void Resize(
int i,
int j);
222 value_type* GetRealData(
int i)
const;
223 value_type* GetImagData(
int i)
const;
228 const entry_type
operator() (
int i,
int j)
const;
229 entry_type&
Val(
int i,
int j);
230 const entry_type&
Val(
int i,
int j)
const;
231 entry_type&
Get(
int i,
int j);
232 const entry_type&
Get(
int i,
int j)
const;
234 value_type&
ValReal(
int i,
int j);
235 const value_type&
ValReal(
int i,
int j)
const;
236 value_type&
ValImag(
int i,
int j);
237 const value_type&
ValImag(
int i,
int j)
const;
238 value_type&
GetReal(
int i,
int j);
239 const value_type&
GetReal(
int i,
int j)
const;
240 value_type&
GetImag(
int i,
int j);
241 const value_type&
GetImag(
int i,
int j)
const;
243 void Set(
int i,
int j,
const entry_type& x);
245 const value_type&
ValueReal(
int num_row,
int i)
const;
246 value_type&
ValueReal(
int num_row,
int i);
249 const value_type&
ValueImag(
int num_row,
int i)
const;
250 value_type&
ValueImag(
int num_row,
int i);
265 void Write(
string FileName)
const;
266 void Write(ostream& FileStream)
const;
267 void WriteText(
string FileName,
bool cplx =
false)
const;
268 void WriteText(ostream& FileStream,
bool cplx =
false)
const;
269 void Read(
string FileName);
270 void Read(istream& FileStream);
271 void ReadText(
string FileName,
bool cplx =
false);
272 void ReadText(istream& FileStream,
bool cplx =
false);
283 void Fill(
const complex<T0>& x);
286 (
const complex<T0>& x);
289 #ifdef SELDON_WITH_VIRTUAL
290 typedef typename ClassComplexType<T>::Treal Treal;
291 typedef typename ClassComplexType<T>::Tcplx Tcplx;
294 const typename ClassComplexType<T>::Treal& omega,
295 int nb_iter,
int stage_ssor)
const;
298 const typename ClassComplexType<T>::Treal& omega,
299 int nb_iter,
int stage_ssor)
const;
301 virtual void MltAddVector(
const Treal& alpha,
const Vector<Treal>& x,
304 virtual void MltAddVector(
const Tcplx& alpha,
const Vector<Tcplx>& x,
324 virtual bool IsSymmetric()
const;
331 template <
class T,
class Prop,
class Allocator>
337 typedef typename Allocator::value_type value_type;
338 typedef Prop property;
340 typedef Allocator allocator;
341 typedef complex<value_type> entry_type;
345 explicit Matrix(
int i,
int j);
348 void ClearRealColumn(
int i);
349 void ClearImagColumn(
int i);
350 void ReallocateRealColumn(
int i,
int j);
351 void ReallocateImagColumn(
int i,
int j);
352 void ResizeRealColumn(
int i,
int j);
353 void ResizeImagColumn(
int i,
int j);
354 void SwapRealColumn(
int i,
int i_);
355 void SwapImagColumn(
int i,
int i_);
356 void ReplaceRealIndexColumn(
int i,
IVect& new_index);
357 void ReplaceImagIndexColumn(
int i,
IVect& new_index);
359 int GetRealColumnSize(
int i)
const;
360 int GetImagColumnSize(
int i)
const;
361 void PrintRealColumn(
int i)
const;
362 void PrintImagColumn(
int i)
const;
363 void AssembleRealColumn(
int i);
364 void AssembleImagColumn(
int i);
366 void AddInteraction(
int i,
int j,
const entry_type& val);
368 void AddInteractionRow(
int i,
int nb,
const IVect& col,
370 bool sorted =
false);
372 void AddInteractionColumn(
int i,
int nb,
const IVect& row,
374 bool sorted =
false);
379 template <
class T,
class Prop,
class Allocator>
385 typedef typename Allocator::value_type value_type;
386 typedef Prop property;
388 typedef Allocator allocator;
389 typedef complex<value_type> entry_type;
393 explicit Matrix(
int i,
int j);
396 void ClearRealRow(
int i);
397 void ClearImagRow(
int i);
398 void ClearRow(
int i);
399 void ReallocateRealRow(
int i,
int j);
400 void ReallocateImagRow(
int i,
int j);
401 void ResizeRealRow(
int i,
int j);
402 void ResizeImagRow(
int i,
int j);
403 void SwapRealRow(
int i,
int i_);
404 void SwapImagRow(
int i,
int i_);
405 void ReplaceRealIndexRow(
int i,
IVect& new_index);
406 void ReplaceImagIndexRow(
int i,
IVect& new_index);
408 int GetRealRowSize(
int i)
const;
409 int GetImagRowSize(
int i)
const;
410 void PrintRealRow(
int i)
const;
411 void PrintImagRow(
int i)
const;
412 void AssembleRealRow(
int i);
413 void AssembleImagRow(
int i);
415 void AddInteraction(
int i,
int j,
const entry_type& val);
417 void AddInteractionRow(
int i,
int nb,
const IVect& col,
419 bool sorted =
false);
421 void AddInteractionColumn(
int i,
int nb,
const IVect& row,
423 bool sorted =
false);
429 template <
class T,
class Prop,
class Allocator>
435 typedef typename Allocator::value_type value_type;
436 typedef Prop property;
438 typedef Allocator allocator;
439 typedef complex<value_type> entry_type;
443 explicit Matrix(
int i,
int j);
445 const entry_type operator() (
int i,
int j)
const;
447 value_type& ValReal(
int i,
int j);
448 const value_type& ValReal(
int i,
int j)
const;
449 value_type& ValImag(
int i,
int j);
450 const value_type& ValImag(
int i,
int j)
const;
451 value_type& GetReal(
int i,
int j);
452 const value_type& GetReal(
int i,
int j)
const;
453 value_type& GetImag(
int i,
int j);
454 const value_type& GetImag(
int i,
int j)
const;
456 void Set(
int i,
int j,
const entry_type& x);
459 void ClearRealColumn(
int i);
460 void ClearImagColumn(
int i);
461 void ReallocateRealColumn(
int i,
int j);
462 void ReallocateImagColumn(
int i,
int j);
463 void ResizeRealColumn(
int i,
int j);
464 void ResizeImagColumn(
int i,
int j);
465 void SwapRealColumn(
int i,
int i_);
466 void SwapImagColumn(
int i,
int i_);
467 void ReplaceRealIndexColumn(
int i,
IVect& new_index);
468 void ReplaceImagIndexColumn(
int i,
IVect& new_index);
470 int GetRealColumnSize(
int i)
const;
471 int GetImagColumnSize(
int i)
const;
472 void PrintRealColumn(
int i)
const;
473 void PrintImagColumn(
int i)
const;
474 void AssembleRealColumn(
int i);
475 void AssembleImagColumn(
int i);
477 void AddInteraction(
int i,
int j,
const entry_type& val);
479 void AddInteractionRow(
int i,
int nb,
const IVect& col,
481 bool sorted =
false);
483 void AddInteractionColumn(
int i,
int nb,
const IVect& row,
485 bool sorted =
false);
491 template <
class T,
class Prop,
class Allocator>
497 typedef typename Allocator::value_type value_type;
498 typedef Prop property;
500 typedef Allocator allocator;
501 typedef complex<value_type> entry_type;
505 explicit Matrix(
int i,
int j);
507 const entry_type operator() (
int i,
int j)
const;
509 value_type& ValReal(
int i,
int j);
510 const value_type& ValReal(
int i,
int j)
const;
511 value_type& ValImag(
int i,
int j);
512 const value_type& ValImag(
int i,
int j)
const;
513 value_type& GetReal(
int i,
int j);
514 const value_type& GetReal(
int i,
int j)
const;
515 value_type& GetImag(
int i,
int j);
516 const value_type& GetImag(
int i,
int j)
const;
518 void Set(
int i,
int j,
const entry_type& x);
521 void ClearRealRow(
int i);
522 void ClearImagRow(
int i);
523 void ClearRow(
int i);
524 void ReallocateRealRow(
int i,
int j);
525 void ReallocateImagRow(
int i,
int j);
526 void ResizeRealRow(
int i,
int j);
527 void ResizeImagRow(
int i,
int j);
528 void SwapRealRow(
int i,
int i_);
529 void SwapImagRow(
int i,
int i_);
530 void ReplaceRealIndexRow(
int i,
IVect& new_index);
531 void ReplaceImagIndexRow(
int i,
IVect& new_index);
533 int GetRealRowSize(
int i)
const;
534 int GetImagRowSize(
int i)
const;
535 void PrintRealRow(
int i)
const;
536 void PrintImagRow(
int i)
const;
537 void AssembleRealRow(
int i);
538 void AssembleImagRow(
int i);
540 void AddInteraction(
int i,
int j,
const entry_type& val);
542 void AddInteractionRow(
int i,
int nb,
const IVect& col,
544 bool sorted =
false);
546 void AddInteractionColumn(
int i,
int nb,
const IVect& row,
553 #define SELDON_FILE_MATRIX_ARRAY_COMPLEX_SPARSE_HXX
void NullifyImag()
Clears the matrix without releasing memory.
Selection of default allocator depending on storage and value type.
value_type & ValReal(int i, int j)
Returns acces to real part of A(i, j)
void Clear()
Clears the matrix.
int IndexReal(int num_row, int i) const
Returns column number of j-th non-zero value of row i (real part).
int IndexImag(int num_row, int i) const
Returns column number of j-th non-zero value of row i (imaginary part).
value_type & ValImag(int i, int j)
Returns acces to imaginary part of A(i, j)
Vector< Vector< value_type, VectSparse, Allocator >, VectFull, NewAlloc< Vector< value_type, VectSparse, Allocator > > > val_imag_
imaginary part rows or columns
void Resize(int i, int j)
Reallocates additional memory to resize the matrix.
void WriteText(string FileName, bool cplx=false) const
Writes the matrix in a file.
Sparse Array-matrix class.
long GetDataSize() const
Returns the number of elements stored in memory (real+imaginary part).
void SetImagData(int, int, Vector< value_type, VectSparse, Allocator > *)
Redefines the imaginary part of the matrix.
Matrix_ArrayComplexSparse()
Default constructor.
void FillRand()
Non-zero entries take a random value.
void Write(string FileName) const
Writes the matrix in a file.
value_type & GetImag(int i, int j)
Returns acces to imaginary part of A(i, j)
void Read(string FileName)
Reads the matrix from a file.
size_t GetMemorySize() const
returns size of matrix in bytes
void NullifyReal()
Clears the matrix without releasing memory.
int * GetRealInd(int i) const
Returns column indices of non-zero entries in row (real part).
void Reallocate(int i, int j)
Reallocates memory to resize the matrix.
entry_type & Get(int i, int j)
Unavailable access method.
long GetNonZeros() const
Returns the number of elements stored in memory (real+imaginary part).
void RemoveSmallEntry(const T0 &epsilon)
removes small entries
void Set(int i, int j, const entry_type &x)
Sets element (i, j) of matrix.
const entry_type operator()(int i, int j) const
Access operator.
void Fill()
Non-zero entries are filled with values 0, 1, 2, 3 ...
void SetRealData(int, int, Vector< value_type, VectSparse, Allocator > *)
Redefines the real part of the matrix.
~Matrix_ArrayComplexSparse()
Destructor.
void SetIdentity()
Matrix is initialized to the identity matrix.
long GetRealDataSize() const
Returns the number of elements stored in memory (real part).
void Assemble()
Assembles the matrix.
long GetImagNonZeros() const
Returns the number of non-zero elements (imaginary part).
Vector< Vector< value_type, VectSparse, Allocator >, VectFull, NewAlloc< Vector< value_type, VectSparse, Allocator > > > val_real_
real part rows or columns
long GetImagDataSize() const
Returns the number of elements stored in memory (imaginary part).
void Print() const
Displays the matrix on the standard output.
long GetRealNonZeros() const
Returns the number of non-zero elements (real part).
int * GetImagInd(int i) const
Returns column indices of non-zero entries in row (imaginary part).
value_type & GetReal(int i, int j)
Returns acces to real part of A(i, j)
void ReadText(string FileName, bool cplx=false)
Reads the matrix from a file.
const value_type & ValueReal(int num_row, int i) const
Returns j-th non-zero value of row i (real part).
Abstract base class for all matrices.
entry_type & Val(int i, int j)
Unavailable access method.
void Zero()
Non-zero entries are set to 0 (but not removed).
const value_type & ValueImag(int num_row, int i) const
Returns j-th non-zero value of row i (imaginary part).