16#if __cplusplus > 201402L
17#define R__RVEC_NODISCARD [[nodiscard]]
19#define R__RVEC_NODISCARD
24 #ifndef _USE_MATH_DEFINES
25 #define _USE_MATH_DEFINES
29 #undef _USE_MATH_DEFINES
31 #define _VECOPS_USE_EXTERN_TEMPLATES false
33 #define _VECOPS_USE_EXTERN_TEMPLATES true
56#include <vdt/vdtMath.h>
81constexpr bool All(
const bool *vals, std::size_t
size)
83 for (
auto i = 0
u; i <
size; ++i)
89template <
typename... T>
92 constexpr const auto nArgs =
sizeof...(T);
93 const std::size_t
sizes[] = {
vs.size()...};
95 for (
auto i = 1UL; i <
nArgs; i++) {
99 msg +=
": input RVec instances have different lengths!";
100 throw std::runtime_error(
msg);
106template <
typename F,
typename...
RVecs>
112 for (
auto i = 0
UL; i <
size; i++)
118template <
typename Tuple_t, std::size_t...
Is>
120 ->
decltype(
MapImpl(std::get<std::tuple_size<Tuple_t>::value - 1>(t), std::get<Is>(t)...))
122 constexpr const auto tupleSizeM1 = std::tuple_size<Tuple_t>::value - 1;
123 return MapImpl(std::get<tupleSizeM1>(t), std::get<Is>(t)...);
155 static constexpr size_t SizeTypeMax() {
return std::numeric_limits<Size_T>::max(); }
163 void grow_pod(
void *FirstEl,
size_t MinSize,
size_t TSize);
167 static void report_size_overflow(
size_t MinSize);
170 static void report_at_maximum_capacity();
173 bool Owns()
const {
return fCapacity != -1; }
194 if (
N > capacity()) {
195 throw std::runtime_error(
"Setting size to a value greater than capacity.");
205 alignas(T)
char FirstEl[
sizeof(T)];
218 return const_cast<void *
>(
reinterpret_cast<const void *
>(
reinterpret_cast<const char *
>(
this) +
228 fBeginX = getFirstEl();
235 bool isSmall()
const {
return this->fBeginX == getFirstEl(); }
240 this->fBeginX = getFirstEl();
243 this->
fSize = this->fCapacity = 0;
263 using Base::capacity;
296 throw std::runtime_error(
"`front` called on an empty RVec");
304 throw std::runtime_error(
"`front` called on an empty RVec");
312 throw std::runtime_error(
"`back` called on an empty RVec");
320 throw std::runtime_error(
"`back` called on an empty RVec");
334template <
typename T,
bool = (std::is_trivially_copy_constructible<T>::value) &&
335 (std::is_trivially_move_constructible<T>::value) &&
336 std::is_trivially_destructible<T>::value>
351 template <
typename It1,
typename It2>
354 std::uninitialized_copy(std::make_move_iterator(
I), std::make_move_iterator(E),
Dest);
359 template <
typename It1,
typename It2>
362 std::uninitialized_copy(
I, E,
Dest);
376 this->SetSizeUnchecked(this->
size() + 1);
383 ::new ((
void *)this->end()) T(::std::move(
Elt));
384 this->SetSizeUnchecked(this->
size() + 1);
389 this->SetSizeUnchecked(this->
size() - 1);
395template <
typename T,
bool TriviallyCopyable>
400 if (MinSize > this->SizeTypeMax())
401 this->report_size_overflow(MinSize);
407 if (this->capacity() == this->SizeTypeMax())
408 this->report_at_maximum_capacity();
417 this->uninitialized_move(this->begin(), this->end(),
NewElts);
421 destroy_range(this->begin(), this->end());
424 if (!this->isSmall())
448 template <
typename It1,
typename It2>
452 uninitialized_copy(
I, E,
Dest);
457 template <
typename It1,
typename It2>
461 std::uninitialized_copy(
I, E,
Dest);
466 template <
typename T1,
typename T2>
469 typename std::enable_if<std::is_same<
typename std::remove_const<T1>::type,
T2>
::value>
::type * =
nullptr)
476 memcpy(
reinterpret_cast<void *
>(
Dest),
I, (E -
I) *
sizeof(T));
483 this->grow_pod(MinSize,
sizeof(T));
496 memcpy(
reinterpret_cast<void *
>(this->end()), &
Elt,
sizeof(T));
497 this->SetSizeUnchecked(this->
size() + 1);
505template <
typename T,
unsigned N>
507 alignas(T)
char InlineElts[
N *
sizeof(T)]{};
524 static constexpr unsigned elementsPerCacheLine = (cacheLineSize -
sizeof(
SmallVectorBase)) /
sizeof(T);
525 static constexpr unsigned maxInlineByteSize = 1024;
529 elementsPerCacheLine >= 8 ? elementsPerCacheLine : (
sizeof(T) * 8 > maxInlineByteSize ? 0 : 8);
533template <
typename ForwardIt>
536#if __cplusplus < 201703L
537 for (; first != last; ++first)
538 new (
static_cast<void *
>(std::addressof(*first)))
typename std::iterator_traits<ForwardIt>::value_type();
540 std::uninitialized_value_construct(first, last);
567 static constexpr bool kIsNoExcept = std::is_nothrow_destructible_v<T> && std::is_nothrow_move_constructible_v<T>;
577 explicit RVecImpl(
unsigned N) :
ROOT::Internal::VecOps::SmallVectorTemplateBase<T>(
N) {}
586 if (!this->isSmall() && this->Owns())
594 this->destroy_range(this->begin(), this->end());
597 this->resetToSmall();
605 this->destroy_range(this->begin() +
N, this->end());
606 this->SetSizeUnchecked(
N);
607 }
else if (
N > this->
size()) {
608 if (this->capacity() <
N)
610 for (
auto I = this->end(), E = this->begin() +
N;
I != E; ++
I)
612 this->SetSizeUnchecked(
N);
620 this->destroy_range(this->begin() +
N, this->end());
621 this->SetSizeUnchecked(
N);
622 }
else if (
N > this->
size()) {
623 if (this->capacity() <
N)
625 std::uninitialized_fill(this->end(), this->begin() +
N,
NV);
626 this->SetSizeUnchecked(
N);
632 if (this->capacity() <
N)
638 if (this->
size() < NumItems) {
639 throw std::runtime_error(
"Popping back more elements than those available.");
642 this->destroy_range(this->end() - NumItems, this->end());
643 this->SetSizeUnchecked(this->
size() - NumItems);
648 T Result = ::std::move(this->back());
657 typename =
typename std::enable_if<std::is_convertible<
658 typename std::iterator_traits<in_iter>::iterator_category, std::input_iterator_tag>
::value>
::type>
663 this->grow(this->
size() + NumInputs);
666 this->SetSizeUnchecked(this->
size() + NumInputs);
673 this->grow(this->
size() + NumInputs);
676 this->SetSizeUnchecked(this->
size() + NumInputs);
688 if (this->capacity() <
NumElts)
690 this->SetSizeUnchecked(
NumElts);
691 std::uninitialized_fill(this->begin(), this->end(),
Elt);
695 typename =
typename std::enable_if<std::is_convertible<
696 typename std::iterator_traits<in_iter>::iterator_category, std::input_iterator_tag>
::value>
::type>
715 throw std::runtime_error(
"The iterator passed to `erase` is out of bounds.");
720 std::move(
I + 1, this->end(),
I);
732 if (
S < this->begin() || E > this->end() || S > E) {
733 throw std::runtime_error(
"Invalid start/end pair passed to `erase` (out of bounds or start > end).");
738 iterator I = std::move(E, this->end(), S);
741 this->destroy_range(
I, this->end());
742 this->SetSizeUnchecked(
I - this->begin());
748 if (
I == this->end()) {
749 this->push_back(::std::move(
Elt));
750 return this->end() - 1;
754 throw std::runtime_error(
"The iterator passed to `insert` is out of bounds.");
757 if (this->
size() >= this->capacity()) {
758 size_t EltNo =
I - this->begin();
760 I = this->begin() +
EltNo;
763 ::new ((
void *)this->end()) T(::std::move(this->back()));
765 std::move_backward(
I, this->end() - 1, this->end());
766 this->SetSizeUnchecked(this->
size() + 1);
780 if (
I == this->end()) {
781 this->push_back(
Elt);
782 return this->end() - 1;
786 throw std::runtime_error(
"The iterator passed to `insert` is out of bounds.");
789 if (this->
size() >= this->capacity()) {
790 size_t EltNo =
I - this->begin();
792 I = this->begin() +
EltNo;
794 ::new ((
void *)this->end()) T(std::move(this->back()));
796 std::move_backward(
I, this->end() - 1, this->end());
797 this->SetSizeUnchecked(this->
size() + 1);
814 if (
I == this->end()) {
820 throw std::runtime_error(
"The iterator passed to `insert` is out of bounds.");
824 reserve(this->
size() + NumToInsert);
835 append(std::move_iterator<iterator>(this->end() -
NumToInsert), std::move_iterator<iterator>(this->end()));
849 this->SetSizeUnchecked(this->
size() + NumToInsert);
861 template <
typename ItTy,
862 typename =
typename std::enable_if<std::is_convertible<
863 typename std::iterator_traits<ItTy>::iterator_category, std::input_iterator_tag>
::value>
::type>
869 if (
I == this->end()) {
875 throw std::runtime_error(
"The iterator passed to `insert` is out of bounds.");
881 reserve(this->
size() + NumToInsert);
892 append(std::move_iterator<iterator>(this->end() -
NumToInsert), std::move_iterator<iterator>(this->end()));
906 this->SetSizeUnchecked(this->
size() + NumToInsert);
929 ::new ((
void *)this->end()) T(std::forward<ArgTypes>(Args)...);
930 this->SetSizeUnchecked(this->
size() + 1);
946 if (!this->isSmall() && !
RHS.isSmall()) {
947 std::swap(this->fBeginX,
RHS.fBeginX);
948 std::swap(this->
fSize, RHS.fSize);
949 std::swap(this->fCapacity,
RHS.fCapacity);
955 if (this->isSmall() && !
RHS.Owns()) {
957 temp = std::move(
RHS);
958 RHS = std::move(*
this);
959 *
this = std::move(temp);
961 }
else if (
RHS.isSmall() && !
this->Owns()) {
963 temp = std::move(*
this);
964 *
this = std::move(
RHS);
965 RHS = std::move(temp);
969 if (
RHS.size() >
this->capacity())
970 this->grow(
RHS.size());
971 if (this->
size() > RHS.capacity())
976 if (NumShared >
RHS.size())
979 std::iter_swap(this->begin() + i,
RHS.
begin() + i);
982 if (this->
size() > RHS.size()) {
984 this->uninitialized_copy(this->begin() +
NumShared, this->end(),
RHS.
end());
987 this->destroy_range(this->begin() +
NumShared, this->end());
989 }
else if (
RHS.size() >
this->size()) {
992 this->SetSizeUnchecked(this->
size() + EltDiff);
1020 this->destroy_range(
NewEnd, this->end());
1023 this->SetSizeUnchecked(
RHSSize);
1031 if (this->capacity() <
RHSSize) {
1034 this->destroy_range(this->begin(), this->end());
1036 this->SetSizeUnchecked(0);
1048 this->SetSizeUnchecked(
RHSSize);
1052template <
typename T>
1060 if (!
RHS.isSmall()) {
1062 this->destroy_range(this->begin(), this->end());
1063 if (!this->isSmall())
1064 free(this->begin());
1066 this->fBeginX =
RHS.fBeginX;
1068 this->fCapacity =
RHS.fCapacity;
1085 this->destroy_range(
NewEnd, this->end());
1086 this->SetSizeUnchecked(
RHSSize);
1099 if (this->capacity() <
RHSSize) {
1102 this->destroy_range(this->begin(), this->end());
1104 this->SetSizeUnchecked(0);
1116 this->SetSizeUnchecked(
RHSSize);
1122template <
typename T>
1128template <
typename T>
1156template <
typename T,
unsigned int N>
1165 this->destroy_range(this->begin(), this->end());
1169 explicit RVecN(
size_t Size,
const T &
Value) : Detail::VecOps::RVecImpl<T>(
N) { this->assign(Size,
Value); }
1171 explicit RVecN(
size_t Size) : Detail::VecOps::RVecImpl<T>(
N)
1179 template <
typename ItTy,
1180 typename =
typename std::enable_if<std::is_convertible<
1181 typename std::iterator_traits<ItTy>::iterator_category, std::input_iterator_tag>
::value>
::type>
1187 RVecN(std::initializer_list<T>
IL) : Detail::VecOps::RVecImpl<T>(
N) { this->assign(
IL); }
1225 this->fCapacity = -1;
1249 return begin()[idx];
1254 return begin()[idx];
1262 if (
n != this->
size()) {
1263 std::string
msg =
"Cannot index RVecN of size " + std::to_string(this->
size()) +
1264 " with condition vector of different size (" + std::to_string(
n) +
").";
1265 throw std::runtime_error(
msg);
1276 ret.push_back(this->
operator[](i));
1292 std::string
msg =
"RVecN::at: size is " + std::to_string(this->
fSize) +
" but out-of-bounds index " +
1293 std::to_string(pos) +
" was requested.";
1294 throw std::out_of_range(
msg);
1296 return this->operator[](pos);
1302 std::string
msg =
"RVecN::at: size is " + std::to_string(this->
fSize) +
" but out-of-bounds index " +
1303 std::to_string(pos) +
" was requested.";
1304 throw std::out_of_range(
msg);
1306 return this->operator[](pos);
1314 return this->operator[](pos);
1322 return this->operator[](pos);
1532template <
typename T>
1543 using SuperClass::begin;
1544 using SuperClass::size;
1552 template <
typename ItTy,
1553 typename =
typename std::enable_if<std::is_convertible<
1554 typename std::iterator_traits<ItTy>::iterator_category, std::input_iterator_tag>
::value>
::type>
1565 SuperClass::operator=(
RHS);
1573 SuperClass::operator=(std::move(
RHS));
1579 template <
unsigned N>
1582 template <
unsigned N>
1593 return RVec<U>(this->begin(), this->end());
1596 using SuperClass::operator[];
1601 return RVec(SuperClass::operator[](
conds));
1604 using SuperClass::at;
1606 friend bool ROOT::Detail::VecOps::IsSmall<T>(
const RVec<T> &
v);
1608 friend bool ROOT::Detail::VecOps::IsAdopting<T>(
const RVec<T> &
v);
1611template <
typename T,
unsigned N>
1614 return X.capacity_in_bytes();
1620#define RVEC_UNARY_OPERATOR(OP) \
1621template <typename T> \
1622RVec<T> operator OP(const RVec<T> &v) \
1625 for (auto &x : ret) \
1634#undef RVEC_UNARY_OPERATOR
1640#define ERROR_MESSAGE(OP) \
1641 "Cannot call operator " #OP " on vectors of different sizes."
1643#define RVEC_BINARY_OPERATOR(OP) \
1644template <typename T0, typename T1> \
1645auto operator OP(const RVec<T0> &v, const T1 &y) \
1646 -> RVec<decltype(v[0] OP y)> \
1648 RVec<decltype(v[0] OP y)> ret(v.size()); \
1649 auto op = [&y](const T0 &x) { return x OP y; }; \
1650 std::transform(v.begin(), v.end(), ret.begin(), op); \
1654template <typename T0, typename T1> \
1655auto operator OP(const T0 &x, const RVec<T1> &v) \
1656 -> RVec<decltype(x OP v[0])> \
1658 RVec<decltype(x OP v[0])> ret(v.size()); \
1659 auto op = [&x](const T1 &y) { return x OP y; }; \
1660 std::transform(v.begin(), v.end(), ret.begin(), op); \
1664template <typename T0, typename T1> \
1665auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
1666 -> RVec<decltype(v0[0] OP v1[0])> \
1668 if (v0.size() != v1.size()) \
1669 throw std::runtime_error(ERROR_MESSAGE(OP)); \
1671 RVec<decltype(v0[0] OP v1[0])> ret(v0.size()); \
1672 auto op = [](const T0 &x, const T1 &y) { return x OP y; }; \
1673 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
1685#undef RVEC_BINARY_OPERATOR
1691#define RVEC_ASSIGNMENT_OPERATOR(OP) \
1692template <typename T0, typename T1> \
1693RVec<T0>& operator OP(RVec<T0> &v, const T1 &y) \
1695 auto op = [&y](T0 &x) { return x OP y; }; \
1696 std::transform(v.begin(), v.end(), v.begin(), op); \
1700template <typename T0, typename T1> \
1701RVec<T0>& operator OP(RVec<T0> &v0, const RVec<T1> &v1) \
1703 if (v0.size() != v1.size()) \
1704 throw std::runtime_error(ERROR_MESSAGE(OP)); \
1706 auto op = [](T0 &x, const T1 &y) { return x OP y; }; \
1707 std::transform(v0.begin(), v0.end(), v1.begin(), v0.begin(), op); \
1721#undef RVEC_ASSIGNMENT_OPERATOR
1727#define RVEC_LOGICAL_OPERATOR(OP) \
1728template <typename T0, typename T1> \
1729auto operator OP(const RVec<T0> &v, const T1 &y) \
1732 RVec<int> ret(v.size()); \
1733 auto op = [y](const T0 &x) -> int { return x OP y; }; \
1734 std::transform(v.begin(), v.end(), ret.begin(), op); \
1738template <typename T0, typename T1> \
1739auto operator OP(const T0 &x, const RVec<T1> &v) \
1742 RVec<int> ret(v.size()); \
1743 auto op = [x](const T1 &y) -> int { return x OP y; }; \
1744 std::transform(v.begin(), v.end(), ret.begin(), op); \
1748template <typename T0, typename T1> \
1749auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
1752 if (v0.size() != v1.size()) \
1753 throw std::runtime_error(ERROR_MESSAGE(OP)); \
1755 RVec<int> ret(v0.size()); \
1756 auto op = [](const T0 &x, const T1 &y) -> int { return x OP y; }; \
1757 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
1769#undef RVEC_LOGICAL_OPERATOR
1784template <
typename T>
1787template <
typename U,
typename V>
1792#define RVEC_UNARY_FUNCTION(NAME, FUNC) \
1793 template <typename T> \
1794 RVec<PromoteType<T>> NAME(const RVec<T> &v) \
1796 RVec<PromoteType<T>> ret(v.size()); \
1797 auto f = [](const T &x) { return FUNC(x); }; \
1798 std::transform(v.begin(), v.end(), ret.begin(), f); \
1802#define RVEC_BINARY_FUNCTION(NAME, FUNC) \
1803 template <typename T0, typename T1> \
1804 RVec<PromoteTypes<T0, T1>> NAME(const T0 &x, const RVec<T1> &v) \
1806 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
1807 auto f = [&x](const T1 &y) { return FUNC(x, y); }; \
1808 std::transform(v.begin(), v.end(), ret.begin(), f); \
1812 template <typename T0, typename T1> \
1813 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v, const T1 &y) \
1815 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
1816 auto f = [&y](const T0 &x) { return FUNC(x, y); }; \
1817 std::transform(v.begin(), v.end(), ret.begin(), f); \
1821 template <typename T0, typename T1> \
1822 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v0, const RVec<T1> &v1) \
1824 if (v0.size() != v1.size()) \
1825 throw std::runtime_error(ERROR_MESSAGE(NAME)); \
1827 RVec<PromoteTypes<T0, T1>> ret(v0.size()); \
1828 auto f = [](const T0 &x, const T1 &y) { return FUNC(x, y); }; \
1829 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), f); \
1833#define RVEC_STD_UNARY_FUNCTION(F) RVEC_UNARY_FUNCTION(F, std::F)
1834#define RVEC_STD_BINARY_FUNCTION(F) RVEC_BINARY_FUNCTION(F, std::F)
1881#undef RVEC_STD_UNARY_FUNCTION
1888#define RVEC_VDT_UNARY_FUNCTION(F) RVEC_UNARY_FUNCTION(F, vdt::F)
1907#undef RVEC_VDT_UNARY_FUNCTION
1911#undef RVEC_UNARY_FUNCTION
1926template <
typename T,
typename V>
1929 if (
v0.size() !=
v1.size())
1930 throw std::runtime_error(
"Cannot compute inner product of vectors of different sizes");
1931 return std::inner_product(
v0.begin(),
v0.end(),
v1.begin(),
decltype(
v0[0] *
v1[0])(0));
1957template <
typename T>
1960 return std::accumulate(
v.begin(),
v.end(),
zero);
1965 return std::accumulate(
v.begin(),
v.end(),
zero);
1969template <
typename T>
1972 return std::accumulate(
v.begin(),
v.end(), init, std::multiplies<T>());
1987template <
typename T>
1990 if (
v.empty())
return 0.;
2019template <
typename T,
typename R = T>
2022 if (
v.empty())
return zero;
2036template <
typename T>
2039 return *std::max_element(
v.begin(),
v.end());
2052template <
typename T>
2055 return *std::min_element(
v.begin(),
v.end());
2070template <
typename T>
2073 return std::distance(
v.begin(), std::max_element(
v.begin(),
v.end()));
2088template <
typename T>
2091 return std::distance(
v.begin(), std::min_element(
v.begin(),
v.end()));
2105template <
typename T>
2108 const std::size_t
size =
v.size();
2109 if (
size < std::size_t(2))
return 0.;
2112 std::for_each(
v.begin(),
v.end(),
pred);
2129template <
typename T>
2132 return std::sqrt(Var(
v));
2153template <
typename... Args>
2166 constexpr auto nArgs =
sizeof...(Args);
2169 "Map: the first N-1 arguments must be RVecs or references to RVecs");
2172 std::make_index_sequence<
sizeof...(args) - 1>());
2185template <
typename T,
typename F>
2191 for (
auto &&val :
v) {
2193 w.emplace_back(val);
2208template <
typename T>
2212 if (
static_cast<bool>(
e) ==
true)
2227template <
typename T>
2231 if (
static_cast<bool>(
e) ==
false)
2236template <
typename T>
2253template <
typename T>
2259 std::sort(i.
begin(), i.
end(), [&
v](size_type
i1, size_type
i2) { return v[i1] < v[i2]; });
2274template <
typename T,
typename Compare>
2281 [&
v, &
c](size_type
i1, size_type
i2) { return c(v[i1], v[i2]); });
2298template <
typename T>
2304 std::stable_sort(i.
begin(), i.
end(), [&
v](size_type
i1, size_type
i2) { return v[i1] < v[i2]; });
2321template <
typename T,
typename Compare>
2327 std::stable_sort(i.
begin(), i.
end(), [&
v, &
c](size_type
i1, size_type
i2) { return c(v[i1], v[i2]); });
2342template <
typename T>
2346 const size_type
isize = i.size();
2348 for (size_type k = 0; k <
isize; k++)
2354template <
typename T>
2358 const size_type
isize = i.size();
2360 for (size_type k = 0; k <
isize; k++)
2362 if (i[k] <
v.size() && i[k]>=0){
2385template <
typename T>
2389 const size_type
size =
v.size();
2390 const size_type
absn = std::abs(
n);
2392 const auto msg = std::to_string(
absn) +
" elements requested from Take but input contains only " +
2393 std::to_string(
size) +
" elements.";
2394 throw std::runtime_error(
msg);
2398 for (size_type k = 0; k <
absn; k++)
2401 for (size_type k = 0; k <
absn; k++)
2426template <
typename T>
2430 const size_type
size =
v.size();
2431 const size_type
absn = std::abs(
n);
2451template <
typename T>
2459 if (
v.size() >
idxs.size())
2460 r.reserve(
v.size() -
idxs.size());
2464 for (
sz_t i = 0
u; i <
v.size(); ++i) {
2468 r.emplace_back(
v[i]);
2484template <
typename T>
2488 std::reverse(
r.begin(),
r.end());
2505template <
typename T>
2509 std::sort(
r.begin(),
r.end());
2530template <
typename T,
typename Compare>
2534 std::sort(
r.begin(),
r.end(), std::forward<Compare>(
c));
2554template <
typename T>
2558 std::stable_sort(
r.begin(),
r.end());
2590template <
typename T,
typename Compare>
2594 std::stable_sort(
r.begin(),
r.end(), std::forward<Compare>(
c));
2612 using size_type = std::size_t;
2617 for(size_type i=0; i<
size1; i++) {
2641template <
typename T1,
typename T2>
2666template <
typename T>
2670 const size_type s =
v.size();
2672 throw std::runtime_error(
"Cannot make unique combinations of size " + std::to_string(
n) +
2673 " from vector of size " + std::to_string(s) +
".");
2677 for(size_type k=0; k<s; k++)
2682 for (size_type
m = s -
n + 2;
m <= s; ++
m)
2685 size_type
factn = 1;
2686 for (size_type i = 2; i <=
n; ++i)
2695 for (size_type k = 0; k <
n; k++)
2712 for (
long j=i+1;
j<(long)
n;
j++)
2714 for (size_type k = 0; k <
n; k++)
2730template <
typename T>
2735 const auto size =
v.size();
2737 for(size_type i=0; i<
size; i++) {
2761template <
typename T>
2769 const auto size =
v1.size();
2772 for(size_type i=0; i<
size; i++) {
2774 r.emplace_back(
v1[i]);
2795template <
typename T>
2799 const size_type
size =
c.size();
2802 for (size_type i=0; i<
size; i++) {
2803 r.emplace_back(
c[i] != 0 ?
v1[i] :
v2[i]);
2823template <
typename T>
2827 const size_type
size =
c.size();
2830 for (size_type i=0; i<
size; i++) {
2831 r.emplace_back(
c[i] != 0 ?
v1[i] :
v2);
2851template <
typename T>
2855 const size_type
size =
c.size();
2858 for (size_type i=0; i<
size; i++) {
2859 r.emplace_back(
c[i] != 0 ?
v1 :
v2[i]);
2877template <
typename T>
2881 const size_type
size =
c.size();
2884 for (size_type i=0; i<
size; i++) {
2885 r.emplace_back(
c[i] != 0 ?
v1 :
v2);
2904 res.reserve(
v0.size() +
v1.size());
2905 std::copy(
v0.begin(),
v0.end(), std::back_inserter(res));
2906 std::copy(
v1.begin(),
v1.end(), std::back_inserter(res));
2916template <
typename T0,
typename T1 = T0,
typename Common_t = std::common_type_t<T0, T1>>
2919 static_assert(std::is_floating_point<T0>::value && std::is_floating_point<T1>::value,
2920 "DeltaPhi must be called with floating point values.");
2921 auto r = std::fmod(
v2 -
v1, 2.0 *
c);
2937template <
typename T0,
typename T1 = T0,
typename Common_t =
typename std::common_type_t<T0, T1>>
2941 const size_type
size =
v1.size();
2943 for (size_type i = 0; i <
size; i++) {
2944 r[i] = DeltaPhi(
v1[i],
v2[i],
c);
2955template <
typename T0,
typename T1 = T0,
typename Common_t =
typename std::common_type_t<T0, T1>>
2959 const size_type
size =
v1.size();
2961 for (size_type i = 0; i <
size; i++) {
2962 r[i] = DeltaPhi(
v1[i],
v2,
c);
2973template <
typename T0,
typename T1 = T0,
typename Common_t =
typename std::common_type_t<T0, T1>>
2977 const size_type
size =
v2.size();
2979 for (size_type i = 0; i <
size; i++) {
2980 r[i] = DeltaPhi(
v1,
v2[i],
c);
2992template <
typename T0,
typename T1 = T0,
typename T2 = T0,
typename T3 = T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3>>
3006template <
typename T0,
typename T1 = T0,
typename T2 = T0,
typename T3 = T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3>>
3019template <
typename T0,
typename T1 = T0,
typename T2 = T0,
typename T3 = T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3>>
3031template <
typename T0,
typename T1 =
T0,
typename T2 =
T0,
typename T3 =
T0,
typename T4 =
T0,
3032 typename T5 =
T0,
typename Common_t = std::common_type_t<T0, T1>>
3045 return std::atan2(
c,
d);
3053template <
typename T0,
typename T1 =
T0,
typename T2 =
T0,
typename T3 =
T0,
typename T4 =
T0,
3054 typename T5 =
T0,
typename T6 =
T0,
typename T7 =
T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3, T4, T5, T6, T7>>
3065 return (
mass1 + mass2);
3067 auto mm =
mass1 + std::sqrt(mass2*mass2 +
p2_sq);
3068 auto m2 = mm*mm -
p2_sq;
3070 return std::sqrt( m2 );
3072 return std::sqrt( -m2 );
3076 auto m2 = mm*mm -
p1_sq;
3078 return std::sqrt( m2 );
3080 return std::sqrt( -m2 );
3084 const auto m2_sq = mass2 * mass2;
3090 const auto cos_a = std::cos(
a);
3093 y = (
x + std::sin(
a) * std::sin(
a)) / (std::sqrt(
x + 1) +
cos_a);
3109template <
typename T0,
typename T1 =
T0,
typename T2 =
T0,
typename T3 =
T0,
typename T4 =
T0,
3110 typename T5 =
T0,
typename T6 =
T0,
typename T7 =
T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3, T4, T5, T6, T7>>
3115 std::size_t
size = px1.size();
3122 for (std::size_t i = 0
u; i <
size; ++i) {
3135template <
typename T0,
typename T1 =
T0,
typename T2 =
T0,
typename T3 =
T0,
typename T4 =
T0,
3136 typename T5 =
T0,
typename T6 =
T0,
typename T7 =
T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3, T4, T5, T6, T7>>
3141 std::size_t
size =
pt1.size();
3148 for (std::size_t i = 0
u; i <
size; ++i) {
3150 const auto x1 =
pt1[i] * std::cos(
phi1[i]);
3151 const auto y1 =
pt1[i] * std::sin(
phi1[i]);
3152 const auto z1 =
pt1[i] * std::sinh(
eta1[i]);
3154 const auto x2 =
pt2[i] * std::cos(
phi2[i]);
3155 const auto y2 =
pt2[i] * std::sin(
phi2[i]);
3156 const auto z2 =
pt2[i] * std::sinh(
eta2[i]);
3171template <
typename T0,
typename T1 = T0,
typename T2 = T0,
typename T3 = T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3>>
3174 const std::size_t
size =
pt.size();
3183 for (std::size_t i = 0
u; i <
size; ++ i) {
3185 const auto x =
pt[i] * std::cos(phi[i]);
3187 const auto y =
pt[i] * std::sin(phi[i]);
3189 const auto z =
pt[i] * std::sinh(eta[i]);
3191 const auto e = std::sqrt(
x *
x +
y *
y + z * z + mass[i] * mass[i]);
3217template <
typename T,
typename...
Args_t>
3223 for (
auto i = 0
UL; i <
size; ++i) {
3224 ret.emplace_back(args[i]...);
3237template <
typename T>
3240 const auto size =
v.size();
3243 for (
auto i = 0
UL; i <
size; ++i) {
3244 ret.emplace_back(i);
3304template <
typename T =
double,
typename Ret_t = std::conditional_t<std::is_
floating_po
int_v<T>, T,
double>>
3307 if (!
n || (
n > std::numeric_limits<long long>::max()))
3312 long double step = std::is_floating_point_v<Ret_t> ?
3313 (end - start) /
static_cast<long double>(
n -
endpoint) :
3314 (end >= start ?
static_cast<long double>(end - start) / (
n -
endpoint) : (
static_cast<long double>(end) - start) / (
n -
endpoint));
3317 temp[0] = std::is_floating_point_v<Ret_t> ?
static_cast<Ret_t
>(start) : std::floor(start);
3318 if constexpr (std::is_floating_point_v<Ret_t>)
3320 for (
unsigned long long i = 1; i <
n; i++)
3322 temp[i] =
static_cast<Ret_t
>(start + i * step);
3327 for (
unsigned long long i = 1; i <
n; i++)
3329 temp[i] = std::floor(start + i * step);
3390template <
typename T =
double,
typename Ret_t = std::conditional_t<std::is_
floating_po
int_v<T>, T,
double>>
3393 if (!
n || (
n > std::numeric_limits<long long>::max()))
3400 long double end_c = end;
3401 long double base_c = base;
3405 temp[0] = std::is_floating_point_v<Ret_t> ?
3409 if constexpr (std::is_floating_point_v<Ret_t>)
3411 for (
unsigned long long i = 1; i <
n; i++)
3419 for (
unsigned long long i = 1; i <
n; i++)
3484template <
typename T =
double,
typename Ret_t = std::conditional_t<std::is_
floating_po
int_v<T>, T,
double>>
3487 unsigned long long n = std::ceil(( end >= start ? (end - start) :
static_cast<long double>(end)-start)/
static_cast<long double>(step));
3489 if (!
n || (
n > std::numeric_limits<long long>::max()))
3497 long double step_c = step;
3499 temp[0] = std::is_floating_point_v<Ret_t> ?
static_cast<Ret_t
>(start) : std::floor(start);
3500 if constexpr (std::is_floating_point_v<Ret_t>)
3502 for (
unsigned long long i = 1; i <
n; i++)
3509 for (
unsigned long long i = 1; i <
n; i++)
3528 for (
auto i = 0
UL; i <
length; ++i) {
3529 ret.emplace_back(i);
3539 ret.reserve(begin < end ? end - begin : 0
u);
3540 for (
auto i = begin; i < end; ++i)
3561 throw std::runtime_error(
"Range: the stride must not be zero");
3564 float ret_cap = std::ceil(
static_cast<float>(end-begin) /
stride);
3573 for (
auto i = begin; i < end; i+=
stride)
3578 for (
auto i = begin; i > end; i+=
stride)
3592 constexpr bool mustConvert = std::is_same<char, T>::value || std::is_same<signed char, T>::value ||
3593 std::is_same<unsigned char, T>::value || std::is_same<wchar_t, T>::value ||
3594 std::is_same<char16_t, T>::value || std::is_same<char32_t, T>::value;
3595 using Print_t =
typename std::conditional<mustConvert, long long int, T>::type;
3597 auto size =
v.size();
3599 for (std::size_t i = 0; i <
size - 1; ++i) {
3608#if (_VECOPS_USE_EXTERN_TEMPLATES)
3610#define RVEC_EXTERN_UNARY_OPERATOR(T, OP) \
3611 extern template RVec<T> operator OP<T>(const RVec<T> &);
3613#define RVEC_EXTERN_BINARY_OPERATOR(T, OP) \
3614 extern template auto operator OP<T, T>(const T &x, const RVec<T> &v) \
3615 -> RVec<decltype(x OP v[0])>; \
3616 extern template auto operator OP<T, T>(const RVec<T> &v, const T &y) \
3617 -> RVec<decltype(v[0] OP y)>; \
3618 extern template auto operator OP<T, T>(const RVec<T> &v0, const RVec<T> &v1)\
3619 -> RVec<decltype(v0[0] OP v1[0])>;
3621#define RVEC_EXTERN_ASSIGN_OPERATOR(T, OP) \
3622 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const T &); \
3623 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const RVec<T> &);
3625#define RVEC_EXTERN_LOGICAL_OPERATOR(T, OP) \
3626 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const T &); \
3627 extern template RVec<int> operator OP<T, T>(const T &, const RVec<T> &); \
3628 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const RVec<T> &);
3630#define RVEC_EXTERN_FLOAT_TEMPLATE(T) \
3631 extern template class RVec<T>; \
3632 RVEC_EXTERN_UNARY_OPERATOR(T, +) \
3633 RVEC_EXTERN_UNARY_OPERATOR(T, -) \
3634 RVEC_EXTERN_UNARY_OPERATOR(T, !) \
3635 RVEC_EXTERN_BINARY_OPERATOR(T, +) \
3636 RVEC_EXTERN_BINARY_OPERATOR(T, -) \
3637 RVEC_EXTERN_BINARY_OPERATOR(T, *) \
3638 RVEC_EXTERN_BINARY_OPERATOR(T, /) \
3639 RVEC_EXTERN_ASSIGN_OPERATOR(T, +=) \
3640 RVEC_EXTERN_ASSIGN_OPERATOR(T, -=) \
3641 RVEC_EXTERN_ASSIGN_OPERATOR(T, *=) \
3642 RVEC_EXTERN_ASSIGN_OPERATOR(T, /=) \
3643 RVEC_EXTERN_LOGICAL_OPERATOR(T, <) \
3644 RVEC_EXTERN_LOGICAL_OPERATOR(T, >) \
3645 RVEC_EXTERN_LOGICAL_OPERATOR(T, ==) \
3646 RVEC_EXTERN_LOGICAL_OPERATOR(T, !=) \
3647 RVEC_EXTERN_LOGICAL_OPERATOR(T, <=) \
3648 RVEC_EXTERN_LOGICAL_OPERATOR(T, >=) \
3649 RVEC_EXTERN_LOGICAL_OPERATOR(T, &&) \
3650 RVEC_EXTERN_LOGICAL_OPERATOR(T, ||)
3652#define RVEC_EXTERN_INTEGER_TEMPLATE(T) \
3653 extern template class RVec<T>; \
3654 RVEC_EXTERN_UNARY_OPERATOR(T, +) \
3655 RVEC_EXTERN_UNARY_OPERATOR(T, -) \
3656 RVEC_EXTERN_UNARY_OPERATOR(T, ~) \
3657 RVEC_EXTERN_UNARY_OPERATOR(T, !) \
3658 RVEC_EXTERN_BINARY_OPERATOR(T, +) \
3659 RVEC_EXTERN_BINARY_OPERATOR(T, -) \
3660 RVEC_EXTERN_BINARY_OPERATOR(T, *) \
3661 RVEC_EXTERN_BINARY_OPERATOR(T, /) \
3662 RVEC_EXTERN_BINARY_OPERATOR(T, %) \
3663 RVEC_EXTERN_BINARY_OPERATOR(T, &) \
3664 RVEC_EXTERN_BINARY_OPERATOR(T, |) \
3665 RVEC_EXTERN_BINARY_OPERATOR(T, ^) \
3666 RVEC_EXTERN_ASSIGN_OPERATOR(T, +=) \
3667 RVEC_EXTERN_ASSIGN_OPERATOR(T, -=) \
3668 RVEC_EXTERN_ASSIGN_OPERATOR(T, *=) \
3669 RVEC_EXTERN_ASSIGN_OPERATOR(T, /=) \
3670 RVEC_EXTERN_ASSIGN_OPERATOR(T, %=) \
3671 RVEC_EXTERN_ASSIGN_OPERATOR(T, &=) \
3672 RVEC_EXTERN_ASSIGN_OPERATOR(T, |=) \
3673 RVEC_EXTERN_ASSIGN_OPERATOR(T, ^=) \
3674 RVEC_EXTERN_ASSIGN_OPERATOR(T, >>=) \
3675 RVEC_EXTERN_ASSIGN_OPERATOR(T, <<=) \
3676 RVEC_EXTERN_LOGICAL_OPERATOR(T, <) \
3677 RVEC_EXTERN_LOGICAL_OPERATOR(T, >) \
3678 RVEC_EXTERN_LOGICAL_OPERATOR(T, ==) \
3679 RVEC_EXTERN_LOGICAL_OPERATOR(T, !=) \
3680 RVEC_EXTERN_LOGICAL_OPERATOR(T, <=) \
3681 RVEC_EXTERN_LOGICAL_OPERATOR(T, >=) \
3682 RVEC_EXTERN_LOGICAL_OPERATOR(T, &&) \
3683 RVEC_EXTERN_LOGICAL_OPERATOR(T, ||)
3700#undef RVEC_EXTERN_UNARY_OPERATOR
3701#undef RVEC_EXTERN_BINARY_OPERATOR
3702#undef RVEC_EXTERN_ASSIGN_OPERATOR
3703#undef RVEC_EXTERN_LOGICAL_OPERATOR
3704#undef RVEC_EXTERN_INTEGER_TEMPLATE
3705#undef RVEC_EXTERN_FLOAT_TEMPLATE
3707#define RVEC_EXTERN_UNARY_FUNCTION(T, NAME, FUNC) \
3708 extern template RVec<PromoteType<T>> NAME(const RVec<T> &);
3710#define RVEC_EXTERN_STD_UNARY_FUNCTION(T, F) RVEC_EXTERN_UNARY_FUNCTION(T, F, std::F)
3712#define RVEC_EXTERN_BINARY_FUNCTION(T0, T1, NAME, FUNC) \
3713 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const T1 &); \
3714 extern template RVec<PromoteTypes<T0, T1>> NAME(const T0 &, const RVec<T1> &); \
3715 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const RVec<T1> &);
3717#define RVEC_EXTERN_STD_BINARY_FUNCTION(T, F) RVEC_EXTERN_BINARY_FUNCTION(T, T, F, std::F)
3719#define RVEC_EXTERN_STD_FUNCTIONS(T) \
3720 RVEC_EXTERN_STD_UNARY_FUNCTION(T, abs) \
3721 RVEC_EXTERN_STD_BINARY_FUNCTION(T, fdim) \
3722 RVEC_EXTERN_STD_BINARY_FUNCTION(T, fmod) \
3723 RVEC_EXTERN_STD_BINARY_FUNCTION(T, remainder) \
3724 RVEC_EXTERN_STD_UNARY_FUNCTION(T, exp) \
3725 RVEC_EXTERN_STD_UNARY_FUNCTION(T, exp2) \
3726 RVEC_EXTERN_STD_UNARY_FUNCTION(T, expm1) \
3727 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log) \
3728 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log10) \
3729 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log2) \
3730 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log1p) \
3731 RVEC_EXTERN_STD_BINARY_FUNCTION(T, pow) \
3732 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sqrt) \
3733 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cbrt) \
3734 RVEC_EXTERN_STD_BINARY_FUNCTION(T, hypot) \
3735 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sin) \
3736 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cos) \
3737 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tan) \
3738 RVEC_EXTERN_STD_UNARY_FUNCTION(T, asin) \
3739 RVEC_EXTERN_STD_UNARY_FUNCTION(T, acos) \
3740 RVEC_EXTERN_STD_UNARY_FUNCTION(T, atan) \
3741 RVEC_EXTERN_STD_BINARY_FUNCTION(T, atan2) \
3742 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sinh) \
3743 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cosh) \
3744 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tanh) \
3745 RVEC_EXTERN_STD_UNARY_FUNCTION(T, asinh) \
3746 RVEC_EXTERN_STD_UNARY_FUNCTION(T, acosh) \
3747 RVEC_EXTERN_STD_UNARY_FUNCTION(T, atanh) \
3748 RVEC_EXTERN_STD_UNARY_FUNCTION(T, floor) \
3749 RVEC_EXTERN_STD_UNARY_FUNCTION(T, ceil) \
3750 RVEC_EXTERN_STD_UNARY_FUNCTION(T, trunc) \
3751 RVEC_EXTERN_STD_UNARY_FUNCTION(T, round) \
3752 RVEC_EXTERN_STD_UNARY_FUNCTION(T, erf) \
3753 RVEC_EXTERN_STD_UNARY_FUNCTION(T, erfc) \
3754 RVEC_EXTERN_STD_UNARY_FUNCTION(T, lgamma) \
3755 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tgamma) \
3759#undef RVEC_EXTERN_STD_UNARY_FUNCTION
3760#undef RVEC_EXTERN_STD_BINARY_FUNCTION
3761#undef RVEC_EXTERN_STD_UNARY_FUNCTIONS
3765#define RVEC_EXTERN_VDT_UNARY_FUNCTION(T, F) RVEC_EXTERN_UNARY_FUNCTION(T, F, vdt::F)
#define R__unlikely(expr)
#define R__RVEC_NODISCARD
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
#define R__CLING_PTRCHECK(ONOFF)
static Double_t Product(const Double_t *x, const Float_t *y)
Product.
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Double_t Dot(const TGLVector3 &v1, const TGLVector3 &v2)
Int_t Compare(const void *item1, const void *item2)
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char y1
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void assign(size_type NumElts, const T &Elt)
typename SuperClass::size_type size_type
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
iterator insert(iterator I, T &&Elt)
void assign(std::initializer_list< T > IL)
void resize(size_type N, const T &NV)
void reserve(size_type N)
iterator insert(iterator I, ItTy From, ItTy To)
reference emplace_back(ArgTypes &&...Args)
RVecImpl & operator=(RVecImpl &&RHS) noexcept(kIsNoExcept)
void assign(in_iter in_start, in_iter in_end)
iterator insert(iterator I, const T &Elt)
iterator insert(iterator I, size_type NumToInsert, const T &Elt)
RVecImpl & operator=(const RVecImpl &RHS)
iterator erase(const_iterator CS, const_iterator CE)
typename SuperClass::reference reference
void append(size_type NumInputs, const T &Elt)
Append NumInputs copies of Elt to the end.
iterator erase(const_iterator CI)
void pop_back_n(size_type NumItems)
RVecImpl(const RVecImpl &)=delete
void append(std::initializer_list< T > IL)
void insert(iterator I, std::initializer_list< T > IL)
This is all the stuff common to all SmallVectors.
SmallVectorBase(void *FirstEl, size_t TotalCapacity)
static constexpr size_t SizeTypeMax()
The maximum value of the Size_T used.
Size_T fCapacity
Always >= -1. fCapacity == -1 indicates the RVec is in "memory adoption" mode.
void SetSizeUnchecked(std::size_t N)
bool Owns() const
If false, the RVec is in "memory adoption" mode, i.e. it is acting as a view on a memory buffer it do...
size_t capacity() const noexcept
void set_size(size_t N)
Set the array size to N, which the current array must have enough capacity for.
void grow(size_t MinSize=0)
Double the size of the allocated memory, guaranteeing space for at least one more element or MinSize ...
typename SuperClass::size_type size_type
typename SuperClass::reference reference
void push_back(const T &Elt)
static void uninitialized_move(It1 I, It1 E, It2 Dest)
Move the range [I, E) onto the uninitialized memory starting with "Dest", constructing elements into ...
SmallVectorTemplateBase(size_t Size)
static void uninitialized_copy(T1 *I, T1 *E, T2 *Dest, typename std::enable_if< std::is_same< typename std::remove_const< T1 >::type, T2 >::value >::type *=nullptr)
Copy the range [I, E) onto the uninitialized memory starting with "Dest", constructing elements into ...
static void destroy_range(T *, T *)
static void uninitialized_copy(It1 I, It1 E, It2 Dest)
Copy the range [I, E) onto the uninitialized memory starting with "Dest", constructing elements into ...
SmallVectorTemplateBase<TriviallyCopyable = false> - This is where we put method implementations that...
void push_back(const T &Elt)
void grow(size_t MinSize=0)
Grow the allocated memory (without initializing new elements), doubling the size of the allocated mem...
static void uninitialized_move(It1 I, It1 E, It2 Dest)
Move the range [I, E) into the uninitialized memory starting with "Dest", constructing elements as ne...
SmallVectorTemplateBase(size_t Size)
static void destroy_range(T *S, T *E)
static void uninitialized_copy(It1 I, It1 E, It2 Dest)
Copy the range [I, E) onto the uninitialized memory starting with "Dest", constructing elements as ne...
This is the part of SmallVectorTemplateBase which does not depend on whether the type T is a POD.
size_type max_size() const noexcept
const_iterator cbegin() const noexcept
void grow_pod(size_t MinSize, size_t TSize)
ptrdiff_t difference_type
reverse_iterator rbegin() noexcept
const_iterator cend() const noexcept
const_reference back() const
void resetToSmall()
Put this vector in a state of being small.
iterator begin() noexcept
std::reverse_iterator< iterator > reverse_iterator
const T & const_reference
bool isSmall() const
Return true if this is a smallvector which has not had dynamic memory allocated for it.
const_reverse_iterator crend() const noexcept
const_iterator end() const noexcept
SmallVectorTemplateCommon(size_t Size)
const_reverse_iterator crbegin() const noexcept
pointer data() noexcept
Return a pointer to the vector's buffer, even if empty().
size_t capacity_in_bytes() const
reverse_iterator rend() noexcept
const_reverse_iterator rbegin() const noexcept
const_reference front() const
size_type size_in_bytes() const
std::reverse_iterator< const_iterator > const_reverse_iterator
const_iterator begin() const noexcept
const_pointer data() const noexcept
Return a pointer to the vector's buffer, even if empty().
void * getFirstEl() const
Find the address of the first element.
const_reverse_iterator rend() const noexcept
const_iterator begin() const
const_iterator end() const
RVecN(Detail::VecOps::RVecImpl< T > &&RHS)
reference operator[](size_type idx)
RVecN(RVecN &&RHS) noexcept(false)
typename Internal::VecOps::SmallVectorTemplateCommon< T >::const_reference const_reference
RVecN operator[](const RVecN< V, M > &conds) const
RVecN(std::initializer_list< T > IL)
const_reference at(size_type pos) const
RVecN & operator=(Detail::VecOps::RVecImpl< T > &&RHS)
typename Internal::VecOps::SmallVectorTemplateCommon< T >::size_type size_type
value_type at(size_type pos, value_type fallback) const
No exception thrown. The user specifies the desired value in case the RVecN is shorter than pos.
RVecN & operator=(std::initializer_list< T > IL)
RVecN & operator=(const RVecN &RHS)
RVecN & operator=(RVecN &&RHS) noexcept(std::is_nothrow_move_assignable_v< Detail::VecOps::RVecImpl< T > >)
RVecN(const std::vector< T > &RHS)
RVecN(size_t Size, const T &Value)
reference at(size_type pos)
value_type at(size_type pos, value_type fallback)
No exception thrown. The user specifies the desired value in case the RVecN is shorter than pos.
typename Internal::VecOps::SmallVectorTemplateCommon< T >::reference reference
typename Internal::VecOps::SmallVectorTemplateCommon< T >::value_type value_type
const_reference operator[](size_type idx) const
A "std::vector"-like collection of values implementing handy operation to analyse them.
RVec(RVecN< T, N > &&RHS)
typename SuperClass::reference reference
RVec(RVec &&RHS) noexcept(std::is_nothrow_move_constructible_v< SuperClass >)
RVec(const RVecN< T, N > &RHS)
RVec(size_t Size, const T &Value)
RVec & operator=(RVec &&RHS) noexcept(std::is_nothrow_move_assignable_v< SuperClass >)
RVec operator[](const RVec< V > &conds) const
RVec(std::initializer_list< T > IL)
typename SuperClass::const_reference const_reference
RVec(const std::vector< T > &RHS)
typename SuperClass::size_type size_type
RVec(Detail::VecOps::RVecImpl< T > &&RHS)
typename SuperClass::value_type value_type
RVec & operator=(const RVec &RHS)
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.
RVec< typename RVec< T >::size_type > Nonzero(const RVec< T > &v)
Return the indices of the elements which are not zero.
#define RVEC_UNARY_OPERATOR(OP)
#define RVEC_ASSIGNMENT_OPERATOR(OP)
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.
RVec< Common_t > Concatenate(const RVec< T0 > &v0, const RVec< T1 > &v1)
Return the concatenation of two RVecs.
Common_t 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),...
T Sum(const RVec< T > &v, const T zero=T(0))
Sum elements of an RVec.
RVec< Common_t > 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 momentu...
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.
#define RVEC_STD_BINARY_FUNCTION(F)
#define RVEC_BINARY_OPERATOR(OP)
RVec< T > 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.
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}.
size_t CapacityInBytes(const RVecN< T, N > &X)
#define RVEC_LOGICAL_OPERATOR(OP)
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.
#define RVEC_STD_UNARY_FUNCTION(F)
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...
auto Map(Args &&... args)
Create new collection applying a callable to the elements of the input collection.
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< 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.
RVec< Ret_t > Arange(T start, T end, T step)
Produce RVec with entries in the range [start, end) in increments of step.
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...
RVec< T > StableSort(const RVec< T > &v)
Return copy of RVec with elements sorted in ascending order while keeping the order of equal elements...
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...
bool IsSmall(const ROOT::VecOps::RVec< T > &v)
bool IsAdopting(const ROOT::VecOps::RVec< T > &v)
auto MapImpl(F &&f, RVecs &&... vs) -> RVec< decltype(f(vs[0]...))>
void ResetView(RVec< T > &v, T *addr, std::size_t sz)
An unsafe function to reset the buffer for which this RVec is acting as a view.
uint64_t NextPowerOf2(uint64_t A)
Return the next power of two (in 64-bits) that is strictly greater than A.
constexpr bool All(const bool *vals, std::size_t size)
std::size_t GetVectorsSize(const std::string &id, const RVec< T > &... vs)
void UninitializedValueConstruct(ForwardIt first, ForwardIt last)
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)...))
The size of the inline storage of an RVec.
Used to figure out the offset of the first element of an RVec.
Storage for the SmallVector elements.