accu.template
Functions
vdop.h File Reference
#include <iostream>
#include <mpi.h>
#include <string>
#include <vector>

Go to the source code of this file.

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

Definition at line 69 of file vdop.cpp.

◆ 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

Definition at line 86 of file vdop.h.

◆ 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\)

Definition at line 40 of file vdop.cpp.

◆ 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

◆ L2_scapr()

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

Definition at line 41 of file vdop.h.

◆ 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

Definition at line 137 of file vdop.h.

◆ 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

Definition at line 60 of file vdop.h.

◆ 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

Definition at line 25 of file vdop.cpp.

◆ 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