18 #ifndef _USE_MATH_DEFINES
19 #define _USE_MATH_DEFINES
23 #undef _USE_MATH_DEFINES
25 #define _VECOPS_USE_EXTERN_TEMPLATES false
27 #define _VECOPS_USE_EXTERN_TEMPLATES true
50#include <vdt/vdtMath.h>
75constexpr bool All(
const bool *vals, std::size_t
size)
77 for (
auto i = 0
u; i <
size; ++i)
83template <
typename... T>
86 constexpr const auto nArgs =
sizeof...(T);
87 const std::size_t
sizes[] = {
vs.size()...};
89 for (
auto i = 1UL; i <
nArgs; i++) {
93 msg +=
": input RVec instances have different lengths!";
94 throw std::runtime_error(
msg);
100template <
typename F,
typename...
RVecs>
106 for (
auto i = 0
UL; i <
size; i++)
112template <
typename Tuple_t, std::size_t...
Is>
114 ->
decltype(
MapImpl(std::get<std::tuple_size<Tuple_t>::value - 1>(t), std::get<Is>(t)...))
116 constexpr const auto tupleSizeM1 = std::tuple_size<Tuple_t>::value - 1;
117 return MapImpl(std::get<tupleSizeM1>(t), std::get<Is>(t)...);
149 static constexpr size_t SizeTypeMax() {
return std::numeric_limits<Size_T>::max(); }
157 void grow_pod(
void *FirstEl,
size_t MinSize,
size_t TSize);
161 static void report_size_overflow(
size_t MinSize);
164 static void report_at_maximum_capacity();
167 bool Owns()
const {
return fCapacity != -1; }
188 if (
N > capacity()) {
189 throw std::runtime_error(
"Setting size to a value greater than capacity.");
199 alignas(T)
char FirstEl[
sizeof(T)];
212 return const_cast<void *
>(
reinterpret_cast<const void *
>(
reinterpret_cast<const char *
>(
this) +
222 fBeginX = getFirstEl();
229 bool isSmall()
const {
return this->fBeginX == getFirstEl(); }
234 this->fBeginX = getFirstEl();
237 this->
fSize = this->fCapacity = 0;
257 using Base::capacity;
290 throw std::runtime_error(
"`front` called on an empty RVec");
298 throw std::runtime_error(
"`front` called on an empty RVec");
306 throw std::runtime_error(
"`back` called on an empty RVec");
314 throw std::runtime_error(
"`back` called on an empty RVec");
328template <
typename T,
bool = (std::is_trivially_copy_constructible<T>::value) &&
329 (std::is_trivially_move_constructible<T>::value) &&
330 std::is_trivially_destructible<T>::value>
345 template <
typename It1,
typename It2>
348 std::uninitialized_copy(std::make_move_iterator(
I), std::make_move_iterator(E),
Dest);
353 template <
typename It1,
typename It2>
356 std::uninitialized_copy(
I, E,
Dest);
370 this->SetSizeUnchecked(this->
size() + 1);
377 ::new ((
void *)this->end()) T(::std::move(
Elt));
378 this->SetSizeUnchecked(this->
size() + 1);
383 this->SetSizeUnchecked(this->
size() - 1);
389template <
typename T,
bool TriviallyCopyable>
394 if (MinSize > this->SizeTypeMax())
395 this->report_size_overflow(MinSize);
401 if (this->capacity() == this->SizeTypeMax())
402 this->report_at_maximum_capacity();
411 this->uninitialized_move(this->begin(), this->end(),
NewElts);
415 destroy_range(this->begin(), this->end());
418 if (!this->isSmall())
442 template <
typename It1,
typename It2>
446 uninitialized_copy(
I, E,
Dest);
451 template <
typename It1,
typename It2>
455 std::uninitialized_copy(
I, E,
Dest);
460 template <
typename T1,
typename T2>
463 typename std::enable_if<std::is_same<
typename std::remove_const<T1>::type,
T2>
::value>
::type * =
nullptr)
470 memcpy(
reinterpret_cast<void *
>(
Dest),
I, (E -
I) *
sizeof(T));
477 this->grow_pod(MinSize,
sizeof(T));
490 memcpy(
reinterpret_cast<void *
>(this->end()), &
Elt,
sizeof(T));
491 this->SetSizeUnchecked(this->
size() + 1);
499template <
typename T,
unsigned N>
501 alignas(T)
char InlineElts[
N *
sizeof(T)]{};
518 static constexpr unsigned elementsPerCacheLine = (cacheLineSize -
sizeof(
SmallVectorBase)) /
sizeof(T);
519 static constexpr unsigned maxInlineByteSize = 1024;
523 elementsPerCacheLine >= 8 ? elementsPerCacheLine : (
sizeof(T) * 8 > maxInlineByteSize ? 0 : 8);
549 static constexpr bool kIsNoExcept = std::is_nothrow_destructible_v<T> && std::is_nothrow_move_constructible_v<T>;
559 explicit RVecImpl(
unsigned N) :
ROOT::Internal::VecOps::SmallVectorTemplateBase<T>(
N) {}
568 if (!this->isSmall() && this->Owns())
576 this->destroy_range(this->begin(), this->end());
579 this->resetToSmall();
587 this->destroy_range(this->begin() +
N, this->end());
588 this->SetSizeUnchecked(
N);
589 }
else if (
N > this->
size()) {
590 if (this->capacity() <
N)
592 for (
auto I = this->end(), E = this->begin() +
N;
I != E; ++
I)
594 this->SetSizeUnchecked(
N);
602 this->destroy_range(this->begin() +
N, this->end());
603 this->SetSizeUnchecked(
N);
604 }
else if (
N > this->
size()) {
605 if (this->capacity() <
N)
607 std::uninitialized_fill(this->end(), this->begin() +
N,
NV);
608 this->SetSizeUnchecked(
N);
614 if (this->capacity() <
N)
620 if (this->
size() < NumItems) {
621 throw std::runtime_error(
"Popping back more elements than those available.");
624 this->destroy_range(this->end() - NumItems, this->end());
625 this->SetSizeUnchecked(this->
size() - NumItems);
630 T Result = ::std::move(this->back());
639 typename =
typename std::enable_if<std::is_convertible<
640 typename std::iterator_traits<in_iter>::iterator_category, std::input_iterator_tag>
::value>
::type>
645 this->grow(this->
size() + NumInputs);
648 this->SetSizeUnchecked(this->
size() + NumInputs);
655 this->grow(this->
size() + NumInputs);
658 this->SetSizeUnchecked(this->
size() + NumInputs);
670 if (this->capacity() <
NumElts)
672 this->SetSizeUnchecked(
NumElts);
673 std::uninitialized_fill(this->begin(), this->end(),
Elt);
677 typename =
typename std::enable_if<std::is_convertible<
678 typename std::iterator_traits<in_iter>::iterator_category, std::input_iterator_tag>
::value>
::type>
697 throw std::runtime_error(
"The iterator passed to `erase` is out of bounds.");
702 std::move(
I + 1, this->end(),
I);
714 if (
S < this->begin() || E > this->end() || S > E) {
715 throw std::runtime_error(
"Invalid start/end pair passed to `erase` (out of bounds or start > end).");
720 iterator I = std::move(E, this->end(), S);
723 this->destroy_range(
I, this->end());
724 this->SetSizeUnchecked(
I - this->begin());
730 if (
I == this->end()) {
731 this->push_back(::std::move(
Elt));
732 return this->end() - 1;
736 throw std::runtime_error(
"The iterator passed to `insert` is out of bounds.");
739 if (this->
size() >= this->capacity()) {
740 size_t EltNo =
I - this->begin();
742 I = this->begin() +
EltNo;
745 ::new ((
void *)this->end()) T(::std::move(this->back()));
747 std::move_backward(
I, this->end() - 1, this->end());
748 this->SetSizeUnchecked(this->
size() + 1);
762 if (
I == this->end()) {
763 this->push_back(
Elt);
764 return this->end() - 1;
768 throw std::runtime_error(
"The iterator passed to `insert` is out of bounds.");
771 if (this->
size() >= this->capacity()) {
772 size_t EltNo =
I - this->begin();
774 I = this->begin() +
EltNo;
776 ::new ((
void *)this->end()) T(std::move(this->back()));
778 std::move_backward(
I, this->end() - 1, this->end());
779 this->SetSizeUnchecked(this->
size() + 1);
796 if (
I == this->end()) {
802 throw std::runtime_error(
"The iterator passed to `insert` is out of bounds.");
806 reserve(this->
size() + NumToInsert);
817 append(std::move_iterator<iterator>(this->end() -
NumToInsert), std::move_iterator<iterator>(this->end()));
831 this->SetSizeUnchecked(this->
size() + NumToInsert);
843 template <
typename ItTy,
844 typename =
typename std::enable_if<std::is_convertible<
845 typename std::iterator_traits<ItTy>::iterator_category, std::input_iterator_tag>
::value>
::type>
851 if (
I == this->end()) {
857 throw std::runtime_error(
"The iterator passed to `insert` is out of bounds.");
863 reserve(this->
size() + NumToInsert);
874 append(std::move_iterator<iterator>(this->end() -
NumToInsert), std::move_iterator<iterator>(this->end()));
888 this->SetSizeUnchecked(this->
size() + NumToInsert);
911 ::new ((
void *)this->end()) T(std::forward<ArgTypes>(Args)...);
912 this->SetSizeUnchecked(this->
size() + 1);
928 if (!this->isSmall() && !
RHS.isSmall()) {
929 std::swap(this->fBeginX,
RHS.fBeginX);
930 std::swap(this->
fSize, RHS.fSize);
931 std::swap(this->fCapacity,
RHS.fCapacity);
937 if (this->isSmall() && !
RHS.Owns()) {
939 temp = std::move(
RHS);
940 RHS = std::move(*
this);
941 *
this = std::move(temp);
943 }
else if (
RHS.isSmall() && !
this->Owns()) {
945 temp = std::move(*
this);
946 *
this = std::move(
RHS);
947 RHS = std::move(temp);
951 if (
RHS.size() >
this->capacity())
952 this->grow(
RHS.size());
953 if (this->
size() > RHS.capacity())
958 if (NumShared >
RHS.size())
961 std::iter_swap(this->begin() + i,
RHS.
begin() + i);
964 if (this->
size() > RHS.size()) {
966 this->uninitialized_copy(this->begin() +
NumShared, this->end(),
RHS.
end());
969 this->destroy_range(this->begin() +
NumShared, this->end());
971 }
else if (
RHS.size() >
this->size()) {
974 this->SetSizeUnchecked(this->
size() + EltDiff);
1002 this->destroy_range(
NewEnd, this->end());
1005 this->SetSizeUnchecked(
RHSSize);
1013 if (this->capacity() <
RHSSize) {
1016 this->destroy_range(this->begin(), this->end());
1018 this->SetSizeUnchecked(0);
1030 this->SetSizeUnchecked(
RHSSize);
1034template <
typename T>
1042 if (!
RHS.isSmall()) {
1044 this->destroy_range(this->begin(), this->end());
1045 if (!this->isSmall())
1046 free(this->begin());
1048 this->fBeginX =
RHS.fBeginX;
1050 this->fCapacity =
RHS.fCapacity;
1067 this->destroy_range(
NewEnd, this->end());
1068 this->SetSizeUnchecked(
RHSSize);
1081 if (this->capacity() <
RHSSize) {
1084 this->destroy_range(this->begin(), this->end());
1086 this->SetSizeUnchecked(0);
1098 this->SetSizeUnchecked(
RHSSize);
1104template <
typename T>
1110template <
typename T>
1138template <
typename T,
unsigned int N>
1147 this->destroy_range(this->begin(), this->end());
1151 explicit RVecN(
size_t Size,
const T &
Value) : Detail::VecOps::RVecImpl<T>(
N) { this->assign(Size,
Value); }
1153 explicit RVecN(
size_t Size) : Detail::VecOps::RVecImpl<T>(
N)
1158 std::uninitialized_value_construct(this->begin(), this->end());
1161 template <
typename ItTy,
1162 typename =
typename std::enable_if<std::is_convertible<
1163 typename std::iterator_traits<ItTy>::iterator_category, std::input_iterator_tag>
::value>
::type>
1169 RVecN(std::initializer_list<T>
IL) : Detail::VecOps::RVecImpl<T>(
N) { this->assign(
IL); }
1207 this->fCapacity = -1;
1231 return begin()[idx];
1236 return begin()[idx];
1244 if (
n != this->
size()) {
1245 std::string
msg =
"Cannot index RVecN of size " + std::to_string(this->
size()) +
1246 " with condition vector of different size (" + std::to_string(
n) +
").";
1247 throw std::runtime_error(
msg);
1258 ret.push_back(this->
operator[](i));
1274 std::string
msg =
"RVecN::at: size is " + std::to_string(this->
fSize) +
" but out-of-bounds index " +
1275 std::to_string(pos) +
" was requested.";
1276 throw std::out_of_range(
msg);
1278 return this->operator[](pos);
1284 std::string
msg =
"RVecN::at: size is " + std::to_string(this->
fSize) +
" but out-of-bounds index " +
1285 std::to_string(pos) +
" was requested.";
1286 throw std::out_of_range(
msg);
1288 return this->operator[](pos);
1296 return this->operator[](pos);
1304 return this->operator[](pos);
1514template <
typename T>
1525 using SuperClass::begin;
1526 using SuperClass::size;
1534 template <
typename ItTy,
1535 typename =
typename std::enable_if<std::is_convertible<
1536 typename std::iterator_traits<ItTy>::iterator_category, std::input_iterator_tag>
::value>
::type>
1547 SuperClass::operator=(
RHS);
1555 SuperClass::operator=(std::move(
RHS));
1561 template <
unsigned N>
1564 template <
unsigned N>
1575 return RVec<U>(this->begin(), this->end());
1578 using SuperClass::operator[];
1583 return RVec(SuperClass::operator[](
conds));
1586 using SuperClass::at;
1588 friend bool ROOT::Detail::VecOps::IsSmall<T>(
const RVec<T> &
v);
1590 friend bool ROOT::Detail::VecOps::IsAdopting<T>(
const RVec<T> &
v);
1593template <
typename T,
unsigned N>
1596 return X.capacity_in_bytes();
1602#define RVEC_UNARY_OPERATOR(OP) \
1603template <typename T> \
1604RVec<T> operator OP(const RVec<T> &v) \
1607 for (auto &x : ret) \
1616#undef RVEC_UNARY_OPERATOR
1622#define ERROR_MESSAGE(OP) \
1623 "Cannot call operator " #OP " on vectors of different sizes."
1625#define RVEC_BINARY_OPERATOR(OP) \
1626template <typename T0, typename T1> \
1627auto operator OP(const RVec<T0> &v, const T1 &y) \
1628 -> RVec<decltype(v[0] OP y)> \
1630 RVec<decltype(v[0] OP y)> ret(v.size()); \
1631 auto op = [&y](const T0 &x) { return x OP y; }; \
1632 std::transform(v.begin(), v.end(), ret.begin(), op); \
1636template <typename T0, typename T1> \
1637auto operator OP(const T0 &x, const RVec<T1> &v) \
1638 -> RVec<decltype(x OP v[0])> \
1640 RVec<decltype(x OP v[0])> ret(v.size()); \
1641 auto op = [&x](const T1 &y) { return x OP y; }; \
1642 std::transform(v.begin(), v.end(), ret.begin(), op); \
1646template <typename T0, typename T1> \
1647auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
1648 -> RVec<decltype(v0[0] OP v1[0])> \
1650 if (v0.size() != v1.size()) \
1651 throw std::runtime_error(ERROR_MESSAGE(OP)); \
1653 RVec<decltype(v0[0] OP v1[0])> ret(v0.size()); \
1654 auto op = [](const T0 &x, const T1 &y) { return x OP y; }; \
1655 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
1667#undef RVEC_BINARY_OPERATOR
1673#define RVEC_ASSIGNMENT_OPERATOR(OP) \
1674template <typename T0, typename T1> \
1675RVec<T0>& operator OP(RVec<T0> &v, const T1 &y) \
1677 auto op = [&y](T0 &x) { return x OP y; }; \
1678 std::transform(v.begin(), v.end(), v.begin(), op); \
1682template <typename T0, typename T1> \
1683RVec<T0>& operator OP(RVec<T0> &v0, const RVec<T1> &v1) \
1685 if (v0.size() != v1.size()) \
1686 throw std::runtime_error(ERROR_MESSAGE(OP)); \
1688 auto op = [](T0 &x, const T1 &y) { return x OP y; }; \
1689 std::transform(v0.begin(), v0.end(), v1.begin(), v0.begin(), op); \
1703#undef RVEC_ASSIGNMENT_OPERATOR
1709#define RVEC_LOGICAL_OPERATOR(OP) \
1710template <typename T0, typename T1> \
1711auto operator OP(const RVec<T0> &v, const T1 &y) \
1714 RVec<int> ret(v.size()); \
1715 auto op = [y](const T0 &x) -> int { return x OP y; }; \
1716 std::transform(v.begin(), v.end(), ret.begin(), op); \
1720template <typename T0, typename T1> \
1721auto operator OP(const T0 &x, const RVec<T1> &v) \
1724 RVec<int> ret(v.size()); \
1725 auto op = [x](const T1 &y) -> int { return x OP y; }; \
1726 std::transform(v.begin(), v.end(), ret.begin(), op); \
1730template <typename T0, typename T1> \
1731auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
1734 if (v0.size() != v1.size()) \
1735 throw std::runtime_error(ERROR_MESSAGE(OP)); \
1737 RVec<int> ret(v0.size()); \
1738 auto op = [](const T0 &x, const T1 &y) -> int { return x OP y; }; \
1739 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
1751#undef RVEC_LOGICAL_OPERATOR
1766template <
typename T>
1769template <
typename U,
typename V>
1774#define RVEC_UNARY_FUNCTION(NAME, FUNC) \
1775 template <typename T> \
1776 RVec<PromoteType<T>> NAME(const RVec<T> &v) \
1778 RVec<PromoteType<T>> ret(v.size()); \
1779 auto f = [](const T &x) { return FUNC(x); }; \
1780 std::transform(v.begin(), v.end(), ret.begin(), f); \
1784#define RVEC_BINARY_FUNCTION(NAME, FUNC) \
1785 template <typename T0, typename T1> \
1786 RVec<PromoteTypes<T0, T1>> NAME(const T0 &x, const RVec<T1> &v) \
1788 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
1789 auto f = [&x](const T1 &y) { return FUNC(x, y); }; \
1790 std::transform(v.begin(), v.end(), ret.begin(), f); \
1794 template <typename T0, typename T1> \
1795 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v, const T1 &y) \
1797 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
1798 auto f = [&y](const T0 &x) { return FUNC(x, y); }; \
1799 std::transform(v.begin(), v.end(), ret.begin(), f); \
1803 template <typename T0, typename T1> \
1804 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v0, const RVec<T1> &v1) \
1806 if (v0.size() != v1.size()) \
1807 throw std::runtime_error(ERROR_MESSAGE(NAME)); \
1809 RVec<PromoteTypes<T0, T1>> ret(v0.size()); \
1810 auto f = [](const T0 &x, const T1 &y) { return FUNC(x, y); }; \
1811 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), f); \
1815#define RVEC_STD_UNARY_FUNCTION(F) RVEC_UNARY_FUNCTION(F, std::F)
1816#define RVEC_STD_BINARY_FUNCTION(F) RVEC_BINARY_FUNCTION(F, std::F)
1863#undef RVEC_STD_UNARY_FUNCTION
1870#define RVEC_VDT_UNARY_FUNCTION(F) RVEC_UNARY_FUNCTION(F, vdt::F)
1889#undef RVEC_VDT_UNARY_FUNCTION
1893#undef RVEC_UNARY_FUNCTION
1908template <
typename T,
typename V>
1911 if (
v0.size() !=
v1.size())
1912 throw std::runtime_error(
"Cannot compute inner product of vectors of different sizes");
1913 return std::inner_product(
v0.begin(),
v0.end(),
v1.begin(),
decltype(
v0[0] *
v1[0])(0));
1939template <
typename T>
1942 return std::accumulate(
v.begin(),
v.end(),
zero);
1947 return std::accumulate(
v.begin(),
v.end(),
zero);
1951template <
typename T>
1954 return std::accumulate(
v.begin(),
v.end(), init, std::multiplies<T>());
1969template <
typename T>
1972 if (
v.empty())
return 0.;
2001template <
typename T,
typename R = T>
2004 if (
v.empty())
return zero;
2018template <
typename T>
2021 return *std::max_element(
v.begin(),
v.end());
2034template <
typename T>
2037 return *std::min_element(
v.begin(),
v.end());
2052template <
typename T>
2055 return std::distance(
v.begin(), std::max_element(
v.begin(),
v.end()));
2070template <
typename T>
2073 return std::distance(
v.begin(), std::min_element(
v.begin(),
v.end()));
2087template <
typename T>
2090 const std::size_t
size =
v.size();
2091 if (
size < std::size_t(2))
return 0.;
2094 std::for_each(
v.begin(),
v.end(),
pred);
2111template <
typename T>
2114 return std::sqrt(
Var(
v));
2135template <
typename... Args>
2148 constexpr auto nArgs =
sizeof...(Args);
2151 "Map: the first N-1 arguments must be RVecs or references to RVecs");
2154 std::make_index_sequence<
sizeof...(args) - 1>());
2167template <
typename T,
typename F>
2173 for (
auto &&val :
v) {
2175 w.emplace_back(val);
2190template <
typename T>
2194 if (
static_cast<bool>(
e) ==
true)
2209template <
typename T>
2213 if (
static_cast<bool>(
e) ==
false)
2218template <
typename T>
2235template <
typename T>
2241 std::sort(i.
begin(), i.
end(), [&
v](size_type
i1, size_type
i2) { return v[i1] < v[i2]; });
2256template <
typename T,
typename Compare>
2263 [&
v, &
c](size_type
i1, size_type
i2) { return c(v[i1], v[i2]); });
2280template <
typename T>
2286 std::stable_sort(i.
begin(), i.
end(), [&
v](size_type
i1, size_type
i2) { return v[i1] < v[i2]; });
2303template <
typename T,
typename Compare>
2309 std::stable_sort(i.
begin(), i.
end(), [&
v, &
c](size_type
i1, size_type
i2) { return c(v[i1], v[i2]); });
2324template <
typename T>
2328 const size_type
isize = i.size();
2330 for (size_type k = 0; k <
isize; k++)
2336template <
typename T>
2340 const size_type
isize = i.size();
2342 for (size_type k = 0; k <
isize; k++)
2344 if (i[k] <
v.size() && i[k]>=0){
2367template <
typename T>
2371 const size_type
size =
v.size();
2372 const size_type
absn = std::abs(
n);
2374 const auto msg = std::to_string(
absn) +
" elements requested from Take but input contains only " +
2375 std::to_string(
size) +
" elements.";
2376 throw std::runtime_error(
msg);
2380 for (size_type k = 0; k <
absn; k++)
2383 for (size_type k = 0; k <
absn; k++)
2408template <
typename T>
2412 const size_type
size =
v.size();
2413 const size_type
absn = std::abs(
n);
2433template <
typename T>
2441 if (
v.size() >
idxs.size())
2442 r.reserve(
v.size() -
idxs.size());
2446 for (
sz_t i = 0
u; i <
v.size(); ++i) {
2450 r.emplace_back(
v[i]);
2466template <
typename T>
2470 std::reverse(
r.begin(),
r.end());
2487template <
typename T>
2491 std::sort(
r.begin(),
r.end());
2512template <
typename T,
typename Compare>
2516 std::sort(
r.begin(),
r.end(), std::forward<Compare>(
c));
2536template <
typename T>
2540 std::stable_sort(
r.begin(),
r.end());
2572template <
typename T,
typename Compare>
2576 std::stable_sort(
r.begin(),
r.end(), std::forward<Compare>(
c));
2594 using size_type = std::size_t;
2599 for(size_type i=0; i<
size1; i++) {
2623template <
typename T1,
typename T2>
2648template <
typename T>
2652 const size_type s =
v.size();
2654 throw std::runtime_error(
"Cannot make unique combinations of size " + std::to_string(
n) +
2655 " from vector of size " + std::to_string(s) +
".");
2659 for(size_type k=0; k<s; k++)
2664 for (size_type
m = s -
n + 2;
m <= s; ++
m)
2667 size_type
factn = 1;
2668 for (size_type i = 2; i <=
n; ++i)
2677 for (size_type k = 0; k <
n; k++)
2694 for (
long j=i+1;
j<(long)
n;
j++)
2696 for (size_type k = 0; k <
n; k++)
2712template <
typename T>
2717 const auto size =
v.size();
2719 for(size_type i=0; i<
size; i++) {
2743template <
typename T>
2751 const auto size =
v1.size();
2754 for(size_type i=0; i<
size; i++) {
2756 r.emplace_back(
v1[i]);
2777template <
typename T>
2781 const size_type
size =
c.size();
2784 for (size_type i=0; i<
size; i++) {
2785 r.emplace_back(
c[i] != 0 ?
v1[i] :
v2[i]);
2805template <
typename T>
2809 const size_type
size =
c.size();
2812 for (size_type i=0; i<
size; i++) {
2813 r.emplace_back(
c[i] != 0 ?
v1[i] :
v2);
2833template <
typename T>
2837 const size_type
size =
c.size();
2840 for (size_type i=0; i<
size; i++) {
2841 r.emplace_back(
c[i] != 0 ?
v1 :
v2[i]);
2859template <
typename T>
2863 const size_type
size =
c.size();
2866 for (size_type i=0; i<
size; i++) {
2867 r.emplace_back(
c[i] != 0 ?
v1 :
v2);
2886 res.reserve(
v0.size() +
v1.size());
2887 std::copy(
v0.begin(),
v0.end(), std::back_inserter(res));
2888 std::copy(
v1.begin(),
v1.end(), std::back_inserter(res));
2898template <
typename T0,
typename T1 = T0,
typename Common_t = std::common_type_t<T0, T1>>
2901 static_assert(std::is_floating_point<T0>::value && std::is_floating_point<T1>::value,
2902 "DeltaPhi must be called with floating point values.");
2903 auto r = std::fmod(
v2 -
v1, 2.0 *
c);
2919template <
typename T0,
typename T1 = T0,
typename Common_t =
typename std::common_type_t<T0, T1>>
2923 const size_type
size =
v1.size();
2925 for (size_type i = 0; i <
size; i++) {
2926 r[i] = DeltaPhi(
v1[i],
v2[i],
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,
c);
2955template <
typename T0,
typename T1 = T0,
typename Common_t =
typename std::common_type_t<T0, T1>>
2959 const size_type
size =
v2.size();
2961 for (size_type i = 0; i <
size; i++) {
2962 r[i] = DeltaPhi(
v1,
v2[i],
c);
2974template <
typename T0,
typename T1 = T0,
typename T2 = T0,
typename T3 = T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3>>
2988template <
typename T0,
typename T1 = T0,
typename T2 = T0,
typename T3 = T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3>>
3001template <
typename T0,
typename T1 = T0,
typename T2 = T0,
typename T3 = T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3>>
3013template <
typename T0,
typename T1 =
T0,
typename T2 =
T0,
typename T3 =
T0,
typename T4 =
T0,
3014 typename T5 =
T0,
typename Common_t = std::common_type_t<T0, T1>>
3027 return std::atan2(
c,
d);
3035template <
typename T0,
typename T1 =
T0,
typename T2 =
T0,
typename T3 =
T0,
typename T4 =
T0,
3036 typename T5 =
T0,
typename T6 =
T0,
typename T7 =
T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3, T4, T5, T6, T7>>
3047 return (
mass1 + mass2);
3049 auto mm =
mass1 + std::sqrt(mass2*mass2 +
p2_sq);
3050 auto m2 = mm*mm -
p2_sq;
3052 return std::sqrt( m2 );
3054 return std::sqrt( -m2 );
3058 auto m2 = mm*mm -
p1_sq;
3060 return std::sqrt( m2 );
3062 return std::sqrt( -m2 );
3066 const auto m2_sq = mass2 * mass2;
3072 const auto cos_a = std::cos(
a);
3075 y = (
x + std::sin(
a) * std::sin(
a)) / (std::sqrt(
x + 1) +
cos_a);
3091template <
typename T0,
typename T1 =
T0,
typename T2 =
T0,
typename T3 =
T0,
typename T4 =
T0,
3092 typename T5 =
T0,
typename T6 =
T0,
typename T7 =
T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3, T4, T5, T6, T7>>
3097 std::size_t
size = px1.size();
3104 for (std::size_t i = 0
u; i <
size; ++i) {
3117template <
typename T0,
typename T1 =
T0,
typename T2 =
T0,
typename T3 =
T0,
typename T4 =
T0,
3118 typename T5 =
T0,
typename T6 =
T0,
typename T7 =
T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3, T4, T5, T6, T7>>
3123 std::size_t
size =
pt1.size();
3130 for (std::size_t i = 0
u; i <
size; ++i) {
3132 const auto x1 =
pt1[i] * std::cos(
phi1[i]);
3133 const auto y1 =
pt1[i] * std::sin(
phi1[i]);
3134 const auto z1 =
pt1[i] * std::sinh(
eta1[i]);
3136 const auto x2 =
pt2[i] * std::cos(
phi2[i]);
3137 const auto y2 =
pt2[i] * std::sin(
phi2[i]);
3138 const auto z2 =
pt2[i] * std::sinh(
eta2[i]);
3153template <
typename T0,
typename T1 = T0,
typename T2 = T0,
typename T3 = T0,
typename Common_t = std::common_type_t<T0, T1, T2, T3>>
3156 const std::size_t
size =
pt.size();
3165 for (std::size_t i = 0
u; i <
size; ++ i) {
3167 const auto x =
pt[i] * std::cos(phi[i]);
3169 const auto y =
pt[i] * std::sin(phi[i]);
3171 const auto z =
pt[i] * std::sinh(eta[i]);
3173 const auto e = std::sqrt(
x *
x +
y *
y + z * z + mass[i] * mass[i]);
3199template <
typename T,
typename...
Args_t>
3205 for (
auto i = 0
UL; i <
size; ++i) {
3206 ret.emplace_back(args[i]...);
3219template <
typename T>
3222 const auto size =
v.size();
3225 for (
auto i = 0
UL; i <
size; ++i) {
3226 ret.emplace_back(i);
3286template <
typename T =
double,
typename Ret_t = std::conditional_t<std::is_
floating_po
int_v<T>, T,
double>>
3289 if (!
n || (
n > std::numeric_limits<long long>::max()))
3294 long double step = std::is_floating_point_v<Ret_t> ?
3295 (end - start) /
static_cast<long double>(
n -
endpoint) :
3296 (end >= start ?
static_cast<long double>(end - start) / (
n -
endpoint) : (
static_cast<long double>(end) - start) / (
n -
endpoint));
3299 temp[0] = std::is_floating_point_v<Ret_t> ?
static_cast<Ret_t
>(start) : std::floor(start);
3300 if constexpr (std::is_floating_point_v<Ret_t>)
3302 for (
unsigned long long i = 1; i <
n; i++)
3304 temp[i] =
static_cast<Ret_t
>(start + i * step);
3309 for (
unsigned long long i = 1; i <
n; i++)
3311 temp[i] = std::floor(start + i * step);
3372template <
typename T =
double,
typename Ret_t = std::conditional_t<std::is_
floating_po
int_v<T>, T,
double>>
3375 if (!
n || (
n > std::numeric_limits<long long>::max()))
3382 long double end_c = end;
3383 long double base_c = base;
3387 temp[0] = std::is_floating_point_v<Ret_t> ?
3391 if constexpr (std::is_floating_point_v<Ret_t>)
3393 for (
unsigned long long i = 1; i <
n; i++)
3401 for (
unsigned long long i = 1; i <
n; i++)
3466template <
typename T =
double,
typename Ret_t = std::conditional_t<std::is_
floating_po
int_v<T>, T,
double>>
3469 unsigned long long n = std::ceil(( end >= start ? (end - start) :
static_cast<long double>(end)-start)/
static_cast<long double>(step));
3471 if (!
n || (
n > std::numeric_limits<long long>::max()))
3479 long double step_c = step;
3481 temp[0] = std::is_floating_point_v<Ret_t> ?
static_cast<Ret_t
>(start) : std::floor(start);
3482 if constexpr (std::is_floating_point_v<Ret_t>)
3484 for (
unsigned long long i = 1; i <
n; i++)
3491 for (
unsigned long long i = 1; i <
n; i++)
3510 for (
auto i = 0
UL; i <
length; ++i) {
3511 ret.emplace_back(i);
3521 ret.reserve(begin < end ? end - begin : 0
u);
3522 for (
auto i = begin; i < end; ++i)
3543 throw std::runtime_error(
"Range: the stride must not be zero");
3546 float ret_cap = std::ceil(
static_cast<float>(end-begin) /
stride);
3555 for (
auto i = begin; i < end; i+=
stride)
3560 for (
auto i = begin; i > end; i+=
stride)
3574 constexpr bool mustConvert = std::is_same<char, T>::value || std::is_same<signed char, T>::value ||
3575 std::is_same<unsigned char, T>::value || std::is_same<wchar_t, T>::value ||
3576 std::is_same<char16_t, T>::value || std::is_same<char32_t, T>::value;
3577 using Print_t =
typename std::conditional<mustConvert, long long int, T>::type;
3579 auto size =
v.size();
3581 for (std::size_t i = 0; i <
size - 1; ++i) {
3590#if (_VECOPS_USE_EXTERN_TEMPLATES)
3592#define RVEC_EXTERN_UNARY_OPERATOR(T, OP) \
3593 extern template RVec<T> operator OP<T>(const RVec<T> &);
3595#define RVEC_EXTERN_BINARY_OPERATOR(T, OP) \
3596 extern template auto operator OP<T, T>(const T &x, const RVec<T> &v) \
3597 -> RVec<decltype(x OP v[0])>; \
3598 extern template auto operator OP<T, T>(const RVec<T> &v, const T &y) \
3599 -> RVec<decltype(v[0] OP y)>; \
3600 extern template auto operator OP<T, T>(const RVec<T> &v0, const RVec<T> &v1)\
3601 -> RVec<decltype(v0[0] OP v1[0])>;
3603#define RVEC_EXTERN_ASSIGN_OPERATOR(T, OP) \
3604 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const T &); \
3605 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const RVec<T> &);
3607#define RVEC_EXTERN_LOGICAL_OPERATOR(T, OP) \
3608 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const T &); \
3609 extern template RVec<int> operator OP<T, T>(const T &, const RVec<T> &); \
3610 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const RVec<T> &);
3612#define RVEC_EXTERN_FLOAT_TEMPLATE(T) \
3613 extern template class RVec<T>; \
3614 RVEC_EXTERN_UNARY_OPERATOR(T, +) \
3615 RVEC_EXTERN_UNARY_OPERATOR(T, -) \
3616 RVEC_EXTERN_UNARY_OPERATOR(T, !) \
3617 RVEC_EXTERN_BINARY_OPERATOR(T, +) \
3618 RVEC_EXTERN_BINARY_OPERATOR(T, -) \
3619 RVEC_EXTERN_BINARY_OPERATOR(T, *) \
3620 RVEC_EXTERN_BINARY_OPERATOR(T, /) \
3621 RVEC_EXTERN_ASSIGN_OPERATOR(T, +=) \
3622 RVEC_EXTERN_ASSIGN_OPERATOR(T, -=) \
3623 RVEC_EXTERN_ASSIGN_OPERATOR(T, *=) \
3624 RVEC_EXTERN_ASSIGN_OPERATOR(T, /=) \
3625 RVEC_EXTERN_LOGICAL_OPERATOR(T, <) \
3626 RVEC_EXTERN_LOGICAL_OPERATOR(T, >) \
3627 RVEC_EXTERN_LOGICAL_OPERATOR(T, ==) \
3628 RVEC_EXTERN_LOGICAL_OPERATOR(T, !=) \
3629 RVEC_EXTERN_LOGICAL_OPERATOR(T, <=) \
3630 RVEC_EXTERN_LOGICAL_OPERATOR(T, >=) \
3631 RVEC_EXTERN_LOGICAL_OPERATOR(T, &&) \
3632 RVEC_EXTERN_LOGICAL_OPERATOR(T, ||)
3634#define RVEC_EXTERN_INTEGER_TEMPLATE(T) \
3635 extern template class RVec<T>; \
3636 RVEC_EXTERN_UNARY_OPERATOR(T, +) \
3637 RVEC_EXTERN_UNARY_OPERATOR(T, -) \
3638 RVEC_EXTERN_UNARY_OPERATOR(T, ~) \
3639 RVEC_EXTERN_UNARY_OPERATOR(T, !) \
3640 RVEC_EXTERN_BINARY_OPERATOR(T, +) \
3641 RVEC_EXTERN_BINARY_OPERATOR(T, -) \
3642 RVEC_EXTERN_BINARY_OPERATOR(T, *) \
3643 RVEC_EXTERN_BINARY_OPERATOR(T, /) \
3644 RVEC_EXTERN_BINARY_OPERATOR(T, %) \
3645 RVEC_EXTERN_BINARY_OPERATOR(T, &) \
3646 RVEC_EXTERN_BINARY_OPERATOR(T, |) \
3647 RVEC_EXTERN_BINARY_OPERATOR(T, ^) \
3648 RVEC_EXTERN_ASSIGN_OPERATOR(T, +=) \
3649 RVEC_EXTERN_ASSIGN_OPERATOR(T, -=) \
3650 RVEC_EXTERN_ASSIGN_OPERATOR(T, *=) \
3651 RVEC_EXTERN_ASSIGN_OPERATOR(T, /=) \
3652 RVEC_EXTERN_ASSIGN_OPERATOR(T, %=) \
3653 RVEC_EXTERN_ASSIGN_OPERATOR(T, &=) \
3654 RVEC_EXTERN_ASSIGN_OPERATOR(T, |=) \
3655 RVEC_EXTERN_ASSIGN_OPERATOR(T, ^=) \
3656 RVEC_EXTERN_ASSIGN_OPERATOR(T, >>=) \
3657 RVEC_EXTERN_ASSIGN_OPERATOR(T, <<=) \
3658 RVEC_EXTERN_LOGICAL_OPERATOR(T, <) \
3659 RVEC_EXTERN_LOGICAL_OPERATOR(T, >) \
3660 RVEC_EXTERN_LOGICAL_OPERATOR(T, ==) \
3661 RVEC_EXTERN_LOGICAL_OPERATOR(T, !=) \
3662 RVEC_EXTERN_LOGICAL_OPERATOR(T, <=) \
3663 RVEC_EXTERN_LOGICAL_OPERATOR(T, >=) \
3664 RVEC_EXTERN_LOGICAL_OPERATOR(T, &&) \
3665 RVEC_EXTERN_LOGICAL_OPERATOR(T, ||)
3682#undef RVEC_EXTERN_UNARY_OPERATOR
3683#undef RVEC_EXTERN_BINARY_OPERATOR
3684#undef RVEC_EXTERN_ASSIGN_OPERATOR
3685#undef RVEC_EXTERN_LOGICAL_OPERATOR
3686#undef RVEC_EXTERN_INTEGER_TEMPLATE
3687#undef RVEC_EXTERN_FLOAT_TEMPLATE
3689#define RVEC_EXTERN_UNARY_FUNCTION(T, NAME, FUNC) \
3690 extern template RVec<PromoteType<T>> NAME(const RVec<T> &);
3692#define RVEC_EXTERN_STD_UNARY_FUNCTION(T, F) RVEC_EXTERN_UNARY_FUNCTION(T, F, std::F)
3694#define RVEC_EXTERN_BINARY_FUNCTION(T0, T1, NAME, FUNC) \
3695 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const T1 &); \
3696 extern template RVec<PromoteTypes<T0, T1>> NAME(const T0 &, const RVec<T1> &); \
3697 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const RVec<T1> &);
3699#define RVEC_EXTERN_STD_BINARY_FUNCTION(T, F) RVEC_EXTERN_BINARY_FUNCTION(T, T, F, std::F)
3701#define RVEC_EXTERN_STD_FUNCTIONS(T) \
3702 RVEC_EXTERN_STD_UNARY_FUNCTION(T, abs) \
3703 RVEC_EXTERN_STD_BINARY_FUNCTION(T, fdim) \
3704 RVEC_EXTERN_STD_BINARY_FUNCTION(T, fmod) \
3705 RVEC_EXTERN_STD_BINARY_FUNCTION(T, remainder) \
3706 RVEC_EXTERN_STD_UNARY_FUNCTION(T, exp) \
3707 RVEC_EXTERN_STD_UNARY_FUNCTION(T, exp2) \
3708 RVEC_EXTERN_STD_UNARY_FUNCTION(T, expm1) \
3709 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log) \
3710 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log10) \
3711 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log2) \
3712 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log1p) \
3713 RVEC_EXTERN_STD_BINARY_FUNCTION(T, pow) \
3714 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sqrt) \
3715 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cbrt) \
3716 RVEC_EXTERN_STD_BINARY_FUNCTION(T, hypot) \
3717 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sin) \
3718 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cos) \
3719 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tan) \
3720 RVEC_EXTERN_STD_UNARY_FUNCTION(T, asin) \
3721 RVEC_EXTERN_STD_UNARY_FUNCTION(T, acos) \
3722 RVEC_EXTERN_STD_UNARY_FUNCTION(T, atan) \
3723 RVEC_EXTERN_STD_BINARY_FUNCTION(T, atan2) \
3724 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sinh) \
3725 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cosh) \
3726 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tanh) \
3727 RVEC_EXTERN_STD_UNARY_FUNCTION(T, asinh) \
3728 RVEC_EXTERN_STD_UNARY_FUNCTION(T, acosh) \
3729 RVEC_EXTERN_STD_UNARY_FUNCTION(T, atanh) \
3730 RVEC_EXTERN_STD_UNARY_FUNCTION(T, floor) \
3731 RVEC_EXTERN_STD_UNARY_FUNCTION(T, ceil) \
3732 RVEC_EXTERN_STD_UNARY_FUNCTION(T, trunc) \
3733 RVEC_EXTERN_STD_UNARY_FUNCTION(T, round) \
3734 RVEC_EXTERN_STD_UNARY_FUNCTION(T, erf) \
3735 RVEC_EXTERN_STD_UNARY_FUNCTION(T, erfc) \
3736 RVEC_EXTERN_STD_UNARY_FUNCTION(T, lgamma) \
3737 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tgamma) \
3741#undef RVEC_EXTERN_STD_UNARY_FUNCTION
3742#undef RVEC_EXTERN_STD_BINARY_FUNCTION
3743#undef RVEC_EXTERN_STD_UNARY_FUNCTIONS
3747#define RVEC_EXTERN_VDT_UNARY_FUNCTION(T, F) RVEC_EXTERN_UNARY_FUNCTION(T, F, vdt::F)
#define R__unlikely(expr)
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)
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)
T Product(const RVec< T > &v, const T init=T(1))
Return the product of the elements of the RVec.
#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...
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...
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)
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.