Go to the documentation of this file. 1 #ifndef PARGEMSLR_SEQUENTIAL_VECTOR_H
2 #define PARGEMSLR_SEQUENTIAL_VECTOR_H
10 #include "../utils/utils.hpp"
11 #include "../utils/structs.hpp"
21 template <
typename T>
class CsrMatrixClass;
28 class SequentialVectorClass:
public VectorClass<T>
34 #if (PARGEMSLR_CUDA_VERSION == 11)
39 cusparseDnVecDescr_t _cusparse_vec;
101 SequentialVectorClass<T>&
operator= (
const SequentialVectorClass<T> &vec);
109 SequentialVectorClass<T>&
operator= (SequentialVectorClass<T>&& vec);
123 int Setup(
int length);
132 int Setup(
int length,
bool setzero);
142 int Setup(
int length,
int location,
bool setzero);
154 int Setup(
int length,
int reserve,
int location,
bool setzero);
190 int UpdatePtr(
void* data,
int location);
200 int SetupPtr(
void* data,
int length,
int location);
211 int SetupPtr(
void* data,
int length,
int location,
bool hold_data);
221 int SetupPtr(
const VectorClass<T> &vec,
int length,
int shift);
232 int SetupPtr(
const VectorClass<T> &vec,
int length,
int shift,
bool hold_data);
243 int Copy(
const T *data,
int length,
int loc_from,
int loc_to);
262 int Resize(
int length,
bool keepdata,
bool setzero);
273 int Resize(
int length,
int reserve,
bool keepdata,
bool setzero);
297 #ifdef PARGEMSLR_CUDA
298 #if (PARGEMSLR_CUDA_VERSION == 11)
303 virtual cusparseDnVecDescr_t GetCusparseVec()
const;
310 int SetCusparseVec(cusparseDnVecDescr_t cusparse_vec);
362 virtual int Fill(
const T &v);
411 int BinarySearch(
const T &val,
int &idx,
bool ascending);
420 int Sort(
bool ascending);
432 int Sort(IntVectorClass<int> &order,
bool ascending,
bool stable);
440 int Perm(IntVectorClass<int> &perm);
450 int Plot(
int conditiona,
int conditionb,
int width);
463 int PlotAbsGnuPlot(
const char *datafilename,
int conditiona,
int conditionb,
bool logx,
bool logy,
int pttype = 0);
479 virtual int Scale(
const T &alpha);
488 virtual int Axpy(
const T &alpha,
const VectorClass<T> &x);
498 virtual int Axpy(
const T &alpha,
const VectorClass<T> &x, VectorClass<T> &z);
509 virtual int Axpy(
const T &alpha,
const VectorClass<T> &x,
const T &beta, VectorClass<T> &z);
517 virtual int Norm2(
float &norm)
const;
525 virtual int Norm2(
double &norm)
const;
533 virtual int NormInf(
float &norm);
541 virtual int NormInf(
double &norm);
550 virtual int Dot(
const VectorClass<T> &y, T &t)
const;
558 virtual int MoveData(
const int &location);
571 typedef SequentialVectorClass<float> vector_seq_float;
572 typedef SequentialVectorClass<double> vector_seq_double;
573 typedef SequentialVectorClass<complexs> vector_seq_complexs;
574 typedef SequentialVectorClass<complexd> vector_seq_complexd;
Integer vector data structure, not a vector_base class.
int SetupPtr(void *data, int length, int location)
Free the current vector, and points the vector to an address in the memory.
Definition: sequential_vector.cpp:327
The virtual vector classes.
virtual int Scale(const T &alpha)
Scale the vector by x = alpha*x, where x is this vector.
Definition: sequential_vector.cpp:1037
int Plot(int conditiona, int conditionb, int width)
Print the vector.
Definition: sequential_vector.cpp:904
T Min() const
Get the min value in the vector.
Definition: sequential_vector.cpp:871
virtual int MoveData(const int &location)
Move the data to another memory location.
Definition: sequential_vector.cpp:1180
int Sort(bool ascending)
Sort the current vector.
Definition: sequential_vector.cpp:755
int SetHoldingData(bool hold_data)
Set if the vector holding its own data.
Definition: sequential_vector.cpp:694
int PushBack(T v)
Insert value at the end of the vector, expand the vector when necessary.
Definition: sequential_vector.cpp:473
virtual long int GetLengthGlobal() const
Get the global length of the vector.
Definition: sequential_vector.cpp:664
int Resize(int length, bool keepdata, bool setzero)
Resize the vector. Re-allocate memory when necessary.
Definition: sequential_vector.cpp:499
SequentialVectorClass< T > & operator=(const SequentialVectorClass< T > &vec)
The = operator of SequentialVectorClass.
Definition: sequential_vector.cpp:100
int WriteToDisk(const char *datafilename)
Write file to disk.
Definition: sequential_vector.cpp:984
int Copy(const T *data, int length, int loc_from, int loc_to)
Free the current vector, allocate memory, and copy data to initilize this vector.
Definition: sequential_vector.cpp:399
int SetupPtrStr(SequentialVectorClass< T > &x)
Setup the length information of a vector pointer to be same as another vector.
Definition: sequential_vector.cpp:263
virtual long int GetStartGlobal() const
Get the global start index of the vector.
Definition: sequential_vector.cpp:674
The class of sequential real/complex vector.
Definition: structs.hpp:12
virtual T * GetData() const
Get the data pointer of the vector.
Definition: sequential_vector.cpp:596
int Setup(int length)
Free the current vector, and malloc memory to initilize the vector.
Definition: sequential_vector.cpp:178
virtual int GetDataLocation() const
Get the data location of the vector.
Definition: sequential_vector.cpp:640
virtual int NormInf(float &norm)
Compute the inf-norm of a vector, result is type float.
Definition: sequential_vector.cpp:1110
The template class complex.
Definition: complex.hpp:24
SequentialVectorClass()
The constructor of SequentialVectorClass.
Definition: sequential_vector.cpp:21
virtual int Dot(const VectorClass< T > &y, T &t) const
Compute the dot product.
Definition: sequential_vector.cpp:1166
T Max() const
Get the max value in the vector.
Definition: sequential_vector.cpp:853
int MinIndex() const
Get the index of the min value in the vector.
Definition: sequential_vector.cpp:881
int UpdatePtr(void *data, int location)
Update the Ptr with new memory address, keep the current length information. Need to call SetupPtrStr...
Definition: sequential_vector.cpp:308
bool IsHoldingData() const
Check if the vector holding its own data.
Definition: sequential_vector.cpp:684
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: sequential_vector.cpp:1047
int BinarySearch(const T &val, int &idx, bool ascending)
Binary search between [s, e] inside an array.
Definition: sequential_vector.cpp:891
int Perm(IntVectorClass< int > &perm)
Apply permutation to the current vector v := v(perm).
Definition: sequential_vector.cpp:828
Tell if a value is a complex value.
Definition: complex.hpp:684
virtual int GetLengthLocal() const
Get the local length of the vector.
Definition: sequential_vector.cpp:654
int ReadFromMMFile(const char *vecfile, int idxin)
Read vector on the host memory, matrix market format.
Definition: sequential_vector.cpp:1192
virtual T & operator[](int i)
Get the reference of an index in the vector.
Definition: sequential_vector.cpp:166
int MaxIndex() const
Get the index of the max value in the vector.
Definition: sequential_vector.cpp:863
virtual ~SequentialVectorClass()
The destructor of SequentialVectorClass.
Definition: sequential_vector.cpp:586
int PlotAbsGnuPlot(const char *datafilename, int conditiona, int conditionb, bool logx, bool logy, int pttype=0)
Print the absolute value of this vector using GnuPlot.
Definition: sequential_vector.cpp:920
virtual int Clear()
Free the current vector.
Definition: sequential_vector.cpp:431
virtual int Fill(const T &v)
Fill the vector with constant value.
Definition: sequential_vector.cpp:706
virtual int Norm2(float &norm) const
Compute the 2-norm of a vector, result is type float.
Definition: sequential_vector.cpp:1084
virtual int Rand()
Fill the vector with random value.
Definition: sequential_vector.cpp:739