ParGeMSLR
|
The class of parallel real/complex vector. More...
#include <parallel_vector.hpp>
Public Member Functions | |
ParallelVectorClass () | |
The constructor of ParallelVectorClass. More... | |
ParallelVectorClass (const ParallelVectorClass< T > &vec) | |
The copy constructor of ParallelVectorClass. More... | |
ParallelVectorClass (ParallelVectorClass< T > &&vec) | |
The copy constructor of ParallelVectorClass. More... | |
ParallelVectorClass< T > & | operator= (const ParallelVectorClass< T > &vec) |
The operator = of ParallelVectorClass. More... | |
ParallelVectorClass< T > & | operator= (ParallelVectorClass< T > &&vec) |
The operator = of ParallelVectorClass. More... | |
virtual | ~ParallelVectorClass () |
The destructor of ParallelVectorClass. More... | |
int | Setup (int n_local, parallel_log &parlog) |
Free the current vector, and malloc memory to initilize the vector on comm. More... | |
int | Setup (int n_local, bool setzero, parallel_log &parlog) |
Free the current vector, and allocate memory to initilize the vector. More... | |
int | Setup (int n_local, int location, bool setzero, parallel_log &parlog) |
Free the current vector, and allocate memory at give location to initilize the vector. More... | |
int | Setup (int n_local, int reserve, int location, bool setzero, parallel_log &parlog) |
Free the current vector, and allocate memory at give location to initilize the vector. More... | |
int | Setup (int n_local, long int n_start, long int n_global, parallel_log &parlog) |
Free the current vector, and malloc memory to initilize the vector on comm. More... | |
int | Setup (int n_local, long int n_start, long int n_global, bool setzero, parallel_log &parlog) |
Free the current vector, and allocate memory to initilize the vector. More... | |
int | Setup (int n_local, long int n_start, long int n_global, int location, bool setzero, parallel_log &parlog) |
Free the current vector, and allocate memory at give location to initilize the vector. More... | |
int | Setup (int n_local, long int n_start, long int n_global, int reserve, int location, bool setzero, parallel_log &parlog) |
Free the current vector, and allocate memory at give location to initilize the vector. More... | |
int | SetupPtrStr (ParallelVectorClass< T > &x) |
Setup the length information of a vector pointer with the information of a ParallelVectorClass. More... | |
int | SetupPtrStr (ParallelCsrMatrixClass< T > &A) |
Setup the length information of a vector pointer with the row information of a ParallelCsrMatrixClass. More... | |
int | UpdatePtr (void *data, int location) |
Update the data with new memory address. Need to call SetupPtrStr first. More... | |
virtual T & | operator[] (int i) |
Get the reference of an index in the local vector. More... | |
virtual int | Clear () |
Free the current vector. More... | |
virtual T * | GetData () const |
Get the data pointer of the vector. More... | |
SequentialVectorClass< T > & | GetDataVector () |
Get the reference of the data vector. More... | |
virtual int | GetDataLocation () const |
Get the data location of the vector. More... | |
virtual int | GetLengthLocal () const |
Get the local length of the vector. More... | |
virtual long int | GetLengthGlobal () const |
Get the global length of the vector. More... | |
virtual long int | GetStartGlobal () const |
Get the global start index of the vector. More... | |
bool | IsHoldingData () const |
Check if the vector holding its own data. More... | |
int | SetHoldingData (bool hold_data) |
Set if the vector holding its own data. More... | |
int | Plot (int conditiona, int conditionb, int width) |
Print the vector. More... | |
int | WriteToDisk (const char *datafilename) |
Write file to disk. More... | |
virtual int | Fill (const T &v) |
Fill the vector with constant value. More... | |
virtual int | Rand () |
Fill the vector with random value. More... | |
virtual int | Scale (const T &alpha) |
Scale the vector by x = alpha*x, where x is this vector. More... | |
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. More... | |
virtual int | Axpy (const T &alpha, const VectorClass< T > &x, VectorClass< T > &y) |
Compute z = alpha * x + y, where z is this vector. Currenlty we don't support x == y, x == z or y == z. More... | |
virtual int | Axpy (const T &alpha, const VectorClass< T > &x, const T &beta, VectorClass< T > &y) |
Compute z = alpha * x + beta * y, where z is this vector. Currenlty we don't support x == y, x == z or y == z. More... | |
virtual int | Norm2 (float &norm) const |
Compute the 2-norm of a vector, result is type float. More... | |
virtual int | Norm2 (double &norm) const |
Compute the 2-norm of a vector, result is type double. More... | |
virtual int | NormInf (float &norm) |
Compute the inf-norm of a vector, result is type float. More... | |
virtual int | NormInf (double &norm) |
Compute the inf-norm of a vector, result is type double. More... | |
virtual int | Dot (const VectorClass< T > &y, T &t) const |
Compute the dot product. More... | |
virtual bool | IsParallel () const |
Tell if this is a prallel vector. More... | |
virtual int | MoveData (const int &location) |
Move the data to another memory location. More... | |
int | ReadFromSingleMMFile (const char *vecfile, int idxin) |
Read vector on the host memory, matrix market format. Note that the vector should be setup already (have the global and local infomation). More... | |
The class of parallel real/complex vector.
template pargemslr::ParallelVectorClass< T >::ParallelVectorClass | ( | ) |
The constructor of ParallelVectorClass. The default memory location is the host memory.
pargemslr::ParallelVectorClass< T >::ParallelVectorClass | ( | const ParallelVectorClass< T > & | vec | ) |
The copy constructor of ParallelVectorClass.
[in] | vec | The target vector. |
pargemslr::ParallelVectorClass< T >::ParallelVectorClass | ( | ParallelVectorClass< T > && | vec | ) |
The copy constructor of ParallelVectorClass.
[in] | vec | The target vector. |
|
virtual |
The destructor of ParallelVectorClass. Simply a call to the free function.
|
virtual |
Compute y = alpha * x + y, where y is this vector. Currenlty we don't support x == y.
[in] | alpha | The alpha value. |
[in] | x | The vector. |
[in] | beta | The beta value. |
|
virtual |
Compute z = alpha * x + beta * y, where z is this vector. Currenlty we don't support x == y, x == z or y == z.
[in] | alpha | The alpha value. |
[in] | x | The first vector. |
[in] | beta | The beta value. |
[in] | y | The second vector. |
|
virtual |
Compute z = alpha * x + y, where z is this vector. Currenlty we don't support x == y, x == z or y == z.
[in] | alpha | The alpha value. |
[in] | x | The first vector. |
[in] | y | The second vector. |
|
virtual |
Free the current vector.
|
virtual |
Compute the dot product.
[in] | y | The vector. |
[out] | t | The result. |
|
virtual |
Fill the vector with constant value.
[in] | v | The value to be filled. |
|
virtual |
Get the data pointer of the vector.
|
virtual |
Get the data location of the vector.
template SequentialVectorClass< complexd > & pargemslr::ParallelVectorClass< T >::GetDataVector | ( | ) |
Get the reference of the data vector.
|
virtual |
Get the global length of the vector.
|
virtual |
Get the local length of the vector.
|
virtual |
Get the global start index of the vector.
template bool pargemslr::ParallelVectorClass< T >::IsHoldingData | ( | ) | const |
Check if the vector holding its own data.
|
virtual |
Tell if this is a prallel vector.
|
virtual |
Move the data to another memory location.
[in] | location | The location move to. |
|
virtual |
Compute the 2-norm of a vector, result is type double.
[out] | norm | The 2-norm. |
|
virtual |
Compute the 2-norm of a vector, result is type float.
[out] | norm | The 2-norm. |
|
virtual |
Compute the inf-norm of a vector, result is type double.
[out] | norm | The inf-norm. |
|
virtual |
Compute the inf-norm of a vector, result is type float.
[out] | norm | The inf-norm. |
ParallelVectorClass< T > & pargemslr::ParallelVectorClass< T >::operator= | ( | const ParallelVectorClass< T > & | vec | ) |
The operator = of ParallelVectorClass.
[in] | vec | The target vector. |
ParallelVectorClass< T > & pargemslr::ParallelVectorClass< T >::operator= | ( | ParallelVectorClass< T > && | vec | ) |
The operator = of ParallelVectorClass.
[in] | vec | The target vector. |
|
virtual |
Get the reference of an index in the local vector. vec[0] is the first local value.
[in] | i | The local index. |
template int pargemslr::ParallelVectorClass< T >::Plot | ( | int | conditiona, |
int | conditionb, | ||
int | width | ||
) |
Print the vector.
[in] | conditiona | First condition. |
[in] | conditionb | Secend condition, only print when conditiona == conditionb. |
[in] | width | The plot width. |
|
virtual |
Fill the vector with random value.
template int pargemslr::ParallelVectorClass< T >::ReadFromSingleMMFile | ( | const char * | vecfile, |
int | idxin | ||
) |
Read vector on the host memory, matrix market format. Note that the vector should be setup already (have the global and local infomation).
[in] | vecfile | The file. |
[in] | idxin | The index base of the input file. 0-based or 1-based. |
|
virtual |
Scale the vector by x = alpha*x, where x is this vector.
[in] | alpha | The scale. |
template int pargemslr::ParallelVectorClass< T >::SetHoldingData | ( | bool | hold_data | ) |
Set if the vector holding its own data.
template int pargemslr::ParallelVectorClass< T >::Setup | ( | int | n_local, |
bool | setzero, | ||
parallel_log & | parlog | ||
) |
Free the current vector, and allocate memory to initilize the vector.
[in] | n_local | The local length of the vector. |
[in] | setzero | Call calloc if we need to fill the memory with 0. |
[in] | parlog | The Parallel log data structure, if parallel_log._comm == NULL, will use the global one. |
template int pargemslr::ParallelVectorClass< T >::Setup | ( | int | n_local, |
int | location, | ||
bool | setzero, | ||
parallel_log & | parlog | ||
) |
Free the current vector, and allocate memory at give location to initilize the vector.
[in] | n_local | The local length of the vector. |
[in] | location | The location of the vector. |
[in] | setzero | Call calloc if we need to fill the memory with 0. |
[in] | parlog | The Parallel log data structure, if parallel_log._comm == NULL, will use the global one. |
template int pargemslr::ParallelVectorClass< T >::Setup | ( | int | n_local, |
int | reserve, | ||
int | location, | ||
bool | setzero, | ||
parallel_log & | parlog | ||
) |
Free the current vector, and allocate memory at give location to initilize the vector.
The actual memory size is set by the value reserve, and the vector length is given by the value length.
[in] | n_local | The local length of the vector. |
[in] | reserve | The length allocated in the memory, should be no less than length. |
[in] | location | The location of the vector. |
[in] | setzero | Call calloc if we need to fill the memory with 0. |
[in] | parlog | The Parallel log data structure, if parallel_log._comm == NULL, will use the global one. |
template int pargemslr::ParallelVectorClass< T >::Setup | ( | int | n_local, |
long int | n_start, | ||
long int | n_global, | ||
bool | setzero, | ||
parallel_log & | parlog | ||
) |
Free the current vector, and allocate memory to initilize the vector.
[in] | n_local | The local length of the vector. |
[in] | n_start | The start index of the vector. |
[in] | n_global | The global length of the vector. |
[in] | setzero | Call calloc if we need to fill the memory with 0. |
[in] | parlog | The Parallel log data structure, if parallel_log._comm == NULL, will use the global one. |
template int pargemslr::ParallelVectorClass< T >::Setup | ( | int | n_local, |
long int | n_start, | ||
long int | n_global, | ||
int | location, | ||
bool | setzero, | ||
parallel_log & | parlog | ||
) |
Free the current vector, and allocate memory at give location to initilize the vector.
[in] | n_local | The local length of the vector. |
[in] | n_start | The start index of the vector. |
[in] | n_global | The global length of the vector. |
[in] | location | The location of the vector. |
[in] | setzero | Call calloc if we need to fill the memory with 0. |
[in] | parlog | The Parallel log data structure, if parallel_log._comm == NULL, will use the global one. |
template int pargemslr::ParallelVectorClass< T >::Setup | ( | int | n_local, |
long int | n_start, | ||
long int | n_global, | ||
int | reserve, | ||
int | location, | ||
bool | setzero, | ||
parallel_log & | parlog | ||
) |
Free the current vector, and allocate memory at give location to initilize the vector.
The actual memory size is set by the value reserve, and the vector length is given by the value length.
[in] | n_local | The local length of the vector. |
[in] | n_start | The start index of the vector. |
[in] | n_global | The global length of the vector. |
[in] | reserve | The length allocated in the memory, should be no less than length. |
[in] | location | The location of the vector. |
[in] | setzero | Call calloc if we need to fill the memory with 0. |
[in] | parlog | The Parallel log data structure, if parallel_log._comm == NULL, will use the global one. |
template int pargemslr::ParallelVectorClass< T >::Setup | ( | int | n_local, |
long int | n_start, | ||
long int | n_global, | ||
parallel_log & | parlog | ||
) |
Free the current vector, and malloc memory to initilize the vector on comm.
[in] | n_local | The local length of the vector. |
[in] | n_start | The start index of the vector. |
[in] | n_global | The global length of the vector. |
[in] | parlog | The Parallel log data structure, if parallel_log._comm == NULL, will use the global one. |
template int pargemslr::ParallelVectorClass< T >::Setup | ( | int | n_local, |
parallel_log & | parlog | ||
) |
Free the current vector, and malloc memory to initilize the vector on comm.
[in] | n_local | The local length of the vector. |
[in] | parlog | The Parallel log data structure, if parallel_log._comm == NULL, will use the global one. |
int pargemslr::ParallelVectorClass< T >::SetupPtrStr | ( | ParallelCsrMatrixClass< T > & | A | ) |
Setup the length information of a vector pointer with the row information of a ParallelCsrMatrixClass.
Need to call UpdatePtr function to set the data before use.
[in] | A | The ParallelCsrMatrixClass. |
int pargemslr::ParallelVectorClass< T >::SetupPtrStr | ( | ParallelVectorClass< T > & | x | ) |
Setup the length information of a vector pointer with the information of a ParallelVectorClass.
Need to call UpdatePtr function to set the data before use.
[in] | x | The ParallelVectorClass. |
template int pargemslr::ParallelVectorClass< T >::UpdatePtr | ( | void * | data, |
int | location | ||
) |
Update the data with new memory address. Need to call SetupPtrStr first.
[in] | data | The address of the data. |
[in] | location | The location of the data. |
template int pargemslr::ParallelVectorClass< T >::WriteToDisk | ( | const char * | datafilename | ) |
Write file to disk.
[in] | datafilename | The filename of the file holding the data. |