19 #define _VECOPS_USE_EXTERN_TEMPLATES false
21 #define _VECOPS_USE_EXTERN_TEMPLATES true
39#define _USE_MATH_DEFINES
48#include <vdt/vdtMath.h>
64template <
typename...
T>
67 constexpr const auto nArgs =
sizeof...(T);
68 const std::size_t sizes[] = {vs.
size()...};
70 for (
auto i = 1UL; i < nArgs; i++) {
71 if (sizes[0] == sizes[i])
74 msg +=
": input RVec instances have different lengths!";
75 throw std::runtime_error(msg);
81template <
typename F,
typename...
T>
85 RVec<
decltype(
f(vs[0]...))> ret(size);
87 for (
auto i = 0UL; i < size; i++)
93template <
typename Tuple_t, std::size_t... Is>
95 ->
decltype(
MapImpl(std::get<std::tuple_size<Tuple_t>::value - 1>(t), std::get<Is>(t)...))
97 constexpr const auto tupleSizeM1 = std::tuple_size<Tuple_t>::value - 1;
98 return MapImpl(std::get<tupleSizeM1>(t), std::get<Is>(t)...);
110template <
typename T,
typename... Args>
113 v.emplace_back(std::forward<Args>(args)...);
116template <
typename... Args>
119 v.push_back(std::forward<Args>(args)...);
279 static constexpr const auto IsVecBool = std::is_same<bool, T>::value;
281 using Impl_t =
typename std::conditional<IsVecBool, std::vector<bool>, std::vector<T, ::ROOT::Detail::VecOps::RAdoptAllocator<T>>>
::type;
317 template <
class InputIt>
342 template <typename U, typename = std::enable_if<std::is_convertible<T, U>::value>>
363 template <typename V, typename = std::enable_if<std::is_convertible<V, bool>::value>>
369 throw std::runtime_error(
"Cannot index RVec with condition vector of different size");
411 template <
class... Args>
419 template<typename U = T, typename std::enable_if<std::is_arithmetic<U>::value,
int>* =
nullptr>
422 return fData.emplace(pos, value);
433#define RVEC_UNARY_OPERATOR(OP) \
434template <typename T> \
435RVec<T> operator OP(const RVec<T> &v) \
438 for (auto &x : ret) \
447#undef RVEC_UNARY_OPERATOR
453#define ERROR_MESSAGE(OP) \
454 "Cannot call operator " #OP " on vectors of different sizes."
456#define RVEC_BINARY_OPERATOR(OP) \
457template <typename T0, typename T1> \
458auto operator OP(const RVec<T0> &v, const T1 &y) \
459 -> RVec<decltype(v[0] OP y)> \
461 RVec<decltype(v[0] OP y)> ret(v.size()); \
462 auto op = [&y](const T0 &x) { return x OP y; }; \
463 std::transform(v.begin(), v.end(), ret.begin(), op); \
467template <typename T0, typename T1> \
468auto operator OP(const T0 &x, const RVec<T1> &v) \
469 -> RVec<decltype(x OP v[0])> \
471 RVec<decltype(x OP v[0])> ret(v.size()); \
472 auto op = [&x](const T1 &y) { return x OP y; }; \
473 std::transform(v.begin(), v.end(), ret.begin(), op); \
477template <typename T0, typename T1> \
478auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
479 -> RVec<decltype(v0[0] OP v1[0])> \
481 if (v0.size() != v1.size()) \
482 throw std::runtime_error(ERROR_MESSAGE(OP)); \
484 RVec<decltype(v0[0] OP v1[0])> ret(v0.size()); \
485 auto op = [](const T0 &x, const T1 &y) { return x OP y; }; \
486 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
498#undef RVEC_BINARY_OPERATOR
504#define RVEC_ASSIGNMENT_OPERATOR(OP) \
505template <typename T0, typename T1> \
506RVec<T0>& operator OP(RVec<T0> &v, const T1 &y) \
508 auto op = [&y](T0 &x) { return x OP y; }; \
509 std::transform(v.begin(), v.end(), v.begin(), op); \
513template <typename T0, typename T1> \
514RVec<T0>& operator OP(RVec<T0> &v0, const RVec<T1> &v1) \
516 if (v0.size() != v1.size()) \
517 throw std::runtime_error(ERROR_MESSAGE(OP)); \
519 auto op = [](T0 &x, const T1 &y) { return x OP y; }; \
520 std::transform(v0.begin(), v0.end(), v1.begin(), v0.begin(), op); \
534#undef RVEC_ASSIGNMENT_OPERATOR
540#define RVEC_LOGICAL_OPERATOR(OP) \
541template <typename T0, typename T1> \
542auto operator OP(const RVec<T0> &v, const T1 &y) \
545 RVec<int> ret(v.size()); \
546 auto op = [y](const T0 &x) -> int { return x OP y; }; \
547 std::transform(v.begin(), v.end(), ret.begin(), op); \
551template <typename T0, typename T1> \
552auto operator OP(const T0 &x, const RVec<T1> &v) \
555 RVec<int> ret(v.size()); \
556 auto op = [x](const T1 &y) -> int { return x OP y; }; \
557 std::transform(v.begin(), v.end(), ret.begin(), op); \
561template <typename T0, typename T1> \
562auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
565 if (v0.size() != v1.size()) \
566 throw std::runtime_error(ERROR_MESSAGE(OP)); \
568 RVec<int> ret(v0.size()); \
569 auto op = [](const T0 &x, const T1 &y) -> int { return x OP y; }; \
570 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
582#undef RVEC_LOGICAL_OPERATOR
589template <
typename T>
struct PromoteTypeImpl;
591template <>
struct PromoteTypeImpl<float> {
using Type = float; };
592template <>
struct PromoteTypeImpl<double> {
using Type = double; };
593template <>
struct PromoteTypeImpl<long double> {
using Type =
long double; };
595template <
typename T>
struct PromoteTypeImpl {
using Type = double; };
600template <
typename U,
typename V>
601using PromoteTypes =
decltype(PromoteType<U>() + PromoteType<V>());
605#define RVEC_UNARY_FUNCTION(NAME, FUNC) \
606 template <typename T> \
607 RVec<PromoteType<T>> NAME(const RVec<T> &v) \
609 RVec<PromoteType<T>> ret(v.size()); \
610 auto f = [](const T &x) { return FUNC(x); }; \
611 std::transform(v.begin(), v.end(), ret.begin(), f); \
615#define RVEC_BINARY_FUNCTION(NAME, FUNC) \
616 template <typename T0, typename T1> \
617 RVec<PromoteTypes<T0, T1>> NAME(const T0 &x, const RVec<T1> &v) \
619 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
620 auto f = [&x](const T1 &y) { return FUNC(x, y); }; \
621 std::transform(v.begin(), v.end(), ret.begin(), f); \
625 template <typename T0, typename T1> \
626 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v, const T1 &y) \
628 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
629 auto f = [&y](const T1 &x) { return FUNC(x, y); }; \
630 std::transform(v.begin(), v.end(), ret.begin(), f); \
634 template <typename T0, typename T1> \
635 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v0, const RVec<T1> &v1) \
637 if (v0.size() != v1.size()) \
638 throw std::runtime_error(ERROR_MESSAGE(NAME)); \
640 RVec<PromoteTypes<T0, T1>> ret(v0.size()); \
641 auto f = [](const T0 &x, const T1 &y) { return FUNC(x, y); }; \
642 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), f); \
646#define RVEC_STD_UNARY_FUNCTION(F) RVEC_UNARY_FUNCTION(F, std::F)
647#define RVEC_STD_BINARY_FUNCTION(F) RVEC_BINARY_FUNCTION(F, std::F)
694#undef RVEC_STD_UNARY_FUNCTION
701#define RVEC_VDT_UNARY_FUNCTION(F) RVEC_UNARY_FUNCTION(F, vdt::F)
703RVEC_VDT_UNARY_FUNCTION(fast_expf)
704RVEC_VDT_UNARY_FUNCTION(fast_logf)
705RVEC_VDT_UNARY_FUNCTION(fast_sinf)
706RVEC_VDT_UNARY_FUNCTION(fast_cosf)
707RVEC_VDT_UNARY_FUNCTION(fast_tanf)
708RVEC_VDT_UNARY_FUNCTION(fast_asinf)
709RVEC_VDT_UNARY_FUNCTION(fast_acosf)
710RVEC_VDT_UNARY_FUNCTION(fast_atanf)
712RVEC_VDT_UNARY_FUNCTION(fast_exp)
713RVEC_VDT_UNARY_FUNCTION(fast_log)
714RVEC_VDT_UNARY_FUNCTION(fast_sin)
715RVEC_VDT_UNARY_FUNCTION(fast_cos)
716RVEC_VDT_UNARY_FUNCTION(fast_tan)
717RVEC_VDT_UNARY_FUNCTION(fast_asin)
718RVEC_VDT_UNARY_FUNCTION(fast_acos)
719RVEC_VDT_UNARY_FUNCTION(fast_atan)
720#undef RVEC_VDT_UNARY_FUNCTION
724#undef RVEC_UNARY_FUNCTION
739template <
typename T,
typename V>
742 if (
v0.size() !=
v1.size())
743 throw std::runtime_error(
"Cannot compute inner product of vectors of different sizes");
760 return std::accumulate(
v.begin(),
v.end(),
T(0));
777 if (
v.empty())
return 0.;
778 return double(
Sum(
v)) /
v.size();
794 return *std::max_element(
v.begin(),
v.end());
810 return *std::min_element(
v.begin(),
v.end());
828 return std::distance(
v.begin(), std::max_element(
v.begin(),
v.end()));
846 return std::distance(
v.begin(), std::min_element(
v.begin(),
v.end()));
863 const std::size_t size =
v.size();
864 if (size < std::size_t(2))
return 0.;
865 T sum_squares(0), squared_sum(0);
866 auto pred = [&sum_squares, &squared_sum](
const T&
x) {sum_squares+=
x*
x; squared_sum+=
x;};
867 std::for_each(
v.begin(),
v.end(), pred);
868 squared_sum *= squared_sum;
869 const auto dsize = (double) size;
870 return 1. / (dsize - 1.) * (sum_squares - squared_sum / dsize );
908template <
typename... Args>
911 std::make_index_sequence<
sizeof...(args) - 1>()))
924 std::make_index_sequence<
sizeof...(args) - 1>());
937template <
typename T,
typename F>
940 const auto thisSize =
v.size();
943 for (
auto &&val :
v) {
1004template <
typename T>
1010 std::sort(i.
begin(), i.
end(), [&
v](size_type i1, size_type i2) { return v[i1] < v[i2]; });
1024template <
typename T>
1028 const size_type isize = i.size();
1030 for (size_type k = 0; k < isize; k++)
1050template <
typename T>
1054 const size_type size =
v.size();
1055 const size_type absn = std::abs(
n);
1057 std::stringstream ss;
1058 ss <<
"Try to take " << absn <<
" elements but vector has only size " << size <<
".";
1059 throw std::runtime_error(ss.str());
1063 for (size_type k = 0; k < absn; k++)
1064 r[k] =
v[size - absn + k];
1066 for (size_type k = 0; k < absn; k++)
1082template <
typename T>
1086 std::reverse(
r.begin(),
r.end());
1103template <
typename T>
1107 std::sort(
r.begin(),
r.end());
1128template <
typename T,
typename Compare>
1132 std::sort(
r.begin(),
r.end(), std::forward<Compare>(
c));
1150 using size_type = std::size_t;
1152 r[0].resize(size1*size2);
1153 r[1].resize(size1*size2);
1155 for(size_type i=0; i<size1; i++) {
1156 for(size_type j=0; j<size2; j++) {
1180template <
typename T1,
typename T2>
1205template <
typename T>
1209 const size_type
s =
v.size();
1211 std::stringstream ss;
1212 ss <<
"Cannot make unique combinations of size " <<
n <<
" from vector of size " <<
s <<
".";
1213 throw std::runtime_error(ss.str());
1216 for(size_type k=0; k<
s; k++)
1219 for(size_type k=0; k<
n; k++)
1222 bool run_through =
true;
1226 run_through =
false;
1234 for (
long j=i+1; j<(long)
n; j++)
1236 for(size_type k=0; k<
n; k++)
1251template <
typename T>
1256 const auto size =
v.size();
1258 for(size_type i=0; i<size; i++) {
1282template <
typename T>
1286 if (!v2_is_sorted) v2_sorted =
Sort(
v2);
1287 const auto v2_begin = v2_is_sorted ?
v2.begin() : v2_sorted.
begin();
1288 const auto v2_end = v2_is_sorted ?
v2.end() : v2_sorted.
end();
1290 const auto size =
v1.size();
1293 for(size_type i=0; i<size; i++) {
1294 if (std::binary_search(v2_begin, v2_end,
v1[i])) {
1295 r.emplace_back(
v1[i]);
1316template <
typename T>
1320 const size_type size =
c.size();
1323 for (size_type i=0; i<size; i++) {
1324 r.emplace_back(
c[i] != 0 ?
v1[i] :
v2[i]);
1344template <
typename T>
1348 const size_type size =
c.size();
1351 for (size_type i=0; i<size; i++) {
1352 r.emplace_back(
c[i] != 0 ?
v1[i] :
v2);
1372template <
typename T>
1376 const size_type size =
c.size();
1379 for (size_type i=0; i<size; i++) {
1380 r.emplace_back(
c[i] != 0 ?
v1 :
v2[i]);
1398template <
typename T>
1402 const size_type size =
c.size();
1405 for (size_type i=0; i<size; i++) {
1406 r.emplace_back(
c[i] != 0 ?
v1 :
v2);
1427 auto &v0AsVect =
v0.AsVector();
1428 auto &v1AsVect =
v1.AsVector();
1429 resAsVect.insert(resAsVect.begin(), v0AsVect.begin(), v0AsVect.end());
1430 resAsVect.insert(resAsVect.end(), v1AsVect.begin(), v1AsVect.end());
1440template <
typename T>
1443 static_assert(std::is_floating_point<T>::value,
1444 "DeltaPhi must be called with floating point values.");
1445 auto r = std::fmod(
v2 -
v1, 2.0 *
c);
1461template <
typename T>
1465 const size_type size =
v1.size();
1467 for (size_type i = 0; i < size; i++) {
1479template <
typename T>
1483 const size_type size =
v1.size();
1485 for (size_type i = 0; i < size; i++) {
1497template <
typename T>
1501 const size_type size =
v2.size();
1503 for (size_type i = 0; i < size; i++) {
1516template <
typename T>
1519 const auto dphi =
DeltaPhi(phi1, phi2,
c);
1520 return (eta1 - eta2) * (eta1 - eta2) + dphi * dphi;
1530template <
typename T>
1543template <
typename T>
1546 const auto dphi =
DeltaPhi(phi1, phi2,
c);
1547 return std::sqrt((eta1 - eta2) * (eta1 - eta2) + dphi * dphi);
1555template <
typename T>
1560 std::size_t size = pt1.
size();
1567 for (std::size_t i = 0u; i < size; ++i) {
1570 const auto y1 = pt1[i] *
std::sin(phi1[i]);
1571 const auto z1 = pt1[i] *
std::sinh(eta1[i]);
1572 const auto e1 =
std::sqrt(
x1 *
x1 + y1 * y1 + z1 * z1 + mass1[i] * mass1[i]);
1575 const auto y2 = pt2[i] *
std::sin(phi2[i]);
1576 const auto z2 = pt2[i] *
std::sinh(eta2[i]);
1577 const auto e2 =
std::sqrt(
x2 *
x2 + y2 * y2 + z2 * z2 + mass2[i] * mass2[i]);
1580 const auto e = e1 + e2;
1581 const auto x =
x1 +
x2;
1582 const auto y = y1 + y2;
1583 const auto z = z1 + z2;
1597template <
typename T>
1600 const std::size_t size =
pt.size();
1609 for (std::size_t i = 0u; i < size; ++ i) {
1617 const auto e =
std::sqrt(
x *
x +
y *
y + z * z + mass[i] * mass[i]);
1622 return std::sqrt(e_sum * e_sum - x_sum * x_sum - y_sum * y_sum - z_sum * z_sum);
1643template <
typename T,
typename... Args_t>
1649 for (
auto i = 0UL; i < size; ++i) {
1661 constexpr bool mustConvert = std::is_same<char, T>::value || std::is_same<signed char, T>::value ||
1662 std::is_same<unsigned char, T>::value || std::is_same<wchar_t, T>::value ||
1663 std::is_same<char16_t, T>::value || std::is_same<char32_t, T>::value;
1666 auto size =
v.size();
1668 for (std::size_t i = 0; i < size - 1; ++i) {
1669 os << (Print_t)
v[i] <<
", ";
1671 os << (Print_t)
v[size - 1];
1677#if (_VECOPS_USE_EXTERN_TEMPLATES)
1679#define RVEC_EXTERN_UNARY_OPERATOR(T, OP) \
1680 extern template RVec<T> operator OP<T>(const RVec<T> &);
1682#define RVEC_EXTERN_BINARY_OPERATOR(T, OP) \
1683 extern template auto operator OP<T, T>(const T &x, const RVec<T> &v) \
1684 -> RVec<decltype(x OP v[0])>; \
1685 extern template auto operator OP<T, T>(const RVec<T> &v, const T &y) \
1686 -> RVec<decltype(v[0] OP y)>; \
1687 extern template auto operator OP<T, T>(const RVec<T> &v0, const RVec<T> &v1)\
1688 -> RVec<decltype(v0[0] OP v1[0])>;
1690#define RVEC_EXTERN_ASSIGN_OPERATOR(T, OP) \
1691 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const T &); \
1692 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const RVec<T> &);
1694#define RVEC_EXTERN_LOGICAL_OPERATOR(T, OP) \
1695 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const T &); \
1696 extern template RVec<int> operator OP<T, T>(const T &, const RVec<T> &); \
1697 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const RVec<T> &);
1699#define RVEC_EXTERN_FLOAT_TEMPLATE(T) \
1700 extern template class RVec<T>; \
1701 RVEC_EXTERN_UNARY_OPERATOR(T, +) \
1702 RVEC_EXTERN_UNARY_OPERATOR(T, -) \
1703 RVEC_EXTERN_UNARY_OPERATOR(T, !) \
1704 RVEC_EXTERN_BINARY_OPERATOR(T, +) \
1705 RVEC_EXTERN_BINARY_OPERATOR(T, -) \
1706 RVEC_EXTERN_BINARY_OPERATOR(T, *) \
1707 RVEC_EXTERN_BINARY_OPERATOR(T, /) \
1708 RVEC_EXTERN_ASSIGN_OPERATOR(T, +=) \
1709 RVEC_EXTERN_ASSIGN_OPERATOR(T, -=) \
1710 RVEC_EXTERN_ASSIGN_OPERATOR(T, *=) \
1711 RVEC_EXTERN_ASSIGN_OPERATOR(T, /=) \
1712 RVEC_EXTERN_LOGICAL_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, ||)
1721#define RVEC_EXTERN_INTEGER_TEMPLATE(T) \
1722 extern template class RVec<T>; \
1723 RVEC_EXTERN_UNARY_OPERATOR(T, +) \
1724 RVEC_EXTERN_UNARY_OPERATOR(T, -) \
1725 RVEC_EXTERN_UNARY_OPERATOR(T, ~) \
1726 RVEC_EXTERN_UNARY_OPERATOR(T, !) \
1727 RVEC_EXTERN_BINARY_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_ASSIGN_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_LOGICAL_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, ||)
1754RVEC_EXTERN_INTEGER_TEMPLATE(
char)
1755RVEC_EXTERN_INTEGER_TEMPLATE(
short)
1756RVEC_EXTERN_INTEGER_TEMPLATE(
int)
1757RVEC_EXTERN_INTEGER_TEMPLATE(
long)
1760RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned char)
1761RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned short)
1762RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned int)
1763RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned long)
1766RVEC_EXTERN_FLOAT_TEMPLATE(
float)
1767RVEC_EXTERN_FLOAT_TEMPLATE(
double)
1769#undef RVEC_EXTERN_UNARY_OPERATOR
1770#undef RVEC_EXTERN_BINARY_OPERATOR
1771#undef RVEC_EXTERN_ASSIGN_OPERATOR
1772#undef RVEC_EXTERN_LOGICAL_OPERATOR
1773#undef RVEC_EXTERN_INTEGER_TEMPLATE
1774#undef RVEC_EXTERN_FLOAT_TEMPLATE
1776#define RVEC_EXTERN_UNARY_FUNCTION(T, NAME, FUNC) \
1777 extern template RVec<PromoteType<T>> NAME(const RVec<T> &);
1779#define RVEC_EXTERN_STD_UNARY_FUNCTION(T, F) RVEC_EXTERN_UNARY_FUNCTION(T, F, std::F)
1781#define RVEC_EXTERN_BINARY_FUNCTION(T0, T1, NAME, FUNC) \
1782 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const T1 &); \
1783 extern template RVec<PromoteTypes<T0, T1>> NAME(const T0 &, const RVec<T1> &); \
1784 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const RVec<T1> &);
1786#define RVEC_EXTERN_STD_BINARY_FUNCTION(T, F) RVEC_EXTERN_BINARY_FUNCTION(T, T, F, std::F)
1788#define RVEC_EXTERN_STD_FUNCTIONS(T) \
1789 RVEC_EXTERN_STD_UNARY_FUNCTION(T, abs) \
1790 RVEC_EXTERN_STD_BINARY_FUNCTION(T, fdim) \
1791 RVEC_EXTERN_STD_BINARY_FUNCTION(T, fmod) \
1792 RVEC_EXTERN_STD_BINARY_FUNCTION(T, remainder) \
1793 RVEC_EXTERN_STD_UNARY_FUNCTION(T, exp) \
1794 RVEC_EXTERN_STD_UNARY_FUNCTION(T, exp2) \
1795 RVEC_EXTERN_STD_UNARY_FUNCTION(T, expm1) \
1796 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log) \
1797 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log10) \
1798 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log2) \
1799 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log1p) \
1800 RVEC_EXTERN_STD_BINARY_FUNCTION(T, pow) \
1801 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sqrt) \
1802 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cbrt) \
1803 RVEC_EXTERN_STD_BINARY_FUNCTION(T, hypot) \
1804 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sin) \
1805 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cos) \
1806 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tan) \
1807 RVEC_EXTERN_STD_UNARY_FUNCTION(T, asin) \
1808 RVEC_EXTERN_STD_UNARY_FUNCTION(T, acos) \
1809 RVEC_EXTERN_STD_UNARY_FUNCTION(T, atan) \
1810 RVEC_EXTERN_STD_BINARY_FUNCTION(T, atan2) \
1811 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sinh) \
1812 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cosh) \
1813 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tanh) \
1814 RVEC_EXTERN_STD_UNARY_FUNCTION(T, asinh) \
1815 RVEC_EXTERN_STD_UNARY_FUNCTION(T, acosh) \
1816 RVEC_EXTERN_STD_UNARY_FUNCTION(T, atanh) \
1817 RVEC_EXTERN_STD_UNARY_FUNCTION(T, floor) \
1818 RVEC_EXTERN_STD_UNARY_FUNCTION(T, ceil) \
1819 RVEC_EXTERN_STD_UNARY_FUNCTION(T, trunc) \
1820 RVEC_EXTERN_STD_UNARY_FUNCTION(T, round) \
1821 RVEC_EXTERN_STD_UNARY_FUNCTION(T, erf) \
1822 RVEC_EXTERN_STD_UNARY_FUNCTION(T, erfc) \
1823 RVEC_EXTERN_STD_UNARY_FUNCTION(T, lgamma) \
1824 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tgamma) \
1826RVEC_EXTERN_STD_FUNCTIONS(
float)
1827RVEC_EXTERN_STD_FUNCTIONS(
double)
1828#undef RVEC_EXTERN_STD_UNARY_FUNCTION
1829#undef RVEC_EXTERN_STD_BINARY_FUNCTION
1830#undef RVEC_EXTERN_STD_UNARY_FUNCTIONS
1834#define RVEC_EXTERN_VDT_UNARY_FUNCTION(T, F) RVEC_EXTERN_UNARY_FUNCTION(T, F, vdt::F)
1836RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_expf)
1837RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_logf)
1838RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_sinf)
1839RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_cosf)
1840RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_tanf)
1841RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_asinf)
1842RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_acosf)
1843RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_atanf)
1845RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_exp)
1846RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_log)
1847RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_sin)
1848RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_cos)
1849RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_tan)
1850RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_asin)
1851RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_acos)
1852RVEC_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...
static constexpr double s