ParGeMSLR
vector.hpp
Go to the documentation of this file.
1 #ifndef PARGEMSLR_VECTOR_H
2 #define PARGEMSLR_VECTOR_H
3 
9 #include "../utils/utils.hpp"
10 #include "../utils/parallel.hpp"
11 #include "../utils/memory.hpp"
12 
13 namespace pargemslr
14 {
15 
20  template <typename T>
22  {
23  public:
24 
30 
36 
42 
48  virtual int Clear();
49 
54  virtual ~VectorVirtualClass();
55 
62  virtual T& operator[] (int i) = 0;
63 
69  virtual T* GetData() const = 0;
70 
76  virtual int GetDataLocation() const = 0;
77 
83  virtual int GetLengthLocal() const = 0;
84 
91  virtual int Fill(const T &v) = 0;
92 
99  virtual int MoveData( const int &location) = 0;
100 
106  virtual bool IsParallel() const;
107 
113  PrecisionEnum GetPrecision() const;
114 
115  };
116 
117  template<> struct PargemslrIsComplex<VectorVirtualClass<complexs> > : public std::true_type {};
118  template<> struct PargemslrIsComplex<VectorVirtualClass<complexd> > : public std::true_type {};
119 
124  template <typename T>
126  {
127  public:
128 
133  VectorClass();
134 
139  VectorClass(const VectorClass<T> &vec);
140 
146 
152  virtual int Clear();
153 
158  virtual ~VectorClass();
159 
160 
161  /* Operations - - - - - - - */
162 
169  virtual T& operator[] (int i) = 0;
170 
176  virtual T* GetData() const = 0;
177 
183  virtual int GetDataLocation() const = 0;
184 
190  virtual int GetLengthLocal() const = 0;
191 
197  virtual long int GetLengthGlobal() const = 0;
198 
204  virtual long int GetStartGlobal() const = 0;
205 
212  virtual int Fill(const T &v) = 0;
213 
219  virtual int Rand() = 0;
220 
227  virtual int Scale( const T &alpha) = 0;
228 
236  virtual int Axpy( const T &alpha, const VectorClass<T> &x) = 0;
237 
246  virtual int Axpy( const T &alpha, const VectorClass<T> &x, VectorClass<T> &y) = 0;
247 
257  virtual int Axpy( const T &alpha, const VectorClass<T> &x, const T &beta, VectorClass<T> &y) = 0;
258 
265  virtual int Norm2( float &norm) const = 0;
266 
273  virtual int Norm2( double &norm) const = 0;
274 
281  virtual int NormInf( float &norm) = 0;
282 
289  virtual int NormInf( double &norm) = 0;
290 
298  virtual int Dot( const VectorClass<T> &y, T &t) const = 0;
299 
300 #ifdef PARGEMSLR_CUDA
301 #if (PARGEMSLR_CUDA_VERSION == 11)
302 
306  virtual cusparseDnVecDescr_t GetCusparseVec() const = 0;
307 #endif
308 #endif
309 
316  virtual int MoveData( const int &location) = 0;
317 
318  };
319 
324  template<> struct PargemslrIsComplex<VectorClass<complexs> > : public std::true_type {};
325  template<> struct PargemslrIsComplex<VectorClass<complexd> > : public std::true_type {};
326 
327 }
328 
329 #endif
pargemslr::VectorClass::GetLengthGlobal
virtual long int GetLengthGlobal() const =0
Get the global length of the vector.
pargemslr::VectorVirtualClass::Clear
virtual int Clear()
Free the current vector.
Definition: vector.cpp:52
pargemslr::VectorClass::Norm2
virtual int Norm2(float &norm) const =0
Compute the 2-norm of a vector, result is type float.
pargemslr::VectorClass::GetStartGlobal
virtual long int GetStartGlobal() const =0
Get the global start index of the vector.
pargemslr::VectorVirtualClass::GetPrecision
PrecisionEnum GetPrecision() const
Get the data precision of the vector.
Definition: vector.cpp:66
pargemslr::VectorClass::operator[]
virtual T & operator[](int i)=0
Get the reference of an index in the vector.
pargemslr::VectorVirtualClass::operator[]
virtual T & operator[](int i)=0
Get the reference of an index in the vector.
pargemslr::VectorVirtualClass::MoveData
virtual int MoveData(const int &location)=0
Move the data to another memory location.
pargemslr::VectorVirtualClass::VectorVirtualClass
VectorVirtualClass()
The constructor of VectorVirtualClass.
Definition: vector.cpp:8
pargemslr::VectorClass::Dot
virtual int Dot(const VectorClass< T > &y, T &t) const =0
Compute the dot product.
pargemslr::VectorVirtualClass::GetDataLocation
virtual int GetDataLocation() const =0
Get the data location of the vector.
pargemslr::VectorClass::Clear
virtual int Clear()
Free the current vector.
Definition: vector.cpp:117
pargemslr::VectorClass::Axpy
virtual int Axpy(const T &alpha, const VectorClass< T > &x)=0
Compute y = alpha * x + y, where y is this vector. Currenlty we don't support x == y.
pargemslr::VectorClass
The virtual class of real/complex vector class.
Definition: vector.hpp:126
pargemslr::VectorClass::NormInf
virtual int NormInf(float &norm)=0
Compute the inf-norm of a vector, result is type float.
pargemslr::VectorVirtualClass::GetData
virtual T * GetData() const =0
Get the data pointer of the vector.
pargemslr::VectorClass::Norm2
virtual int Norm2(double &norm) const =0
Compute the 2-norm of a vector, result is type double.
pargemslr::VectorClass::NormInf
virtual int NormInf(double &norm)=0
Compute the inf-norm of a vector, result is type double.
pargemslr::ComplexValueClass
The template class complex.
Definition: complex.hpp:24
pargemslr::VectorClass::GetDataLocation
virtual int GetDataLocation() const =0
Get the data location of the vector.
pargemslr::VectorVirtualClass::Fill
virtual int Fill(const T &v)=0
Fill the vector with constant value.
pargemslr::VectorClass::GetData
virtual T * GetData() const =0
Get the data pointer of the vector.
pargemslr::VectorClass::Axpy
virtual int Axpy(const T &alpha, const VectorClass< T > &x, VectorClass< T > &y)=0
Compute z = alpha * x + y, where z is this vector. Currenlty we don't support x == y,...
pargemslr::parallel_log
class pargemslr::ParallelLogClass parallel_log
The data structure for parallel computing, including data structures for MPI and CUDA.
pargemslr::VectorClass::VectorClass
VectorClass()
The constructor of VectorClass.
Definition: vector.cpp:90
pargemslr::VectorVirtualClass::IsParallel
virtual bool IsParallel() const
Tell if this is a prallel vector.
Definition: vector.cpp:78
pargemslr::VectorVirtualClass::~VectorVirtualClass
virtual ~VectorVirtualClass()
The destructor of VectorVirtualClass.
Definition: vector.cpp:41
pargemslr::VectorClass::Axpy
virtual int Axpy(const T &alpha, const VectorClass< T > &x, const T &beta, VectorClass< T > &y)=0
Compute z = alpha * x + beta * y, where z is this vector. Currenlty we don't support x == y,...
pargemslr::VectorClass::Rand
virtual int Rand()=0
Fill the vector with random value.
pargemslr::VectorVirtualClass::GetLengthLocal
virtual int GetLengthLocal() const =0
Get the local length of the vector.
pargemslr::VectorClass::Scale
virtual int Scale(const T &alpha)=0
Scale the vector by x = alpha*x, where x is this vector.
pargemslr::VectorClass::GetLengthLocal
virtual int GetLengthLocal() const =0
Get the local length of the vector.
pargemslr::VectorVirtualClass
The virtual class of all vector classes.
Definition: vector.hpp:22
pargemslr::PargemslrIsComplex
Tell if a value is a complex value.
Definition: complex.hpp:684
pargemslr::VectorClass::Fill
virtual int Fill(const T &v)=0
Fill the vector with constant value.
pargemslr::VectorClass::MoveData
virtual int MoveData(const int &location)=0
Move the data to another memory location.
pargemslr::VectorClass::~VectorClass
virtual ~VectorClass()
The destructor of VectorClass.
Definition: vector.cpp:129
pargemslr::PrecisionEnum
PrecisionEnum
The precision enum.
Definition: utils.hpp:453