Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
RVec and VecOps

RVec is a "std::vector"-like collection of values that can adopt memory for fast data manipulation.

This page lists functions to perform operations on RVecs to manipulate and analyse them.

Classes

class  ROOT::VecOps::RVec< T >
 A "std::vector"-like collection of values implementing handy operation to analyse them. More...
class  ROOT::VecOps::RVecN< T, N >

Functions

template<typename T>
auto ROOT::VecOps::All (const RVec< T > &v) -> decltype(v[0]==false)
 Return true if all of the elements equate to true, return false otherwise.
template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename T4 = T0, typename T5 = T0, typename Common_t = std::common_type_t<T0, T1>>
Common_t ROOT::VecOps::Angle (T0 x1, T1 y1, T2 z1, T3 x2, T4 y2, T5 z2)
 Return the angle between two three-vectors given the quantities x coordinate (x), y coordinate (y), z coordinate (y).
template<typename T>
auto ROOT::VecOps::Any (const RVec< T > &v) -> decltype(v[0]==true)
 Return true if any of the elements equates to true, return false otherwise.
template<typename T = double, typename Ret_t = std::conditional_t<std::is_floating_point_v<T>, T, double>>
RVec< Ret_t > ROOT::VecOps::Arange (T start, T end, T step)
 Produce RVec with entries in the range [start, end) in increments of step.
template<typename T>
std::size_t ROOT::VecOps::ArgMax (const RVec< T > &v)
 Get the index of the greatest element of an RVec In case of multiple occurrences of the maximum values, the index corresponding to the first occurrence is returned.
template<typename T>
std::size_t ROOT::VecOps::ArgMin (const RVec< T > &v)
 Get the index of the smallest element of an RVec In case of multiple occurrences of the minimum values, the index corresponding to the first occurrence is returned.
template<typename T>
RVec< typename RVec< T >::size_type > ROOT::VecOps::Argsort (const RVec< T > &v)
 Return an RVec of indices that sort the input RVec.
template<typename T, typename Compare>
RVec< typename RVec< T >::size_type > ROOT::VecOps::Argsort (const RVec< T > &v, Compare &&c)
 Return an RVec of indices that sort the input RVec based on a comparison function.
template<typename T, unsigned N>
size_t ROOT::VecOps::CapacityInBytes (const RVecN< T, N > &X)
template<typename T>
RVec< RVec< typename RVec< T >::size_type > > ROOT::VecOps::Combinations (const RVec< T > &v, const typename RVec< T >::size_type n)
 Return the indices that represent all unique combinations of the elements of a given RVec.
template<typename T1, typename T2>
RVec< RVec< typename RVec< T1 >::size_type > > ROOT::VecOps::Combinations (const RVec< T1 > &v1, const RVec< T2 > &v2)
 Return the indices that represent all combinations of the elements of two RVecs.
RVec< RVec< std::size_t > > ROOT::VecOps::Combinations (const std::size_t size1, const std::size_t size2)
 Return the indices that represent all combinations of the elements of two RVecs.
template<typename T0, typename T1, typename Common_t = typename std::common_type<T0, T1>::type>
RVec< Common_t > ROOT::VecOps::Concatenate (const RVec< T0 > &v0, const RVec< T1 > &v1)
 Return the concatenation of two RVecs.
template<typename T, typename... Args_t>
RVec< T > ROOT::VecOps::Construct (const RVec< Args_t > &... args)
 Build an RVec of objects starting from RVecs of input to their constructors.
template<typename T0, typename T1 = T0, typename Common_t = typename std::common_type_t<T0, T1>>
RVec< Common_t > ROOT::VecOps::DeltaPhi (const RVec< T0 > &v1, const RVec< T1 > &v2, const Common_t c=M_PI)
 Return the angle difference \(\Delta \phi\) in radians of two vectors.
template<typename T0, typename T1 = T0, typename Common_t = typename std::common_type_t<T0, T1>>
RVec< Common_t > ROOT::VecOps::DeltaPhi (const RVec< T0 > &v1, T1 v2, const Common_t c=M_PI)
 Return the angle difference \(\Delta \phi\) in radians of a vector and a scalar.
template<typename T0, typename T1 = T0, typename Common_t = typename std::common_type_t<T0, T1>>
RVec< Common_t > ROOT::VecOps::DeltaPhi (T0 v1, const RVec< T1 > &v2, const Common_t c=M_PI)
 Return the angle difference \(\Delta \phi\) in radians of a scalar and a vector.
template<typename T0, typename T1 = T0, typename Common_t = std::common_type_t<T0, T1>>
Common_t ROOT::VecOps::DeltaPhi (T0 v1, T1 v2, const Common_t c=M_PI)
 Return the angle difference \(\Delta \phi\) of two scalars.
template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3>>
RVec< Common_t > ROOT::VecOps::DeltaR (const RVec< T0 > &eta1, const RVec< T1 > &eta2, const RVec< T2 > &phi1, const RVec< T3 > &phi2, const Common_t c=M_PI)
 Return the distance on the \(\eta\)- \(\phi\) plane ( \(\Delta R\)) from the collections eta1, eta2, phi1 and phi2.
template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3>>
Common_t ROOT::VecOps::DeltaR (T0 eta1, T1 eta2, T2 phi1, T3 phi2, const Common_t c=M_PI)
 Return the distance on the \(\eta\)- \(\phi\) plane ( \(\Delta R\)) from the scalars eta1, eta2, phi1 and phi2.
template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3>>
RVec< Common_t > ROOT::VecOps::DeltaR2 (const RVec< T0 > &eta1, const RVec< T1 > &eta2, const RVec< T2 > &phi1, const RVec< T3 > &phi2, const Common_t c=M_PI)
 Return the square of the distance on the \(\eta\)- \(\phi\) plane ( \(\Delta R\)) from the collections eta1, eta2, phi1 and phi2.
template<typename T, typename V>
auto ROOT::VecOps::Dot (const RVec< T > &v0, const RVec< V > &v1) -> decltype(v0[0] *v1[0])
 Inner product.
template<typename T>
RVec< T > ROOT::VecOps::Drop (const RVec< T > &v, RVec< typename RVec< T >::size_type > idxs)
 Return a copy of the container without the elements at the specified indices.
template<typename T>
RVec< typename RVec< T >::size_type > ROOT::VecOps::Enumerate (const RVec< T > &v)
 For any Rvec v produce another RVec with entries starting from 0, and incrementing by 1 until a N = v.size() is reached.
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.
template<typename T>
RVec< T > ROOT::VecOps::Intersect (const RVec< T > &v1, const RVec< T > &v2, bool v2_is_sorted=false)
 Return the intersection of elements of two RVecs.
template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3>>
Common_t ROOT::VecOps::InvariantMass (const RVec< T0 > &pt, const RVec< T1 > &eta, const RVec< T2 > &phi, const RVec< T3 > &mass)
 Return the invariant mass of multiple particles given the collections of the quantities transverse momentum (pt), rapidity (eta), azimuth (phi) and mass.
template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename T4 = T0, typename T5 = T0, typename T6 = T0, typename T7 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3, T4, T5, T6, T7>>
RVec< Common_t > ROOT::VecOps::InvariantMasses (const RVec< T0 > &pt1, const RVec< T1 > &eta1, const RVec< T2 > &phi1, const RVec< T3 > &mass1, const RVec< T4 > &pt2, const RVec< T5 > &eta2, const RVec< T6 > &phi2, const RVec< T7 > &mass2)
 Return the invariant mass of two particles given the collections of the quantities transverse momentum (pt), rapidity (eta), azimuth (phi) and mass.
template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename T4 = T0, typename T5 = T0, typename T6 = T0, typename T7 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3, T4, T5, T6, T7>>
RVec< Common_t > ROOT::VecOps::InvariantMasses_PxPyPzM (const RVec< T0 > &px1, const RVec< T1 > &py1, const RVec< T2 > &pz1, const RVec< T3 > &mass1, const RVec< T4 > &px2, const RVec< T5 > &py2, const RVec< T6 > &pz2, const RVec< T7 > &mass2)
 Return the invariant mass of two particles given the collections of the quantities x coordinate (px), y coordinate (py), z coordinate (pz) and mass.
template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename T4 = T0, typename T5 = T0, typename T6 = T0, typename T7 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3, T4, T5, T6, T7>>
Common_t ROOT::VecOps::InvariantMasses_PxPyPzM (const T0 &x1, const T1 &y1, const T2 &z1, const T3 &mass1, const T4 &x2, const T5 &y2, const T6 &z2, const T7 &mass2)
 Return the invariant mass of two particles given x coordinate (px), y coordinate (py), z coordinate (pz) and mass.
template<typename T = double, typename Ret_t = std::conditional_t<std::is_floating_point_v<T>, T, double>>
RVec< Ret_t > ROOT::VecOps::Linspace (T start, T end, unsigned long long n=128, const bool endpoint=true)
 Produce RVec with N evenly-spaced entries from start to end.
template<typename T = double, typename Ret_t = std::conditional_t<std::is_floating_point_v<T>, T, double>>
RVec< Ret_t > ROOT::VecOps::Logspace (T start, T end, unsigned long long n=128, const bool endpoint=true, T base=10.0)
 Produce RVec with n log-spaced entries from base^{start} to base^{end}.
template<typename... Args>
auto ROOT::VecOps::Map (Args &&... args)
 Create new collection applying a callable to the elements of the input collection.
template<typename T>
ROOT::VecOps::Max (const RVec< T > &v)
 Get the greatest element of an RVec.
template<typename T>
double ROOT::VecOps::Mean (const RVec< T > &v)
 Get the mean of the elements of an RVec.
template<typename T, typename R = T>
R ROOT::VecOps::Mean (const RVec< T > &v, const R zero)
 Get the mean of the elements of an RVec with custom initial value.
template<typename T>
ROOT::VecOps::Min (const RVec< T > &v)
 Get the smallest element of an RVec.
template<typename T>
RVec< typename RVec< T >::size_type > ROOT::VecOps::Nonzero (const RVec< T > &v)
 Return the indices of the elements which are not zero.
template<class T>
std::ostream & ROOT::VecOps::operator<< (std::ostream &os, const RVec< T > &v)
 Print a RVec at the prompt:
template<typename T>
ROOT::VecOps::Product (const RVec< T > &v, const T init=T(1))
 Return the product of the elements of the RVec.
RVec< long long intROOT::VecOps::Range (long long int begin, long long int end, long long int stride)
 Allows for negative begin, end, and/or stride.
RVec< std::size_t > ROOT::VecOps::Range (std::size_t begin, std::size_t end)
 Produce RVec with entries equal to begin, begin+1, ..., end-1.
RVec< std::size_t > ROOT::VecOps::Range (std::size_t length)
 Produce RVec with entries starting from 0, and incrementing by 1 until a user-specified N is reached.
template<typename T>
RVec< T > ROOT::VecOps::Reverse (const RVec< T > &v)
 Return copy of reversed vector.
template<typename T>
RVec< T > ROOT::VecOps::Sort (const RVec< T > &v)
 Return copy of RVec with elements sorted in ascending order.
template<typename T, typename Compare>
RVec< T > ROOT::VecOps::Sort (const RVec< T > &v, Compare &&c)
 Return copy of RVec with elements sorted based on a comparison operator.
template<typename T>
RVec< typename RVec< T >::size_type > ROOT::VecOps::StableArgsort (const RVec< T > &v)
 Return an RVec of indices that sort the input RVec while keeping the order of equal elements.
template<typename T, typename Compare>
RVec< typename RVec< T >::size_type > ROOT::VecOps::StableArgsort (const RVec< T > &v, Compare &&c)
 Return an RVec of indices that sort the input RVec based on a comparison function while keeping the order of equal elements.
template<typename T>
RVec< T > ROOT::VecOps::StableSort (const RVec< T > &v)
 Return copy of RVec with elements sorted in ascending order while keeping the order of equal elements.
template<typename T, typename Compare>
RVec< T > ROOT::VecOps::StableSort (const RVec< T > &v, Compare &&c)
 Return copy of RVec with elements sorted based on a comparison operator while keeping the order of equal elements.
template<typename T>
double ROOT::VecOps::StdDev (const RVec< T > &v)
 Get the standard deviation of the elements of an RVec.
std::size_t ROOT::VecOps::Sum (const RVec< bool > &v, std::size_t zero=0ul)
template<typename T>
ROOT::VecOps::Sum (const RVec< T > &v, const T zero=T(0))
 Sum elements of an RVec.
template<typename T>
void ROOT::VecOps::swap (RVec< T > &lhs, RVec< T > &rhs)
template<typename T>
RVec< T > ROOT::VecOps::Take (const RVec< T > &v, const int n)
 Return first n elements of an RVec if n > 0 and last n elements if n < 0.
template<typename T>
RVec< T > ROOT::VecOps::Take (const RVec< T > &v, const int n, const T default_val)
 Return first n elements of an RVec if n > 0 and last n elements if n < 0.
template<typename T>
RVec< T > ROOT::VecOps::Take (const RVec< T > &v, const RVec< typename RVec< T >::size_type > &i)
 Return elements of a vector at given indices.
template<typename T>
RVec< T > ROOT::VecOps::Take (const RVec< T > &v, const RVec< typename RVec< T >::size_type > &i, const T default_val)
 Take version that defaults to (user-specified) output value if some index is out of range.
template<typename T>
double ROOT::VecOps::Var (const RVec< T > &v)
 Get the variance of the elements of an RVec.
template<typename T>
RVec< T > ROOT::VecOps::Where (const RVec< int > &c, const RVec< T > &v1, const RVec< T > &v2)
 Return the elements of v1 if the condition c is true and v2 if the condition c is false.
template<typename T>
RVec< T > ROOT::VecOps::Where (const RVec< int > &c, const RVec< T > &v1, typename RVec< T >::value_type v2)
 Return the elements of v1 if the condition c is true and sets the value v2 if the condition c is false.
template<typename T>
RVec< T > ROOT::VecOps::Where (const RVec< int > &c, T v1, T v2)
 Return a vector with the value v2 if the condition c is false and sets the value v1 if the condition c is true.
template<typename T>
RVec< T > ROOT::VecOps::Where (const RVec< int > &c, typename RVec< T >::value_type v1, const RVec< T > &v2)
 Return the elements of v2 if the condition c is false and sets the value v1 if the condition c is true.

RVec Unary Arithmetic Operators

template<typename T>
RVec< T > ROOT::VecOps::operator+ (const RVec< T > &v)
template<typename T>
RVec< T > ROOT::VecOps::operator- (const RVec< T > &v)
template<typename T>
RVec< T > ROOT::VecOps::operator~ (const RVec< T > &v)
template<typename T>
RVec< T > ROOT::VecOps::operator! (const RVec< T > &v)
#define RVEC_UNARY_OPERATOR(OP)

RVec Binary Arithmetic Operators

template<typename T0, typename T1>
auto ROOT::VecOps::operator+ (const RVec< T0 > &v, const T1 &y) -> RVec< decltype(v[0]+y)>
template<typename T0, typename T1>
auto ROOT::VecOps::operator+ (const T0 &x, const RVec< T1 > &v) -> RVec< decltype(x+v[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator+ (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< decltype(v0[0]+v1[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator- (const RVec< T0 > &v, const T1 &y) -> RVec< decltype(v[0] - y)>
template<typename T0, typename T1>
auto ROOT::VecOps::operator- (const T0 &x, const RVec< T1 > &v) -> RVec< decltype(x - v[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator- (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< decltype(v0[0] - v1[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator* (const RVec< T0 > &v, const T1 &y) -> RVec< decltype(v[0] *y)>
template<typename T0, typename T1>
auto ROOT::VecOps::operator* (const T0 &x, const RVec< T1 > &v) -> RVec< decltype(x *v[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator* (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< decltype(v0[0] *v1[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator/ (const RVec< T0 > &v, const T1 &y) -> RVec< decltype(v[0]/y)>
template<typename T0, typename T1>
auto ROOT::VecOps::operator/ (const T0 &x, const RVec< T1 > &v) -> RVec< decltype(x/v[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator/ (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< decltype(v0[0]/v1[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator% (const RVec< T0 > &v, const T1 &y) -> RVec< decltype(v[0] % y)>
template<typename T0, typename T1>
auto ROOT::VecOps::operator% (const T0 &x, const RVec< T1 > &v) -> RVec< decltype(x % v[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator% (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< decltype(v0[0] % v1[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator^ (const RVec< T0 > &v, const T1 &y) -> RVec< decltype(v[0] ^ y)>
template<typename T0, typename T1>
auto ROOT::VecOps::operator^ (const T0 &x, const RVec< T1 > &v) -> RVec< decltype(x ^ v[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator^ (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< decltype(v0[0] ^ v1[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator| (const RVec< T0 > &v, const T1 &y) -> RVec< decltype(v[0]|y)>
template<typename T0, typename T1>
auto ROOT::VecOps::operator| (const T0 &x, const RVec< T1 > &v) -> RVec< decltype(x|v[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator| (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< decltype(v0[0]|v1[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator& (const RVec< T0 > &v, const T1 &y) -> RVec< decltype(v[0] &y)>
template<typename T0, typename T1>
auto ROOT::VecOps::operator& (const T0 &x, const RVec< T1 > &v) -> RVec< decltype(x &v[0])>
template<typename T0, typename T1>
auto ROOT::VecOps::operator& (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< decltype(v0[0] &v1[0])>
#define ERROR_MESSAGE(OP)
#define RVEC_BINARY_OPERATOR(OP)

RVec Assignment Arithmetic Operators

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator+= (RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator+= (RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator-= (RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator-= (RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator*= (RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator*= (RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator/= (RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator/= (RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator%= (RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator%= (RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator^= (RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator^= (RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator|= (RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator|= (RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator&= (RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator&= (RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator>>= (RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator>>= (RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator<<= (RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator<<= (RVec< T0 > &v0, const RVec< T1 > &v1)
#define RVEC_ASSIGNMENT_OPERATOR(OP)

RVec Comparison and Logical Operators

template<typename T0, typename T1>
auto ROOT::VecOps::operator< (const RVec< T0 > &v, const T1 &y) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator< (const T0 &x, const RVec< T1 > &v) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator< (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator> (const RVec< T0 > &v, const T1 &y) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator> (const T0 &x, const RVec< T1 > &v) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator> (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator== (const RVec< T0 > &v, const T1 &y) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator== (const T0 &x, const RVec< T1 > &v) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator== (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator!= (const RVec< T0 > &v, const T1 &y) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator!= (const T0 &x, const RVec< T1 > &v) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator!= (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator<= (const RVec< T0 > &v, const T1 &y) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator<= (const T0 &x, const RVec< T1 > &v) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator<= (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator>= (const RVec< T0 > &v, const T1 &y) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator>= (const T0 &x, const RVec< T1 > &v) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator>= (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator&& (const RVec< T0 > &v, const T1 &y) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator&& (const T0 &x, const RVec< T1 > &v) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator&& (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator|| (const RVec< T0 > &v, const T1 &y) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator|| (const T0 &x, const RVec< T1 > &v) -> RVec< int >
template<typename T0, typename T1>
auto ROOT::VecOps::operator|| (const RVec< T0 > &v0, const RVec< T1 > &v1) -> RVec< int >
#define RVEC_LOGICAL_OPERATOR(OP)

RVec Standard Mathematical Functions

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::abs (const RVec< T > &v)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::fdim (const T0 &x, const RVec< T1 > &v)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::fdim (const RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::fdim (const RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::fmod (const T0 &x, const RVec< T1 > &v)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::fmod (const RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::fmod (const RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::remainder (const T0 &x, const RVec< T1 > &v)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::remainder (const RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::remainder (const RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::exp (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::exp2 (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::expm1 (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::log (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::log10 (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::log2 (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::log1p (const RVec< T > &v)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::pow (const T0 &x, const RVec< T1 > &v)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::pow (const RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::pow (const RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::sqrt (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::cbrt (const RVec< T > &v)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::hypot (const T0 &x, const RVec< T1 > &v)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::hypot (const RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::hypot (const RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::sin (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::cos (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::tan (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::asin (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::acos (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::atan (const RVec< T > &v)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::atan2 (const T0 &x, const RVec< T1 > &v)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::atan2 (const RVec< T0 > &v, const T1 &y)
template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::atan2 (const RVec< T0 > &v0, const RVec< T1 > &v1)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::sinh (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::cosh (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::tanh (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::asinh (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::acosh (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::atanh (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::floor (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::ceil (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::trunc (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::round (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::lround (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::llround (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::erf (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::erfc (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::lgamma (const RVec< T > &v)
template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::tgamma (const RVec< T > &v)
#define RVEC_UNARY_FUNCTION(NAME, FUNC)
#define RVEC_BINARY_FUNCTION(NAME, FUNC)
#define RVEC_STD_UNARY_FUNCTION(F)
#define RVEC_STD_BINARY_FUNCTION(F)

Macro Definition Documentation

◆ ERROR_MESSAGE

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

Definition at line 1632 of file RVec.hxx.

◆ RVEC_ASSIGNMENT_OPERATOR

#define RVEC_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; \
} \
A "std::vector"-like collection of values implementing handy operation to analyse them.
Definition RVec.hxx:1525
#define ERROR_MESSAGE(OP)
Definition RVec.hxx:1632
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
#define T1
Definition md5.inl:146

Definition at line 1683 of file RVec.hxx.

◆ RVEC_BINARY_FUNCTION

#define RVEC_BINARY_FUNCTION ( NAME,
FUNC )
Value:
template <typename T0, typename T1> \
RVec<PromoteTypes<T0, T1>> NAME(const T0 &x, const RVec<T1> &v) \
{ \
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 T0 &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
char * ret
Definition Rotated.cxx:221

Definition at line 1794 of file RVec.hxx.

◆ RVEC_BINARY_OPERATOR

#define RVEC_BINARY_OPERATOR ( OP)

Definition at line 1635 of file RVec.hxx.

◆ RVEC_LOGICAL_OPERATOR

#define RVEC_LOGICAL_OPERATOR ( OP)

Definition at line 1719 of file RVec.hxx.

◆ RVEC_STD_BINARY_FUNCTION

#define RVEC_STD_BINARY_FUNCTION ( F)
Value:
#define RVEC_BINARY_FUNCTION(NAME, FUNC)
Definition RVec.hxx:1794
#define F(x, y, z)

Definition at line 1826 of file RVec.hxx.

◆ RVEC_STD_UNARY_FUNCTION

#define RVEC_STD_UNARY_FUNCTION ( F)
Value:
#define RVEC_UNARY_FUNCTION(NAME, FUNC)
Definition RVec.hxx:1784

Definition at line 1825 of file RVec.hxx.

◆ RVEC_UNARY_FUNCTION

#define RVEC_UNARY_FUNCTION ( NAME,
FUNC )
Value:
template <typename T> \
RVec<PromoteType<T>> NAME(const RVec<T> &v) \
{ \
auto f = [](const T &x) { return FUNC(x); }; \
std::transform(v.begin(), v.end(), ret.begin(), f); \
return ret; \
}

Definition at line 1784 of file RVec.hxx.

◆ RVEC_UNARY_OPERATOR

#define RVEC_UNARY_OPERATOR ( OP)
Value:
template <typename T> \
RVec<T> operator OP(const RVec<T> &v) \
{ \
for (auto &x : ret) \
x = OP x; \
return ret; \
} \

Definition at line 1612 of file RVec.hxx.

Function Documentation

◆ abs()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::abs ( const RVec< T > & v)

Definition at line 1828 of file RVec.hxx.

◆ acos()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::acos ( const RVec< T > & v)

Definition at line 1851 of file RVec.hxx.

◆ acosh()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::acosh ( const RVec< T > & v)

Definition at line 1859 of file RVec.hxx.

◆ All()

template<typename T>
auto ROOT::VecOps::All ( const RVec< T > & v) -> decltype(v[0]==false)

Return true if all of the elements equate to true, return false otherwise.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecI v {0, 1, 0};
auto allTrue = All(v);
allTrue
// (bool) false
auto All(const RVec< T > &v) -> decltype(v[0]==false)
Return true if all of the elements equate to true, return false otherwise.
Definition RVec.hxx:2220
ROOT::VecOps::RVec< int > RVecI
Definition RVec.hxx:3792

Definition at line 2220 of file RVec.hxx.

◆ Angle()

template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename T4 = T0, typename T5 = T0, typename Common_t = std::common_type_t<T0, T1>>
Common_t ROOT::VecOps::Angle ( T0 x1,
T1 y1,
T2 z1,
T3 x2,
T4 y2,
T5 z2 )

Return the angle between two three-vectors given the quantities x coordinate (x), y coordinate (y), z coordinate (y).

The function computes the angle between two three-vectors (x1, y2, z1) and (x2, y2, z2).

Definition at line 3025 of file RVec.hxx.

◆ Any()

template<typename T>
auto ROOT::VecOps::Any ( const RVec< T > & v) -> decltype(v[0]==true)

Return true if any of the elements equates to true, return false otherwise.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecI v {0, 1, 0};
auto anyTrue = Any(v);
anyTrue
// (bool) true
auto Any(const RVec< T > &v) -> decltype(v[0]==true)
Return true if any of the elements equates to true, return false otherwise.
Definition RVec.hxx:2201

Definition at line 2201 of file RVec.hxx.

◆ Arange()

template<typename T = double, typename Ret_t = std::conditional_t<std::is_floating_point_v<T>, T, double>>
RVec< Ret_t > ROOT::VecOps::Arange ( T start,
T end,
T step )
inline

Produce RVec with entries in the range [start, end) in increments of step.

This function generates a vector of values starting at start and incremented by step, continuing until the values reach or exceed end (the interval is half-open: [start, end)). The number of elements is computed as:

\[ n = \lceil \frac{\text{end} - \text{start}}{\text{step}} \rceil \]

ensuring that the arithmetic is performed in a floating-point context when needed.

The function is templated to allow for different return types. The return type Ret_t, if not explicitly specified, is determined as follows: if T is a floating point type, that type is used; otherwise, the return type is double.

Template Parameters
TType of the start, end, and step values. Default is double.
Ret_tReturn type, which, if not explicitly specified, is T if that is a floating point type, or double otherwise.
Parameters
startThe first value in the range.
endThe end of the range (exclusive).
stepThe increment between consecutive values.
Returns
A vector (RVec<Ret_t>) containing values starting at start, each incremented by step, up to but not including any value equal to or greater than end.
Note
The check if (!n || (n > std::numeric_limits<long long>::max())) is used to ensure that:
  • n is nonzero, and
  • n does not exceed std::numeric_limits<long long>::max(), which would indicate that a negative range (or other arithmetic issue) has resulted in an extremely large unsigned value, thereby preventing an attempt to reserve an absurd amount of memory.
If the template parameter Ret_t is explicitly overridden with an integral type, the returned results are rounded towards negative (std::floor) and then cast to the integer type. This is equivalent to setting dtype = int in numpy. To cast to integer without rounding, use instead RVec<integral_type>(Arange(...)), which would be equivalent to np.arange(...).astype(integral_type) in numpy.
C++23 Enumerate Support:
With C++23, you can use the range-based enumerate view to iterate over the resulting vector with both the index and the value, similar to Python's enumerate. For example:
for (auto const [index, val] : std::views::enumerate(ROOT::VecOps::Arange(1, 13, 5))) {
// Process index and val.
}
RVec< Ret_t > Arange(T start, T end, T step)
Produce RVec with entries in the range [start, end) in increments of step.
Definition RVec.hxx:3477
Example code, at the ROOT prompt:
using namespace ROOT::VecOps;
cout << Arange(0, 0, 5) << '\n';
// { }
cout << Arange(-7, 20, 4) << '\n';
// { -7, -3, 1, 5, 9, 13, 17 }
cout << Arange(1, 13, 5) << '\n';
// { 1, 6, 11 }
cout << Arange<unsigned int, unsigned int>(5, 9, 1) << '\n';
// { 5, 6, 7, 8 }

Definition at line 3477 of file RVec.hxx.

◆ ArgMax()

template<typename T>
std::size_t ROOT::VecOps::ArgMax ( const RVec< T > & v)

Get the index of the greatest element of an RVec In case of multiple occurrences of the maximum values, the index corresponding to the first occurrence is returned.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecF v {1.f, 2.f, 4.f};
auto v_argmax = ArgMax(v);
v_argmax
// (unsigned long) 2
std::size_t ArgMax(const RVec< T > &v)
Get the index of the greatest element of an RVec In case of multiple occurrences of the maximum value...
Definition RVec.hxx:2063
ROOT::VecOps::RVec< float > RVecF
Definition RVec.hxx:3791

Definition at line 2063 of file RVec.hxx.

◆ ArgMin()

template<typename T>
std::size_t ROOT::VecOps::ArgMin ( const RVec< T > & v)

Get the index of the smallest element of an RVec In case of multiple occurrences of the minimum values, the index corresponding to the first occurrence is returned.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecF v {1.f, 2.f, 4.f};
auto v_argmin = ArgMin(v);
v_argmin
// (unsigned long) 0
std::size_t ArgMin(const RVec< T > &v)
Get the index of the smallest element of an RVec In case of multiple occurrences of the minimum value...
Definition RVec.hxx:2081

Definition at line 2081 of file RVec.hxx.

◆ Argsort() [1/2]

template<typename T>
RVec< typename RVec< T >::size_type > ROOT::VecOps::Argsort ( const RVec< T > & v)

Return an RVec of indices that sort the input RVec.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v {2., 3., 1.};
auto sortIndices = Argsort(v)
// (ROOT::VecOps::RVec<unsigned long> &) { 2, 0, 1 }
auto values = Take(v, sortIndices)
// (ROOT::VecOps::RVec<double> &) { 1.0000000, 2.0000000, 3.0000000 }
RVec< T > Take(const RVec< T > &v, const RVec< typename RVec< T >::size_type > &i)
Return elements of a vector at given indices.
Definition RVec.hxx:2335
RVec< typename RVec< T >::size_type > Argsort(const RVec< T > &v)
Return an RVec of indices that sort the input RVec.
Definition RVec.hxx:2246
ROOT::VecOps::RVec< double > RVecD
Definition RVec.hxx:3790

Definition at line 2246 of file RVec.hxx.

◆ Argsort() [2/2]

template<typename T, typename Compare>
RVec< typename RVec< T >::size_type > ROOT::VecOps::Argsort ( const RVec< T > & v,
Compare && c )

Return an RVec of indices that sort the input RVec based on a comparison function.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v {2., 3., 1.};
auto sortIndices = Argsort(v, [](double x, double y) {return x > y;})
// (ROOT::VecOps::RVec<unsigned long> &) { 1, 0, 2 }
auto values = Take(v, sortIndices)
// (ROOT::VecOps::RVec<double> &) { 3.0000000, 2.0000000, 1.0000000 }

Definition at line 2267 of file RVec.hxx.

◆ asin()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::asin ( const RVec< T > & v)

Definition at line 1850 of file RVec.hxx.

◆ asinh()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::asinh ( const RVec< T > & v)

Definition at line 1858 of file RVec.hxx.

◆ atan()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::atan ( const RVec< T > & v)

Definition at line 1852 of file RVec.hxx.

◆ atan2() [1/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::atan2 ( const RVec< T0 > & v,
const T1 & y )

Definition at line 1853 of file RVec.hxx.

◆ atan2() [2/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::atan2 ( const RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1853 of file RVec.hxx.

◆ atan2() [3/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::atan2 ( const T0 & x,
const RVec< T1 > & v )

Definition at line 1853 of file RVec.hxx.

◆ atanh()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::atanh ( const RVec< T > & v)

Definition at line 1860 of file RVec.hxx.

◆ CapacityInBytes()

template<typename T, unsigned N>
size_t ROOT::VecOps::CapacityInBytes ( const RVecN< T, N > & X)
inline

Definition at line 1604 of file RVec.hxx.

◆ cbrt()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::cbrt ( const RVec< T > & v)

Definition at line 1844 of file RVec.hxx.

◆ ceil()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::ceil ( const RVec< T > & v)

Definition at line 1863 of file RVec.hxx.

◆ Combinations() [1/3]

template<typename T>
RVec< RVec< typename RVec< T >::size_type > > ROOT::VecOps::Combinations ( const RVec< T > & v,
const typename RVec< T >::size_type n )

Return the indices that represent all unique combinations of the elements of a given RVec.

using namespace ROOT::VecOps;
RVecD v {1., 2., 3., 4.};
auto v_1 = Combinations(v, 1);
v_1
auto v_2 = Combinations(v, 2);
v_2
(ROOT::VecOps::RVec<ROOT::VecOps::RVec<unsigned long> > &) { { 0, 0, 0, 1, 1, 2 }, { 1, 2, 3, 2, 3, 3 } }
auto v_3 = Combinations(v, 3);
v_3
(ROOT::VecOps::RVec<ROOT::VecOps::RVec<unsigned long> > &) { { 0, 0, 0, 1 }, { 1, 1, 2, 2 }, { 2, 3, 3, 3 } }
auto v_4 = Combinations(v, 4);
v_4
(ROOT::VecOps::RVec<ROOT::VecOps::RVec<unsigned long> > &) { { 0 }, { 1 }, { 2 }, { 3 } }
A "std::vector"-like collection of values implementing handy operation to analyse them.
Definition RVec.hxx:1525
RVec< RVec< std::size_t > > Combinations(const std::size_t size1, const std::size_t size2)
Return the indices that represent all combinations of the elements of two RVecs.
Definition RVec.hxx:2602

Definition at line 2659 of file RVec.hxx.

◆ Combinations() [2/3]

template<typename T1, typename T2>
RVec< RVec< typename RVec< T1 >::size_type > > ROOT::VecOps::Combinations ( const RVec< T1 > & v1,
const RVec< T2 > & v2 )

Return the indices that represent all combinations of the elements of two RVecs.

The type of the return value is an RVec of two RVecs containing indices.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v1 {1., 2., 3.};
RVecD v2 {-4., -5.};
auto comb_idx = Combinations(v1, v2);
comb_idx
// (ROOT::VecOps::RVec<ROOT::VecOps::RVec<unsigned long> > &) { { 0, 0, 1, 1, 2, 2 }, { 0, 1, 0, 1, 0, 1 } }

Definition at line 2634 of file RVec.hxx.

◆ Combinations() [3/3]

RVec< RVec< std::size_t > > ROOT::VecOps::Combinations ( const std::size_t size1,
const std::size_t size2 )
inline

Return the indices that represent all combinations of the elements of two RVecs.

The type of the return value is an RVec of two RVecs containing indices.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
auto comb_idx = Combinations(3, 2);
comb_idx
// (ROOT::VecOps::RVec<ROOT::VecOps::RVec<unsigned long> > &) { { 0, 0, 1, 1, 2, 2 }, { 0, 1, 0, 1, 0, 1 } }

Definition at line 2602 of file RVec.hxx.

◆ Concatenate()

template<typename T0, typename T1, typename Common_t = typename std::common_type<T0, T1>::type>
RVec< Common_t > ROOT::VecOps::Concatenate ( const RVec< T0 > & v0,
const RVec< T1 > & v1 )

Return the concatenation of two RVecs.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecF rvf {0.f, 1.f, 2.f};
RVecI rvi {7, 8, 9};
Concatenate(rvf, rvi)
// (ROOT::VecOps::RVec<float>) { 0.00000f, 1.00000f, 2.00000f, 7.00000f, 8.00000f, 9.00000f }
RVec< Common_t > Concatenate(const RVec< T0 > &v0, const RVec< T1 > &v1)
Return the concatenation of two RVecs.
Definition RVec.hxx:2893

Definition at line 2893 of file RVec.hxx.

◆ Construct()

template<typename T, typename... Args_t>
RVec< T > ROOT::VecOps::Construct ( const RVec< Args_t > &... args)

Build an RVec of objects starting from RVecs of input to their constructors.

Template Parameters
TType of the objects contained in the created RVec.
Args_tPack of types templating the input RVecs.
Parameters
[in]argsThe RVecs containing the values used to initialise the output objects.
Returns
The RVec of objects initialised with the input parameters.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecF pts = {15.5, 34.32, 12.95};
RVecF etas = {0.3, 2.2, 1.32};
RVecF phis = {0.1, 3.02, 2.2};
RVecF masses = {105.65, 105.65, 105.65};
auto fourVecs = Construct<ROOT::Math::PtEtaPhiMVector>(pts, etas, phis, masses);
cout << fourVecs << endl;
// { (15.5,0.3,0.1,105.65), (34.32,2.2,3.02,105.65), (12.95,1.32,2.2,105.65) }
RVec< T > Construct(const RVec< Args_t > &... args)
Build an RVec of objects starting from RVecs of input to their constructors.
Definition RVec.hxx:3210

Definition at line 3210 of file RVec.hxx.

◆ cos()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::cos ( const RVec< T > & v)

Definition at line 1848 of file RVec.hxx.

◆ cosh()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::cosh ( const RVec< T > & v)

Definition at line 1856 of file RVec.hxx.

◆ DeltaPhi() [1/4]

template<typename T0, typename T1 = T0, typename Common_t = typename std::common_type_t<T0, T1>>
RVec< Common_t > ROOT::VecOps::DeltaPhi ( const RVec< T0 > & v1,
const RVec< T1 > & v2,
const Common_t c = M_PI )

Return the angle difference \(\Delta \phi\) in radians of two vectors.

The function computes the closest angle from v1 to v2 with sign and is therefore in the range \([-\pi, \pi]\). The computation is done per default in radians \(c = \pi\) but can be switched to degrees \(c = 180\).

Definition at line 2930 of file RVec.hxx.

◆ DeltaPhi() [2/4]

template<typename T0, typename T1 = T0, typename Common_t = typename std::common_type_t<T0, T1>>
RVec< Common_t > ROOT::VecOps::DeltaPhi ( const RVec< T0 > & v1,
T1 v2,
const Common_t c = M_PI )

Return the angle difference \(\Delta \phi\) in radians of a vector and a scalar.

The function computes the closest angle from v1 to v2 with sign and is therefore in the range \([-\pi, \pi]\). The computation is done per default in radians \(c = \pi\) but can be switched to degrees \(c = 180\).

Definition at line 2948 of file RVec.hxx.

◆ DeltaPhi() [3/4]

template<typename T0, typename T1 = T0, typename Common_t = typename std::common_type_t<T0, T1>>
RVec< Common_t > ROOT::VecOps::DeltaPhi ( T0 v1,
const RVec< T1 > & v2,
const Common_t c = M_PI )

Return the angle difference \(\Delta \phi\) in radians of a scalar and a vector.

The function computes the closest angle from v1 to v2 with sign and is therefore in the range \([-\pi, \pi]\). The computation is done per default in radians \(c = \pi\) but can be switched to degrees \(c = 180\).

Definition at line 2966 of file RVec.hxx.

◆ DeltaPhi() [4/4]

template<typename T0, typename T1 = T0, typename Common_t = std::common_type_t<T0, T1>>
Common_t ROOT::VecOps::DeltaPhi ( T0 v1,
T1 v2,
const Common_t c = M_PI )

Return the angle difference \(\Delta \phi\) of two scalars.

The function computes the closest angle from v1 to v2 with sign and is therefore in the range \([-\pi, \pi]\). The computation is done per default in radians \(c = \pi\) but can be switched to degrees \(c = 180\).

Definition at line 2909 of file RVec.hxx.

◆ DeltaR() [1/2]

template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3>>
RVec< Common_t > ROOT::VecOps::DeltaR ( const RVec< T0 > & eta1,
const RVec< T1 > & eta2,
const RVec< T2 > & phi1,
const RVec< T3 > & phi2,
const Common_t c = M_PI )

Return the distance on the \(\eta\)- \(\phi\) plane ( \(\Delta R\)) from the collections eta1, eta2, phi1 and phi2.

The function computes \(\Delta R = \sqrt{(\eta_1 - \eta_2)^2 + (\phi_1 - \phi_2)^2}\) of the given collections eta1, eta2, phi1 and phi2. The angle \(\phi\) can be set to radian or degrees using the optional argument c, see the documentation of the DeltaPhi helper.

Definition at line 2999 of file RVec.hxx.

◆ DeltaR() [2/2]

template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3>>
Common_t ROOT::VecOps::DeltaR ( T0 eta1,
T1 eta2,
T2 phi1,
T3 phi2,
const Common_t c = M_PI )

Return the distance on the \(\eta\)- \(\phi\) plane ( \(\Delta R\)) from the scalars eta1, eta2, phi1 and phi2.

The function computes \(\Delta R = \sqrt{(\eta_1 - \eta_2)^2 + (\phi_1 - \phi_2)^2}\) of the given scalars eta1, eta2, phi1 and phi2. The angle \(\phi\) can be set to radian or degrees using the optional argument c, see the documentation of the DeltaPhi helper.

Definition at line 3012 of file RVec.hxx.

◆ DeltaR2()

template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3>>
RVec< Common_t > ROOT::VecOps::DeltaR2 ( const RVec< T0 > & eta1,
const RVec< T1 > & eta2,
const RVec< T2 > & phi1,
const RVec< T3 > & phi2,
const Common_t c = M_PI )

Return the square of the distance on the \(\eta\)- \(\phi\) plane ( \(\Delta R\)) from the collections eta1, eta2, phi1 and phi2.

The function computes \(\Delta R^2 = (\eta_1 - \eta_2)^2 + (\phi_1 - \phi_2)^2\) of the given collections eta1, eta2, phi1 and phi2. The angle \(\phi\) can be set to radian or degrees using the optional argument c, see the documentation of the DeltaPhi helper.

Definition at line 2985 of file RVec.hxx.

◆ Dot()

template<typename T, typename V>
auto ROOT::VecOps::Dot ( const RVec< T > & v0,
const RVec< V > & v1 ) -> decltype(v0[0] *v1[0])

Inner product.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVec<float> v1 {1., 2., 3.};
RVec<float> v2 {4., 5., 6.};
auto v1_dot_v2 = Dot(v1, v2);
v1_dot_v2
// (float) 32.0000f
auto Dot(const RVec< T > &v0, const RVec< V > &v1) -> decltype(v0[0] *v1[0])
Inner product.
Definition RVec.hxx:1919

Definition at line 1919 of file RVec.hxx.

◆ Drop()

template<typename T>
RVec< T > ROOT::VecOps::Drop ( const RVec< T > & v,
RVec< typename RVec< T >::size_type > idxs )

Return a copy of the container without the elements at the specified indices.

Duplicated and out-of-range indices in idxs are ignored.

Definition at line 2444 of file RVec.hxx.

◆ Enumerate()

template<typename T>
RVec< typename RVec< T >::size_type > ROOT::VecOps::Enumerate ( const RVec< T > & v)

For any Rvec v produce another RVec with entries starting from 0, and incrementing by 1 until a N = v.size() is reached.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecF v = {1., 2., 3.};
cout << Enumerate(v1) << "\n";
// { 0, 1, 2 }
RVec< typename RVec< T >::size_type > Enumerate(const RVec< T > &v)
For any Rvec v produce another RVec with entries starting from 0, and incrementing by 1 until a N = v...
Definition RVec.hxx:3230

Definition at line 3230 of file RVec.hxx.

◆ erf()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::erf ( const RVec< T > & v)

Definition at line 1869 of file RVec.hxx.

◆ erfc()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::erfc ( const RVec< T > & v)

Definition at line 1870 of file RVec.hxx.

◆ exp()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::exp ( const RVec< T > & v)

Definition at line 1833 of file RVec.hxx.

◆ exp2()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::exp2 ( const RVec< T > & v)

Definition at line 1834 of file RVec.hxx.

◆ expm1()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::expm1 ( const RVec< T > & v)

Definition at line 1835 of file RVec.hxx.

◆ fdim() [1/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::fdim ( const RVec< T0 > & v,
const T1 & y )

Definition at line 1829 of file RVec.hxx.

◆ fdim() [2/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::fdim ( const RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1829 of file RVec.hxx.

◆ fdim() [3/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::fdim ( const T0 & x,
const RVec< T1 > & v )

Definition at line 1829 of file RVec.hxx.

◆ Filter()

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.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecI v {1, 2, 4};
auto v_even = Filter(v, [](int i){return 0 == i%2;});
v_even
// (ROOT::VecOps::RVec<int> &) { 2, 4 }
RVec< T > Filter(const RVec< T > &v, F &&f)
Create a new collection with the elements passing the filter expressed by the predicate.
Definition RVec.hxx:2178

Definition at line 2178 of file RVec.hxx.

◆ floor()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::floor ( const RVec< T > & v)

Definition at line 1862 of file RVec.hxx.

◆ fmod() [1/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::fmod ( const RVec< T0 > & v,
const T1 & y )

Definition at line 1830 of file RVec.hxx.

◆ fmod() [2/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::fmod ( const RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1830 of file RVec.hxx.

◆ fmod() [3/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::fmod ( const T0 & x,
const RVec< T1 > & v )

Definition at line 1830 of file RVec.hxx.

◆ hypot() [1/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::hypot ( const RVec< T0 > & v,
const T1 & y )

Definition at line 1845 of file RVec.hxx.

◆ hypot() [2/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::hypot ( const RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1845 of file RVec.hxx.

◆ hypot() [3/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::hypot ( const T0 & x,
const RVec< T1 > & v )

Definition at line 1845 of file RVec.hxx.

◆ Intersect()

template<typename T>
RVec< T > ROOT::VecOps::Intersect ( const RVec< T > & v1,
const RVec< T > & v2,
bool v2_is_sorted = false )

Return the intersection of elements of two RVecs.

Each element of v1 is looked up in v2 and added to the returned vector if found. Following, the order of v1 is preserved. If v2 is already sorted, the optional argument v2_is_sorted can be used to toggle of the internal sorting step, therewith optimising runtime.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v1 {1., 2., 3.};
RVecD v2 {-4., -5., 2., 1.};
auto v1_intersect_v2 = Intersect(v1, v2);
v1_intersect_v2
// (ROOT::VecOps::RVec<double> &) { 1.0000000, 2.0000000 }
RVec< T > Intersect(const RVec< T > &v1, const RVec< T > &v2, bool v2_is_sorted=false)
Return the intersection of elements of two RVecs.
Definition RVec.hxx:2754

Definition at line 2754 of file RVec.hxx.

◆ InvariantMass()

template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3>>
Common_t ROOT::VecOps::InvariantMass ( const RVec< T0 > & pt,
const RVec< T1 > & eta,
const RVec< T2 > & phi,
const RVec< T3 > & mass )

Return the invariant mass of multiple particles given the collections of the quantities transverse momentum (pt), rapidity (eta), azimuth (phi) and mass.

The function computes the invariant mass of multiple particles with the four-vectors (pt, eta, phi, mass).

Definition at line 3164 of file RVec.hxx.

◆ InvariantMasses()

template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename T4 = T0, typename T5 = T0, typename T6 = T0, typename T7 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3, T4, T5, T6, T7>>
RVec< Common_t > ROOT::VecOps::InvariantMasses ( const RVec< T0 > & pt1,
const RVec< T1 > & eta1,
const RVec< T2 > & phi1,
const RVec< T3 > & mass1,
const RVec< T4 > & pt2,
const RVec< T5 > & eta2,
const RVec< T6 > & phi2,
const RVec< T7 > & mass2 )

Return the invariant mass of two particles given the collections of the quantities transverse momentum (pt), rapidity (eta), azimuth (phi) and mass.

The function computes the invariant mass of two particles with the four-vectors (pt1, eta2, phi1, mass1) and (pt2, eta2, phi2, mass2).

Definition at line 3129 of file RVec.hxx.

◆ InvariantMasses_PxPyPzM() [1/2]

template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename T4 = T0, typename T5 = T0, typename T6 = T0, typename T7 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3, T4, T5, T6, T7>>
RVec< Common_t > ROOT::VecOps::InvariantMasses_PxPyPzM ( const RVec< T0 > & px1,
const RVec< T1 > & py1,
const RVec< T2 > & pz1,
const RVec< T3 > & mass1,
const RVec< T4 > & px2,
const RVec< T5 > & py2,
const RVec< T6 > & pz2,
const RVec< T7 > & mass2 )

Return the invariant mass of two particles given the collections of the quantities x coordinate (px), y coordinate (py), z coordinate (pz) and mass.

The function computes the invariant mass of two particles with the four-vectors (px1, py2, pz1, mass1) and (px2, py2, pz2, mass2).

Definition at line 3103 of file RVec.hxx.

◆ InvariantMasses_PxPyPzM() [2/2]

template<typename T0, typename T1 = T0, typename T2 = T0, typename T3 = T0, typename T4 = T0, typename T5 = T0, typename T6 = T0, typename T7 = T0, typename Common_t = std::common_type_t<T0, T1, T2, T3, T4, T5, T6, T7>>
Common_t ROOT::VecOps::InvariantMasses_PxPyPzM ( const T0 & x1,
const T1 & y1,
const T2 & z1,
const T3 & mass1,
const T4 & x2,
const T5 & y2,
const T6 & z2,
const T7 & mass2 )

Return the invariant mass of two particles given x coordinate (px), y coordinate (py), z coordinate (pz) and mass.

The function computes the invariant mass of two particles with the four-vectors (x1, y2, z1, mass1) and (x2, py2, pz2, mass2).

Definition at line 3047 of file RVec.hxx.

◆ lgamma()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::lgamma ( const RVec< T > & v)

Definition at line 1871 of file RVec.hxx.

◆ Linspace()

template<typename T = double, typename Ret_t = std::conditional_t<std::is_floating_point_v<T>, T, double>>
RVec< Ret_t > ROOT::VecOps::Linspace ( T start,
T end,
unsigned long long n = 128,
const bool endpoint = true )
inline

Produce RVec with N evenly-spaced entries from start to end.

This function generates a vector of evenly spaced values, starting at start and (depending on the endpoint parameter) either including or excluding end. If endpoint is true (default), the vector contains n values with end as the final element, and the spacing is computed as \(\text{step} = \frac{\text{end} - \text{start}}{n-1}\). If endpoint is false, the sequence consists of n values computed as if there were n+1 evenly spaced samples, with the final value (end) omitted; in this case, \(\text{step} = \frac{\text{end} - \text{start}}{n}\).

The function is templated to allow for different return types. The return type Ret_t, if not explicitly specified, is determined as follows: if T is a floating point type, that type is used; otherwise, the return type is double.

Template Parameters
TType of the start and end value. Default is double.
Ret_tReturn type used, which, if not explicitly specified in the template, is T if that is a floating point type, or double otherwise.
Parameters
startThe first value in the sequence.
endThe last value in the sequence if endpoint is true; otherwise, end is excluded.
nThe number of evenly spaced entries to produce. The default value is 128, which is different than numpy's default value of 50.
endpointIf true (default), end is included as the final element; if false, end is excluded.
Returns
A vector (RVec<Ret_t>) containing n evenly spaced values.
Note
If n is 1, the resulting vector will contain only the value start.
The check if (!n || (n > std::numeric_limits<long long>::max())) is used to ensure that:
  • division by zero is avoided when calculating step
  • n does not exceed std::numeric_limits<long long>::max(), which would indicate that a negative range (or other arithmetic issue) has resulted in an extremely large unsigned value, thereby preventing an attempt to reserve an absurd amount of memory.
If the template parameter Ret_t is explicitly overridden with an integral type, the returned results are rounded towards negative (std::floor) and then cast to the integer type. This is equivalent to setting dtype = int in numpy.linspace. To cast to integer without rounding, use instead RVec<integral_type>(Linspace(...)), which would be equivalent to np.linspace(...).astype(integral_type) in numpy.
C++23 Enumerate Support:
With C++23, you can use the range-based enumerate view to iterate over the resulting vector with both the index and the value, similar to Python's enumerate. For example:
for (auto const [index, val] : std::views::enumerate(ROOT::VecOps::Linspace(6, 10, 16))) {
// Process index and val.
}
RVec< Ret_t > Linspace(T start, T end, unsigned long long n=128, const bool endpoint=true)
Produce RVec with N evenly-spaced entries from start to end.
Definition RVec.hxx:3297
Example code, at the ROOT prompt:
using namespace ROOT::VecOps;
cout << Linspace(-1, 5, 5) << "\n";
// { -1, 0.5, 2, 3.5, 5 }
cout << Linspace(3, 12, 5) << "\n";
// { 3, 5.25, 7.5, 9.75, 12 }
cout << Linspace(3, 12, 5, false) << "\n";
// { 3, 4.8, 6.6, 8.4, 10.2 }
cout << Linspace<int, int>(1, 10, 3) << "\n";
// { 1, 5, 10 }

Definition at line 3297 of file RVec.hxx.

◆ llround()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::llround ( const RVec< T > & v)

Definition at line 1867 of file RVec.hxx.

◆ log()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::log ( const RVec< T > & v)

Definition at line 1837 of file RVec.hxx.

◆ log10()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::log10 ( const RVec< T > & v)

Definition at line 1838 of file RVec.hxx.

◆ log1p()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::log1p ( const RVec< T > & v)

Definition at line 1840 of file RVec.hxx.

◆ log2()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::log2 ( const RVec< T > & v)

Definition at line 1839 of file RVec.hxx.

◆ Logspace()

template<typename T = double, typename Ret_t = std::conditional_t<std::is_floating_point_v<T>, T, double>>
RVec< Ret_t > ROOT::VecOps::Logspace ( T start,
T end,
unsigned long long n = 128,
const bool endpoint = true,
T base = 10.0 )
inline

Produce RVec with n log-spaced entries from base^{start} to base^{end}.

This function generates a vector of values where the exponents are evenly spaced, and then returns the corresponding values of base raised to these exponents. If endpoint is true (default), the vector contains n values with the last element equal to \(base^{end}\). If endpoint is false, the sequence is computed as if there were n+1 evenly spaced samples over the interval in the exponent space, and the final value ( \(base^{end}\)) is excluded, resulting in a sequence of n values.

The function is templated to allow for different return types. The return type Ret_t, if not explicitly specified, is determined as follows: if T is a floating point type, that type is used; otherwise, the return type is double.

Template Parameters
TType of the start and end exponents and the base. Default is double.
Ret_tDeduced type used for return type, which, if not explicitly specified, is T if that is a floating point type, or double otherwise.
Parameters
startThe exponent corresponding to the first element (i.e., the first element is \(base^{start}\)).
endThe exponent corresponding to the final element if endpoint is true; otherwise, end is excluded.
nThe number of log-spaced entries to produce. The default value is 128, which is different than numpy's default value of 50.
endpointIf true (default), \(base^{end}\) is included as the final element; if false, \(base^{end}\) is excluded.
baseThe base to be used in the exponentiation (default is 10.0).
Returns
A vector (RVec<Ret_t>) containing n log-spaced values.
Note
If n is 1, the resulting vector will contain only the value \(base^{start}\).
The check if (!n || (n > std::numeric_limits<long long>::max())) is used to ensure that:
  • division by zero is avoided when calculating step
  • n does not exceed std::numeric_limits<long long>::max(), which would indicate that a negative range (or other arithmetic issue) has resulted in an extremely large unsigned value, thereby preventing an attempt to reserve an absurd amount of memory.
If the template parameter Ret_t is explicitly overridden with an integral type, the returned results are rounded towards negative (std::floor) and then cast to the integer type. This is equivalent to setting dtype = int in numpy.linspace. To cast to integer without rounding, use instead RVec<integral_type>(Logspace(...)), which would be equivalent to np.logspace(...).astype(integral_type) in numpy.
C++23 Enumerate Support:
With C++23, you can use the range-based enumerate view to iterate over the resulting vector with both the index and the value, similar to Python's enumerate. For example:
for (auto const [index, val] : std::views::enumerate(ROOT::VecOps::Logspace(4, 10, 12))) {
// Process index and val.
}
RVec< Ret_t > Logspace(T start, T end, unsigned long long n=128, const bool endpoint=true, T base=10.0)
Produce RVec with n log-spaced entries from base^{start} to base^{end}.
Definition RVec.hxx:3383
Example code, at the ROOT prompt:
using namespace ROOT::VecOps;
cout << Logspace(4, 10, 12) << '\n';
// { 10000, 35111.9, 123285, 432876, 1.51991e+06, 5.3367e+06, 1.87382e+07, 6.57933e+07, 2.31013e+08, 8.11131e+08, 2.84804e+09, 1e+10 }
cout << Logspace(0, 0, 50) << '\n';
// { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
cout << Logspace(0, 0, 0) << '\n';
// { }
cout << Logspace(4, 10, 12, 10.0, false) << '\n';
// { 10000, 31622.8, 100000, 316228, 1e+06, 3.16228e+06, 1e+07, 3.16228e+07, 1e+08, 3.16228e+08, 1e+09, 3.16228e+09 }
cout << Logspace<int, int>(1, 5, 3) << '\n';
// { 10, 1000, 100000 }

Definition at line 3383 of file RVec.hxx.

◆ lround()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::lround ( const RVec< T > & v)

Definition at line 1866 of file RVec.hxx.

◆ Map()

template<typename... Args>
auto ROOT::VecOps::Map ( Args &&... args)

Create new collection applying a callable to the elements of the input collection.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecF v {1.f, 2.f, 4.f};
auto v_square = Map(v, [](float f){return f* 2.f;});
v_square
// (ROOT::VecOps::RVec<float> &) { 2.00000f, 4.00000f, 8.00000f }
RVecF x({1.f, 2.f, 3.f});
RVecF y({4.f, 5.f, 6.f});
RVecF z({7.f, 8.f, 9.f});
auto mod = [](float x, float y, float z) { return sqrt(x * x + y * y + z * z); };
auto v_mod = Map(x, y, z, mod);
v_mod
// (ROOT::VecOps::RVec<float> &) { 8.12404f, 9.64365f, 11.2250f }
RVec< PromoteType< T > > sqrt(const RVec< T > &v)
Definition RVec.hxx:1843
auto Map(Args &&... args)
Create new collection applying a callable to the elements of the input collection.
Definition RVec.hxx:2146

Definition at line 2146 of file RVec.hxx.

◆ Max()

template<typename T>
T ROOT::VecOps::Max ( const RVec< T > & v)

Get the greatest element of an RVec.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecF v {1.f, 2.f, 4.f};
auto v_max = Max(v);
v_max
(float) 4.00000f
T Max(const RVec< T > &v)
Get the greatest element of an RVec.
Definition RVec.hxx:2029

Definition at line 2029 of file RVec.hxx.

◆ Mean() [1/2]

template<typename T>
double ROOT::VecOps::Mean ( const RVec< T > & v)

Get the mean of the elements of an RVec.

The return type is a double precision floating point number.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecF v {1.f, 2.f, 4.f};
auto v_mean = Mean(v);
v_mean
// (double) 2.3333333
double Mean(const RVec< T > &v)
Get the mean of the elements of an RVec.
Definition RVec.hxx:1980

Definition at line 1980 of file RVec.hxx.

◆ Mean() [2/2]

template<typename T, typename R = T>
R ROOT::VecOps::Mean ( const RVec< T > & v,
const R zero )

Get the mean of the elements of an RVec with custom initial value.

The return type will be deduced from the zero parameter

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecF v {1.f, 2.f, 4.f};
auto v_mean_f = Mean(v, 0.f);
v_mean_f
// (float) 2.33333f
auto v_mean_d = Mean(v, 0.);
v_mean_d
// (double) 2.3333333
using namespace ROOT::VecOps;
const ROOT::Math::PtEtaPhiMVector lv0 {15.5f, .3f, .1f, 105.65f},
lv1 {34.32f, 2.2f, 3.02f, 105.65f},
lv2 {12.95f, 1.32f, 2.2f, 105.65f};
auto v_mean_lv = Mean(v, ROOT::Math::PtEtaPhiMVector());
v_mean_lv
// (ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> > &) (10.283,2.46534,2.58947,120.361)
LorentzVector< PtEtaPhiM4D< double > > PtEtaPhiMVector
LorentzVector based on the cylindrical coordinates pt, eta, phi and Mass in double precision.
Definition Vector4Dfwd.h:84

Definition at line 2012 of file RVec.hxx.

◆ Min()

template<typename T>
T ROOT::VecOps::Min ( const RVec< T > & v)

Get the smallest element of an RVec.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecF v {1.f, 2.f, 4.f};
auto v_min = Min(v);
v_min
(float) 1.00000f
T Min(const RVec< T > &v)
Get the smallest element of an RVec.
Definition RVec.hxx:2045

Definition at line 2045 of file RVec.hxx.

◆ Nonzero()

template<typename T>
RVec< typename RVec< T >::size_type > ROOT::VecOps::Nonzero ( const RVec< T > & v)

Return the indices of the elements which are not zero.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v {2., 0., 3., 0., 1.};
auto nonzero_idx = Nonzero(v);
nonzero_idx
// (ROOT::VecOps::RVec<unsigned long> &) { 0, 2, 4 }
RVec< typename RVec< T >::size_type > Nonzero(const RVec< T > &v)
Return the indices of the elements which are not zero.
Definition RVec.hxx:2723

Definition at line 2723 of file RVec.hxx.

◆ operator!()

template<typename T>
RVec< T > ROOT::VecOps::operator! ( const RVec< T > & v)

Definition at line 1625 of file RVec.hxx.

◆ operator!=() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator!= ( const RVec< T0 > & v,
const T1 & y ) -> RVec< int >

Definition at line 1756 of file RVec.hxx.

◆ operator!=() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator!= ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< int >

Definition at line 1756 of file RVec.hxx.

◆ operator!=() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator!= ( const T0 & x,
const RVec< T1 > & v ) -> RVec< int >

Definition at line 1756 of file RVec.hxx.

◆ operator%() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator% ( const RVec< T0 > & v,
const T1 & y ) -> RVec< decltype(v[0] % y)>

Definition at line 1673 of file RVec.hxx.

◆ operator%() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator% ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< decltype(v0[0] % v1[0])>

Definition at line 1673 of file RVec.hxx.

◆ operator%() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator% ( const T0 & x,
const RVec< T1 > & v ) -> RVec< decltype(x % v[0])>

Definition at line 1673 of file RVec.hxx.

◆ operator%=() [1/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator%= ( RVec< T0 > & v,
const T1 & y )

Definition at line 1707 of file RVec.hxx.

◆ operator%=() [2/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator%= ( RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1707 of file RVec.hxx.

◆ operator&() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator& ( const RVec< T0 > & v,
const T1 & y ) -> RVec< decltype(v[0] &y)>

Definition at line 1676 of file RVec.hxx.

◆ operator&() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator& ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< decltype(v0[0] &v1[0])>

Definition at line 1676 of file RVec.hxx.

◆ operator&() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator& ( const T0 & x,
const RVec< T1 > & v ) -> RVec< decltype(x &v[0])>

Definition at line 1676 of file RVec.hxx.

◆ operator&&() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator&& ( const RVec< T0 > & v,
const T1 & y ) -> RVec< int >

Definition at line 1759 of file RVec.hxx.

◆ operator&&() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator&& ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< int >

Definition at line 1759 of file RVec.hxx.

◆ operator&&() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator&& ( const T0 & x,
const RVec< T1 > & v ) -> RVec< int >

Definition at line 1759 of file RVec.hxx.

◆ operator&=() [1/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator&= ( RVec< T0 > & v,
const T1 & y )

Definition at line 1710 of file RVec.hxx.

◆ operator&=() [2/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator&= ( RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1710 of file RVec.hxx.

◆ operator*() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator* ( const RVec< T0 > & v,
const T1 & y ) -> RVec< decltype(v[0] *y)>

Definition at line 1671 of file RVec.hxx.

◆ operator*() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator* ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< decltype(v0[0] *v1[0])>

Definition at line 1671 of file RVec.hxx.

◆ operator*() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator* ( const T0 & x,
const RVec< T1 > & v ) -> RVec< decltype(x *v[0])>

Definition at line 1671 of file RVec.hxx.

◆ operator*=() [1/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator*= ( RVec< T0 > & v,
const T1 & y )

Definition at line 1705 of file RVec.hxx.

◆ operator*=() [2/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator*= ( RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1705 of file RVec.hxx.

◆ operator+() [1/4]

template<typename T>
RVec< T > ROOT::VecOps::operator+ ( const RVec< T > & v)

Definition at line 1622 of file RVec.hxx.

◆ operator+() [2/4]

template<typename T0, typename T1>
auto ROOT::VecOps::operator+ ( const RVec< T0 > & v,
const T1 & y ) -> RVec< decltype(v[0]+y)>

Definition at line 1669 of file RVec.hxx.

◆ operator+() [3/4]

template<typename T0, typename T1>
auto ROOT::VecOps::operator+ ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< decltype(v0[0]+v1[0])>

Definition at line 1669 of file RVec.hxx.

◆ operator+() [4/4]

template<typename T0, typename T1>
auto ROOT::VecOps::operator+ ( const T0 & x,
const RVec< T1 > & v ) -> RVec< decltype(x+v[0])>

Definition at line 1669 of file RVec.hxx.

◆ operator+=() [1/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator+= ( RVec< T0 > & v,
const T1 & y )

Definition at line 1703 of file RVec.hxx.

◆ operator+=() [2/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator+= ( RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1703 of file RVec.hxx.

◆ operator-() [1/4]

template<typename T>
RVec< T > ROOT::VecOps::operator- ( const RVec< T > & v)

Definition at line 1623 of file RVec.hxx.

◆ operator-() [2/4]

template<typename T0, typename T1>
auto ROOT::VecOps::operator- ( const RVec< T0 > & v,
const T1 & y ) -> RVec< decltype(v[0] - y)>

Definition at line 1670 of file RVec.hxx.

◆ operator-() [3/4]

template<typename T0, typename T1>
auto ROOT::VecOps::operator- ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< decltype(v0[0] - v1[0])>

Definition at line 1670 of file RVec.hxx.

◆ operator-() [4/4]

template<typename T0, typename T1>
auto ROOT::VecOps::operator- ( const T0 & x,
const RVec< T1 > & v ) -> RVec< decltype(x - v[0])>

Definition at line 1670 of file RVec.hxx.

◆ operator-=() [1/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator-= ( RVec< T0 > & v,
const T1 & y )

Definition at line 1704 of file RVec.hxx.

◆ operator-=() [2/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator-= ( RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1704 of file RVec.hxx.

◆ operator/() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator/ ( const RVec< T0 > & v,
const T1 & y ) -> RVec< decltype(v[0]/y)>

Definition at line 1672 of file RVec.hxx.

◆ operator/() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator/ ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< decltype(v0[0]/v1[0])>

Definition at line 1672 of file RVec.hxx.

◆ operator/() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator/ ( const T0 & x,
const RVec< T1 > & v ) -> RVec< decltype(x/v[0])>

Definition at line 1672 of file RVec.hxx.

◆ operator/=() [1/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator/= ( RVec< T0 > & v,
const T1 & y )

Definition at line 1706 of file RVec.hxx.

◆ operator/=() [2/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator/= ( RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1706 of file RVec.hxx.

◆ operator<() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator< ( const RVec< T0 > & v,
const T1 & y ) -> RVec< int >

Definition at line 1753 of file RVec.hxx.

◆ operator<() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator< ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< int >

Definition at line 1753 of file RVec.hxx.

◆ operator<() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator< ( const T0 & x,
const RVec< T1 > & v ) -> RVec< int >

Definition at line 1753 of file RVec.hxx.

◆ operator<<()

template<class T>
std::ostream & ROOT::VecOps::operator<< ( std::ostream & os,
const RVec< T > & v )

Print a RVec at the prompt:

Definition at line 3581 of file RVec.hxx.

◆ operator<<=() [1/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator<<= ( RVec< T0 > & v,
const T1 & y )

Definition at line 1711 of file RVec.hxx.

◆ operator<<=() [2/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator<<= ( RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1711 of file RVec.hxx.

◆ operator<=() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator<= ( const RVec< T0 > & v,
const T1 & y ) -> RVec< int >

Definition at line 1757 of file RVec.hxx.

◆ operator<=() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator<= ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< int >

Definition at line 1757 of file RVec.hxx.

◆ operator<=() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator<= ( const T0 & x,
const RVec< T1 > & v ) -> RVec< int >

Definition at line 1757 of file RVec.hxx.

◆ operator==() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator== ( const RVec< T0 > & v,
const T1 & y ) -> RVec< int >

Definition at line 1755 of file RVec.hxx.

◆ operator==() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator== ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< int >

Definition at line 1755 of file RVec.hxx.

◆ operator==() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator== ( const T0 & x,
const RVec< T1 > & v ) -> RVec< int >

Definition at line 1755 of file RVec.hxx.

◆ operator>() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator> ( const RVec< T0 > & v,
const T1 & y ) -> RVec< int >

Definition at line 1754 of file RVec.hxx.

◆ operator>() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator> ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< int >

Definition at line 1754 of file RVec.hxx.

◆ operator>() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator> ( const T0 & x,
const RVec< T1 > & v ) -> RVec< int >

Definition at line 1754 of file RVec.hxx.

◆ operator>=() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator>= ( const RVec< T0 > & v,
const T1 & y ) -> RVec< int >

Definition at line 1758 of file RVec.hxx.

◆ operator>=() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator>= ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< int >

Definition at line 1758 of file RVec.hxx.

◆ operator>=() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator>= ( const T0 & x,
const RVec< T1 > & v ) -> RVec< int >

Definition at line 1758 of file RVec.hxx.

◆ operator>>=() [1/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator>>= ( RVec< T0 > & v,
const T1 & y )

Definition at line 1711 of file RVec.hxx.

◆ operator>>=() [2/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator>>= ( RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1711 of file RVec.hxx.

◆ operator^() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator^ ( const RVec< T0 > & v,
const T1 & y ) -> RVec< decltype(v[0] ^ y)>

Definition at line 1674 of file RVec.hxx.

◆ operator^() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator^ ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< decltype(v0[0] ^ v1[0])>

Definition at line 1674 of file RVec.hxx.

◆ operator^() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator^ ( const T0 & x,
const RVec< T1 > & v ) -> RVec< decltype(x ^ v[0])>

Definition at line 1674 of file RVec.hxx.

◆ operator^=() [1/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator^= ( RVec< T0 > & v,
const T1 & y )

Definition at line 1708 of file RVec.hxx.

◆ operator^=() [2/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator^= ( RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1708 of file RVec.hxx.

◆ operator|() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator| ( const RVec< T0 > & v,
const T1 & y ) -> RVec< decltype(v[0]|y)>

Definition at line 1675 of file RVec.hxx.

◆ operator|() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator| ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< decltype(v0[0]|v1[0])>

Definition at line 1675 of file RVec.hxx.

◆ operator|() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator| ( const T0 & x,
const RVec< T1 > & v ) -> RVec< decltype(x|v[0])>

Definition at line 1675 of file RVec.hxx.

◆ operator|=() [1/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator|= ( RVec< T0 > & v,
const T1 & y )

Definition at line 1709 of file RVec.hxx.

◆ operator|=() [2/2]

template<typename T0, typename T1>
RVec< T0 > & ROOT::VecOps::operator|= ( RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1709 of file RVec.hxx.

◆ operator||() [1/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator|| ( const RVec< T0 > & v,
const T1 & y ) -> RVec< int >

Definition at line 1760 of file RVec.hxx.

◆ operator||() [2/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator|| ( const RVec< T0 > & v0,
const RVec< T1 > & v1 ) -> RVec< int >

Definition at line 1760 of file RVec.hxx.

◆ operator||() [3/3]

template<typename T0, typename T1>
auto ROOT::VecOps::operator|| ( const T0 & x,
const RVec< T1 > & v ) -> RVec< int >

Definition at line 1760 of file RVec.hxx.

◆ operator~()

template<typename T>
RVec< T > ROOT::VecOps::operator~ ( const RVec< T > & v)

Definition at line 1624 of file RVec.hxx.

◆ pow() [1/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::pow ( const RVec< T0 > & v,
const T1 & y )

Definition at line 1842 of file RVec.hxx.

◆ pow() [2/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::pow ( const RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1842 of file RVec.hxx.

◆ pow() [3/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::pow ( const T0 & x,
const RVec< T1 > & v )

Definition at line 1842 of file RVec.hxx.

◆ Product()

template<typename T>
T ROOT::VecOps::Product ( const RVec< T > & v,
const T init = T(1) )

Return the product of the elements of the RVec.

Definition at line 1962 of file RVec.hxx.

◆ Range() [1/3]

RVec< long long int > ROOT::VecOps::Range ( long long int begin,
long long int end,
long long int stride )
inline

Allows for negative begin, end, and/or stride.

Produce RVec<int> with entries equal to begin, begin+stride, ... , N, where N is the first integer such that N+stride exceeds or equals N in the positive or negative direction (same as in Python). An empty RVec is returned if begin >= end and stride > 0 or if begin < end and stride < 0. Throws a runtime_error if stride==0 Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
cout << Range(1, 5, 2) << "\n";
// { 1, 3 }
cout << Range(-1, -11, -4) << "\n";
// { -1, -5, -9 }
RVec< std::size_t > Range(std::size_t length)
Produce RVec with entries starting from 0, and incrementing by 1 until a user-specified N is reached.
Definition RVec.hxx:3516

Definition at line 3549 of file RVec.hxx.

◆ Range() [2/3]

RVec< std::size_t > ROOT::VecOps::Range ( std::size_t begin,
std::size_t end )
inline

Produce RVec with entries equal to begin, begin+1, ..., end-1.

An empty RVec is returned if begin >= end.

Definition at line 3528 of file RVec.hxx.

◆ Range() [3/3]

RVec< std::size_t > ROOT::VecOps::Range ( std::size_t length)
inline

Produce RVec with entries starting from 0, and incrementing by 1 until a user-specified N is reached.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
cout << Range(3) << "\n";
// { 0, 1, 2 }

Definition at line 3516 of file RVec.hxx.

◆ remainder() [1/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::remainder ( const RVec< T0 > & v,
const T1 & y )

Definition at line 1831 of file RVec.hxx.

◆ remainder() [2/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::remainder ( const RVec< T0 > & v0,
const RVec< T1 > & v1 )

Definition at line 1831 of file RVec.hxx.

◆ remainder() [3/3]

template<typename T0, typename T1>
RVec< PromoteTypes< T0, T1 > > ROOT::VecOps::remainder ( const T0 & x,
const RVec< T1 > & v )

Definition at line 1831 of file RVec.hxx.

◆ Reverse()

template<typename T>
RVec< T > ROOT::VecOps::Reverse ( const RVec< T > & v)

Return copy of reversed vector.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v {2., 3., 1.};
auto v_reverse = Reverse(v);
v_reverse
// (ROOT::VecOps::RVec<double> &) { 1.0000000, 3.0000000, 2.0000000 }
RVec< T > Reverse(const RVec< T > &v)
Return copy of reversed vector.
Definition RVec.hxx:2477

Definition at line 2477 of file RVec.hxx.

◆ round()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::round ( const RVec< T > & v)

Definition at line 1865 of file RVec.hxx.

◆ sin()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::sin ( const RVec< T > & v)

Definition at line 1847 of file RVec.hxx.

◆ sinh()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::sinh ( const RVec< T > & v)

Definition at line 1855 of file RVec.hxx.

◆ Sort() [1/2]

template<typename T>
RVec< T > ROOT::VecOps::Sort ( const RVec< T > & v)

Return copy of RVec with elements sorted in ascending order.

This helper is different from Argsort since it does not return an RVec of indices, but an RVec of values.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v {2., 3., 1.};
auto v_sorted = Sort(v);
v_sorted
// (ROOT::VecOps::RVec<double> &) { 1.0000000, 2.0000000, 3.0000000 }
RVec< T > Sort(const RVec< T > &v)
Return copy of RVec with elements sorted in ascending order.
Definition RVec.hxx:2498

Definition at line 2498 of file RVec.hxx.

◆ Sort() [2/2]

template<typename T, typename Compare>
RVec< T > ROOT::VecOps::Sort ( const RVec< T > & v,
Compare && c )

Return copy of RVec with elements sorted based on a comparison operator.

The comparison operator has to fulfill the same requirements of the predicate of by std::sort.

This helper is different from Argsort since it does not return an RVec of indices, but an RVec of values.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v {2., 3., 1.};
auto v_sorted = Sort(v, [](double x, double y) {return 1/x < 1/y;});
v_sorted
// (ROOT::VecOps::RVec<double> &) { 3.0000000, 2.0000000, 1.0000000 }

Definition at line 2523 of file RVec.hxx.

◆ sqrt()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::sqrt ( const RVec< T > & v)

Definition at line 1843 of file RVec.hxx.

◆ StableArgsort() [1/2]

template<typename T>
RVec< typename RVec< T >::size_type > ROOT::VecOps::StableArgsort ( const RVec< T > & v)

Return an RVec of indices that sort the input RVec while keeping the order of equal elements.

This is the stable variant of Argsort.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v {2., 3., 2., 1.};
auto sortIndices = StableArgsort(v)
// (ROOT::VecOps::RVec<unsigned long> &) { 3, 0, 2, 1 }
auto values = Take(v, sortIndices)
// (ROOT::VecOps::RVec<double> &) { 1.0000000, 2.0000000, 2.0000000, 3.0000000 }
RVec< typename RVec< T >::size_type > StableArgsort(const RVec< T > &v)
Return an RVec of indices that sort the input RVec while keeping the order of equal elements.
Definition RVec.hxx:2291

Definition at line 2291 of file RVec.hxx.

◆ StableArgsort() [2/2]

template<typename T, typename Compare>
RVec< typename RVec< T >::size_type > ROOT::VecOps::StableArgsort ( const RVec< T > & v,
Compare && c )

Return an RVec of indices that sort the input RVec based on a comparison function while keeping the order of equal elements.

This is the stable variant of Argsort.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v {2., 3., 2., 1.};
auto sortIndices = StableArgsort(v, [](double x, double y) {return x > y;})
// (ROOT::VecOps::RVec<unsigned long> &) { 1, 0, 2, 3 }
auto values = Take(v, sortIndices)
// (ROOT::VecOps::RVec<double> &) { 3.0000000, 2.0000000, 2.0000000, 1.0000000 }

Definition at line 2314 of file RVec.hxx.

◆ StableSort() [1/2]

template<typename T>
RVec< T > ROOT::VecOps::StableSort ( const RVec< T > & v)

Return copy of RVec with elements sorted in ascending order while keeping the order of equal elements.

This is the stable variant of Sort.

This helper is different from StableArgsort since it does not return an RVec of indices, but an RVec of values.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v {2., 3., 2, 1.};
auto v_sorted = StableSort(v);
v_sorted
// (ROOT::VecOps::RVec<double> &) { 1.0000000, 2.0000000, 2.0000000, 3.0000000 }
RVec< T > StableSort(const RVec< T > &v)
Return copy of RVec with elements sorted in ascending order while keeping the order of equal elements...
Definition RVec.hxx:2547

Definition at line 2547 of file RVec.hxx.

◆ StableSort() [2/2]

template<typename T, typename Compare>
RVec< T > ROOT::VecOps::StableSort ( const RVec< T > & v,
Compare && c )

Return copy of RVec with elements sorted based on a comparison operator while keeping the order of equal elements.

The comparison operator has to fulfill the same requirements of the predicate of std::stable_sort.

This helper is different from StableArgsort since it does not return an RVec of indices, but an RVec of values.

This is the stable variant of Sort.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v {2., 3., 2., 1.};
auto v_sorted = StableSort(v, [](double x, double y) {return 1/x < 1/y;});
v_sorted
// (ROOT::VecOps::RVec<double> &) { 3.0000000, 2.0000000, 2.0000000, 1.0000000 }
using namespace ROOT::VecOps;
RVec<RVecD> v {{2., 4.}, {3., 1.}, {2, 1.}, {1., 4.}};
auto v_sorted = StableSort(StableSort(v, [](const RVecD &x, const RVecD &y) {return x[1] < y[1];}), [](const RVecD &x, const RVecD &y) {return x[0] < y[0];});
v_sorted
// (ROOT::VecOps::RVec<ROOT::VecOps::RVec<double> > &) { { 1.0000000, 4.0000000 }, { 2.0000000, 1.0000000 }, { 2.0000000, 4.0000000 }, { 3.0000000, 1.0000000 } }

Definition at line 2583 of file RVec.hxx.

◆ StdDev()

template<typename T>
double ROOT::VecOps::StdDev ( const RVec< T > & v)

Get the standard deviation of the elements of an RVec.

The return type is a double precision floating point number. Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecF v {1.f, 2.f, 4.f};
auto v_sd = StdDev(v);
v_sd
// (double) 1.5275252
double StdDev(const RVec< T > &v)
Get the standard deviation of the elements of an RVec.
Definition RVec.hxx:2122

Definition at line 2122 of file RVec.hxx.

◆ Sum() [1/2]

std::size_t ROOT::VecOps::Sum ( const RVec< bool > & v,
std::size_t zero = 0ul )
inline

Definition at line 1955 of file RVec.hxx.

◆ Sum() [2/2]

template<typename T>
T ROOT::VecOps::Sum ( const RVec< T > & v,
const T zero = T(0) )

Sum elements of an RVec.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecF v {1.f, 2.f, 3.f};
auto v_sum = Sum(v);
v_sum
// (float) 6.f
auto v_sum_d = Sum(v, 0.);
v_sum_d
// (double) 6.0000000
T Sum(const RVec< T > &v, const T zero=T(0))
Sum elements of an RVec.
Definition RVec.hxx:1950
using namespace ROOT::VecOps;
const ROOT::Math::PtEtaPhiMVector lv0 {15.5f, .3f, .1f, 105.65f},
lv1 {34.32f, 2.2f, 3.02f, 105.65f},
lv2 {12.95f, 1.32f, 2.2f, 105.65f};
auto v_sum_lv = Sum(v, ROOT::Math::PtEtaPhiMVector());
v_sum_lv
// (ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> > &) (30.8489,2.46534,2.58947,361.084)

Definition at line 1950 of file RVec.hxx.

◆ swap()

template<typename T>
void ROOT::VecOps::swap ( RVec< T > & lhs,
RVec< T > & rhs )

Definition at line 2229 of file RVec.hxx.

◆ Take() [1/4]

template<typename T>
RVec< T > ROOT::VecOps::Take ( const RVec< T > & v,
const int n )

Return first n elements of an RVec if n > 0 and last n elements if n < 0.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v {2., 3., 1.};
auto firstTwo = Take(v, 2);
firstTwo
// (ROOT::VecOps::RVec<double>) { 2.0000000, 3.0000000 }
auto lastOne = Take(v, -1);
lastOne
// (ROOT::VecOps::RVec<double>) { 1.0000000 }

Definition at line 2378 of file RVec.hxx.

◆ Take() [2/4]

template<typename T>
RVec< T > ROOT::VecOps::Take ( const RVec< T > & v,
const int n,
const T default_val )

Return first n elements of an RVec if n > 0 and last n elements if n < 0.

This Take version defaults to a user-specified value default_val if the absolute value of n is greater than the size of the RVec v

Example code, at the ROOT prompt:

RVec<int> x{1,2,3,4};
Take(x,-5,1)
// (ROOT::VecOps::RVec<int>) { 1, 1, 2, 3, 4 }
Take(x,5,20)
// (ROOT::VecOps::RVec<int>) { 1, 2, 3, 4, 20 }
Take(x,-1,1)
// (ROOT::VecOps::RVec<int>) { 4 }
Take(x,4,1)
// (ROOT::VecOps::RVec<int>) { 1, 2, 3, 4 }

Definition at line 2419 of file RVec.hxx.

◆ Take() [3/4]

template<typename T>
RVec< T > ROOT::VecOps::Take ( const RVec< T > & v,
const RVec< typename RVec< T >::size_type > & i )

Return elements of a vector at given indices.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v {2., 3., 1.};
auto vTaken = Take(v, {0,2});
vTaken
// (ROOT::VecOps::RVec<double>) { 2.0000000, 1.0000000 }

Definition at line 2335 of file RVec.hxx.

◆ Take() [4/4]

template<typename T>
RVec< T > ROOT::VecOps::Take ( const RVec< T > & v,
const RVec< typename RVec< T >::size_type > & i,
const T default_val )

Take version that defaults to (user-specified) output value if some index is out of range.

Definition at line 2347 of file RVec.hxx.

◆ tan()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::tan ( const RVec< T > & v)

Definition at line 1849 of file RVec.hxx.

◆ tanh()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::tanh ( const RVec< T > & v)

Definition at line 1857 of file RVec.hxx.

◆ tgamma()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::tgamma ( const RVec< T > & v)

Definition at line 1872 of file RVec.hxx.

◆ trunc()

template<typename T>
RVec< PromoteType< T > > ROOT::VecOps::trunc ( const RVec< T > & v)

Definition at line 1864 of file RVec.hxx.

◆ Var()

template<typename T>
double ROOT::VecOps::Var ( const RVec< T > & v)

Get the variance of the elements of an RVec.

The return type is a double precision floating point number. Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecF v {1.f, 2.f, 4.f};
auto v_var = Var(v);
v_var
// (double) 2.3333333
double Var(const RVec< T > &v)
Get the variance of the elements of an RVec.
Definition RVec.hxx:2098

Definition at line 2098 of file RVec.hxx.

◆ Where() [1/4]

template<typename T>
RVec< T > ROOT::VecOps::Where ( const RVec< int > & c,
const RVec< T > & v1,
const RVec< T > & v2 )

Return the elements of v1 if the condition c is true and v2 if the condition c is false.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v1 {1., 2., 3.};
RVecD v2 {-1., -2., -3.};
auto c = v1 > 1;
// (ROOT::VecOps::RVec<int> &) { 0, 1, 1 }
auto if_c_v1_else_v2 = Where(c, v1, v2);
if_c_v1_else_v2
// (ROOT::VecOps::RVec<double> &) { -1.0000000, 2.0000000, 3.0000000 }
#define c(i)
Definition RSha256.hxx:101
RVec< T > Where(const RVec< int > &c, const RVec< T > &v1, const RVec< T > &v2)
Return the elements of v1 if the condition c is true and v2 if the condition c is false.
Definition RVec.hxx:2788

Definition at line 2788 of file RVec.hxx.

◆ Where() [2/4]

template<typename T>
RVec< T > ROOT::VecOps::Where ( const RVec< int > & c,
const RVec< T > & v1,
typename RVec< T >::value_type v2 )

Return the elements of v1 if the condition c is true and sets the value v2 if the condition c is false.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
RVecD v1 {1., 2., 3.};
double v2 = 4.;
auto c = v1 > 1;
// (ROOT::VecOps::RVec<int> &) { 0, 1, 1 }
auto if_c_v1_else_v2 = Where(c, v1, v2);
if_c_v1_else_v2
// (ROOT::VecOps::RVec<double>) { 4.0000000, 2.0000000, 3.0000000 }

Definition at line 2816 of file RVec.hxx.

◆ Where() [3/4]

template<typename T>
RVec< T > ROOT::VecOps::Where ( const RVec< int > & c,
T v1,
T v2 )

Return a vector with the value v2 if the condition c is false and sets the value v1 if the condition c is true.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
double v1 = 4.;
double v2 = 2.;
RVecI c {0, 1, 1};
auto if_c_v1_else_v2 = Where(c, v1, v2);
if_c_v1_else_v2
// (ROOT::VecOps::RVec<double>) { 2.0000000, 4.0000000, 4.0000000 }

Definition at line 2870 of file RVec.hxx.

◆ Where() [4/4]

template<typename T>
RVec< T > ROOT::VecOps::Where ( const RVec< int > & c,
typename RVec< T >::value_type v1,
const RVec< T > & v2 )

Return the elements of v2 if the condition c is false and sets the value v1 if the condition c is true.

Example code, at the ROOT prompt:

using namespace ROOT::VecOps;
double v1 = 4.;
RVecD v2 {1., 2., 3.};
auto c = v2 > 1;
// (ROOT::VecOps::RVec<int> &) { 0, 1, 1 }
auto if_c_v1_else_v2 = Where(c, v1, v2);
if_c_v1_else_v2
// (ROOT::VecOps::RVec<double>) { 1.0000000, 4.0000000, 4.0000000 }

Definition at line 2844 of file RVec.hxx.