Global MPI operations
Functions
vdop.h File Reference
#include <iostream>
#include <mpi.h>
#include <string>
#include <vector>

Functions

void vddiv (std::vector< double > &x, std::vector< double > const &y, std::vector< double > const &z)
 Element-wise vector divison x_k = y_k/z_k. More...
 
void vdaxpy (std::vector< double > &x, std::vector< double > const &y, double alpha, std::vector< double > const &z)
 Element-wise daxpy operation x(k) = y(k) + alpha*z(k). More...
 
void Send_ProcD (const int to, std::vector< double > const &xin, MPI_Comm const &icomm)
 
void Recv_ProcD (const int from, std::vector< double > &xout, MPI_Comm const &icomm)
 
void ExchangeD (const int yourid, std::vector< double > const &xin, std::vector< double > &xout, MPI_Comm const &icomm)
 
double dscapr (std::vector< double > const &x, std::vector< double > const &y)
 Calculates the Euclidean inner product of two vectors. More...
 
double L2_scapr (std::vector< double > const &x, std::vector< double > const &y)
 
double par_scalar (std::vector< double > const &x, std::vector< double > const &y, MPI_Comm const &icomm=MPI_COMM_WORLD)
 
int ReadIn (std::string const &ss=std::string(), MPI_Comm const &icomm=MPI_COMM_WORLD)
 
template<class T >
void DebugVector (std::vector< T > const &v, std::string const &ss=std::string(), MPI_Comm const &icomm=MPI_COMM_WORLD)
 
bool CompareVectors (std::vector< double > const &x, int n, double const y[], double const eps=0.0)
 Compares an STL vector with POD vector. More...
 
template<class T >
std::ostream & operator<< (std::ostream &s, std::vector< T > const &v)
 
void ExchangeAll (std::vector< double > const &xin, std::vector< double > &yout, MPI_Comm const &icomm=MPI_COMM_WORLD)
 
void ExchangeAllInPlace (std::vector< double > &xin, MPI_Comm const &icomm=MPI_COMM_WORLD)
 

Function Documentation

◆ CompareVectors()

bool CompareVectors ( std::vector< double > const &  x,
int  n,
double const  y[],
double const  eps = 0.0 
)

Compares an STL vector with POD vector.

The accuracy criteria \( |x_k-y_k| < \varepsilon \left({1+0.5(|x_k|+|y_k|)}\right) \) follows the book by Stoyan/Baran, p.8.

Parameters
[in]xSTL vector
[in]nlength of POD vector
[in]yPOD vector
[in]epsrelative accuracy criteria (default := 0.0).
Returns
true iff pairwise vector elements are relatively close to each other.

◆ DebugVector()

template<class T >
void DebugVector ( std::vector< T > const &  v,
std::string const &  ss = std::string(),
MPI_Comm const &  icomm = MPI_COMM_WORLD 
)

Print entries of a vector to standard output.

Parameters
[in]vvector values
[in]ssstring containing the vector name
[in]icommcommunicator group for MPI

◆ dscapr()

double dscapr ( std::vector< double > const &  x,
std::vector< double > const &  y 
)

Calculates the Euclidean inner product of two vectors.

Parameters
[in]xvector
[in]yvector
Returns
Euclidean inner product \(\langle x,y \rangle\)

◆ ExchangeAll()

void ExchangeAll ( std::vector< double > const &  xin,
std::vector< double > &  yout,
MPI_Comm const &  icomm = MPI_COMM_WORLD 
)

Exchanges equal size partions of vector xin with all MPI processes. The received data are return in vector yout .

Parameters
[in]xininput vector
[out]youtoutput vector
[in]icommMPI communicator

◆ ExchangeAllInPlace()

void ExchangeAllInPlace ( std::vector< double > &  xin,
MPI_Comm const &  icomm = MPI_COMM_WORLD 
)

Exchanges equal size partions of vector xin with all MPI processes. The received data are return in vector xin .

Parameters
[in,out]xininput/output vector
[in]icommMPI communicator

◆ ExchangeD()

void ExchangeD ( const int  yourid,
std::vector< double > const &  xin,
std::vector< double > &  xout,
MPI_Comm const &  icomm 
)

Exchanges vectors between my process and the process with rank yourid .

Parameters
[in]youridrank of process in communicator icomm to send the message
[in]xinmy vector
[in,out]xoutvector (preallocated, size might change depending on data to receive)
[in]icommcommunicator to use

◆ L2_scapr()

double L2_scapr ( std::vector< double > const &  x,
std::vector< double > const &  y 
)
inline

◆ operator<<()

template<class T >
std::ostream& operator<< ( std::ostream &  s,
std::vector< T > const &  v 
)

Output operator for vector

Parameters
[in,out]soutput stream, e.g. cout
[in]vvector
@return    output stream

◆ par_scalar()

double par_scalar ( std::vector< double > const &  x,
std::vector< double > const &  y,
MPI_Comm const &  icomm = MPI_COMM_WORLD 
)

Parallel inner product

Parameters
[in]xvector
[in]yvector
[in]icommMPI communicator
Returns
resulting Euclidian inner product <x,y>

◆ ReadIn()

int ReadIn ( std::string const &  ss = std::string(),
MPI_Comm const &  icomm = MPI_COMM_WORLD 
)
inline

◆ Recv_ProcD()

void Recv_ProcD ( const int  from,
std::vector< double > &  xout,
MPI_Comm const &  icomm 
)

Receives data from process with rank from into a double-vector xout .

Parameters
[in]fromrank of process in communicator icomm to receive the message from
[in,out]xoutvector (preallocated, size might change depending on data to receive)
[in]icommcommunicator to use

◆ Send_ProcD()

void Send_ProcD ( const int  to,
std::vector< double > const &  xin,
MPI_Comm const &  icomm 
)

Sends data of double-vector xin to the process with rank to .

Parameters
[in]torank of process in communicator icomm to send the message
[in]xinvector
[in]icommcommunicator to use

◆ vdaxpy()

void vdaxpy ( std::vector< double > &  x,
std::vector< double > const &  y,
double  alpha,
std::vector< double > const &  z 
)

Element-wise daxpy operation x(k) = y(k) + alpha*z(k).

Parameters
[out]xtarget vector
[in]ysource vector
[in]alphascalar
[in]zsource vector

◆ vddiv()

void vddiv ( std::vector< double > &  x,
std::vector< double > const &  y,
std::vector< double > const &  z 
)

Element-wise vector divison x_k = y_k/z_k.

Parameters
[out]xtarget vector
[in]ysource vector
[in]zsource vector