A class which defines a vector distributed across 1D MPI grid. More...
#include <parVector.hpp>
Public Member Functions | |
parVector (MPI_Comm ncomm, S lbound, S ubound) | |
A constructor of `parVector`. More... | |
parVector (parVectorMap< S > map) | |
A constructor of `parVectorMap`. More... | |
~parVector () | |
A destructor. | |
parVectorMap< S > | GetVecMap () |
Return parVector::index_map. | |
S | GetLowerBound () |
Return the lower_bound on each MPI proc. | |
S | GetUpperBound () |
Return the upper_bound on each MPI proc. | |
S | GetGlobalSize () |
Return parVector<S>::global_size. | |
S | GetLocalSize () |
Return parVector<S>::local_size. | |
S | GetRank () |
Return parVector<S>::MyPID. | |
T | GetUpperNeighbor (S offset) |
For each MPI of rank `i`, get a value from the local vector stored on rank `i-1`. More... | |
T | GetLowerNeighbor (S offset) |
For each MPI of rank `i`, get a value from the local vector stored on rank `i+1`. More... | |
T | GetValue (S index) |
Get a value of vector with a given global index. More... | |
T | GetValueLocal (S lindex) |
Get a value of vector with a given local index on each MPI proc. More... | |
T * | GetArray () |
Get the pointer `*array` which stores the local piece of vector on each MPI proc. | |
MPI_Comm | GetComm () |
Get working MPI communicator. | |
S | Loc2Glob (S local_index) |
Convert a index of local vector on each MPI proc into its index in the global distributed vector. More... | |
S | Glob2Loc (S global_index) |
Convert a index of global vector into its index in the local vector on each MPI proc. More... | |
void | SetToValue (T value) |
Set all the entries of a vector to a same value. More... | |
void | SetToZero () |
Set all the entries of a vector to zero. | |
void | SetValueLocal (S row, T value) |
Set a value on a local index of piece of distributed vector on each MPI proc. More... | |
void | SetValuesLocal (S nindex, S *rows, T *values) |
Set multiple values with multiple local indices of piece of distributed vector on each MPI proc. More... | |
void | SetValueGlobal (S index, T value) |
Set a value with a global index distributed vector. More... | |
void | SetValuesGlobal (S nindex, S *rows, T *values) |
Set multiple values with multiple global indices of distributed vector. More... | |
void | AddValueLocal (S row, T value) |
add a value onto the value with a given global index of distributed vector More... | |
void | AddValuesLocal (S nindex, S *rows, T *values) |
Add multiple values with multiple global indices onto the related values of distributed vector. More... | |
void | VecAdd (parVector v) |
Add with another vector. More... | |
void | VecScale (T scale) |
Scale all the elements of a vector with `scale`. More... | |
T | VecDot (parVector v) |
Compute the dot product with another vector `v`. More... | |
void | ReadExtVec (std::string spectrum) |
Read a vector from local text file. More... | |
void | writeToTxt (std::string file_name) |
Write a parVector in real scalar to a local file. More... | |
void | writeToTxtCmplx (std::string file_name) |
Write a parVector in complex scalar to a local file. More... | |
void | VecView () |
Display the vector in a distributed manner. | |
Private Attributes | |
T * | array |
An array store the local piece of a global vector on each MPI proc. | |
S | local_size |
The number of elements of vector stored on each MPI proc. | |
S | global_size |
Global size of this distributed vector. | |
MPI_Comm | comm |
The working MPI Communicator. | |
parVectorMap< S > | index_map |
A parVectorMap object which shows the distribution scheme of a vector. | |
int | MyPID |
rank of each MPI procs within the working MPI communicator parVectorMap::comm | |
int | nProcs |
number of MPI procs within the working MPI communicator parVectorMap::comm | |
A class which defines a vector distributed across 1D MPI grid.
T | describes the scalar types of the entries of vector. |
S | type of integer to describes the dimension of vector to be generated. |
parVector< T, S >::parVector | ( | MPI_Comm | ncomm, |
S | lbound, | ||
S | ubound | ||
) |
A constructor of `parVector`.
[in] | ncomm | the working MPI Communicator |
[in] | lbound | the smallest index of a distributed vector on each MPI proc |
[in] | ubound | `ubound-1 = ` the largest index of a distributed vector on each MPI proc |
parVector< T, S >::parVector | ( | parVectorMap< S > | map | ) |
A constructor of `parVectorMap`.
[in] | map | the distribution scheme determined by this object of type parVectorMap |
void parVector< T, S >::AddValueLocal | ( | S | row, |
T | value | ||
) |
add a value onto the value with a given global index of distributed vector
[in] | row | the global index |
[in] | value | the scalar to be added |
void parVector< T, S >::AddValuesLocal | ( | S | nindex, |
S * | rows, | ||
T * | values | ||
) |
Add multiple values with multiple global indices onto the related values of distributed vector.
[in] | nindex | number of values to be set |
[in] | rows | an pointer stores all the values to be set |
[in] | values | an pointer stores all the indices to be set |
T parVector< T, S >::GetLowerNeighbor | ( | S | offset | ) |
For each MPI of rank `i`, get a value from the local vector stored on rank `i+1`.
[in] | offset | get the value from local vector on rank `i+1` with index `offset`. |
T parVector< T, S >::GetUpperNeighbor | ( | S | offset | ) |
For each MPI of rank `i`, get a value from the local vector stored on rank `i-1`.
[in] | offset | get the value from local vector on rank `i-1` with index `upper_bound-1-offset`. |
|
inline |
Get a value of vector with a given global index.
[in] | index | the querying global index |
|
inline |
Get a value of vector with a given local index on each MPI proc.
[in] | lindex | the querying local index |
|
inline |
Convert a index of global vector into its index in the local vector on each MPI proc.
[in] | global_index | the index global vector to be converted |
|
inline |
Convert a index of local vector on each MPI proc into its index in the global distributed vector.
[in] | local_index | the index local vector to be converted |
void parVector< T, S >::ReadExtVec | ( | std::string | spectrum | ) |
Read a vector from local text file.
[in] | spectrum | a `std::string` indicates the path+filename of local text file |
void parVector< T, S >::SetToValue | ( | T | value | ) |
Set all the entries of a vector to a same value.
[in] | value | the value to be set |
void parVector< T, S >::SetValueGlobal | ( | S | index, |
T | value | ||
) |
Set a value with a global index distributed vector.
[in] | index | the global index |
[in] | value | the scalar to be set |
void parVector< T, S >::SetValueLocal | ( | S | row, |
T | value | ||
) |
Set a value on a local index of piece of distributed vector on each MPI proc.
[in] | row | the local index |
[in] | value | the scalar to be set |
void parVector< T, S >::SetValuesGlobal | ( | S | nindex, |
S * | rows, | ||
T * | values | ||
) |
Set multiple values with multiple global indices of distributed vector.
[in] | nindex | number of values to be set |
[in] | rows | an pointer stores all the values to be set |
[in] | values | an pointer stores all the indices to be set |
void parVector< T, S >::SetValuesLocal | ( | S | nindex, |
S * | rows, | ||
T * | values | ||
) |
Set multiple values with multiple local indices of piece of distributed vector on each MPI proc.
[in] | nindex | number of values to be set |
[in] | rows | an pointer stores all the values to be set |
[in] | values | an pointer stores all the indices to be set |
Add with another vector.
[in] | v | the parVector object used to be added |
Compute the dot product with another vector `v`.
[in] | v | the parVector object used to perform a dot product |
void parVector< T, S >::VecScale | ( | T | scale | ) |
Scale all the elements of a vector with `scale`.
[in] | scale | the value used for scaling on the vector |
void parVector< T, S >::writeToTxt | ( | std::string | file_name | ) |
Write a parVector in real scalar to a local file.
[in] | file_name | a `std::string` indicates the path+filename to write into |
void parVector< T, S >::writeToTxtCmplx | ( | std::string | file_name | ) |
Write a parVector in complex scalar to a local file.
[in] | file_name | a `std::string` indicates the path+filename to write into |