ParGeMSLR
Public Member Functions | List of all members
pargemslr::ParallelVectorClass< T > Class Template Reference

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...
 

Detailed Description

template<typename T>
class pargemslr::ParallelVectorClass< T >

The class of parallel real/complex vector.

Constructor & Destructor Documentation

◆ ParallelVectorClass() [1/3]

template<typename T >
template pargemslr::ParallelVectorClass< T >::ParallelVectorClass ( )

The constructor of ParallelVectorClass. The default memory location is the host memory.

◆ ParallelVectorClass() [2/3]

template<typename T >
pargemslr::ParallelVectorClass< T >::ParallelVectorClass ( const ParallelVectorClass< T > &  vec)

The copy constructor of ParallelVectorClass.

Parameters
[in]vecThe target vector.

◆ ParallelVectorClass() [3/3]

template<typename T >
pargemslr::ParallelVectorClass< T >::ParallelVectorClass ( ParallelVectorClass< T > &&  vec)

The copy constructor of ParallelVectorClass.

Parameters
[in]vecThe target vector.

◆ ~ParallelVectorClass()

template<typename T >
template pargemslr::ParallelVectorClass< T >::~ParallelVectorClass ( )
virtual

The destructor of ParallelVectorClass. Simply a call to the free function.

Member Function Documentation

◆ Axpy() [1/3]

template<typename T >
int pargemslr::ParallelVectorClass< T >::Axpy ( const T &  alpha,
const VectorClass< T > &  x 
)
virtual

Compute y = alpha * x + y, where y is this vector. Currenlty we don't support x == y.

Parameters
[in]alphaThe alpha value.
[in]xThe vector.
[in]betaThe beta value.
Returns
Return error message.

◆ Axpy() [2/3]

template<typename T >
int pargemslr::ParallelVectorClass< T >::Axpy ( const T &  alpha,
const VectorClass< T > &  x,
const T &  beta,
VectorClass< T > &  y 
)
virtual

Compute z = alpha * x + beta * y, where z is this vector. Currenlty we don't support x == y, x == z or y == z.

Parameters
[in]alphaThe alpha value.
[in]xThe first vector.
[in]betaThe beta value.
[in]yThe second vector.
Returns
Return error message.

◆ Axpy() [3/3]

template<typename T >
int pargemslr::ParallelVectorClass< T >::Axpy ( const T &  alpha,
const VectorClass< T > &  x,
VectorClass< T > &  y 
)
virtual

Compute z = alpha * x + y, where z is this vector. Currenlty we don't support x == y, x == z or y == z.

Parameters
[in]alphaThe alpha value.
[in]xThe first vector.
[in]yThe second vector.
Returns
Return error message.

◆ Clear()

template<typename T >
template int pargemslr::ParallelVectorClass< T >::Clear ( )
virtual

Free the current vector.

Returns
Return error message.

◆ Dot()

template<typename T >
template int pargemslr::ParallelVectorClass< T >::Dot ( const VectorClass< T > &  y,
T &  t 
) const
virtual

Compute the dot product.

Parameters
[in]yThe vector.
[out]tThe result.
Returns
Return error message.

◆ Fill()

template<typename T >
template int pargemslr::ParallelVectorClass< T >::Fill ( const T &  v)
virtual

Fill the vector with constant value.

Parameters
[in]vThe value to be filled.
Returns
Return error message.

◆ GetData()

template<typename T >
template complexd * pargemslr::ParallelVectorClass< T >::GetData ( ) const
virtual

Get the data pointer of the vector.

Returns
Return the data pointer.

◆ GetDataLocation()

template<typename T >
template int pargemslr::ParallelVectorClass< T >::GetDataLocation ( ) const
virtual

Get the data location of the vector.

Returns
Return the data location of the vector.

◆ GetDataVector()

template<typename T >
template SequentialVectorClass< complexd > & pargemslr::ParallelVectorClass< T >::GetDataVector ( )

Get the reference of the data vector.

Returns
Return the data vector.

◆ GetLengthGlobal()

template<typename T >
template long int pargemslr::ParallelVectorClass< T >::GetLengthGlobal ( ) const
virtual

Get the global length of the vector.

Returns
Return the global length of the vector.

◆ GetLengthLocal()

template<typename T >
template int pargemslr::ParallelVectorClass< T >::GetLengthLocal ( ) const
virtual

Get the local length of the vector.

Returns
Return the local length of the vector.

◆ GetStartGlobal()

template<typename T >
template long int pargemslr::ParallelVectorClass< T >::GetStartGlobal ( ) const
virtual

Get the global start index of the vector.

Returns
Return the global start index of the vector.

◆ IsHoldingData()

template<typename T >
template bool pargemslr::ParallelVectorClass< T >::IsHoldingData ( ) const

Check if the vector holding its own data.

Returns
Return true if vector holding data.

◆ IsParallel()

template<typename T >
template bool pargemslr::ParallelVectorClass< T >::IsParallel ( ) const
virtual

Tell if this is a prallel vector.

Returns
Return true is this is a parallel vector.

◆ MoveData()

template<typename T >
template int pargemslr::ParallelVectorClass< T >::MoveData ( const int &  location)
virtual

Move the data to another memory location.

Parameters
[in]locationThe location move to.
Returns
Return error message.

◆ Norm2() [1/2]

template<typename T >
template int pargemslr::ParallelVectorClass< T >::Norm2 ( double &  norm) const
virtual

Compute the 2-norm of a vector, result is type double.

Parameters
[out]normThe 2-norm.
Returns
Return error message.

◆ Norm2() [2/2]

template<typename T >
template int pargemslr::ParallelVectorClass< T >::Norm2 ( float &  norm) const
virtual

Compute the 2-norm of a vector, result is type float.

Parameters
[out]normThe 2-norm.
Returns
Return error message.

◆ NormInf() [1/2]

template<typename T >
template int pargemslr::ParallelVectorClass< T >::NormInf ( double &  norm)
virtual

Compute the inf-norm of a vector, result is type double.

Parameters
[out]normThe inf-norm.
Returns
Return error message.

◆ NormInf() [2/2]

template<typename T >
template int pargemslr::ParallelVectorClass< T >::NormInf ( float &  norm)
virtual

Compute the inf-norm of a vector, result is type float.

Parameters
[out]normThe inf-norm.
Returns
Return error message.

◆ operator=() [1/2]

template<typename T >
ParallelVectorClass< T > & pargemslr::ParallelVectorClass< T >::operator= ( const ParallelVectorClass< T > &  vec)

The operator = of ParallelVectorClass.

Parameters
[in]vecThe target vector.
Returns
Return the vector.

◆ operator=() [2/2]

template<typename T >
ParallelVectorClass< T > & pargemslr::ParallelVectorClass< T >::operator= ( ParallelVectorClass< T > &&  vec)

The operator = of ParallelVectorClass.

Parameters
[in]vecThe target vector.
Returns
Return the vector.

◆ operator[]()

template<typename T >
template complexd & pargemslr::ParallelVectorClass< T >::operator[] ( int  i)
virtual

Get the reference of an index in the local vector. vec[0] is the first local value.

Parameters
[in]iThe local index.
Returns
The reference of the value on that index.

◆ Plot()

template<typename T >
template int pargemslr::ParallelVectorClass< T >::Plot ( int  conditiona,
int  conditionb,
int  width 
)

Print the vector.

Parameters
[in]conditionaFirst condition.
[in]conditionbSecend condition, only print when conditiona == conditionb.
[in]widthThe plot width.
Returns
Return error message.

◆ Rand()

template<typename T >
template int pargemslr::ParallelVectorClass< T >::Rand ( )
virtual

Fill the vector with random value.

Returns
Return error message.

◆ ReadFromSingleMMFile()

template<typename T >
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).

Parameters
[in]vecfileThe file.
[in]idxinThe index base of the input file. 0-based or 1-based.
Returns
Return error message.

◆ Scale()

template<typename T >
template int pargemslr::ParallelVectorClass< T >::Scale ( const T &  alpha)
virtual

Scale the vector by x = alpha*x, where x is this vector.

Parameters
[in]alphaThe scale.
Returns
Return error message.

◆ SetHoldingData()

template<typename T >
template int pargemslr::ParallelVectorClass< T >::SetHoldingData ( bool  hold_data)

Set if the vector holding its own data.

Returns
Return error message.

◆ Setup() [1/8]

template<typename T >
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.

Parameters
[in]n_localThe local length of the vector.
[in]setzeroCall calloc if we need to fill the memory with 0.
[in]parlogThe Parallel log data structure, if parallel_log._comm == NULL, will use the global one.
Returns
Return error message.

◆ Setup() [2/8]

template<typename T >
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.

Parameters
[in]n_localThe local length of the vector.
[in]locationThe location of the vector.
[in]setzeroCall calloc if we need to fill the memory with 0.
[in]parlogThe Parallel log data structure, if parallel_log._comm == NULL, will use the global one.
Returns
Return error message.

◆ Setup() [3/8]

template<typename T >
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.

Parameters
[in]n_localThe local length of the vector.
[in]reserveThe length allocated in the memory, should be no less than length.
[in]locationThe location of the vector.
[in]setzeroCall calloc if we need to fill the memory with 0.
[in]parlogThe Parallel log data structure, if parallel_log._comm == NULL, will use the global one.
Returns
Return error message.

◆ Setup() [4/8]

template<typename T >
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.

Parameters
[in]n_localThe local length of the vector.
[in]n_startThe start index of the vector.
[in]n_globalThe global length of the vector.
[in]setzeroCall calloc if we need to fill the memory with 0.
[in]parlogThe Parallel log data structure, if parallel_log._comm == NULL, will use the global one.
Returns
Return error message.

◆ Setup() [5/8]

template<typename T >
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.

Parameters
[in]n_localThe local length of the vector.
[in]n_startThe start index of the vector.
[in]n_globalThe global length of the vector.
[in]locationThe location of the vector.
[in]setzeroCall calloc if we need to fill the memory with 0.
[in]parlogThe Parallel log data structure, if parallel_log._comm == NULL, will use the global one.
Returns
Return error message.

◆ Setup() [6/8]

template<typename T >
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.

Parameters
[in]n_localThe local length of the vector.
[in]n_startThe start index of the vector.
[in]n_globalThe global length of the vector.
[in]reserveThe length allocated in the memory, should be no less than length.
[in]locationThe location of the vector.
[in]setzeroCall calloc if we need to fill the memory with 0.
[in]parlogThe Parallel log data structure, if parallel_log._comm == NULL, will use the global one.
Returns
Return error message.

◆ Setup() [7/8]

template<typename T >
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.

Parameters
[in]n_localThe local length of the vector.
[in]n_startThe start index of the vector.
[in]n_globalThe global length of the vector.
[in]parlogThe Parallel log data structure, if parallel_log._comm == NULL, will use the global one.
Returns
Return error message.

◆ Setup() [8/8]

template<typename T >
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.

Parameters
[in]n_localThe local length of the vector.
[in]parlogThe Parallel log data structure, if parallel_log._comm == NULL, will use the global one.
Returns
Return error message.

◆ SetupPtrStr() [1/2]

template<typename T >
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.

Parameters
[in]AThe ParallelCsrMatrixClass.
Returns
Return error message.

◆ SetupPtrStr() [2/2]

template<typename T >
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.

Parameters
[in]xThe ParallelVectorClass.
Returns
Return error message.

◆ UpdatePtr()

template<typename T >
template int pargemslr::ParallelVectorClass< T >::UpdatePtr ( void *  data,
int  location 
)

Update the data with new memory address. Need to call SetupPtrStr first.

Parameters
[in]dataThe address of the data.
[in]locationThe location of the data.
Returns
Return error message.

◆ WriteToDisk()

template<typename T >
template int pargemslr::ParallelVectorClass< T >::WriteToDisk ( const char *  datafilename)

Write file to disk.

Parameters
[in]datafilenameThe filename of the file holding the data.
Returns
Return error message.

The documentation for this class was generated from the following files: