ParGeMSLR
Functions
vectorops.hpp File Reference

Vector operations. More...

#include <vector>
#include "../utils/utils.hpp"
#include "vector.hpp"
#include "int_vector.hpp"
#include "sequential_vector.hpp"
#include "parallel_vector.hpp"

Go to the source code of this file.

Functions

PrecisionEnum pargemslr::GetVectorPrecision (const VectorVirtualClass< int > &vec)
 Get the precision of a vector. More...
 
PrecisionEnum pargemslr::GetVectorPrecision (const VectorVirtualClass< long int > &vec)
 Get the precision of a vector. More...
 
PrecisionEnum pargemslr::GetVectorPrecision (const VectorVirtualClass< float > &vec)
 Get the precision of a vector. More...
 
PrecisionEnum pargemslr::GetVectorPrecision (const VectorVirtualClass< double > &vec)
 Get the precision of a vector. More...
 
PrecisionEnum pargemslr::GetVectorPrecision (const VectorVirtualClass< complexs > &vec)
 Get the precision of a vector. More...
 
PrecisionEnum pargemslr::GetVectorPrecision (const VectorVirtualClass< complexd > &vec)
 Get the precision of a vector. More...
 
PrecisionEnum pargemslr::GetVectorPPrecision (const VectorVirtualClass< int > *vec)
 Get the precision of a vector. More...
 
PrecisionEnum pargemslr::GetVectorPPrecision (const VectorVirtualClass< long int > *vec)
 Get the precision of a vector. More...
 
PrecisionEnum pargemslr::GetVectorPPrecision (const VectorVirtualClass< float > *vec)
 Get the precision of a vector. More...
 
PrecisionEnum pargemslr::GetVectorPPrecision (const VectorVirtualClass< double > *vec)
 Get the precision of a vector. More...
 
PrecisionEnum pargemslr::GetVectorPPrecision (const VectorVirtualClass< complexs > *vec)
 Get the precision of a vector. More...
 
PrecisionEnum pargemslr::GetVectorPPrecision (const VectorVirtualClass< complexd > *vec)
 Get the precision of a vector. More...
 
template<typename T >
int pargemslr::VectorPDotTemplate (int n, const T *x, const T *y, T &t)
 DOT product of two float vectors. More...
 
int pargemslr::VectorDot (const vector_base_float &x, const vector_base_float &y, float &t)
 DOT product of two float vectors. More...
 
int pargemslr::VectorDot (const vector_base_double &x, const vector_base_double &y, double &t)
 DOT product of two double vectors. More...
 
int pargemslr::VectorDot (const vector_base_complexs &x, const vector_base_complexs &y, complexs &t)
 DOTC product of two single complex vectors. More...
 
int pargemslr::VectorDot (const vector_base_complexd &x, const vector_base_complexd &y, complexd &t)
 DOTC product of two double complex vectors. More...
 
template<typename T >
int pargemslr::VectorPScaleTemplate (int n, T *x, const T &a)
 Scale a float vector. More...
 
int pargemslr::VectorScale (VectorClass< float > &x, const float &a)
 Scale a float vector. More...
 
int pargemslr::VectorScale (VectorClass< double > &x, const double &a)
 Scale a double vector. More...
 
int pargemslr::VectorScale (VectorClass< complexs > &x, const complexs &a)
 Scale a single complex vector. More...
 
int pargemslr::VectorScale (VectorClass< complexd > &x, const complexd &a)
 Scale a double complex vector. More...
 
template<typename T >
int pargemslr::VectorPAxpyTemplate (int n, const T &a, const T *x, T *y)
 AXPY of two float vectors, in place version. y = a*x + y. More...
 
int pargemslr::VectorAxpy (const float &a, const VectorClass< float > &x, VectorClass< float > &y)
 AXPY of two float vectors, in place version. y = a*x + y. More...
 
int pargemslr::VectorAxpy (const double &a, const VectorClass< double > &x, VectorClass< double > &y)
 AXPY of two double vectors, in place version. y = a*x + y. More...
 
int pargemslr::VectorAxpy (const complexs &a, const VectorClass< complexs > &x, VectorClass< complexs > &y)
 AXPY of two single complex vectors, in place version. y = a*x + y. More...
 
int pargemslr::VectorAxpy (const complexd &a, const VectorClass< complexd > &x, VectorClass< complexd > &y)
 AXPY of two double complex vectors, in place version. y = a*x + y. Currenlty we don't support x == y. More...
 
template<typename T >
int pargemslr::VectorPBsearchHost (const T *v, const T &val, int s, int e, int &idx, bool ascending)
 Binary search between [s, e] inside an array. More...
 
template<typename T >
int pargemslr::VectorPlotHost (const VectorVirtualClass< T > &x, int conditiona, int conditionb, int width)
 Print the vector. More...
 
int pargemslr::SequentialVectorReadFromFile (SequentialVectorClass< float > &vec, const char *vecfile, int idxin)
 Read a vector from matrix marker format file. More...
 
int pargemslr::SequentialVectorReadFromFile (SequentialVectorClass< double > &vec, const char *vecfile, int idxin)
 Read a vector from matrix marker format file. More...
 
int pargemslr::SequentialVectorReadFromFile (SequentialVectorClass< complexs > &vec, const char *vecfile, int idxin)
 Read a vector from matrix marker format file. More...
 
int pargemslr::SequentialVectorReadFromFile (SequentialVectorClass< complexd > &vec, const char *vecfile, int idxin)
 Read a vector from matrix marker format file. More...
 
template<typename T1 , typename T2 >
int pargemslr::VectorCopy (VectorClass< T1 > &vec_in, VectorClass< T2 > &vec2_out)
 Copy data from vector of type T1 to vector of type T2. More...
 

Detailed Description

Vector operations.
VectorXxx: functions for base vector.
SequentialVectorXxx: functions for sequential vector.

Function Documentation

◆ GetVectorPPrecision() [1/6]

PrecisionEnum pargemslr::GetVectorPPrecision ( const VectorVirtualClass< complexd > *  vec)

Get the precision of a vector.

Parameters
[in]vecthe vector type.
Returns
Return the precision in PrecisionEnum form.

◆ GetVectorPPrecision() [2/6]

PrecisionEnum pargemslr::GetVectorPPrecision ( const VectorVirtualClass< complexs > *  vec)

Get the precision of a vector.

Parameters
[in]vecthe vector type.
Returns
Return the precision in PrecisionEnum form.

◆ GetVectorPPrecision() [3/6]

PrecisionEnum pargemslr::GetVectorPPrecision ( const VectorVirtualClass< double > *  vec)

Get the precision of a vector.

Parameters
[in]vecthe vector type.
Returns
Return the precision in PrecisionEnum form.

◆ GetVectorPPrecision() [4/6]

PrecisionEnum pargemslr::GetVectorPPrecision ( const VectorVirtualClass< float > *  vec)

Get the precision of a vector.

Parameters
[in]vecthe vector type.
Returns
Return the precision in PrecisionEnum form.

◆ GetVectorPPrecision() [5/6]

PrecisionEnum pargemslr::GetVectorPPrecision ( const VectorVirtualClass< int > *  vec)

Get the precision of a vector.

Parameters
[in]vecthe vector type.
Returns
Return the precision in PrecisionEnum form.

◆ GetVectorPPrecision() [6/6]

PrecisionEnum pargemslr::GetVectorPPrecision ( const VectorVirtualClass< long int > *  vec)

Get the precision of a vector.

Parameters
[in]vecthe vector type.
Returns
Return the precision in PrecisionEnum form.

◆ GetVectorPrecision() [1/6]

PrecisionEnum pargemslr::GetVectorPrecision ( const VectorVirtualClass< complexd > &  vec)

Get the precision of a vector.

Parameters
[in]vecthe vector type.
Returns
Return the precision in PrecisionEnum form.

◆ GetVectorPrecision() [2/6]

PrecisionEnum pargemslr::GetVectorPrecision ( const VectorVirtualClass< complexs > &  vec)

Get the precision of a vector.

Parameters
[in]vecthe vector type.
Returns
Return the precision in PrecisionEnum form.

◆ GetVectorPrecision() [3/6]

PrecisionEnum pargemslr::GetVectorPrecision ( const VectorVirtualClass< double > &  vec)

Get the precision of a vector.

Parameters
[in]vecthe vector type.
Returns
Return the precision in PrecisionEnum form.

◆ GetVectorPrecision() [4/6]

PrecisionEnum pargemslr::GetVectorPrecision ( const VectorVirtualClass< float > &  vec)

Get the precision of a vector.

Parameters
[in]vecthe vector type.
Returns
Return the precision in PrecisionEnum form.

◆ GetVectorPrecision() [5/6]

PrecisionEnum pargemslr::GetVectorPrecision ( const VectorVirtualClass< int > &  vec)

Get the precision of a vector.

Parameters
[in]vecthe vector type.
Returns
Return the precision in PrecisionEnum form.

◆ GetVectorPrecision() [6/6]

PrecisionEnum pargemslr::GetVectorPrecision ( const VectorVirtualClass< long int > &  vec)

Get the precision of a vector.

Parameters
[in]vecthe vector type.
Returns
Return the precision in PrecisionEnum form.

◆ SequentialVectorReadFromFile() [1/4]

int pargemslr::SequentialVectorReadFromFile ( SequentialVectorClass< complexd > &  vec,
const char *  vecfile,
int  idxin 
)

Read a vector from matrix marker format file.

Parameters
[out]vecThe return vector.
[in]vecfileThe file name.
[in]idxinThe index base of the input vector, 0-based or 1-based.
Returns
Return error message.

◆ SequentialVectorReadFromFile() [2/4]

int pargemslr::SequentialVectorReadFromFile ( SequentialVectorClass< complexs > &  vec,
const char *  vecfile,
int  idxin 
)

Read a vector from matrix marker format file.

Parameters
[out]vecThe return vector.
[in]vecfileThe file name.
[in]idxinThe index base of the input vector, 0-based or 1-based.
Returns
Return error message.

◆ SequentialVectorReadFromFile() [3/4]

int pargemslr::SequentialVectorReadFromFile ( SequentialVectorClass< double > &  vec,
const char *  vecfile,
int  idxin 
)

Read a vector from matrix marker format file.

Parameters
[out]vecThe return vector.
[in]vecfileThe file name.
[in]idxinThe index base of the input vector, 0-based or 1-based.
Returns
Return error message.

◆ SequentialVectorReadFromFile() [4/4]

int pargemslr::SequentialVectorReadFromFile ( SequentialVectorClass< float > &  vec,
const char *  vecfile,
int  idxin 
)

Read a vector from matrix marker format file.

Parameters
[out]vecThe return vector.
[in]vecfileThe file name.
[in]idxinThe index base of the input vector, 0-based or 1-based.
Returns
Return error message.

◆ VectorAxpy() [1/4]

int pargemslr::VectorAxpy ( const complexd a,
const VectorClass< complexd > &  x,
VectorClass< complexd > &  y 
)

AXPY of two double complex vectors, in place version. y = a*x + y. Currenlty we don't support x == y.

Parameters
[in]aThe scaling scalar.
[in]xThe left vector.
[in,out]yThe right vector.
Returns
Return error message.

◆ VectorAxpy() [2/4]

int pargemslr::VectorAxpy ( const complexs a,
const VectorClass< complexs > &  x,
VectorClass< complexs > &  y 
)

AXPY of two single complex vectors, in place version. y = a*x + y.

Parameters
[in]aThe scaling scalar.
[in]xThe left vector.
[in,out]yThe right vector.
Returns
Return error message.

◆ VectorAxpy() [3/4]

int pargemslr::VectorAxpy ( const double &  a,
const VectorClass< double > &  x,
VectorClass< double > &  y 
)

AXPY of two double vectors, in place version. y = a*x + y.

Parameters
[in]aThe scaling scalar.
[in]xThe left vector.
[in,out]yThe right vector.
Returns
Return error message.

◆ VectorAxpy() [4/4]

int pargemslr::VectorAxpy ( const float &  a,
const VectorClass< float > &  x,
VectorClass< float > &  y 
)

AXPY of two float vectors, in place version. y = a*x + y.

Parameters
[in]aThe scaling scalar.
[in]xThe left vector.
[in,out]yThe right vector.
Returns
Return error message.

◆ VectorCopy()

template<typename T1 , typename T2 >
int pargemslr::VectorCopy ( VectorClass< T1 > &  vec_in,
VectorClass< T2 > &  vec2_out 
)

Copy data from vector of type T1 to vector of type T2.
Currently only supports float <-> double and complexs <-> conplexd

Parameters
[in]vec_inThe input vector.
[out]vec_outThe output vector.
Returns
Return error message.

◆ VectorDot() [1/4]

int pargemslr::VectorDot ( const vector_base_complexd x,
const vector_base_complexd y,
complexd t 
)

DOTC product of two double complex vectors.

Parameters
[in]xThe left vector.
[in]yThe right vector.
[out]tThe dot product.
Returns
Return error message.

◆ VectorDot() [2/4]

int pargemslr::VectorDot ( const vector_base_complexs x,
const vector_base_complexs y,
complexs t 
)

DOTC product of two single complex vectors.

Parameters
[in]xThe left vector.
[in]yThe right vector.
[out]tThe dot product.
Returns
Return error message.

◆ VectorDot() [3/4]

int pargemslr::VectorDot ( const vector_base_double x,
const vector_base_double y,
double &  t 
)

DOT product of two double vectors.

Parameters
[in]xThe left vector.
[in]yThe right vector.
[out]tThe dot product.
Returns
Return error message.

◆ VectorDot() [4/4]

int pargemslr::VectorDot ( const vector_base_float x,
const vector_base_float y,
float &  t 
)

DOT product of two float vectors.

Parameters
[in]xThe left vector.
[in]yThe right vector.
[out]tThe dot product.
Returns
Return error message.

◆ VectorPAxpyTemplate()

template<typename T >
int pargemslr::VectorPAxpyTemplate ( int  n,
const T &  a,
const T *  x,
T *  y 
)

AXPY of two float vectors, in place version. y = a*x + y.

Parameters
[in]nThe length of the vectors.
[in]aThe scaling scalar.
[in]xThe left vector.
[in,out]yThe right vector.
Returns
Return error message.

◆ VectorPBsearchHost()

template<typename T >
int pargemslr::VectorPBsearchHost ( const T *  v,
const T &  val,
int  s,
int  e,
int &  idx,
bool  ascending 
)

Binary search between [s, e] inside an array.

Parameters
[in]vThe target vector.
[in]valThe target value.
[in]sThe start location in the array
[in]eThe end(include) location in the array
[out]idxIf found the value, set to the index of the value. Otherwise the position to insert, or -1 if s > e.
[in]descendThe array is descend or ascend.
Returns
return -1 if the value isnot found. Otherwise the index of it.

◆ VectorPDotTemplate()

template<typename T >
int pargemslr::VectorPDotTemplate ( int  n,
const T *  x,
const T *  y,
T &  t 
)

DOT product of two float vectors.

Parameters
[in]nThe length of the vectors.
[in]xThe left vector.
[in]yThe right vector.
[out]tThe dot product.
Returns
Return error message.

◆ VectorPlotHost()

template<typename T >
int pargemslr::VectorPlotHost ( const VectorVirtualClass< T > &  x,
int  conditiona,
int  conditionb,
int  width 
)

Print the vector.

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

◆ VectorPScaleTemplate()

template<typename T >
int pargemslr::VectorPScaleTemplate ( int  n,
T *  x,
const T &  a 
)

Scale a float vector.

Parameters
[in]nThe length of the vectors.
[in,out]xThe target vector.
[in]aThe scaling scalar.
Returns
Return error message.

◆ VectorScale() [1/4]

int pargemslr::VectorScale ( VectorClass< complexd > &  x,
const complexd a 
)

Scale a double complex vector.

Parameters
[in,out]xThe target vector.
[in]aThe scaling scalar.
Returns
Return error message.

◆ VectorScale() [2/4]

int pargemslr::VectorScale ( VectorClass< complexs > &  x,
const complexs a 
)

Scale a single complex vector.

Parameters
[in,out]xThe target vector.
[in]aThe scaling scalar.
Returns
Return error message.

◆ VectorScale() [3/4]

int pargemslr::VectorScale ( VectorClass< double > &  x,
const double &  a 
)

Scale a double vector.

Parameters
[in,out]xThe target vector.
[in]aThe scaling scalar.
Returns
Return error message.

◆ VectorScale() [4/4]

int pargemslr::VectorScale ( VectorClass< float > &  x,
const float &  a 
)

Scale a float vector.

Parameters
[in,out]xThe target vector.
[in]aThe scaling scalar.
Returns
Return error message.