Generic vector implementation. More...
#include "generic.h"
#include <iostream>
#include <cassert>
#include <cstring>
#include <cmath>
Go to the source code of this file.
Classes | |
class | Vector< DataType, size > |
Generic vector implementation. More... | |
Defines | |
#define | Vector_Vector_Operator(ope, op) |
#define | Vector_Scalar_Operator(ope, op) |
#define | Vector_Vector_RelOperator(op) |
#define | Vector_Vector_RelOperator(op) |
#define | Vector_Scalar_RelOperator(op) |
#define | Vector_Scalar_RelOperator(op) |
#define | Global_Vector_Scalar_Operator(op) |
#define | Global_Vector_Function(fct) |
#define | Vector_Vector_Functions(NameTo, NameFrom, ope) |
Functions | |
template<class DataType , int size> | |
std::ostream & | operator<< (std::ostream &os, const Vector< DataType, size > &v) |
template<class DataType , int size> | |
Vector< DataType, size > | operator+ (const DataType &v, const Vector< DataType, size > &x) |
template<class DataType , int size> | |
Vector< DataType, size > | operator- (const DataType &v, const Vector< DataType, size > &x) |
template<class DataType , int size> | |
Vector< DataType, size > | operator* (const DataType &v, const Vector< DataType, size > &x) |
template<class DataType , int size> | |
Vector< DataType, size > | operator/ (const DataType &v, const Vector< DataType, size > &x) |
template<class DataType , int size> | |
Vector< DataType, size > | fabs (const Vector< DataType, size > &x) |
template<class DataType , int size> | |
Vector< DataType, size > | sqrt (const Vector< DataType, size > &x) |
template<class DataType , int size> | |
Vector< DataType, size > | Min (const Vector< DataType, size > &x, const Vector< DataType, size > &y) |
template<class DataType , int size> | |
Vector< DataType, size > | Max (const Vector< DataType, size > &x, const Vector< DataType, size > &y) |
template<class DataType , int size> | |
double | Abs (const Vector< DataType, size > &x) |
template<class DataType , int size> | |
DataType | mincomp (const Vector< DataType, size > &x) |
template<class DataType , int size> | |
DataType | maxcomp (const Vector< DataType, size > &x) |
template<class DataType , class VectorType , int size> | |
void | equals_to (Vector< DataType, size > &x, const VectorType &y) |
template<class DataType , class VectorType , int size> | |
void | equals_from (VectorType &x, const Vector< DataType, size > &y) |
template<class DataType , class VectorType , int size> | |
void | plus_to (Vector< DataType, size > &x, const VectorType &y) |
template<class DataType , class VectorType , int size> | |
void | plus_from (VectorType &x, const Vector< DataType, size > &y) |
template<class DataType , class VectorType , int size> | |
void | minus_to (Vector< DataType, size > &x, const VectorType &y) |
template<class DataType , class VectorType , int size> | |
void | minus_from (VectorType &x, const Vector< DataType, size > &y) |
template<class DataType , class VectorType , int size> | |
void | multiply_to (Vector< DataType, size > &x, const VectorType &y) |
template<class DataType , class VectorType , int size> | |
void | multiply_from (VectorType &x, const Vector< DataType, size > &y) |
template<class DataType , class VectorType , int size> | |
void | divide_to (Vector< DataType, size > &x, const VectorType &y) |
template<class DataType , class VectorType , int size> | |
void | divide_from (VectorType &x, const Vector< DataType, size > &y) |
Generic vector implementation.
#define Global_Vector_Function | ( | fct | ) |
template <class DataType, int size> \ inline Vector<DataType,size> fct(const Vector<DataType,size> &x) \ { \ Vector<DataType,size> ret; \ for (register int n=0; n<size; n++) \ ret[n] = std::fct(x[n]); \ return(ret); \ }
#define Global_Vector_Scalar_Operator | ( | op | ) |
template <class DataType, int size> \ inline Vector<DataType,size> operator op (const DataType &v, \ const Vector<DataType,size> &x) \ { return(x op v); }
#define Vector_Scalar_Operator | ( | ope, | |||
op | ) |
inline TVector& operator ope (const DataType &v) \ { \ for (register int n=0; n<size; n++) \ data_[n] ope v; \ return(*this); \ } \ inline TVector operator op (const DataType &v) const \ { \ TVector ret(*this); \ for (register int n=0; n<size; n++) \ ret.data_[n] ope v; \ return(ret); \ }
#define Vector_Scalar_RelOperator | ( | op | ) |
inline int operator op (const DataType &v) const \ { \ bool ret = (data_[0] op v); \ for (register int n=1; n<size; n++) \ ret = ret || (data_[n] op v); \ return(ret); \ }
#define Vector_Scalar_RelOperator | ( | op | ) |
inline int operator op (const DataType &v) const \ { \ bool ret = (data_[0] op v); \ for (register int n=1; n<size; n++) \ ret = ret && (data_[n] op v); \ return(ret); \ }
#define Vector_Vector_Functions | ( | NameTo, | |||
NameFrom, | |||||
ope | ) |
template <class DataType, class VectorType, int size> \ inline void NameTo (Vector<DataType,size> &x, const VectorType &y) \ { \ for (register int n=0; n<size; n++) \ x(n) ope y(n); \ } \ template <class DataType, class VectorType, int size> \ inline void NameFrom (VectorType &x, const Vector<DataType,size> &y) \ { \ for (register int n=0; n<size; n++) \ x(n) ope y(n); \ }
#define Vector_Vector_Operator | ( | ope, | |||
op | ) |
inline TVector& operator ope (const TVector &x) \ { \ for (register int n=0; n<size; n++) \ data_[n] ope x.data_[n]; \ return(*this); \ } \ inline TVector operator op (const TVector &x) const \ { \ TVector ret(*this); \ for (register int n=0; n<size; n++) \ ret.data_[n] ope x.data_[n]; \ return(ret); \ }
#define Vector_Vector_RelOperator | ( | op | ) |
inline int operator op (const TVector &x) const \ { \ bool ret = (data_[0] op x.data_[0]); \ for (register int n=1; n<size; n++) \ ret = ret || (data_[n] op x.data_[n]); \ return(ret); \ }
#define Vector_Vector_RelOperator | ( | op | ) |
inline int operator op (const TVector &x) const \ { \ bool ret = (data_[0] op x.data_[0]); \ for (register int n=1; n<size; n++) \ ret = ret && (data_[n] op x.data_[n]); \ return(ret); \ }
double Abs | ( | const Vector< DataType, size > & | x | ) | [inline] |
References Vector< DataType, size >::abs().
void divide_from | ( | VectorType & | x, | |
const Vector< DataType, size > & | y | |||
) | [inline] |
void divide_to | ( | Vector< DataType, size > & | x, | |
const VectorType & | y | |||
) | [inline] |
void equals_from | ( | VectorType & | x, | |
const Vector< DataType, size > & | y | |||
) | [inline] |
void equals_to | ( | Vector< DataType, size > & | x, | |
const VectorType & | y | |||
) | [inline] |
Vector<DataType,size> fabs | ( | const Vector< DataType, size > & | x | ) | [inline] |
Referenced by Abs(), partition_all(), and partition_two().
Vector<DataType,size> Max | ( | const Vector< DataType, size > & | x, | |
const Vector< DataType, size > & | y | |||
) | [inline] |
References Vector< DataType, size >::max().
DataType maxcomp | ( | const Vector< DataType, size > & | x | ) | [inline] |
References Vector< DataType, size >::maxcomp().
Vector<DataType,size> Min | ( | const Vector< DataType, size > & | x, | |
const Vector< DataType, size > & | y | |||
) | [inline] |
References Vector< DataType, size >::min().
DataType mincomp | ( | const Vector< DataType, size > & | x | ) | [inline] |
References Vector< DataType, size >::mincomp().
void minus_from | ( | VectorType & | x, | |
const Vector< DataType, size > & | y | |||
) | [inline] |
void minus_to | ( | Vector< DataType, size > & | x, | |
const VectorType & | y | |||
) | [inline] |
void multiply_from | ( | VectorType & | x, | |
const Vector< DataType, size > & | y | |||
) | [inline] |
void multiply_to | ( | Vector< DataType, size > & | x, | |
const VectorType & | y | |||
) | [inline] |
Vector<DataType,size> operator* | ( | const DataType & | v, | |
const Vector< DataType, size > & | x | |||
) | [inline] |
Vector<DataType,size> operator+ | ( | const DataType & | v, | |
const Vector< DataType, size > & | x | |||
) | [inline] |
Vector<DataType,size> operator- | ( | const DataType & | v, | |
const Vector< DataType, size > & | x | |||
) | [inline] |
Vector<DataType,size> operator/ | ( | const DataType & | v, | |
const Vector< DataType, size > & | x | |||
) | [inline] |
std::ostream& operator<< | ( | std::ostream & | os, | |
const Vector< DataType, size > & | v | |||
) | [inline] |
References size().
void plus_from | ( | VectorType & | x, | |
const Vector< DataType, size > & | y | |||
) | [inline] |
void plus_to | ( | Vector< DataType, size > & | x, | |
const VectorType & | y | |||
) | [inline] |
Vector<DataType,size> sqrt | ( | const Vector< DataType, size > & | x | ) | [inline] |
Referenced by Vector< DataType, size >::abs(), and GridFunction< GFType, dim >::GF_norm().