20 #ifndef SELDON_FILE_BAND_MATRIX_HXX
34 template <
class T,
class Prop,
class Storage,
class Allocator
35 =
typename SeldonDefaultAllocator<Storage, T>::allocator>
80 const T&
Get(
int i,
int j)
const;
83 const T&
Val(
int i,
int j)
const;
85 void Set(
int,
int,
const T&);
91 void Fill(
const T0& x);
100 void Add_(
const T0& alpha,
103 template<
class T0,
class T1>
113 void Write(
string FileName)
const;
114 void Write(ostream& FileStream)
const;
116 void WriteText(ostream& FileStream)
const;
118 #ifdef SELDON_WITH_VIRTUAL
119 typedef typename ClassComplexType<T>::Treal Treal;
120 typedef typename ClassComplexType<T>::Tcplx Tcplx;
123 const typename ClassComplexType<T>::Treal& omega,
124 int nb_iter,
int stage_ssor)
const;
127 const typename ClassComplexType<T>::Treal& omega,
128 int nb_iter,
int stage_ssor)
const;
130 virtual void MltAddVector(
const Treal& alpha,
const Vector<Treal>& x,
133 virtual void MltAddVector(
const Tcplx& alpha,
const Vector<Tcplx>& x,
153 virtual bool IsSymmetric()
const;
160 template<
class T,
class Allocator>
162 :
public Matrix_Band<T, General, BandedCol, Allocator>
168 template <
class T,
class Prop,
class Storage,
class Allocator
169 =
typename SeldonDefaultAllocator<Storage, T>::allocator>
196 int nb_last_row = 0,
int nb_last_col = 0);
201 bool sorted =
false);
209 T&
Get(
int i,
int j);
210 const T&
Get(
int i,
int j)
const;
212 T&
Val(
int i,
int j);
213 const T&
Val(
int i,
int j)
const;
215 void Set(
int,
int,
const T&);
221 void Fill(
const T0& x);
228 void Add_(
const T0& alpha,
231 template<
class T0,
class T1>
238 void Write(
string FileName)
const;
239 void Write(ostream& FileStream)
const;
241 void WriteText(ostream& FileStream)
const;
252 template<
class T,
class Allocator>
262 template<
class T,
class Allocator>
265 bool keep_matrix =
false);
267 template<
class T,
class Allocator>
270 template<
class T,
class Allocator>
273 template<
class T,
class Allocator>
278 template<
class Allocator>
282 template<
class Allocator>
287 template<
class Allocator>
292 template<
class Allocator>
296 template<
class Allocator>
297 void SolveLU(
const Matrix<complex<double>,
302 template<
class T,
class Allocator>
306 template<
class T,
class Allocator>
311 template<
class T,
class Allocator>
316 template<
class T,
class Allocator>
320 template<
class T0,
class T1,
class Prop1,
class Allocator1,
321 class T2,
class Prop2,
class Allocator2>
326 template<
class T0,
class T1,
class T,
class T2,
class Allocator>
327 void MltAddVector(
const T0& alpha,
331 template<
class T0,
class T1,
class T,
class T2,
class Allocator>
336 template<
class T,
class Allocator,
class T1>
340 template<
class T,
class Allocator,
class T1>
345 template<
class T0,
class T1,
class Allocator>
349 template<
class T,
class Allocator>
353 template<
class T,
class Allocator>
356 bool keep_matrix =
false);
358 template<
class T,
class Allocator>
361 template<
class T,
class Allocator>
364 template<
class T,
class Allocator>
367 template<
class T0,
class T1,
class Prop1,
class Allocator1,
368 class T2,
class Prop2,
class Allocator2>
373 template<
class T0,
class T1,
class T,
class T2,
class Allocator>
374 void MltAddVector(
const T0& alpha,
378 template<
class T0,
class T1,
class T,
class T2,
class Allocator>
383 template<
class T,
class Allocator,
class T1>
387 template<
class T,
class Allocator,
class T1>
392 template<
class T0,
class T1,
class Allocator>
396 template<
class T,
class Prop,
class Allocator,
397 class T1,
class Allocator1,
class T2,
class Allocator2>
402 template<
class T,
class Allocator>
408 #define SELDON_FILE_BAND_MATRIX_HXX
Matrix< T, General, RowMajor, Allocator > last_rows_
last rows
size_t GetMemorySize() const
returns the memory used by the object in bytes
void Set(int, int, const T &)
sets A(i, j)
base class for a banded-matrix
size_t GetMemorySize() const
returns the memory used by the object in bytes
void Add_(const T0 &alpha, const Matrix< T, General, BandedCol, Allocator > &A)
performs the operation *this = *this + alpha A
void AddInteraction(int i, int j, const T &val)
performs the operation A(i, j) = A(i, j) + val
base class for arrow matrix (banded matrix + dense columns/rows)
void Fill(const T0 &x)
sets all non-zero entries to a same value
void Add_(const T0 &alpha, const Matrix< T, General, ArrowCol, Allocator > &A)
performs the operation *this = *this + alpha A
void MltScalar(const T0 &alpha, Array3D< T, Allocator > &A)
Multiplication of all elements of a 3D array by a scalar.
void MltAdd(const T0 &alpha, const SeldonTranspose &trans, const Vector< T1 > &x, Vector< T1 > &y) const
performs matrix-vector product y = y + alpha A x
int GetN() const
returns the number of rows
void Factorize()
performs LU factorisation without pivoting
void FillRand()
sets all non-zero entries to random values
T * GetData() const
returns a pointer to the array containing values
void AddInteractionRow(int i, int n, const IVect &num, const Vector< T > &val, bool sorted=false)
adds severals values on a single row of the matrix
void Solve(Vector< T1 > &x) const
solves A x = b, assuming that Factorize has been previously called
void Zero()
fills non-zero entries with 0
arrow matrix stored by columns
T & Val(int i, int j)
returns a reference to A(i, j)
void Set(int, int, const T &)
sets A(i, j)
void Copy(const Matrix< T, General, ArrayRowSparse > &A)
conversion from a CSR matrix
Matrix< T, General, ColMajor, Allocator > last_block_
last block
Matrix< T, General, ColMajor, Allocator > last_columns_
last columns
void SetIdentity()
sets the matrix to the identity matrix
int GetM() const
returns the number of rows
int kl_
number of extra-diagonals in lower part
const T operator()(int i, int j) const
returns entry (i, j) of the matrix
void HideMessages()
present for compatibility
Matrix_Band()
default constructor
const T operator()(int i, int j) const
returns entry (i, j) of the matrix
void Solve(Vector< T1 > &x) const
solves A x = b, assuming that Factorize has been previously called
banded matrix stored by columns (Lapack format)
Matrix< T, Prop, Storage, Allocator > & operator*=(const T &alpha)
multiplication by a scalar
void AddInteractionRow(int i, int n, const IVect &num, const Vector< T > &val, bool sorted=false)
adds severals values on a single row of the matrix
int GetN() const
returns the number of columns
void Reallocate(int m, int n)
changes the size of the matrix
void Clear()
clears the matrix
void SetEntry(int, int, const T &)
sets A(i, j)
void Clear()
clears the matrix
int GetNbLastCol() const
returns the number of dense columns placed at the end of the matrix
T & Get(int i, int j)
returns a reference to A(i, j)
T & Val(int i, int j)
returns a reference to A(i, j)
void ClearRow(int i)
clears row i, fills it with 0
int GetNbLastRow() const
returns the number of dense rows placed at the end of the matrix
int ku_
number of extra-diagonals in upper part
Matrix_Arrow()
default constructor
void ClearRow(int i)
clears row i, fills it with 0
long GetDataSize() const
returns the number of elements stored in the matrix
void Write(string FileName) const
writes the matrix in a file in binary format
void SetEntry(int, int, const T &)
sets A(i, j)
void GetLU(Matrix< T0, Prop0, Storage0, Allocator0 > &A)
Returns the LU factorization of a matrix.
Matrix< T, General, ColMajor, Allocator > data_
values are stored in a dense matrix (in Lapack format)
void AddInteraction(int i, int j, const T &val)
sets A(i, j) = A(i, j) + val
T & Get(int i, int j)
returns a reference to A(i, j)
void Write(string FileName) const
writes the matrix in a file in binary format
long GetDataSize() const
returns the number of non-zero entries
int GetKU() const
returns the number of extra-diagonals in upper part of the matrix
Matrix< T, Prop, Storage, Allocator > & operator*=(const T &alpha)
multiplication by a scalar
void Fill(const T0 &x)
sets all non-zero entries to a same value
void HideMessages()
present for compatibility
int GetM() const
returns the number of rows
void FillRand()
sets all non-zero entries to random values
void Reallocate(int m, int n)
changes the size of the matrix, previous entries are lost
void Zero()
sets all non-zero entries to 0
void SetIdentity()
sets the matrix to the identity matrix
ostream & operator<<(ostream &out, const Array< T, N, Allocator > &A)
operator<< overloaded for a 3D array.
void WriteText(string FileName) const
writes the matrix in a file in text format
void Factorize()
performs LU factorisation without pivoting
void WriteText(string FileName) const
writes the matrix in a file in text format
void AddMatrix(const T0 &alpha, const Matrix< T1, Prop1, Storage1, Allocator1 > &A, Matrix< T2, Prop2, Storage2, Allocator2 > &B)
Adds two matrices.
int GetKL() const
returns the number of extra-diagonals in lower part of the matrix
void MltAdd(const T0 &alpha, const SeldonTranspose &trans, const Vector< T1 > &x, Vector< T1 > &y) const
performs matrix-vector product y = y + alpha A x
Abstract base class for all matrices.