Logo ROOT   6.14/05
Reference Guide
Classes | Namespaces | Macros | Functions
RVec.hxx File Reference
#include <ROOT/RAdoptAllocator.hxx>
#include <ROOT/TypeTraits.hxx>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <sstream>
#include <stdexcept>
#include <vector>
#include <utility>
Include dependency graph for RVec.hxx:
This graph shows which files directly or indirectly include this file:

Classes

struct  ROOT::VecOps::PromoteTypeImpl< T >
 
struct  ROOT::VecOps::PromoteTypeImpl< T >
 
struct  ROOT::VecOps::PromoteTypeImpl< double >
 
struct  ROOT::VecOps::PromoteTypeImpl< float >
 
struct  ROOT::VecOps::PromoteTypeImpl< long double >
 
class  ROOT::VecOps::RVec< T >
 A "std::vector"-like collection of values implementing handy operation to analyse them. More...
 

Namespaces

 ROOT
 Namespace for new ROOT classes and functions.
 
 ROOT::VecOps
 

Macros

#define _VECOPS_USE_EXTERN_TEMPLATES   true
 
RVec Unary Arithmetic Operators
#define TVEC_UNARY_OPERATOR(OP)
 
RVec Binary Arithmetic Operators
#define ERROR_MESSAGE(OP)   "Cannot call operator " #OP " on vectors of different sizes."
 
#define TVEC_BINARY_OPERATOR(OP)
 
RVec Assignment Arithmetic Operators
#define TVEC_ASSIGNMENT_OPERATOR(OP)
 
RVec Comparison and Logical Operators
#define TVEC_LOGICAL_OPERATOR(OP)
 

Functions

template<typename T , typename V >
auto ROOT::VecOps::Dot (const RVec< T > &v0, const RVec< V > &v1) -> decltype(v0[0] *v1[0])
 Inner product. More...
 
template<typename T , typename F >
RVec< T > ROOT::VecOps::Filter (const RVec< T > &v, F &&f)
 Create a new collection with the elements passing the filter expressed by the predicate. More...
 
template<typename T , typename F >
auto ROOT::VecOps::Map (const RVec< T > &v, F &&f) -> RVec< decltype(f(v[0]))>
 Create new collection applying a callable to the elements of the input collection. More...
 
template<typename T >
double ROOT::VecOps::Mean (const RVec< T > &v)
 Get Mean. More...
 
template<class T >
std::ostream & ROOT::VecOps::operator<< (std::ostream &os, const RVec< T > &v)
 Print a RVec at the prompt: More...
 
template<typename T >
double ROOT::VecOps::StdDev (const RVec< T > &v)
 Get standard deviation. More...
 
template<typename T >
ROOT::VecOps::Sum (const RVec< T > &v)
 Sum elements. More...
 
template<typename T >
void ROOT::VecOps::swap (RVec< T > &lhs, RVec< T > &rhs)
 
template<typename T >
double ROOT::VecOps::Var (const RVec< T > &v)
 Get variance. More...
 

RVec Standard Mathematical Functions

#define TVEC_UNARY_FUNCTION(NAME, FUNC)
 
#define TVEC_BINARY_FUNCTION(NAME, FUNC)
 
#define TVEC_STD_UNARY_FUNCTION(F)   TVEC_UNARY_FUNCTION(F, std::F)
 
#define TVEC_STD_BINARY_FUNCTION(F)   TVEC_BINARY_FUNCTION(F, std::F)
 
template<typename T >
using ROOT::VecOps::PromoteType = typename PromoteTypeImpl< T >::Type
 
template<typename U , typename V >
using ROOT::VecOps::PromoteTypes = decltype(PromoteType< U >()+PromoteType< V >())
 

Macro Definition Documentation

◆ _VECOPS_USE_EXTERN_TEMPLATES

#define _VECOPS_USE_EXTERN_TEMPLATES   true

Definition at line 21 of file RVec.hxx.

◆ ERROR_MESSAGE

#define ERROR_MESSAGE (   OP)    "Cannot call operator " #OP " on vectors of different sizes."

Definition at line 308 of file RVec.hxx.

◆ TVEC_ASSIGNMENT_OPERATOR

#define TVEC_ASSIGNMENT_OPERATOR (   OP)
Value:
template <typename T0, typename T1> \
RVec<T0>& operator OP(RVec<T0> &v, const T1 &y) \
{ \
auto op = [&y](T0 &x) { return x OP y; }; \
std::transform(v.begin(), v.end(), v.begin(), op); \
return v; \
} \
\
template <typename T0, typename T1> \
RVec<T0>& operator OP(RVec<T0> &v0, const RVec<T1> &v1) \
{ \
if (v0.size() != v1.size()) \
throw std::runtime_error(ERROR_MESSAGE(OP)); \
\
auto op = [](T0 &x, const T1 &y) { return x OP y; }; \
std::transform(v0.begin(), v0.end(), v1.begin(), v0.begin(), op); \
return v0; \
} \
#define ERROR_MESSAGE(OP)
Definition: RVec.hxx:308
Double_t x[n]
Definition: legend1.C:17
SVector< double, 2 > v
Definition: Dict.h:5
Double_t y[n]
Definition: legend1.C:17
#define T1
Definition: md5.inl:145

Definition at line 359 of file RVec.hxx.

◆ TVEC_BINARY_FUNCTION

#define TVEC_BINARY_FUNCTION (   NAME,
  FUNC 
)
Value:
template <typename T0, typename T1> \
RVec<PromoteTypes<T0, T1>> NAME(const T0 &x, const RVec<T1> &v) \
{ \
RVec<PromoteTypes<T0, T1>> ret(v.size()); \
auto f = [&x](const T1 &y) { return FUNC(x, y); }; \
std::transform(v.begin(), v.end(), ret.begin(), f); \
return ret; \
} \
\
template <typename T0, typename T1> \
RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v, const T1 &y) \
{ \
RVec<PromoteTypes<T0, T1>> ret(v.size()); \
auto f = [&y](const T1 &x) { return FUNC(x, y); }; \
std::transform(v.begin(), v.end(), ret.begin(), f); \
return ret; \
} \
\
template <typename T0, typename T1> \
RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v0, const RVec<T1> &v1) \
{ \
if (v0.size() != v1.size()) \
throw std::runtime_error(ERROR_MESSAGE(NAME)); \
\
RVec<PromoteTypes<T0, T1>> ret(v0.size()); \
auto f = [](const T0 &x, const T1 &y) { return FUNC(x, y); }; \
std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), f); \
return ret; \
} \
#define f(i)
Definition: RSha256.hxx:104
#define ERROR_MESSAGE(OP)
Definition: RVec.hxx:308
Double_t x[n]
Definition: legend1.C:17
SVector< double, 2 > v
Definition: Dict.h:5
Double_t y[n]
Definition: legend1.C:17
#define T1
Definition: md5.inl:145

Definition at line 467 of file RVec.hxx.

◆ TVEC_BINARY_OPERATOR

#define TVEC_BINARY_OPERATOR (   OP)

Definition at line 311 of file RVec.hxx.

◆ TVEC_LOGICAL_OPERATOR

#define TVEC_LOGICAL_OPERATOR (   OP)

Definition at line 395 of file RVec.hxx.

◆ TVEC_STD_BINARY_FUNCTION

#define TVEC_STD_BINARY_FUNCTION (   F)    TVEC_BINARY_FUNCTION(F, std::F)

Definition at line 499 of file RVec.hxx.

◆ TVEC_STD_UNARY_FUNCTION

#define TVEC_STD_UNARY_FUNCTION (   F)    TVEC_UNARY_FUNCTION(F, std::F)

Definition at line 498 of file RVec.hxx.

◆ TVEC_UNARY_FUNCTION

#define TVEC_UNARY_FUNCTION (   NAME,
  FUNC 
)
Value:
template <typename T> \
RVec<PromoteType<T>> NAME(const RVec<T> &v) \
{ \
RVec<PromoteType<T>> ret(v.size()); \
auto f = [](const T &x) { return FUNC(x); }; \
std::transform(v.begin(), v.end(), ret.begin(), f); \
return ret; \
}
double T(double x)
Definition: ChebyshevPol.h:34
#define f(i)
Definition: RSha256.hxx:104
Double_t x[n]
Definition: legend1.C:17
SVector< double, 2 > v
Definition: Dict.h:5

Definition at line 457 of file RVec.hxx.

◆ TVEC_UNARY_OPERATOR

#define TVEC_UNARY_OPERATOR (   OP)
Value:
template <typename T> \
RVec<T> operator OP(const RVec<T> &v) \
{ \
RVec<T> ret(v); \
for (auto &x : ret) \
x = OP x; \
return ret; \
} \
Double_t x[n]
Definition: legend1.C:17
SVector< double, 2 > v
Definition: Dict.h:5

Definition at line 288 of file RVec.hxx.