Go to the documentation of this file. 1 #ifndef PARGEMSLR_PARALLEL_VECTOR_H
2 #define PARGEMSLR_PARALLEL_VECTOR_H
10 #include "../utils/utils.hpp"
14 #include "../matrices/parallel_csr_matrix.hpp"
24 class ParallelVectorClass:
public VectorClass<T>
32 SequentialVectorClass<T> _data_vec;
74 ParallelVectorClass<T>&
operator= (
const ParallelVectorClass<T> &vec);
82 ParallelVectorClass<T>&
operator= ( ParallelVectorClass<T> &&vec);
97 int Setup(
int n_local, parallel_log &parlog);
107 int Setup(
int n_local,
bool setzero, parallel_log &parlog);
118 int Setup(
int n_local,
int location,
bool setzero, parallel_log &parlog);
131 int Setup(
int n_local,
int reserve,
int location,
bool setzero, parallel_log &parlog);
142 int Setup(
int n_local,
long int n_start,
long int n_global, parallel_log &parlog);
154 int Setup(
int n_local,
long int n_start,
long int n_global,
bool setzero, parallel_log &parlog);
167 int Setup(
int n_local,
long int n_start,
long int n_global,
int location,
bool setzero, parallel_log &parlog);
182 int Setup(
int n_local,
long int n_start,
long int n_global,
int reserve,
int location,
bool setzero, parallel_log &parlog);
209 int UpdatePtr(
void* data,
int location);
290 int Plot(
int conditiona,
int conditionb,
int width);
306 virtual int Fill(
const T &v);
321 virtual int Scale(
const T &alpha);
331 virtual int Axpy(
const T &alpha,
const VectorClass<T> &x);
341 virtual int Axpy(
const T &alpha,
const VectorClass<T> &x, VectorClass<T> &y);
352 virtual int Axpy(
const T &alpha,
const VectorClass<T> &x,
const T &beta, VectorClass<T> &y);
360 virtual int Norm2(
float &norm)
const;
368 virtual int Norm2(
double &norm)
const;
376 virtual int NormInf(
float &norm);
384 virtual int NormInf(
double &norm);
393 virtual int Dot(
const VectorClass<T> &y, T &t)
const;
402 #ifdef PARGEMSLR_CUDA
403 #if (PARGEMSLR_CUDA_VERSION == 11)
408 virtual cusparseDnVecDescr_t GetCusparseVec()
const;
415 int SetCusparseVec(cusparseDnVecDescr_t cusparse_vec);
425 virtual int MoveData(
const int &location);
438 typedef ParallelVectorClass<float> vector_par_float;
439 typedef ParallelVectorClass<double> vector_par_double;
440 typedef ParallelVectorClass<complexs> vector_par_complexs;
441 typedef ParallelVectorClass<complexd> vector_par_complexd;
Integer vector data structure, not a vector_base class.
int Plot(int conditiona, int conditionb, int width)
Print the vector.
Definition: parallel_vector.cpp:446
virtual bool IsParallel() const
Tell if this is a prallel vector.
Definition: parallel_vector.cpp:601
The virtual vector classes.
virtual T * GetData() const
Get the data pointer of the vector.
Definition: parallel_vector.cpp:304
int UpdatePtr(void *data, int location)
Update the data with new memory address. Need to call SetupPtrStr first.
Definition: parallel_vector.cpp:266
virtual int NormInf(float &norm)
Compute the inf-norm of a vector, result is type float.
Definition: parallel_vector.cpp:555
virtual int Norm2(float &norm) const
Compute the 2-norm of a vector, result is type float.
Definition: parallel_vector.cpp:529
Tell if a value is a parallel data structure.
Definition: utils.hpp:444
int SetupPtrStr(ParallelVectorClass< T > &x)
Setup the length information of a vector pointer with the information of a ParallelVectorClass.
Definition: parallel_vector.cpp:214
virtual int Fill(const T &v)
Fill the vector with constant value.
Definition: parallel_vector.cpp:462
Sequential vector data structure.
virtual int MoveData(const int &location)
Move the data to another memory location.
Definition: parallel_vector.cpp:611
ParallelVectorClass()
The constructor of ParallelVectorClass.
Definition: parallel_vector.cpp:22
int Setup(int n_local, parallel_log &parlog)
Free the current vector, and malloc memory to initilize the vector on comm.
Definition: parallel_vector.cpp:101
virtual int GetDataLocation() const
Get the data location of the vector.
Definition: parallel_vector.cpp:324
The class of parallel real/complex vector.
Definition: structs.hpp:14
SequentialVectorClass< T > & GetDataVector()
Get the reference of the data vector.
Definition: parallel_vector.cpp:314
The template class complex.
Definition: complex.hpp:24
bool IsHoldingData() const
Check if the vector holding its own data.
Definition: parallel_vector.cpp:364
virtual int Dot(const VectorClass< T > &y, T &t) const
Compute the dot product.
Definition: parallel_vector.cpp:587
virtual int Rand()
Fill the vector with random value.
Definition: parallel_vector.cpp:472
virtual int Scale(const T &alpha)
Scale the vector by x = alpha*x, where x is this vector.
Definition: parallel_vector.cpp:482
virtual int Axpy(const T &alpha, const VectorClass< T > &x)
Compute y = alpha * x + y, where y is this vector. Currenlty we don't support x == y.
Definition: parallel_vector.cpp:492
Tell if a value is a complex value.
Definition: complex.hpp:684
int WriteToDisk(const char *datafilename)
Write file to disk.
Definition: parallel_vector.cpp:384
virtual T & operator[](int i)
Get the reference of an index in the local vector.
Definition: parallel_vector.cpp:91
virtual long int GetStartGlobal() const
Get the global start index of the vector.
Definition: parallel_vector.cpp:354
int ReadFromSingleMMFile(const char *vecfile, int idxin)
Read vector on the host memory, matrix market format. Note that the vector should be setup already (h...
Definition: parallel_vector.cpp:646
ParallelVectorClass< T > & operator=(const ParallelVectorClass< T > &vec)
The operator = of ParallelVectorClass.
Definition: parallel_vector.cpp:59
int SetHoldingData(bool hold_data)
Set if the vector holding its own data.
Definition: parallel_vector.cpp:374
virtual int Clear()
Free the current vector.
Definition: parallel_vector.cpp:277
virtual int GetLengthLocal() const
Get the local length of the vector.
Definition: parallel_vector.cpp:334
virtual long int GetLengthGlobal() const
Get the global length of the vector.
Definition: parallel_vector.cpp:344
virtual ~ParallelVectorClass()
The destructor of ParallelVectorClass.
Definition: parallel_vector.cpp:294