23 #ifndef SELDON_FILE_MATRIX_SYMSPARSE_HXX
25 #include "../share/Common.hxx"
26 #include "../share/Properties.hxx"
27 #include "../share/Storage.hxx"
28 #include "../share/Errors.hxx"
29 #include "../share/Allocator.hxx"
44 template <
class T,
class Prop,
class Storage,
class Allocator
45 =
typename SeldonDefaultAllocator<Storage, T>::allocator>
50 typedef typename Allocator::value_type value_type;
51 typedef typename Allocator::pointer pointer;
52 typedef typename Allocator::const_pointer const_pointer;
53 typedef typename Allocator::reference reference;
54 typedef typename Allocator::const_reference const_reference;
55 typedef typename Allocator::value_type entry_type;
56 typedef typename Allocator::value_type access_type;
57 typedef typename Allocator::value_type const_access_type;
58 typedef typename SeldonDefaultAllocator<VectFull, int>::allocator AllocatorInt;
59 typedef typename SeldonDefaultAllocator<VectFull, long>::allocator AllocatorLong;
76 template <
class Storage0,
class Allocator0,
77 class Storage1,
class Allocator1,
78 class Storage2,
class Allocator2>
89 template <
class Storage0,
class Allocator0,
90 class Storage1,
class Allocator1,
91 class Storage2,
class Allocator2>
96 void SetData(
int i,
int j,
long nz, pointer values,
long* ptr,
int* ind);
100 void Resize(
int i,
int j);
101 void Resize(
int i,
int j,
long nz);
115 const value_type
operator() (
int i,
int j)
const;
116 value_type&
Val(
int i,
int j);
117 value_type&
Get(
int i,
int j);
118 const value_type&
Val(
int i,
int j)
const;
119 const value_type&
Get(
int i,
int j)
const;
120 void Set(
int i,
int j,
const T& x);
121 void SetEntry(
int i,
int j,
const T& x);
136 void Fill(
const T0& x);
140 void Write(
string FileName)
const;
141 void Write(ostream& FileStream)
const;
142 void WriteText(
string FileName,
bool cplx =
false)
const;
143 void WriteText(ostream& FileStream,
bool cplx =
false)
const;
144 void Read(
string FileName);
145 void Read(istream& FileStream);
146 void ReadText(
string FileName,
bool cplx =
false);
147 void ReadText(istream& FileStream,
bool cplx =
false);
149 #ifdef SELDON_WITH_VIRTUAL
150 typedef typename ClassComplexType<T>::Treal Treal;
151 typedef typename ClassComplexType<T>::Tcplx Tcplx;
154 const typename ClassComplexType<T>::Treal& omega,
155 int nb_iter,
int stage_ssor)
const;
158 const typename ClassComplexType<T>::Treal& omega,
159 int nb_iter,
int stage_ssor)
const;
161 virtual void MltAddVector(
const Treal& alpha,
const Vector<Treal>& x,
164 virtual void MltAddVector(
const Tcplx& alpha,
const Vector<Tcplx>& x,
184 virtual bool IsSymmetric()
const;
191 template <
class T,
class Prop,
class Allocator>
197 typedef typename Allocator::value_type value_type;
198 typedef Prop property;
200 typedef Allocator allocator;
204 explicit Matrix(
int i,
int j);
205 explicit Matrix(
int i,
int j,
long nz);
206 template <
class Storage0,
class Allocator0,
207 class Storage1,
class Allocator1,
208 class Storage2,
class Allocator2>
217 template <
class T,
class Prop,
class Allocator>
223 typedef typename Allocator::value_type value_type;
224 typedef Prop property;
226 typedef Allocator allocator;
230 explicit Matrix(
int i,
int j);
231 explicit Matrix(
int i,
int j,
long nz);
232 template <
class Storage0,
class Allocator0,
233 class Storage1,
class Allocator1,
234 class Storage2,
class Allocator2>
243 #define SELDON_FILE_MATRIX_SYMSPARSE_HXX
const value_type operator()(int i, int j) const
Access operator.
void SetIdentity()
Sets the matrix to identity.
int * GetInd() const
Returns (row or column) indices of non-zero entries.
size_t GetMemorySize() const
returns size of matrix in bytes
Base class for all matrices.
Matrix_SymSparse< T, Prop, Storage, Allocator > & operator=(const Matrix_SymSparse< T, Prop, Storage, Allocator > &A)
Duplicates a matrix (assignment operator).
void Fill()
Fills the non-zero entries with 0, 1, 2, ...
int GetPtrSize() const
Returns the length of the array of start indices.
void SetEntry(int i, int j, const T &x)
Sets an element (i, j) to a value.
Symmetric sparse-matrix class.
void Write(string FileName) const
Writes the matrix in a file.
long * GetPtr() const
Returns (row or column) start indices.
long GetDataSize() const
Returns the number of elements stored in memory.
void Reallocate(int i, int j)
Initialization of an empty sparse matrix with i rows and j columns.
void Nullify()
Clears the matrix without releasing memory.
void Zero()
Resets all non-zero entries to 0-value.
~Matrix_SymSparse()
Destructor.
void Print() const
Displays the matrix on the standard output.
void FillRand()
Fills the non-zero entries randomly.
void Copy(const Matrix_SymSparse< T, Prop, Storage, Allocator > &A)
Copies a matrix.
void ReadText(string FileName, bool cplx=false)
Reads the matrix from a file.
void Set(int i, int j, const T &x)
Sets an element (i, j) to a value.
void SetData(int i, int j, Vector< T, Storage0, Allocator0 > &values, Vector< long, Storage1, Allocator1 > &ptr, Vector< int, Storage2, Allocator2 > &ind)
Redefines the matrix.
void WriteText(string FileName, bool cplx=false) const
Writes the matrix in a file.
void FillPtrInt(Vector< int > &) const
Fills vector ptr with integers instead of longs.
void AddInteraction(int i, int j, const T &x)
Add a value to a non-zero entry.
value_type & Val(int i, int j)
Access method.
long GetNonZeros() const
Returns the number of elements stored in memory.
Matrix_SymSparse()
Default constructor.
void Clear()
Clears the matrix.
long GetIndSize() const
Returns the length of the array of (column or row) indices.
void Read(string FileName)
Reads the matrix from a file.
value_type & Get(int i, int j)
Access method.
void Resize(int i, int j)
Changing the number of rows and columns.
void AddInteractionRow(int i, int nb, const Vector< int > &col, const Vector< T > &val, bool sorted)
Adds values to several non-zero entries on a given row.