22 #ifndef SELDON_FILE_MATRIX_POINTERS_HXX
24 #include "../share/Common.hxx"
25 #include "../share/Properties.hxx"
26 #include "../share/Storage.hxx"
27 #include "../share/Errors.hxx"
28 #include "../share/Allocator.hxx"
35 template <
class T,
class Prop,
class Storage,
class Allocator
36 =
typename SeldonDefaultAllocator<Storage, T>::allocator>
41 typedef typename Allocator::value_type value_type;
42 typedef typename Allocator::pointer pointer;
43 typedef typename Allocator::const_pointer const_pointer;
44 typedef typename Allocator::reference reference;
45 typedef typename Allocator::const_reference const_reference;
46 typedef typename Allocator::value_type entry_type;
47 typedef typename Allocator::reference access_type;
48 typedef typename Allocator::const_reference const_access_type;
68 pointer*
GetMe()
const;
72 void SetData(
int i,
int j, pointer data);
80 const_reference
operator() (
int i,
int j)
const;
82 reference
Val(
int i,
int j);
83 reference
Get(
int i,
int j);
85 const_reference
Val(
int i,
int j)
const;
86 const_reference
Get(
int i,
int j)
const;
94 void Set(
int i,
int j,
const T& val);
103 void Fill(
const T0& x);
110 void Print(
int a,
int b,
int m,
int n)
const;
111 void Print(
int l)
const;
114 void Append(
string FileName)
const;
115 void Write(
string FileName,
bool with_size =
true)
const;
116 #ifdef SELDON_WITH_HDF5
117 void WriteHDF5(
string FileName,
string group_name,
string dataset_name)
120 void Write(ostream& FileStream,
bool with_size =
true)
const;
122 void WriteText(ostream& FileStream)
const;
123 void Read(
string FileName,
bool with_size =
true);
124 void Read(istream& FileStream,
bool with_size =
true);
128 #ifdef SELDON_WITH_VIRTUAL
132 virtual bool IsSymmetric()
const;
134 virtual void AddInteraction(
int,
int,
const T&);
135 virtual void AddInteractionRow(
int,
int,
const Vector<int>&,
136 const Vector<T>& val,
bool sorted =
false);
138 virtual void AddInteractionColumn(
int,
int,
const Vector<int>&,
139 const Vector<T>& val,
bool sorted =
false);
141 virtual void ClearRow(
int i);
143 typedef typename ClassComplexType<T>::Treal Treal;
144 typedef typename ClassComplexType<T>::Tcplx Tcplx;
146 virtual void MltAddVector(
const Treal& alpha,
const Vector<Treal>& x,
149 virtual void MltAddVector(
const Tcplx& alpha,
const Vector<Tcplx>& x,
175 template <
class T,
class Prop,
class Allocator>
181 typedef typename Allocator::value_type value_type;
182 typedef Prop property;
184 typedef Allocator allocator;
188 explicit Matrix(
int i,
int j);
191 void WriteColumn(
string FileName,
int col)
const;
192 void WriteColumn(ostream& FileStream,
int col)
const;
206 template <
class T,
class Prop,
class Allocator>
212 typedef typename Allocator::value_type value_type;
213 typedef Prop property;
215 typedef Allocator allocator;
219 explicit Matrix(
int i,
int j);
222 void WriteRow(
string FileName,
int row)
const;
223 void WriteRow(ostream& FileStream,
int row)
const;
239 #define SELDON_FILE_MATRIX_POINTERS_HXX
size_t GetMemorySize() const
Returns size of A in bytes used to store the matrix.
Base class for all matrices.
void Nullify()
Clears the matrix without releasing memory.
void Append(string FileName) const
Appends the matrix in a file.
pointer * GetMe() const
Returns the pointer 'me_'.
void Reallocate(int i, int j)
Reallocates memory to resize the matrix.
void WriteText(string FileName) const
Writes the matrix in a file.
~Matrix_Pointers()
Destructor.
void FillRand()
Fills the matrix randomly.
void Set(int i, int j, const T &val)
Sets an element of the matrix.
long GetDataSize() const
Returns the number of elements stored in memory.
void Clear()
Clears the matrix.
reference Val(int i, int j)
Access operator.
void Zero()
Sets all elements to zero.
void Read(string FileName, bool with_size=true)
Reads the matrix from a file.
reference operator()(int i, int j)
Access operator.
Row-major full-matrix class.
Matrix_Pointers< T, Prop, Storage, Allocator > & operator=(const Matrix_Pointers< T, Prop, Storage, Allocator > &A)
Duplicates a matrix (assignment operator).
void Fill()
Fills the matrix the matrix with 0, 1, 2, ...
void SetIdentity()
Sets the current matrix to the identity.
void Print() const
Displays the matrix on the standard output.
void ReadText(string FileName)
Reads the matrix from a file.
int GetLD() const
Returns the leading dimension.
void SetData(int i, int j, pointer data)
Changes the size of the matrix and sets its data array (low level method).
void Copy(const Matrix_Pointers< T, Prop, Storage, Allocator > &A)
Duplicates a matrix.
void Write(string FileName, bool with_size=true) const
Writes the matrix in a file.
void Resize(int i, int j)
Reallocates memory to resize the matrix and keeps previous entries.
pointer GetDataPointer(int i, int j) const
Returns a pointer to a data element.
reference Get(int i, int j)
Access operator.
Matrix_Pointers()
Default constructor.
Column-major full-matrix class.
reference operator[](int i)
Access to elements of the data array.