19 #define _VECOPS_USE_EXTERN_TEMPLATES false
21 #define _VECOPS_USE_EXTERN_TEMPLATES true
40#define _USE_MATH_DEFINES
49#include <vdt/vdtMath.h>
65template <
typename...
T>
68 constexpr const auto nArgs =
sizeof...(T);
69 const std::size_t sizes[] = {vs.
size()...};
71 for (
auto i = 1UL; i < nArgs; i++) {
72 if (sizes[0] == sizes[i])
75 msg +=
": input RVec instances have different lengths!";
76 throw std::runtime_error(msg);
82template <
typename F,
typename...
T>
86 RVec<
decltype(
f(vs[0]...))> ret(size);
88 for (
auto i = 0UL; i < size; i++)
94template <
typename Tuple_t, std::size_t... Is>
96 ->
decltype(
MapImpl(std::get<std::tuple_size<Tuple_t>::value - 1>(t), std::get<Is>(t)...))
98 constexpr const auto tupleSizeM1 = std::tuple_size<Tuple_t>::value - 1;
99 return MapImpl(std::get<tupleSizeM1>(t), std::get<Is>(t)...);
111template <
typename T,
typename... Args>
114 v.emplace_back(std::forward<Args>(args)...);
117template <
typename... Args>
120 v.push_back(std::forward<Args>(args)...);
280 static constexpr const auto IsVecBool = std::is_same<bool, T>::value;
282 using Impl_t =
typename std::conditional<IsVecBool, std::vector<bool>, std::vector<T, ::ROOT::Detail::VecOps::RAdoptAllocator<T>>>
::type;
318 template <
class InputIt>
343 template <typename U, typename = std::enable_if<std::is_convertible<T, U>::value>>
364 template <typename V, typename = std::enable_if<std::is_convertible<V, bool>::value>>
370 throw std::runtime_error(
"Cannot index RVec with condition vector of different size");
412 template <
class... Args>
420 template<typename U = T, typename std::enable_if<std::is_arithmetic<U>::value,
int>* =
nullptr>
423 return fData.emplace(pos, value);
434#define RVEC_UNARY_OPERATOR(OP) \
435template <typename T> \
436RVec<T> operator OP(const RVec<T> &v) \
439 for (auto &x : ret) \
448#undef RVEC_UNARY_OPERATOR
454#define ERROR_MESSAGE(OP) \
455 "Cannot call operator " #OP " on vectors of different sizes."
457#define RVEC_BINARY_OPERATOR(OP) \
458template <typename T0, typename T1> \
459auto operator OP(const RVec<T0> &v, const T1 &y) \
460 -> RVec<decltype(v[0] OP y)> \
462 RVec<decltype(v[0] OP y)> ret(v.size()); \
463 auto op = [&y](const T0 &x) { return x OP y; }; \
464 std::transform(v.begin(), v.end(), ret.begin(), op); \
468template <typename T0, typename T1> \
469auto operator OP(const T0 &x, const RVec<T1> &v) \
470 -> RVec<decltype(x OP v[0])> \
472 RVec<decltype(x OP v[0])> ret(v.size()); \
473 auto op = [&x](const T1 &y) { return x OP y; }; \
474 std::transform(v.begin(), v.end(), ret.begin(), op); \
478template <typename T0, typename T1> \
479auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
480 -> RVec<decltype(v0[0] OP v1[0])> \
482 if (v0.size() != v1.size()) \
483 throw std::runtime_error(ERROR_MESSAGE(OP)); \
485 RVec<decltype(v0[0] OP v1[0])> ret(v0.size()); \
486 auto op = [](const T0 &x, const T1 &y) { return x OP y; }; \
487 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
499#undef RVEC_BINARY_OPERATOR
505#define RVEC_ASSIGNMENT_OPERATOR(OP) \
506template <typename T0, typename T1> \
507RVec<T0>& operator OP(RVec<T0> &v, const T1 &y) \
509 auto op = [&y](T0 &x) { return x OP y; }; \
510 std::transform(v.begin(), v.end(), v.begin(), op); \
514template <typename T0, typename T1> \
515RVec<T0>& operator OP(RVec<T0> &v0, const RVec<T1> &v1) \
517 if (v0.size() != v1.size()) \
518 throw std::runtime_error(ERROR_MESSAGE(OP)); \
520 auto op = [](T0 &x, const T1 &y) { return x OP y; }; \
521 std::transform(v0.begin(), v0.end(), v1.begin(), v0.begin(), op); \
535#undef RVEC_ASSIGNMENT_OPERATOR
541#define RVEC_LOGICAL_OPERATOR(OP) \
542template <typename T0, typename T1> \
543auto operator OP(const RVec<T0> &v, const T1 &y) \
546 RVec<int> ret(v.size()); \
547 auto op = [y](const T0 &x) -> int { return x OP y; }; \
548 std::transform(v.begin(), v.end(), ret.begin(), op); \
552template <typename T0, typename T1> \
553auto operator OP(const T0 &x, const RVec<T1> &v) \
556 RVec<int> ret(v.size()); \
557 auto op = [x](const T1 &y) -> int { return x OP y; }; \
558 std::transform(v.begin(), v.end(), ret.begin(), op); \
562template <typename T0, typename T1> \
563auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
566 if (v0.size() != v1.size()) \
567 throw std::runtime_error(ERROR_MESSAGE(OP)); \
569 RVec<int> ret(v0.size()); \
570 auto op = [](const T0 &x, const T1 &y) -> int { return x OP y; }; \
571 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
583#undef RVEC_LOGICAL_OPERATOR
590template <
typename T>
struct PromoteTypeImpl;
592template <>
struct PromoteTypeImpl<float> {
using Type = float; };
596template <
typename T>
struct PromoteTypeImpl {
using Type =
double; };
601template <
typename U,
typename V>
602using PromoteTypes =
decltype(PromoteType<U>() + PromoteType<V>());
606#define RVEC_UNARY_FUNCTION(NAME, FUNC) \
607 template <typename T> \
608 RVec<PromoteType<T>> NAME(const RVec<T> &v) \
610 RVec<PromoteType<T>> ret(v.size()); \
611 auto f = [](const T &x) { return FUNC(x); }; \
612 std::transform(v.begin(), v.end(), ret.begin(), f); \
616#define RVEC_BINARY_FUNCTION(NAME, FUNC) \
617 template <typename T0, typename T1> \
618 RVec<PromoteTypes<T0, T1>> NAME(const T0 &x, const RVec<T1> &v) \
620 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
621 auto f = [&x](const T1 &y) { return FUNC(x, y); }; \
622 std::transform(v.begin(), v.end(), ret.begin(), f); \
626 template <typename T0, typename T1> \
627 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v, const T1 &y) \
629 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
630 auto f = [&y](const T1 &x) { return FUNC(x, y); }; \
631 std::transform(v.begin(), v.end(), ret.begin(), f); \
635 template <typename T0, typename T1> \
636 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v0, const RVec<T1> &v1) \
638 if (v0.size() != v1.size()) \
639 throw std::runtime_error(ERROR_MESSAGE(NAME)); \
641 RVec<PromoteTypes<T0, T1>> ret(v0.size()); \
642 auto f = [](const T0 &x, const T1 &y) { return FUNC(x, y); }; \
643 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), f); \
647#define RVEC_STD_UNARY_FUNCTION(F) RVEC_UNARY_FUNCTION(F, std::F)
648#define RVEC_STD_BINARY_FUNCTION(F) RVEC_BINARY_FUNCTION(F, std::F)
695#undef RVEC_STD_UNARY_FUNCTION
702#define RVEC_VDT_UNARY_FUNCTION(F) RVEC_UNARY_FUNCTION(F, vdt::F)
704RVEC_VDT_UNARY_FUNCTION(fast_expf)
705RVEC_VDT_UNARY_FUNCTION(fast_logf)
706RVEC_VDT_UNARY_FUNCTION(fast_sinf)
707RVEC_VDT_UNARY_FUNCTION(fast_cosf)
708RVEC_VDT_UNARY_FUNCTION(fast_tanf)
709RVEC_VDT_UNARY_FUNCTION(fast_asinf)
710RVEC_VDT_UNARY_FUNCTION(fast_acosf)
711RVEC_VDT_UNARY_FUNCTION(fast_atanf)
713RVEC_VDT_UNARY_FUNCTION(fast_exp)
714RVEC_VDT_UNARY_FUNCTION(fast_log)
715RVEC_VDT_UNARY_FUNCTION(fast_sin)
716RVEC_VDT_UNARY_FUNCTION(fast_cos)
717RVEC_VDT_UNARY_FUNCTION(fast_tan)
718RVEC_VDT_UNARY_FUNCTION(fast_asin)
719RVEC_VDT_UNARY_FUNCTION(fast_acos)
720RVEC_VDT_UNARY_FUNCTION(fast_atan)
721#undef RVEC_VDT_UNARY_FUNCTION
725#undef RVEC_UNARY_FUNCTION
740template <
typename T,
typename V>
743 if (
v0.size() !=
v1.size())
744 throw std::runtime_error(
"Cannot compute inner product of vectors of different sizes");
761 return std::accumulate(
v.begin(),
v.end(),
T(0));
778 if (
v.empty())
return 0.;
795 return *std::max_element(
v.begin(),
v.end());
811 return *std::min_element(
v.begin(),
v.end());
829 return std::distance(
v.begin(), std::max_element(
v.begin(),
v.end()));
847 return std::distance(
v.begin(), std::min_element(
v.begin(),
v.end()));
864 const std::size_t size =
v.size();
865 if (size < std::size_t(2))
return 0.;
866 T sum_squares(0), squared_sum(0);
867 auto pred = [&sum_squares, &squared_sum](
const T&
x) {sum_squares+=
x*
x; squared_sum+=
x;};
868 std::for_each(
v.begin(),
v.end(), pred);
869 squared_sum *= squared_sum;
870 const auto dsize = (
double) size;
871 return 1. / (dsize - 1.) * (sum_squares - squared_sum / dsize );
909template <
typename... Args>
912 std::make_index_sequence<
sizeof...(args) - 1>()))
925 std::make_index_sequence<
sizeof...(args) - 1>());
938template <
typename T,
typename F>
941 const auto thisSize =
v.size();
944 for (
auto &&val :
v) {
1005template <
typename T>
1011 std::sort(i.
begin(), i.
end(), [&
v](size_type i1, size_type i2) { return v[i1] < v[i2]; });
1025template <
typename T>
1029 const size_type isize = i.size();
1031 for (size_type k = 0; k < isize; k++)
1051template <
typename T>
1055 const size_type size =
v.size();
1056 const size_type absn = std::abs(
n);
1058 std::stringstream ss;
1059 ss <<
"Try to take " << absn <<
" elements but vector has only size " << size <<
".";
1060 throw std::runtime_error(ss.str());
1064 for (size_type k = 0; k < absn; k++)
1065 r[k] =
v[size - absn + k];
1067 for (size_type k = 0; k < absn; k++)
1083template <
typename T>
1087 std::reverse(
r.begin(),
r.end());
1104template <
typename T>
1108 std::sort(
r.begin(),
r.end());
1129template <
typename T,
typename Compare>
1133 std::sort(
r.begin(),
r.end(), std::forward<Compare>(
c));
1151 using size_type = std::size_t;
1153 r[0].resize(size1*size2);
1154 r[1].resize(size1*size2);
1156 for(size_type i=0; i<size1; i++) {
1157 for(size_type j=0; j<size2; j++) {
1181template <
typename T1,
typename T2>
1206template <
typename T>
1210 const size_type
s =
v.size();
1212 std::stringstream ss;
1213 ss <<
"Cannot make unique combinations of size " <<
n <<
" from vector of size " <<
s <<
".";
1214 throw std::runtime_error(ss.str());
1217 for(size_type k=0; k<
s; k++)
1220 for(size_type k=0; k<
n; k++)
1223 bool run_through =
true;
1227 run_through =
false;
1235 for (
long j=i+1; j<(
long)
n; j++)
1237 for(size_type k=0; k<
n; k++)
1252template <
typename T>
1257 const auto size =
v.size();
1259 for(size_type i=0; i<size; i++) {
1283template <
typename T>
1287 if (!v2_is_sorted) v2_sorted =
Sort(
v2);
1288 const auto v2_begin = v2_is_sorted ?
v2.begin() : v2_sorted.
begin();
1289 const auto v2_end = v2_is_sorted ?
v2.end() : v2_sorted.
end();
1291 const auto size =
v1.size();
1294 for(size_type i=0; i<size; i++) {
1295 if (std::binary_search(v2_begin, v2_end,
v1[i])) {
1296 r.emplace_back(
v1[i]);
1317template <
typename T>
1321 const size_type size =
c.size();
1324 for (size_type i=0; i<size; i++) {
1325 r.emplace_back(
c[i] != 0 ?
v1[i] :
v2[i]);
1345template <
typename T>
1349 const size_type size =
c.size();
1352 for (size_type i=0; i<size; i++) {
1353 r.emplace_back(
c[i] != 0 ?
v1[i] :
v2);
1373template <
typename T>
1377 const size_type size =
c.size();
1380 for (size_type i=0; i<size; i++) {
1381 r.emplace_back(
c[i] != 0 ?
v1 :
v2[i]);
1399template <
typename T>
1403 const size_type size =
c.size();
1406 for (size_type i=0; i<size; i++) {
1407 r.emplace_back(
c[i] != 0 ?
v1 :
v2);
1428 auto &v0AsVect =
v0.AsVector();
1429 auto &v1AsVect =
v1.AsVector();
1430 resAsVect.insert(resAsVect.begin(), v0AsVect.begin(), v0AsVect.end());
1431 resAsVect.insert(resAsVect.end(), v1AsVect.begin(), v1AsVect.end());
1441template <
typename T>
1444 static_assert(std::is_floating_point<T>::value,
1445 "DeltaPhi must be called with floating point values.");
1446 auto r = std::fmod(
v2 -
v1, 2.0 *
c);
1462template <
typename T>
1466 const size_type size =
v1.size();
1468 for (size_type i = 0; i < size; i++) {
1480template <
typename T>
1484 const size_type size =
v1.size();
1486 for (size_type i = 0; i < size; i++) {
1498template <
typename T>
1502 const size_type size =
v2.size();
1504 for (size_type i = 0; i < size; i++) {
1517template <
typename T>
1520 const auto dphi =
DeltaPhi(phi1, phi2,
c);
1521 return (eta1 - eta2) * (eta1 - eta2) + dphi * dphi;
1531template <
typename T>
1544template <
typename T>
1547 const auto dphi =
DeltaPhi(phi1, phi2,
c);
1548 return std::sqrt((eta1 - eta2) * (eta1 - eta2) + dphi * dphi);
1556template <
typename T>
1561 std::size_t size = pt1.
size();
1568 for (std::size_t i = 0u; i < size; ++i) {
1571 const auto y1 = pt1[i] *
std::sin(phi1[i]);
1572 const auto z1 = pt1[i] *
std::sinh(eta1[i]);
1573 const auto e1 =
std::sqrt(
x1 *
x1 + y1 * y1 + z1 * z1 + mass1[i] * mass1[i]);
1576 const auto y2 = pt2[i] *
std::sin(phi2[i]);
1577 const auto z2 = pt2[i] *
std::sinh(eta2[i]);
1578 const auto e2 =
std::sqrt(
x2 *
x2 + y2 * y2 + z2 * z2 + mass2[i] * mass2[i]);
1581 const auto e = e1 + e2;
1582 const auto x =
x1 +
x2;
1583 const auto y = y1 + y2;
1584 const auto z = z1 + z2;
1598template <
typename T>
1601 const std::size_t size =
pt.size();
1610 for (std::size_t i = 0u; i < size; ++ i) {
1618 const auto e =
std::sqrt(
x *
x +
y *
y + z * z + mass[i] * mass[i]);
1623 return std::sqrt(e_sum * e_sum - x_sum * x_sum - y_sum * y_sum - z_sum * z_sum);
1644template <
typename T,
typename... Args_t>
1650 for (
auto i = 0UL; i < size; ++i) {
1662 constexpr bool mustConvert = std::is_same<char, T>::value || std::is_same<signed char, T>::value ||
1663 std::is_same<unsigned char, T>::value || std::is_same<wchar_t, T>::value ||
1664 std::is_same<char16_t, T>::value || std::is_same<char32_t, T>::value;
1667 auto size =
v.size();
1669 for (std::size_t i = 0; i < size - 1; ++i) {
1670 os << (Print_t)
v[i] <<
", ";
1672 os << (Print_t)
v[size - 1];
1678#if (_VECOPS_USE_EXTERN_TEMPLATES)
1680#define RVEC_EXTERN_UNARY_OPERATOR(T, OP) \
1681 extern template RVec<T> operator OP<T>(const RVec<T> &);
1683#define RVEC_EXTERN_BINARY_OPERATOR(T, OP) \
1684 extern template auto operator OP<T, T>(const T &x, const RVec<T> &v) \
1685 -> RVec<decltype(x OP v[0])>; \
1686 extern template auto operator OP<T, T>(const RVec<T> &v, const T &y) \
1687 -> RVec<decltype(v[0] OP y)>; \
1688 extern template auto operator OP<T, T>(const RVec<T> &v0, const RVec<T> &v1)\
1689 -> RVec<decltype(v0[0] OP v1[0])>;
1691#define RVEC_EXTERN_ASSIGN_OPERATOR(T, OP) \
1692 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const T &); \
1693 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const RVec<T> &);
1695#define RVEC_EXTERN_LOGICAL_OPERATOR(T, OP) \
1696 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const T &); \
1697 extern template RVec<int> operator OP<T, T>(const T &, const RVec<T> &); \
1698 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const RVec<T> &);
1700#define RVEC_EXTERN_FLOAT_TEMPLATE(T) \
1701 extern template class RVec<T>; \
1702 RVEC_EXTERN_UNARY_OPERATOR(T, +) \
1703 RVEC_EXTERN_UNARY_OPERATOR(T, -) \
1704 RVEC_EXTERN_UNARY_OPERATOR(T, !) \
1705 RVEC_EXTERN_BINARY_OPERATOR(T, +) \
1706 RVEC_EXTERN_BINARY_OPERATOR(T, -) \
1707 RVEC_EXTERN_BINARY_OPERATOR(T, *) \
1708 RVEC_EXTERN_BINARY_OPERATOR(T, /) \
1709 RVEC_EXTERN_ASSIGN_OPERATOR(T, +=) \
1710 RVEC_EXTERN_ASSIGN_OPERATOR(T, -=) \
1711 RVEC_EXTERN_ASSIGN_OPERATOR(T, *=) \
1712 RVEC_EXTERN_ASSIGN_OPERATOR(T, /=) \
1713 RVEC_EXTERN_LOGICAL_OPERATOR(T, <) \
1714 RVEC_EXTERN_LOGICAL_OPERATOR(T, >) \
1715 RVEC_EXTERN_LOGICAL_OPERATOR(T, ==) \
1716 RVEC_EXTERN_LOGICAL_OPERATOR(T, !=) \
1717 RVEC_EXTERN_LOGICAL_OPERATOR(T, <=) \
1718 RVEC_EXTERN_LOGICAL_OPERATOR(T, >=) \
1719 RVEC_EXTERN_LOGICAL_OPERATOR(T, &&) \
1720 RVEC_EXTERN_LOGICAL_OPERATOR(T, ||)
1722#define RVEC_EXTERN_INTEGER_TEMPLATE(T) \
1723 extern template class RVec<T>; \
1724 RVEC_EXTERN_UNARY_OPERATOR(T, +) \
1725 RVEC_EXTERN_UNARY_OPERATOR(T, -) \
1726 RVEC_EXTERN_UNARY_OPERATOR(T, ~) \
1727 RVEC_EXTERN_UNARY_OPERATOR(T, !) \
1728 RVEC_EXTERN_BINARY_OPERATOR(T, +) \
1729 RVEC_EXTERN_BINARY_OPERATOR(T, -) \
1730 RVEC_EXTERN_BINARY_OPERATOR(T, *) \
1731 RVEC_EXTERN_BINARY_OPERATOR(T, /) \
1732 RVEC_EXTERN_BINARY_OPERATOR(T, %) \
1733 RVEC_EXTERN_BINARY_OPERATOR(T, &) \
1734 RVEC_EXTERN_BINARY_OPERATOR(T, |) \
1735 RVEC_EXTERN_BINARY_OPERATOR(T, ^) \
1736 RVEC_EXTERN_ASSIGN_OPERATOR(T, +=) \
1737 RVEC_EXTERN_ASSIGN_OPERATOR(T, -=) \
1738 RVEC_EXTERN_ASSIGN_OPERATOR(T, *=) \
1739 RVEC_EXTERN_ASSIGN_OPERATOR(T, /=) \
1740 RVEC_EXTERN_ASSIGN_OPERATOR(T, %=) \
1741 RVEC_EXTERN_ASSIGN_OPERATOR(T, &=) \
1742 RVEC_EXTERN_ASSIGN_OPERATOR(T, |=) \
1743 RVEC_EXTERN_ASSIGN_OPERATOR(T, ^=) \
1744 RVEC_EXTERN_ASSIGN_OPERATOR(T, >>=) \
1745 RVEC_EXTERN_ASSIGN_OPERATOR(T, <<=) \
1746 RVEC_EXTERN_LOGICAL_OPERATOR(T, <) \
1747 RVEC_EXTERN_LOGICAL_OPERATOR(T, >) \
1748 RVEC_EXTERN_LOGICAL_OPERATOR(T, ==) \
1749 RVEC_EXTERN_LOGICAL_OPERATOR(T, !=) \
1750 RVEC_EXTERN_LOGICAL_OPERATOR(T, <=) \
1751 RVEC_EXTERN_LOGICAL_OPERATOR(T, >=) \
1752 RVEC_EXTERN_LOGICAL_OPERATOR(T, &&) \
1753 RVEC_EXTERN_LOGICAL_OPERATOR(T, ||)
1755RVEC_EXTERN_INTEGER_TEMPLATE(
char)
1756RVEC_EXTERN_INTEGER_TEMPLATE(
short)
1757RVEC_EXTERN_INTEGER_TEMPLATE(
int)
1758RVEC_EXTERN_INTEGER_TEMPLATE(
long)
1761RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned char)
1762RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned short)
1763RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned int)
1764RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned long)
1767RVEC_EXTERN_FLOAT_TEMPLATE(
float)
1768RVEC_EXTERN_FLOAT_TEMPLATE(
double)
1770#undef RVEC_EXTERN_UNARY_OPERATOR
1771#undef RVEC_EXTERN_BINARY_OPERATOR
1772#undef RVEC_EXTERN_ASSIGN_OPERATOR
1773#undef RVEC_EXTERN_LOGICAL_OPERATOR
1774#undef RVEC_EXTERN_INTEGER_TEMPLATE
1775#undef RVEC_EXTERN_FLOAT_TEMPLATE
1777#define RVEC_EXTERN_UNARY_FUNCTION(T, NAME, FUNC) \
1778 extern template RVec<PromoteType<T>> NAME(const RVec<T> &);
1780#define RVEC_EXTERN_STD_UNARY_FUNCTION(T, F) RVEC_EXTERN_UNARY_FUNCTION(T, F, std::F)
1782#define RVEC_EXTERN_BINARY_FUNCTION(T0, T1, NAME, FUNC) \
1783 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const T1 &); \
1784 extern template RVec<PromoteTypes<T0, T1>> NAME(const T0 &, const RVec<T1> &); \
1785 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const RVec<T1> &);
1787#define RVEC_EXTERN_STD_BINARY_FUNCTION(T, F) RVEC_EXTERN_BINARY_FUNCTION(T, T, F, std::F)
1789#define RVEC_EXTERN_STD_FUNCTIONS(T) \
1790 RVEC_EXTERN_STD_UNARY_FUNCTION(T, abs) \
1791 RVEC_EXTERN_STD_BINARY_FUNCTION(T, fdim) \
1792 RVEC_EXTERN_STD_BINARY_FUNCTION(T, fmod) \
1793 RVEC_EXTERN_STD_BINARY_FUNCTION(T, remainder) \
1794 RVEC_EXTERN_STD_UNARY_FUNCTION(T, exp) \
1795 RVEC_EXTERN_STD_UNARY_FUNCTION(T, exp2) \
1796 RVEC_EXTERN_STD_UNARY_FUNCTION(T, expm1) \
1797 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log) \
1798 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log10) \
1799 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log2) \
1800 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log1p) \
1801 RVEC_EXTERN_STD_BINARY_FUNCTION(T, pow) \
1802 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sqrt) \
1803 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cbrt) \
1804 RVEC_EXTERN_STD_BINARY_FUNCTION(T, hypot) \
1805 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sin) \
1806 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cos) \
1807 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tan) \
1808 RVEC_EXTERN_STD_UNARY_FUNCTION(T, asin) \
1809 RVEC_EXTERN_STD_UNARY_FUNCTION(T, acos) \
1810 RVEC_EXTERN_STD_UNARY_FUNCTION(T, atan) \
1811 RVEC_EXTERN_STD_BINARY_FUNCTION(T, atan2) \
1812 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sinh) \
1813 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cosh) \
1814 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tanh) \
1815 RVEC_EXTERN_STD_UNARY_FUNCTION(T, asinh) \
1816 RVEC_EXTERN_STD_UNARY_FUNCTION(T, acosh) \
1817 RVEC_EXTERN_STD_UNARY_FUNCTION(T, atanh) \
1818 RVEC_EXTERN_STD_UNARY_FUNCTION(T, floor) \
1819 RVEC_EXTERN_STD_UNARY_FUNCTION(T, ceil) \
1820 RVEC_EXTERN_STD_UNARY_FUNCTION(T, trunc) \
1821 RVEC_EXTERN_STD_UNARY_FUNCTION(T, round) \
1822 RVEC_EXTERN_STD_UNARY_FUNCTION(T, erf) \
1823 RVEC_EXTERN_STD_UNARY_FUNCTION(T, erfc) \
1824 RVEC_EXTERN_STD_UNARY_FUNCTION(T, lgamma) \
1825 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tgamma) \
1827RVEC_EXTERN_STD_FUNCTIONS(
float)
1828RVEC_EXTERN_STD_FUNCTIONS(
double)
1829#undef RVEC_EXTERN_STD_UNARY_FUNCTION
1830#undef RVEC_EXTERN_STD_BINARY_FUNCTION
1831#undef RVEC_EXTERN_STD_UNARY_FUNCTIONS
1835#define RVEC_EXTERN_VDT_UNARY_FUNCTION(T, F) RVEC_EXTERN_UNARY_FUNCTION(T, F, vdt::F)
1837RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_expf)
1838RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_logf)
1839RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_sinf)
1840RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_cosf)
1841RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_tanf)
1842RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_asinf)
1843RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_acosf)
1844RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_atanf)
1846RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_exp)
1847RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_log)
1848RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_sin)
1849RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_cos)
1850RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_tan)
1851RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_asin)
1852RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_acos)
1853RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_atan)
#define RVEC_UNARY_OPERATOR(OP)
#define RVEC_ASSIGNMENT_OPERATOR(OP)
#define RVEC_STD_BINARY_FUNCTION(F)
#define RVEC_BINARY_OPERATOR(OP)
#define RVEC_LOGICAL_OPERATOR(OP)
#define RVEC_STD_UNARY_FUNCTION(F)
static const double x2[5]
static const double x1[5]
Int_t Compare(const void *item1, const void *item2)
double atan2(double, double)
double pow(double, double)
A "std::vector"-like collection of values implementing handy operation to analyse them.
typename std::conditional< IsVecBool, std::vector< bool >, std::vector< T, ::ROOT::Detail::VecOps::RAdoptAllocator< T > > >::type Impl_t
typename Impl_t::iterator iterator
static constexpr const auto IsVecBool
const_iterator begin() const noexcept
reverse_iterator rbegin() noexcept
const_iterator cbegin() const noexcept
typename Impl_t::value_type value_type
reference operator[](size_type pos)
iterator erase(iterator pos)
RVec< T > & operator=(std::initializer_list< T > ilist)
typename Impl_t::const_pointer const_pointer
RVec(std::initializer_list< T > init)
void resize(size_type count)
void push_back(T &&value)
const_reference back() const
typename Impl_t::difference_type difference_type
const_reverse_iterator crbegin() const noexcept
RVec operator[](const RVec< V > &conds) const
iterator erase(iterator first, iterator last)
RVec< T > & operator=(RVec< T > &&v)
const_reverse_iterator crend() const noexcept
const_reference at(size_type pos) const
typename Impl_t::const_iterator const_iterator
bool empty() const noexcept
typename Impl_t::reference reference
void push_back(const value_type &value)
size_type size() const noexcept
RVec(size_type count, const T &value)
const_iterator end() const noexcept
iterator emplace(const_iterator pos, U value)
This method is intended only for arithmetic types unlike the std::vector corresponding one which is g...
typename Impl_t::const_reference const_reference
const_iterator cend() const noexcept
typename Impl_t::const_reverse_iterator const_reverse_iterator
const_reference front() const
void reserve(size_type new_cap)
reference at(size_type pos)
const_reverse_iterator rend() const noexcept
typename std::conditional< IsVecBool, void, typename Impl_t::pointer >::type data_t
typename Impl_t::reverse_iterator reverse_iterator
const_reference operator[](size_type pos) const
typename Impl_t::pointer pointer
size_type capacity() const noexcept
reverse_iterator rend() noexcept
RVec< T > & operator=(const RVec< T > &v)
typename std::conditional< IsVecBool, void, typename Impl_t::const_pointer >::type const_data_t
const Impl_t & AsVector() const
value_type at(size_type pos, value_type fallback)
No exception thrown. The user specifies the desired value in case the RVec is shorter than pos.
iterator begin() noexcept
const_reverse_iterator rbegin() const noexcept
value_type at(size_type pos, value_type fallback) const
No exception thrown. The user specifies the desired value in case the RVec is shorter than pos.
typename Impl_t::size_type size_type
void resize(size_type count, const value_type &value)
reference emplace_back(Args &&... args)
const_data_t data() const noexcept
RVec(const std::vector< T > &v)
void swap(RVec< T > &other)
RVec(InputIt first, InputIt last)
RVec(pointer p, size_type n)
size_type max_size() const noexcept
Type
enumeration specifying the integration types.
double erfc(double x)
Complementary error function.
double tgamma(double x)
The gamma function is defined to be the extension of the factorial to real numbers.
double lgamma(double x)
Calculates the logarithm of the gamma function.
double erf(double x)
Error function encountered in integrating the normal distribution.
basic_string_view< char > string_view
EvaluateInfo init(std::vector< RooRealProxy > parameters, std::vector< ArrayWrapper * > wrappers, std::vector< double * > arrays, size_t begin, size_t batchSize)
std::size_t GetVectorsSize(std::string_view id, const RVec< T > &... vs)
auto MapFromTuple(Tuple_t &&t, std::index_sequence< Is... >) -> decltype(MapImpl(std::get< std::tuple_size< Tuple_t >::value - 1 >(t), std::get< Is >(t)...))
ROOT::VecOps::RVec< T > RVec
auto MapImpl(F &&f, const RVec< T > &... vs) -> RVec< decltype(f(vs[0]...))>
void EmplaceBack(T &v, Args &&... args)
double log1p(double x)
declarations for functions which are not implemented by some compilers
double expm1(double x)
exp(x) -1 with error cancellation when x is small
double inner_product(const LAVector &, const LAVector &)
T Max(const RVec< T > &v)
Get the greatest element of an RVec.
RVec< T > Reverse(const RVec< T > &v)
Return copy of reversed vector.
RVec< T > Intersect(const RVec< T > &v1, const RVec< T > &v2, bool v2_is_sorted=false)
Return the intersection of elements of two RVecs.
auto All(const RVec< T > &v) -> decltype(v[0]==false)
Return true if all of the elements equate to true, return false otherwise.
T Sum(const RVec< T > &v)
Sum elements of an RVec.
RVec< typename RVec< T >::size_type > Nonzero(const RVec< T > &v)
Return the indices of the elements which are not zero.
auto Map(Args &&... args) -> decltype(ROOT::Detail::VecOps::MapFromTuple(std::forward_as_tuple(args...), std::make_index_sequence< sizeof...(args) - 1 >()))
Create new collection applying a callable to the elements of the input collection.
RVec< T > Sort(const RVec< T > &v)
Return copy of RVec with elements sorted in ascending order.
T InvariantMass(const RVec< T > &pt, const RVec< T > &eta, const RVec< T > &phi, const RVec< T > &mass)
Return the invariant mass of multiple particles given the collections of the quantities transverse mo...
std::ostream & operator<<(std::ostream &os, const RVec< T > &v)
Print a RVec at the prompt:
RVec< Common_t > Concatenate(const RVec< T0 > &v0, const RVec< T1 > &v1)
Return the concatenation of two RVecs.
RVec< T > DeltaR(const RVec< T > &eta1, const RVec< T > &eta2, const RVec< T > &phi1, const RVec< T > &phi2, const T c=M_PI)
Return the distance on the - plane ( ) from the collections eta1, eta2, phi1 and phi2.
RVec< T > InvariantMasses(const RVec< T > &pt1, const RVec< T > &eta1, const RVec< T > &phi1, const RVec< T > &mass1, const RVec< T > &pt2, const RVec< T > &eta2, const RVec< T > &phi2, const RVec< T > &mass2)
Return the invariant mass of two particles given the collections of the quantities transverse momentu...
RVec< T > DeltaR2(const RVec< T > &eta1, const RVec< T > &eta2, const RVec< T > &phi1, const RVec< T > &phi2, const T c=M_PI)
Return the square of the distance on the - plane ( ) from the collections eta1, eta2,...
double Mean(const RVec< T > &v)
Get the mean of the elements of an RVec.
RVec< T > Take(const RVec< T > &v, const RVec< typename RVec< T >::size_type > &i)
Return elements of a vector at given indices.
void swap(RVec< T > &lhs, RVec< T > &rhs)
RVec< T > Construct(const RVec< Args_t > &... args)
Build an RVec of objects starting from RVecs of input to their constructors.
T DeltaPhi(T v1, T v2, const T c=M_PI)
Return the angle difference of two scalars.
auto Dot(const RVec< T > &v0, const RVec< V > &v1) -> decltype(v0[0] *v1[0])
Inner product.
T Min(const RVec< T > &v)
Get the smallest element of an RVec.
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.
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.
double StdDev(const RVec< T > &v)
Get the standard deviation of the elements of an RVec.
auto Any(const RVec< T > &v) -> decltype(v[0]==true)
Return true if any of the elements equates to true, return false otherwise.
RVec< typename RVec< T >::size_type > Argsort(const RVec< T > &v)
Return an RVec of indices that sort the input RVec.
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...
double Var(const RVec< T > &v)
Get the variance of the elements of an RVec.
RVec< T > Filter(const RVec< T > &v, F &&f)
Create a new collection with the elements passing the filter expressed by the predicate.
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...
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
static constexpr double s