20 #ifndef _USE_MATH_DEFINES
21 #define _USE_MATH_DEFINES
24 #undef _USE_MATH_DEFINES
26 #define _VECOPS_USE_EXTERN_TEMPLATES false
28 #define _VECOPS_USE_EXTERN_TEMPLATES true
52#include <vdt/vdtMath.h>
76 RBranchSet &outputBranches);
86template <
typename... T>
89 constexpr const auto nArgs =
sizeof...(T);
90 const std::size_t sizes[] = {vs.
size()...};
92 for (
auto i = 1UL; i < nArgs; i++) {
93 if (sizes[0] == sizes[i])
96 msg +=
": input RVec instances have different lengths!";
97 throw std::runtime_error(msg);
103template <
typename F,
typename... T>
107 RVec<
decltype(
f(vs[0]...))> ret(size);
109 for (
auto i = 0UL; i < size; i++)
110 ret[i] =
f(vs[i]...);
115template <
typename Tuple_t, std::size_t... Is>
117 ->
decltype(
MapImpl(std::get<std::tuple_size<Tuple_t>::value - 1>(t), std::get<Is>(t)...))
119 constexpr const auto tupleSizeM1 = std::tuple_size<Tuple_t>::value - 1;
120 return MapImpl(std::get<tupleSizeM1>(t), std::get<Is>(t)...);
132template <
typename T,
typename... Args>
135 v.emplace_back(std::forward<Args>(args)...);
138template <
typename... Args>
141 v.push_back(std::forward<Args>(args)...);
300 const std::string &inName,
const std::string &outName,
302 ROOT::Internal::RDF::RBranchSet &outputBranches);
308 static constexpr const auto IsVecBool = std::is_same<bool, T>::value;
310 using Impl_t =
typename std::conditional<IsVecBool, std::vector<bool>, std::vector<T, ::ROOT::Detail::VecOps::RAdoptAllocator<T>>>
::type;
320 using data_t =
typename std::conditional<IsVecBool, void, typename Impl_t::pointer>::type;
321 using const_data_t =
typename std::conditional<IsVecBool, void, typename Impl_t::const_pointer>::type;
346 template <
class InputIt>
360 std::swap(
fData,
v.fData);
371 template <typename U, typename = std::enable_if<std::is_convertible<T, U>::value>>
379 R__DEPRECATED(6, 26,
"Please use `std::vector<T>(rvec.begin(), rvec.end())` instead.")
396 template <typename V, typename = std::enable_if<std::is_convertible<V, bool>::value>>
402 throw std::runtime_error(
"Cannot index RVec with condition vector of different size");
444 template <
class... Args>
452 template<typename U = T, typename std::enable_if<std::is_arithmetic<U>::value,
int>* =
nullptr>
455 return fData.emplace(pos, value);
466#define RVEC_UNARY_OPERATOR(OP) \
467template <typename T> \
468RVec<T> operator OP(const RVec<T> &v) \
471 for (auto &x : ret) \
480#undef RVEC_UNARY_OPERATOR
486#define ERROR_MESSAGE(OP) \
487 "Cannot call operator " #OP " on vectors of different sizes."
489#define RVEC_BINARY_OPERATOR(OP) \
490template <typename T0, typename T1> \
491auto operator OP(const RVec<T0> &v, const T1 &y) \
492 -> RVec<decltype(v[0] OP y)> \
494 RVec<decltype(v[0] OP y)> ret(v.size()); \
495 auto op = [&y](const T0 &x) { return x OP y; }; \
496 std::transform(v.begin(), v.end(), ret.begin(), op); \
500template <typename T0, typename T1> \
501auto operator OP(const T0 &x, const RVec<T1> &v) \
502 -> RVec<decltype(x OP v[0])> \
504 RVec<decltype(x OP v[0])> ret(v.size()); \
505 auto op = [&x](const T1 &y) { return x OP y; }; \
506 std::transform(v.begin(), v.end(), ret.begin(), op); \
510template <typename T0, typename T1> \
511auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
512 -> RVec<decltype(v0[0] OP v1[0])> \
514 if (v0.size() != v1.size()) \
515 throw std::runtime_error(ERROR_MESSAGE(OP)); \
517 RVec<decltype(v0[0] OP v1[0])> ret(v0.size()); \
518 auto op = [](const T0 &x, const T1 &y) { return x OP y; }; \
519 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
531#undef RVEC_BINARY_OPERATOR
537#define RVEC_ASSIGNMENT_OPERATOR(OP) \
538template <typename T0, typename T1> \
539RVec<T0>& operator OP(RVec<T0> &v, const T1 &y) \
541 auto op = [&y](T0 &x) { return x OP y; }; \
542 std::transform(v.begin(), v.end(), v.begin(), op); \
546template <typename T0, typename T1> \
547RVec<T0>& operator OP(RVec<T0> &v0, const RVec<T1> &v1) \
549 if (v0.size() != v1.size()) \
550 throw std::runtime_error(ERROR_MESSAGE(OP)); \
552 auto op = [](T0 &x, const T1 &y) { return x OP y; }; \
553 std::transform(v0.begin(), v0.end(), v1.begin(), v0.begin(), op); \
567#undef RVEC_ASSIGNMENT_OPERATOR
573#define RVEC_LOGICAL_OPERATOR(OP) \
574template <typename T0, typename T1> \
575auto operator OP(const RVec<T0> &v, const T1 &y) \
578 RVec<int> ret(v.size()); \
579 auto op = [y](const T0 &x) -> int { return x OP y; }; \
580 std::transform(v.begin(), v.end(), ret.begin(), op); \
584template <typename T0, typename T1> \
585auto operator OP(const T0 &x, const RVec<T1> &v) \
588 RVec<int> ret(v.size()); \
589 auto op = [x](const T1 &y) -> int { return x OP y; }; \
590 std::transform(v.begin(), v.end(), ret.begin(), op); \
594template <typename T0, typename T1> \
595auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
598 if (v0.size() != v1.size()) \
599 throw std::runtime_error(ERROR_MESSAGE(OP)); \
601 RVec<int> ret(v0.size()); \
602 auto op = [](const T0 &x, const T1 &y) -> int { return x OP y; }; \
603 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
615#undef RVEC_LOGICAL_OPERATOR
622template <
typename T>
struct PromoteTypeImpl;
624template <>
struct PromoteTypeImpl<float> {
using Type = float; };
628template <
typename T>
struct PromoteTypeImpl {
using Type =
double; };
631using PromoteType =
typename PromoteTypeImpl<T>::Type;
633template <
typename U,
typename V>
634using PromoteTypes =
decltype(PromoteType<U>() + PromoteType<V>());
638#define RVEC_UNARY_FUNCTION(NAME, FUNC) \
639 template <typename T> \
640 RVec<PromoteType<T>> NAME(const RVec<T> &v) \
642 RVec<PromoteType<T>> ret(v.size()); \
643 auto f = [](const T &x) { return FUNC(x); }; \
644 std::transform(v.begin(), v.end(), ret.begin(), f); \
648#define RVEC_BINARY_FUNCTION(NAME, FUNC) \
649 template <typename T0, typename T1> \
650 RVec<PromoteTypes<T0, T1>> NAME(const T0 &x, const RVec<T1> &v) \
652 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
653 auto f = [&x](const T1 &y) { return FUNC(x, y); }; \
654 std::transform(v.begin(), v.end(), ret.begin(), f); \
658 template <typename T0, typename T1> \
659 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v, const T1 &y) \
661 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
662 auto f = [&y](const T1 &x) { return FUNC(x, y); }; \
663 std::transform(v.begin(), v.end(), ret.begin(), f); \
667 template <typename T0, typename T1> \
668 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v0, const RVec<T1> &v1) \
670 if (v0.size() != v1.size()) \
671 throw std::runtime_error(ERROR_MESSAGE(NAME)); \
673 RVec<PromoteTypes<T0, T1>> ret(v0.size()); \
674 auto f = [](const T0 &x, const T1 &y) { return FUNC(x, y); }; \
675 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), f); \
679#define RVEC_STD_UNARY_FUNCTION(F) RVEC_UNARY_FUNCTION(F, std::F)
680#define RVEC_STD_BINARY_FUNCTION(F) RVEC_BINARY_FUNCTION(F, std::F)
727#undef RVEC_STD_UNARY_FUNCTION
734#define RVEC_VDT_UNARY_FUNCTION(F) RVEC_UNARY_FUNCTION(F, vdt::F)
736RVEC_VDT_UNARY_FUNCTION(fast_expf)
737RVEC_VDT_UNARY_FUNCTION(fast_logf)
738RVEC_VDT_UNARY_FUNCTION(fast_sinf)
739RVEC_VDT_UNARY_FUNCTION(fast_cosf)
740RVEC_VDT_UNARY_FUNCTION(fast_tanf)
741RVEC_VDT_UNARY_FUNCTION(fast_asinf)
742RVEC_VDT_UNARY_FUNCTION(fast_acosf)
743RVEC_VDT_UNARY_FUNCTION(fast_atanf)
745RVEC_VDT_UNARY_FUNCTION(fast_exp)
746RVEC_VDT_UNARY_FUNCTION(fast_log)
747RVEC_VDT_UNARY_FUNCTION(fast_sin)
748RVEC_VDT_UNARY_FUNCTION(fast_cos)
749RVEC_VDT_UNARY_FUNCTION(fast_tan)
750RVEC_VDT_UNARY_FUNCTION(fast_asin)
751RVEC_VDT_UNARY_FUNCTION(fast_acos)
752RVEC_VDT_UNARY_FUNCTION(fast_atan)
753#undef RVEC_VDT_UNARY_FUNCTION
757#undef RVEC_UNARY_FUNCTION
772template <
typename T,
typename V>
775 if (
v0.size() !=
v1.size())
776 throw std::runtime_error(
"Cannot compute inner product of vectors of different sizes");
777 return std::inner_product(
v0.begin(),
v0.end(),
v1.begin(),
decltype(
v0[0] *
v1[0])(0));
793 return std::accumulate(
v.begin(),
v.end(), T(0));
810 if (
v.empty())
return 0.;
827 return *std::max_element(
v.begin(),
v.end());
843 return *std::min_element(
v.begin(),
v.end());
861 return std::distance(
v.begin(), std::max_element(
v.begin(),
v.end()));
879 return std::distance(
v.begin(), std::min_element(
v.begin(),
v.end()));
896 const std::size_t size =
v.size();
897 if (size < std::size_t(2))
return 0.;
898 T sum_squares(0), squared_sum(0);
899 auto pred = [&sum_squares, &squared_sum](
const T&
x) {sum_squares+=
x*
x; squared_sum+=
x;};
900 std::for_each(
v.begin(),
v.end(), pred);
901 squared_sum *= squared_sum;
902 const auto dsize = (
double) size;
903 return 1. / (dsize - 1.) * (sum_squares - squared_sum / dsize );
920 return std::sqrt(
Var(
v));
941template <
typename... Args>
944 std::make_index_sequence<
sizeof...(args) - 1>()))
957 std::make_index_sequence<
sizeof...(args) - 1>());
970template <
typename T,
typename F>
973 const auto thisSize =
v.size();
976 for (
auto &&val :
v) {
1012template <
typename T>
1021template <
typename T>
1037template <
typename T>
1043 std::sort(i.
begin(), i.
end(), [&
v](size_type i1, size_type i2) { return v[i1] < v[i2]; });
1057template <
typename T>
1061 const size_type isize = i.size();
1063 for (size_type k = 0; k < isize; k++)
1083template <
typename T>
1087 const size_type size =
v.size();
1088 const size_type absn = std::abs(
n);
1090 std::stringstream ss;
1091 ss <<
"Try to take " << absn <<
" elements but vector has only size " << size <<
".";
1092 throw std::runtime_error(ss.str());
1096 for (size_type k = 0; k < absn; k++)
1097 r[k] =
v[size - absn + k];
1099 for (size_type k = 0; k < absn; k++)
1115template <
typename T>
1119 std::reverse(
r.begin(),
r.end());
1136template <
typename T>
1140 std::sort(
r.begin(),
r.end());
1161template <
typename T,
typename Compare>
1165 std::sort(
r.begin(),
r.end(), std::forward<Compare>(
c));
1183 using size_type = std::size_t;
1185 r[0].resize(size1*size2);
1186 r[1].resize(size1*size2);
1188 for(size_type i=0; i<size1; i++) {
1189 for(size_type j=0; j<size2; j++) {
1213template <
typename T1,
typename T2>
1238template <
typename T>
1242 const size_type s =
v.size();
1244 std::stringstream ss;
1245 ss <<
"Cannot make unique combinations of size " <<
n <<
" from vector of size " << s <<
".";
1246 throw std::runtime_error(ss.str());
1249 for(size_type k=0; k<s; k++)
1252 for(size_type k=0; k<
n; k++)
1255 bool run_through =
true;
1259 run_through =
false;
1267 for (
long j=i+1; j<(
long)
n; j++)
1269 for(size_type k=0; k<
n; k++)
1284template <
typename T>
1289 const auto size =
v.size();
1291 for(size_type i=0; i<size; i++) {
1315template <
typename T>
1319 if (!v2_is_sorted) v2_sorted = Sort(
v2);
1320 const auto v2_begin = v2_is_sorted ?
v2.begin() : v2_sorted.
begin();
1321 const auto v2_end = v2_is_sorted ?
v2.end() : v2_sorted.
end();
1323 const auto size =
v1.size();
1326 for(size_type i=0; i<size; i++) {
1327 if (std::binary_search(v2_begin, v2_end,
v1[i])) {
1328 r.emplace_back(
v1[i]);
1349template <
typename T>
1353 const size_type size =
c.size();
1356 for (size_type i=0; i<size; i++) {
1357 r.emplace_back(
c[i] != 0 ?
v1[i] :
v2[i]);
1377template <
typename T>
1381 const size_type size =
c.size();
1384 for (size_type i=0; i<size; i++) {
1385 r.emplace_back(
c[i] != 0 ?
v1[i] :
v2);
1405template <
typename T>
1409 const size_type size =
c.size();
1412 for (size_type i=0; i<size; i++) {
1413 r.emplace_back(
c[i] != 0 ?
v1 :
v2[i]);
1431template <
typename T>
1435 const size_type size =
c.size();
1438 for (size_type i=0; i<size; i++) {
1439 r.emplace_back(
c[i] != 0 ?
v1 :
v2);
1454template <typename T0, typename T1, typename Common_t = typename std::common_type<T0, T1>::type>
1459 std::copy(
v0.begin(),
v0.end(), std::back_inserter(res));
1460 std::copy(
v1.begin(),
v1.end(), std::back_inserter(res));
1470template <
typename T>
1473 static_assert(std::is_floating_point<T>::value,
1474 "DeltaPhi must be called with floating point values.");
1475 auto r = std::fmod(
v2 -
v1, 2.0 *
c);
1491template <
typename T>
1495 const size_type size =
v1.size();
1497 for (size_type i = 0; i < size; i++) {
1498 r[i] = DeltaPhi(
v1[i],
v2[i],
c);
1509template <
typename T>
1513 const size_type size =
v1.size();
1515 for (size_type i = 0; i < size; i++) {
1516 r[i] = DeltaPhi(
v1[i],
v2,
c);
1527template <
typename T>
1531 const size_type size =
v2.size();
1533 for (size_type i = 0; i < size; i++) {
1534 r[i] = DeltaPhi(
v1,
v2[i],
c);
1546template <
typename T>
1549 const auto dphi = DeltaPhi(phi1, phi2,
c);
1550 return (eta1 - eta2) * (eta1 - eta2) + dphi * dphi;
1560template <
typename T>
1563 return sqrt(DeltaR2(eta1, eta2, phi1, phi2,
c));
1573template <
typename T>
1574T DeltaR(T eta1, T eta2, T phi1, T phi2,
const T
c =
M_PI)
1576 const auto dphi = DeltaPhi(phi1, phi2,
c);
1577 return std::sqrt((eta1 - eta2) * (eta1 - eta2) + dphi * dphi);
1585template <
typename T>
1590 std::size_t size = pt1.
size();
1597 for (std::size_t i = 0u; i < size; ++i) {
1599 const auto x1 = pt1[i] * std::cos(phi1[i]);
1600 const auto y1 = pt1[i] * std::sin(phi1[i]);
1601 const auto z1 = pt1[i] * std::sinh(eta1[i]);
1602 const auto e1 = std::sqrt(
x1 *
x1 + y1 * y1 + z1 * z1 + mass1[i] * mass1[i]);
1604 const auto x2 = pt2[i] * std::cos(phi2[i]);
1605 const auto y2 = pt2[i] * std::sin(phi2[i]);
1606 const auto z2 = pt2[i] * std::sinh(eta2[i]);
1607 const auto e2 = std::sqrt(
x2 *
x2 + y2 * y2 + z2 * z2 + mass2[i] * mass2[i]);
1610 const auto e = e1 + e2;
1611 const auto x =
x1 +
x2;
1612 const auto y = y1 + y2;
1613 const auto z = z1 + z2;
1615 inv_masses[i] = std::sqrt(
e *
e -
x *
x -
y *
y - z * z);
1627template <
typename T>
1630 const std::size_t size =
pt.size();
1639 for (std::size_t i = 0u; i < size; ++ i) {
1641 const auto x =
pt[i] * std::cos(phi[i]);
1643 const auto y =
pt[i] * std::sin(phi[i]);
1645 const auto z =
pt[i] * std::sinh(eta[i]);
1647 const auto e = std::sqrt(
x *
x +
y *
y + z * z + mass[i] * mass[i]);
1652 return std::sqrt(e_sum * e_sum - x_sum * x_sum - y_sum * y_sum - z_sum * z_sum);
1673template <
typename T,
typename... Args_t>
1679 for (
auto i = 0UL; i < size; ++i) {
1691 constexpr bool mustConvert = std::is_same<char, T>::value || std::is_same<signed char, T>::value ||
1692 std::is_same<unsigned char, T>::value || std::is_same<wchar_t, T>::value ||
1693 std::is_same<char16_t, T>::value || std::is_same<char32_t, T>::value;
1694 using Print_t =
typename std::conditional<mustConvert, long long int, T>::type;
1696 auto size =
v.size();
1698 for (std::size_t i = 0; i < size - 1; ++i) {
1699 os << (Print_t)
v[i] <<
", ";
1701 os << (Print_t)
v[size - 1];
1707#if (_VECOPS_USE_EXTERN_TEMPLATES)
1709#define RVEC_EXTERN_UNARY_OPERATOR(T, OP) \
1710 extern template RVec<T> operator OP<T>(const RVec<T> &);
1712#define RVEC_EXTERN_BINARY_OPERATOR(T, OP) \
1713 extern template auto operator OP<T, T>(const T &x, const RVec<T> &v) \
1714 -> RVec<decltype(x OP v[0])>; \
1715 extern template auto operator OP<T, T>(const RVec<T> &v, const T &y) \
1716 -> RVec<decltype(v[0] OP y)>; \
1717 extern template auto operator OP<T, T>(const RVec<T> &v0, const RVec<T> &v1)\
1718 -> RVec<decltype(v0[0] OP v1[0])>;
1720#define RVEC_EXTERN_ASSIGN_OPERATOR(T, OP) \
1721 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const T &); \
1722 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const RVec<T> &);
1724#define RVEC_EXTERN_LOGICAL_OPERATOR(T, OP) \
1725 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const T &); \
1726 extern template RVec<int> operator OP<T, T>(const T &, const RVec<T> &); \
1727 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const RVec<T> &);
1729#define RVEC_EXTERN_FLOAT_TEMPLATE(T) \
1730 extern template class RVec<T>; \
1731 RVEC_EXTERN_UNARY_OPERATOR(T, +) \
1732 RVEC_EXTERN_UNARY_OPERATOR(T, -) \
1733 RVEC_EXTERN_UNARY_OPERATOR(T, !) \
1734 RVEC_EXTERN_BINARY_OPERATOR(T, +) \
1735 RVEC_EXTERN_BINARY_OPERATOR(T, -) \
1736 RVEC_EXTERN_BINARY_OPERATOR(T, *) \
1737 RVEC_EXTERN_BINARY_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_LOGICAL_OPERATOR(T, <) \
1743 RVEC_EXTERN_LOGICAL_OPERATOR(T, >) \
1744 RVEC_EXTERN_LOGICAL_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, ||)
1751#define RVEC_EXTERN_INTEGER_TEMPLATE(T) \
1752 extern template class RVec<T>; \
1753 RVEC_EXTERN_UNARY_OPERATOR(T, +) \
1754 RVEC_EXTERN_UNARY_OPERATOR(T, -) \
1755 RVEC_EXTERN_UNARY_OPERATOR(T, ~) \
1756 RVEC_EXTERN_UNARY_OPERATOR(T, !) \
1757 RVEC_EXTERN_BINARY_OPERATOR(T, +) \
1758 RVEC_EXTERN_BINARY_OPERATOR(T, -) \
1759 RVEC_EXTERN_BINARY_OPERATOR(T, *) \
1760 RVEC_EXTERN_BINARY_OPERATOR(T, /) \
1761 RVEC_EXTERN_BINARY_OPERATOR(T, %) \
1762 RVEC_EXTERN_BINARY_OPERATOR(T, &) \
1763 RVEC_EXTERN_BINARY_OPERATOR(T, |) \
1764 RVEC_EXTERN_BINARY_OPERATOR(T, ^) \
1765 RVEC_EXTERN_ASSIGN_OPERATOR(T, +=) \
1766 RVEC_EXTERN_ASSIGN_OPERATOR(T, -=) \
1767 RVEC_EXTERN_ASSIGN_OPERATOR(T, *=) \
1768 RVEC_EXTERN_ASSIGN_OPERATOR(T, /=) \
1769 RVEC_EXTERN_ASSIGN_OPERATOR(T, %=) \
1770 RVEC_EXTERN_ASSIGN_OPERATOR(T, &=) \
1771 RVEC_EXTERN_ASSIGN_OPERATOR(T, |=) \
1772 RVEC_EXTERN_ASSIGN_OPERATOR(T, ^=) \
1773 RVEC_EXTERN_ASSIGN_OPERATOR(T, >>=) \
1774 RVEC_EXTERN_ASSIGN_OPERATOR(T, <<=) \
1775 RVEC_EXTERN_LOGICAL_OPERATOR(T, <) \
1776 RVEC_EXTERN_LOGICAL_OPERATOR(T, >) \
1777 RVEC_EXTERN_LOGICAL_OPERATOR(T, ==) \
1778 RVEC_EXTERN_LOGICAL_OPERATOR(T, !=) \
1779 RVEC_EXTERN_LOGICAL_OPERATOR(T, <=) \
1780 RVEC_EXTERN_LOGICAL_OPERATOR(T, >=) \
1781 RVEC_EXTERN_LOGICAL_OPERATOR(T, &&) \
1782 RVEC_EXTERN_LOGICAL_OPERATOR(T, ||)
1784RVEC_EXTERN_INTEGER_TEMPLATE(
char)
1785RVEC_EXTERN_INTEGER_TEMPLATE(
short)
1786RVEC_EXTERN_INTEGER_TEMPLATE(
int)
1787RVEC_EXTERN_INTEGER_TEMPLATE(
long)
1790RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned char)
1791RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned short)
1792RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned int)
1793RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned long)
1796RVEC_EXTERN_FLOAT_TEMPLATE(
float)
1797RVEC_EXTERN_FLOAT_TEMPLATE(
double)
1799#undef RVEC_EXTERN_UNARY_OPERATOR
1800#undef RVEC_EXTERN_BINARY_OPERATOR
1801#undef RVEC_EXTERN_ASSIGN_OPERATOR
1802#undef RVEC_EXTERN_LOGICAL_OPERATOR
1803#undef RVEC_EXTERN_INTEGER_TEMPLATE
1804#undef RVEC_EXTERN_FLOAT_TEMPLATE
1806#define RVEC_EXTERN_UNARY_FUNCTION(T, NAME, FUNC) \
1807 extern template RVec<PromoteType<T>> NAME(const RVec<T> &);
1809#define RVEC_EXTERN_STD_UNARY_FUNCTION(T, F) RVEC_EXTERN_UNARY_FUNCTION(T, F, std::F)
1811#define RVEC_EXTERN_BINARY_FUNCTION(T0, T1, NAME, FUNC) \
1812 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const T1 &); \
1813 extern template RVec<PromoteTypes<T0, T1>> NAME(const T0 &, const RVec<T1> &); \
1814 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const RVec<T1> &);
1816#define RVEC_EXTERN_STD_BINARY_FUNCTION(T, F) RVEC_EXTERN_BINARY_FUNCTION(T, T, F, std::F)
1818#define RVEC_EXTERN_STD_FUNCTIONS(T) \
1819 RVEC_EXTERN_STD_UNARY_FUNCTION(T, abs) \
1820 RVEC_EXTERN_STD_BINARY_FUNCTION(T, fdim) \
1821 RVEC_EXTERN_STD_BINARY_FUNCTION(T, fmod) \
1822 RVEC_EXTERN_STD_BINARY_FUNCTION(T, remainder) \
1823 RVEC_EXTERN_STD_UNARY_FUNCTION(T, exp) \
1824 RVEC_EXTERN_STD_UNARY_FUNCTION(T, exp2) \
1825 RVEC_EXTERN_STD_UNARY_FUNCTION(T, expm1) \
1826 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log) \
1827 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log10) \
1828 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log2) \
1829 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log1p) \
1830 RVEC_EXTERN_STD_BINARY_FUNCTION(T, pow) \
1831 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sqrt) \
1832 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cbrt) \
1833 RVEC_EXTERN_STD_BINARY_FUNCTION(T, hypot) \
1834 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sin) \
1835 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cos) \
1836 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tan) \
1837 RVEC_EXTERN_STD_UNARY_FUNCTION(T, asin) \
1838 RVEC_EXTERN_STD_UNARY_FUNCTION(T, acos) \
1839 RVEC_EXTERN_STD_UNARY_FUNCTION(T, atan) \
1840 RVEC_EXTERN_STD_BINARY_FUNCTION(T, atan2) \
1841 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sinh) \
1842 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cosh) \
1843 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tanh) \
1844 RVEC_EXTERN_STD_UNARY_FUNCTION(T, asinh) \
1845 RVEC_EXTERN_STD_UNARY_FUNCTION(T, acosh) \
1846 RVEC_EXTERN_STD_UNARY_FUNCTION(T, atanh) \
1847 RVEC_EXTERN_STD_UNARY_FUNCTION(T, floor) \
1848 RVEC_EXTERN_STD_UNARY_FUNCTION(T, ceil) \
1849 RVEC_EXTERN_STD_UNARY_FUNCTION(T, trunc) \
1850 RVEC_EXTERN_STD_UNARY_FUNCTION(T, round) \
1851 RVEC_EXTERN_STD_UNARY_FUNCTION(T, erf) \
1852 RVEC_EXTERN_STD_UNARY_FUNCTION(T, erfc) \
1853 RVEC_EXTERN_STD_UNARY_FUNCTION(T, lgamma) \
1854 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tgamma) \
1856RVEC_EXTERN_STD_FUNCTIONS(
float)
1857RVEC_EXTERN_STD_FUNCTIONS(
double)
1858#undef RVEC_EXTERN_STD_UNARY_FUNCTION
1859#undef RVEC_EXTERN_STD_BINARY_FUNCTION
1860#undef RVEC_EXTERN_STD_UNARY_FUNCTIONS
1864#define RVEC_EXTERN_VDT_UNARY_FUNCTION(T, F) RVEC_EXTERN_UNARY_FUNCTION(T, F, vdt::F)
1866RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_expf)
1867RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_logf)
1868RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_sinf)
1869RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_cosf)
1870RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_tanf)
1871RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_asinf)
1872RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_acosf)
1873RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_atanf)
1875RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_exp)
1876RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_log)
1877RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_sin)
1878RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_cos)
1879RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_tan)
1880RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_asin)
1881RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_acos)
1882RVEC_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]
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Int_t Compare(const void *item1, const void *item2)
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
R__DEPRECATED(6, 26, "Please use `std::vector<T>(rvec.begin(), rvec.end())` instead.") Impl_t &AsVector()
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
R__DEPRECATED(6, 26, "Please use `std::vector<T>(rvec.begin(), rvec.end())` instead.") const Impl_t &AsVector() 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
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
A TTree is a list of TBranches.
A TTree represents a columnar dataset.
Type
enumeration specifying the integration types.
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)...))
auto MapImpl(F &&f, const RVec< T > &... vs) -> RVec< decltype(f(vs[0]...))>
void SetBranchesHelper(BoolArrayMap &boolArrays, TTree *inputTree, TTree &outputTree, const std::string &inName, const std::string &outName, TBranch *&branch, void *&branchAddress, ROOT::VecOps::RVec< T > *ab, RBranchSet &outputBranches)
std::map< std::string, BoolArray > BoolArrayMap
void EmplaceBack(T &v, Args &&... args)
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< Common_t > Concatenate(const RVec< T0 > &v0, const RVec< T1 > &v1)
Return the concatenation of two RVecs.
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 > Take(const RVec< T > &v, const RVec< typename RVec< T >::size_type > &i)
Return elements of a vector at given indices.
RVec< T > Construct(const RVec< Args_t > &... args)
Build an RVec of objects starting from RVecs of input to their constructors.
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.
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...