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
28 #undef _USE_MATH_DEFINES
30 #define _VECOPS_USE_EXTERN_TEMPLATES false
32 #define _VECOPS_USE_EXTERN_TEMPLATES true
54#include <vdt/vdtMath.h>
79constexpr bool All(
const bool *vals, std::size_t
size)
81 for (
auto i = 0u; i <
size; ++i)
87template <
typename...
T>
90 constexpr const auto nArgs =
sizeof...(T);
91 const std::size_t sizes[] = {vs.
size()...};
93 for (
auto i = 1UL; i < nArgs; i++) {
94 if (sizes[0] == sizes[i])
97 msg +=
": input RVec instances have different lengths!";
98 throw std::runtime_error(msg);
104template <
typename F,
typename... RVecs>
110 for (
auto i = 0UL; i <
size; i++)
111 ret[i] =
f(vs[i]...);
116template <
typename Tuple_t, std::size_t... Is>
121 return MapImpl(std::get<tupleSizeM1>(t), std::get<Is>(t)...);
153 static constexpr size_t SizeTypeMax() {
return std::numeric_limits<Size_T>::max(); }
156 SmallVectorBase(
void *FirstEl,
size_t TotalCapacity) : fBeginX(FirstEl), fCapacity(TotalCapacity) {}
161 void grow_pod(
void *FirstEl,
size_t MinSize,
size_t TSize);
165 static void report_size_overflow(
size_t MinSize);
168 static void report_at_maximum_capacity();
171 bool Owns()
const {
return fCapacity != -1; }
190 if (
N > capacity()) {
191 throw std::runtime_error(
"Setting size to a value greater than capacity.");
201 alignas(
T)
char FirstEl[
sizeof(
T)];
214 return const_cast<void *
>(
reinterpret_cast<const void *
>(
reinterpret_cast<const char *
>(
this) +
222 void grow_pod(
size_t MinSize,
size_t TSize) { Base::grow_pod(getFirstEl(), MinSize, TSize); }
226 bool isSmall()
const {
return this->fBeginX == getFirstEl(); }
231 this->fBeginX = getFirstEl();
234 this->
fSize = this->fCapacity = 0;
254 using Base::capacity;
287 throw std::runtime_error(
"`front` called on an empty RVec");
295 throw std::runtime_error(
"`front` called on an empty RVec");
303 throw std::runtime_error(
"`back` called on an empty RVec");
311 throw std::runtime_error(
"`back` called on an empty RVec");
325template <
typename T,
bool = (std::is_trivially_copy_constructible<T>::value) &&
326 (std::is_trivially_move_constructible<T>::value) &&
327 std::is_trivially_destructible<T>::value>
342 template <
typename It1,
typename It2>
345 std::uninitialized_copy(std::make_move_iterator(
I), std::make_move_iterator(
E), Dest);
350 template <
typename It1,
typename It2>
353 std::uninitialized_copy(
I,
E, Dest);
366 ::new ((
void *)this->end())
T(Elt);
367 this->set_size(this->
size() + 1);
374 ::new ((
void *)this->end())
T(::std::move(Elt));
375 this->set_size(this->
size() + 1);
380 this->set_size(this->
size() - 1);
386template <
typename T,
bool TriviallyCopyable>
391 if (MinSize > this->SizeTypeMax())
392 this->report_size_overflow(MinSize);
398 if (this->capacity() == this->SizeTypeMax())
399 this->report_at_maximum_capacity();
402 size_t NewCapacity = size_t(
NextPowerOf2(this->capacity() + 2));
403 NewCapacity = std::min(std::max(NewCapacity, MinSize), this->SizeTypeMax());
404 T *NewElts =
static_cast<T *
>(
malloc(NewCapacity *
sizeof(
T)));
408 this->uninitialized_move(this->begin(), this->end(), NewElts);
412 destroy_range(this->begin(), this->end());
415 if (!this->isSmall())
419 this->fBeginX = NewElts;
420 this->fCapacity = NewCapacity;
439 template <
typename It1,
typename It2>
443 uninitialized_copy(
I,
E, Dest);
448 template <
typename It1,
typename It2>
452 std::uninitialized_copy(
I,
E, Dest);
457 template <
typename T1,
typename T2>
467 memcpy(
reinterpret_cast<void *
>(Dest),
I, (
E -
I) *
sizeof(
T));
474 this->grow_pod(MinSize,
sizeof(
T));
487 memcpy(
reinterpret_cast<void *
>(this->end()), &Elt,
sizeof(
T));
488 this->set_size(this->
size() + 1);
496template <
typename T,
unsigned N>
498 alignas(
T)
char InlineElts[
N *
sizeof(
T)]{};
514#ifdef R__HAS_HARDWARE_INTERFERENCE_SIZE
515 constexpr std::size_t cacheLineSize = std::hardware_destructive_interference_size;
518 static constexpr std::size_t cacheLineSize = 64;
520 static constexpr unsigned elementsPerCacheLine = (cacheLineSize -
sizeof(
SmallVectorBase)) /
sizeof(
T);
521 static constexpr unsigned maxInlineByteSize = 1024;
525 elementsPerCacheLine >= 8 ? elementsPerCacheLine : (
sizeof(
T) * 8 > maxInlineByteSize ? 0 : 8);
529template <
typename ForwardIt>
532#if __cplusplus < 201703L
534 new (
static_cast<void *
>(std::addressof(*
first)))
typename std::iterator_traits<ForwardIt>::value_type();
536 std::uninitialized_value_construct(
first, last);
560 explicit RVecImpl(
unsigned N) :
ROOT::Internal::VecOps::SmallVectorTemplateBase<
T>(
N) {}
569 if (!this->isSmall() && this->Owns())
577 this->destroy_range(this->begin(), this->end());
580 this->resetToSmall();
586 if (N < this->
size()) {
588 this->destroy_range(this->begin() +
N, this->end());
590 }
else if (
N > this->
size()) {
591 if (this->capacity() <
N)
593 for (
auto I = this->end(),
E = this->begin() +
N;
I !=
E; ++
I)
601 if (N < this->
size()) {
603 this->destroy_range(this->begin() +
N, this->end());
605 }
else if (
N > this->
size()) {
606 if (this->capacity() <
N)
608 std::uninitialized_fill(this->end(), this->begin() +
N, NV);
615 if (this->capacity() <
N)
621 if (this->
size() < NumItems) {
622 throw std::runtime_error(
"Popping back more elements than those available.");
625 this->destroy_range(this->end() - NumItems, this->end());
626 this->set_size(this->
size() - NumItems);
631 T Result = ::std::move(this->back());
639 template <
typename in_iter,
640 typename =
typename std::enable_if<std::is_convertible<
641 typename std::iterator_traits<in_iter>::iterator_category, std::input_iterator_tag>
::value>
::type>
642 void append(in_iter in_start, in_iter in_end)
644 size_type NumInputs = std::distance(in_start, in_end);
645 if (NumInputs > this->capacity() - this->
size())
646 this->grow(this->
size() + NumInputs);
648 this->uninitialized_copy(in_start, in_end, this->end());
649 this->set_size(this->
size() + NumInputs);
655 if (NumInputs > this->capacity() - this->
size())
656 this->grow(this->
size() + NumInputs);
658 std::uninitialized_fill_n(this->end(), NumInputs, Elt);
659 this->set_size(this->
size() + NumInputs);
662 void append(std::initializer_list<T> IL) {
append(IL.begin(), IL.end()); }
671 if (this->capacity() < NumElts)
673 this->set_size(NumElts);
674 std::uninitialized_fill(this->begin(), this->end(), Elt);
677 template <
typename in_iter,
678 typename =
typename std::enable_if<std::is_convertible<
679 typename std::iterator_traits<in_iter>::iterator_category, std::input_iterator_tag>
::value>
::type>
680 void assign(in_iter in_start, in_iter in_end)
683 append(in_start, in_end);
697 if (I < this->begin() ||
I >= this->end()) {
698 throw std::runtime_error(
"The iterator passed to `erase` is out of bounds.");
703 std::move(
I + 1, this->end(),
I);
715 if (S < this->begin() ||
E > this->end() ||
S >
E) {
716 throw std::runtime_error(
"Invalid start/end pair passed to `erase` (out of bounds or start > end).");
724 this->destroy_range(
I, this->end());
725 this->set_size(
I - this->begin());
731 if (
I == this->end()) {
732 this->push_back(::std::move(Elt));
733 return this->end() - 1;
736 if (I < this->begin() ||
I > this->end()) {
737 throw std::runtime_error(
"The iterator passed to `insert` is out of bounds.");
740 if (this->
size() >= this->capacity()) {
741 size_t EltNo =
I - this->begin();
743 I = this->begin() + EltNo;
746 ::new ((
void *)this->end())
T(::std::move(this->back()));
748 std::move_backward(
I, this->end() - 1, this->end());
749 this->set_size(this->
size() + 1);
754 if (
I <= EltPtr && EltPtr < this->end())
757 *
I = ::std::move(*EltPtr);
763 if (
I == this->end()) {
764 this->push_back(Elt);
765 return this->end() - 1;
768 if (I < this->begin() ||
I > this->end()) {
769 throw std::runtime_error(
"The iterator passed to `insert` is out of bounds.");
772 if (this->
size() >= this->capacity()) {
773 size_t EltNo =
I - this->begin();
775 I = this->begin() + EltNo;
777 ::new ((
void *)this->end())
T(std::move(this->back()));
779 std::move_backward(
I, this->end() - 1, this->end());
780 this->set_size(this->
size() + 1);
784 const T *EltPtr = &Elt;
785 if (
I <= EltPtr && EltPtr < this->end())
795 size_t InsertElt =
I - this->begin();
797 if (
I == this->end()) {
798 append(NumToInsert, Elt);
799 return this->begin() + InsertElt;
802 if (I < this->begin() ||
I > this->end()) {
803 throw std::runtime_error(
"The iterator passed to `insert` is out of bounds.");
807 reserve(this->
size() + NumToInsert);
810 I = this->begin() + InsertElt;
816 if (
size_t(this->end() -
I) >= NumToInsert) {
817 T *OldEnd = this->end();
818 append(std::move_iterator<iterator>(this->end() - NumToInsert), std::move_iterator<iterator>(this->end()));
821 std::move_backward(
I, OldEnd - NumToInsert, OldEnd);
823 std::fill_n(
I, NumToInsert, Elt);
831 T *OldEnd = this->end();
832 this->set_size(this->
size() + NumToInsert);
833 size_t NumOverwritten = OldEnd -
I;
834 this->uninitialized_move(
I, OldEnd, this->end() - NumOverwritten);
837 std::fill_n(
I, NumOverwritten, Elt);
840 std::uninitialized_fill_n(OldEnd, NumToInsert - NumOverwritten, Elt);
844 template <
typename ItTy,
845 typename =
typename std::enable_if<std::is_convertible<
846 typename std::iterator_traits<ItTy>::iterator_category, std::input_iterator_tag>
::value>
::type>
850 size_t InsertElt =
I - this->begin();
852 if (
I == this->end()) {
854 return this->begin() + InsertElt;
857 if (I < this->begin() ||
I > this->end()) {
858 throw std::runtime_error(
"The iterator passed to `insert` is out of bounds.");
861 size_t NumToInsert = std::distance(From, To);
864 reserve(this->
size() + NumToInsert);
867 I = this->begin() + InsertElt;
873 if (
size_t(this->end() -
I) >= NumToInsert) {
874 T *OldEnd = this->end();
875 append(std::move_iterator<iterator>(this->end() - NumToInsert), std::move_iterator<iterator>(this->end()));
878 std::move_backward(
I, OldEnd - NumToInsert, OldEnd);
880 std::copy(From, To,
I);
888 T *OldEnd = this->end();
889 this->set_size(this->
size() + NumToInsert);
890 size_t NumOverwritten = OldEnd -
I;
891 this->uninitialized_move(
I, OldEnd, this->end() - NumOverwritten);
894 for (
T *J =
I; NumOverwritten > 0; --NumOverwritten) {
901 this->uninitialized_copy(From, To, OldEnd);
907 template <
typename... ArgTypes>
912 ::new ((
void *)this->end())
T(std::forward<ArgTypes>(Args)...);
913 this->set_size(this->
size() + 1);
929 if (!this->isSmall() && !RHS.
isSmall()) {
938 if (this->isSmall() && !RHS.
Owns()) {
940 temp = std::move(RHS);
941 RHS = std::move(*
this);
942 *
this = std::move(temp);
944 }
else if (RHS.
isSmall() && !this->Owns()) {
946 temp = std::move(*
this);
947 *
this = std::move(RHS);
948 RHS = std::move(temp);
952 if (RHS.
size() > this->capacity())
953 this->grow(RHS.
size());
958 size_t NumShared = this->
size();
959 if (NumShared > RHS.
size())
960 NumShared = RHS.
size();
961 for (
size_type i = 0; i != NumShared; ++i)
962 std::iter_swap(this->begin() + i, RHS.
begin() + i);
966 size_t EltDiff = this->
size() - RHS.
size();
967 this->uninitialized_copy(this->begin() + NumShared, this->end(), RHS.
end());
970 this->destroy_range(this->begin() + NumShared, this->end());
971 this->set_size(NumShared);
972 }
else if (RHS.
size() > this->size()) {
973 size_t EltDiff = RHS.
size() - this->
size();
974 this->uninitialized_copy(RHS.
begin() + NumShared, RHS.
end(), this->end());
975 this->set_size(this->
size() + EltDiff);
977 this->destroy_range(RHS.
begin() + NumShared, RHS.
end());
991 size_t RHSSize = RHS.
size();
992 size_t CurSize = this->
size();
993 if (CurSize >= RHSSize) {
997 NewEnd = std::copy(RHS.
begin(), RHS.
begin() + RHSSize, this->begin());
999 NewEnd = this->begin();
1003 this->destroy_range(NewEnd, this->end());
1006 this->set_size(RHSSize);
1014 if (this->capacity() < RHSSize) {
1017 this->destroy_range(this->begin(), this->end());
1021 this->grow(RHSSize);
1022 }
else if (CurSize) {
1024 std::copy(RHS.
begin(), RHS.
begin() + CurSize, this->begin());
1028 this->uninitialized_copy(RHS.
begin() + CurSize, RHS.
end(), this->begin() + CurSize);
1031 this->set_size(RHSSize);
1035template <
typename T>
1043 if (!RHS.isSmall()) {
1045 this->destroy_range(this->begin(), this->end());
1046 if (!this->isSmall())
1047 free(this->begin());
1049 this->fBeginX = RHS.fBeginX;
1050 this->
fSize = RHS.fSize;
1051 this->fCapacity = RHS.fCapacity;
1058 size_t RHSSize = RHS.size();
1059 size_t CurSize = this->
size();
1060 if (CurSize >= RHSSize) {
1064 NewEnd = std::move(RHS.begin(), RHS.end(), NewEnd);
1068 this->destroy_range(NewEnd, this->end());
1069 this->set_size(RHSSize);
1082 if (this->capacity() < RHSSize) {
1085 this->destroy_range(this->begin(), this->end());
1089 this->grow(RHSSize);
1090 }
else if (CurSize) {
1092 std::move(RHS.begin(), RHS.begin() + CurSize, this->begin());
1096 this->uninitialized_move(RHS.begin() + CurSize, RHS.end(), this->begin() + CurSize);
1099 this->set_size(RHSSize);
1105template <
typename T>
1111template <
typename T>
1138template <
typename T,
unsigned int N>
1147 this->destroy_range(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); }
1195 RVecN(
const std::vector<T> &RHS) :
RVecN(RHS.begin(), RHS.end()) {}
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(std::move(msg));
1256 ret.
begin()[j] = 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(std::move(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(std::move(msg));
1288 return this->operator[](pos);
1296 return this->operator[](pos);
1304 return this->operator[](pos);
1477template <
typename T>
1478class R__CLING_PTRCHECK(off)
RVec :
public RVecN<T, Internal::VecOps::RVecInlineStorageSize<T>::value> {
1485 using SuperClass::begin;
1494 template <
typename ItTy,
1495 typename =
typename std::enable_if<std::is_convertible<
1496 typename std::iterator_traits<ItTy>::iterator_category, std::input_iterator_tag>
::value>
::type>
1521 template <
unsigned N>
1524 template <
unsigned N>
1535 return RVec<U>(this->begin(), this->end());
1538 using SuperClass::operator[];
1543 return RVec(SuperClass::operator[](conds));
1546 using SuperClass::at;
1548 friend bool ROOT::Detail::VecOps::IsSmall<T>(
const RVec<T> &
v);
1550 friend bool ROOT::Detail::VecOps::IsAdopting<T>(
const RVec<T> &
v);
1553template <
typename T,
unsigned N>
1562#define RVEC_UNARY_OPERATOR(OP) \
1563template <typename T> \
1564RVec<T> operator OP(const RVec<T> &v) \
1567 for (auto &x : ret) \
1576#undef RVEC_UNARY_OPERATOR
1582#define ERROR_MESSAGE(OP) \
1583 "Cannot call operator " #OP " on vectors of different sizes."
1585#define RVEC_BINARY_OPERATOR(OP) \
1586template <typename T0, typename T1> \
1587auto operator OP(const RVec<T0> &v, const T1 &y) \
1588 -> RVec<decltype(v[0] OP y)> \
1590 RVec<decltype(v[0] OP y)> ret(v.size()); \
1591 auto op = [&y](const T0 &x) { return x OP y; }; \
1592 std::transform(v.begin(), v.end(), ret.begin(), op); \
1596template <typename T0, typename T1> \
1597auto operator OP(const T0 &x, const RVec<T1> &v) \
1598 -> RVec<decltype(x OP v[0])> \
1600 RVec<decltype(x OP v[0])> ret(v.size()); \
1601 auto op = [&x](const T1 &y) { return x OP y; }; \
1602 std::transform(v.begin(), v.end(), ret.begin(), op); \
1606template <typename T0, typename T1> \
1607auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
1608 -> RVec<decltype(v0[0] OP v1[0])> \
1610 if (v0.size() != v1.size()) \
1611 throw std::runtime_error(ERROR_MESSAGE(OP)); \
1613 RVec<decltype(v0[0] OP v1[0])> ret(v0.size()); \
1614 auto op = [](const T0 &x, const T1 &y) { return x OP y; }; \
1615 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
1627#undef RVEC_BINARY_OPERATOR
1633#define RVEC_ASSIGNMENT_OPERATOR(OP) \
1634template <typename T0, typename T1> \
1635RVec<T0>& operator OP(RVec<T0> &v, const T1 &y) \
1637 auto op = [&y](T0 &x) { return x OP y; }; \
1638 std::transform(v.begin(), v.end(), v.begin(), op); \
1642template <typename T0, typename T1> \
1643RVec<T0>& operator OP(RVec<T0> &v0, const RVec<T1> &v1) \
1645 if (v0.size() != v1.size()) \
1646 throw std::runtime_error(ERROR_MESSAGE(OP)); \
1648 auto op = [](T0 &x, const T1 &y) { return x OP y; }; \
1649 std::transform(v0.begin(), v0.end(), v1.begin(), v0.begin(), op); \
1663#undef RVEC_ASSIGNMENT_OPERATOR
1669#define RVEC_LOGICAL_OPERATOR(OP) \
1670template <typename T0, typename T1> \
1671auto operator OP(const RVec<T0> &v, const T1 &y) \
1674 RVec<int> ret(v.size()); \
1675 auto op = [y](const T0 &x) -> int { return x OP y; }; \
1676 std::transform(v.begin(), v.end(), ret.begin(), op); \
1680template <typename T0, typename T1> \
1681auto operator OP(const T0 &x, const RVec<T1> &v) \
1684 RVec<int> ret(v.size()); \
1685 auto op = [x](const T1 &y) -> int { return x OP y; }; \
1686 std::transform(v.begin(), v.end(), ret.begin(), op); \
1690template <typename T0, typename T1> \
1691auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
1694 if (v0.size() != v1.size()) \
1695 throw std::runtime_error(ERROR_MESSAGE(OP)); \
1697 RVec<int> ret(v0.size()); \
1698 auto op = [](const T0 &x, const T1 &y) -> int { return x OP y; }; \
1699 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
1711#undef RVEC_LOGICAL_OPERATOR
1718template <
typename T>
struct PromoteTypeImpl;
1720template <>
struct PromoteTypeImpl<float> {
using Type = float; };
1722template <>
struct PromoteTypeImpl<long
double> {
using Type =
long double; };
1724template <
typename T>
struct PromoteTypeImpl {
using Type =
double; };
1726template <
typename T>
1729template <
typename U,
typename V>
1730using PromoteTypes =
decltype(PromoteType<U>() + PromoteType<V>());
1734#define RVEC_UNARY_FUNCTION(NAME, FUNC) \
1735 template <typename T> \
1736 RVec<PromoteType<T>> NAME(const RVec<T> &v) \
1738 RVec<PromoteType<T>> ret(v.size()); \
1739 auto f = [](const T &x) { return FUNC(x); }; \
1740 std::transform(v.begin(), v.end(), ret.begin(), f); \
1744#define RVEC_BINARY_FUNCTION(NAME, FUNC) \
1745 template <typename T0, typename T1> \
1746 RVec<PromoteTypes<T0, T1>> NAME(const T0 &x, const RVec<T1> &v) \
1748 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
1749 auto f = [&x](const T1 &y) { return FUNC(x, y); }; \
1750 std::transform(v.begin(), v.end(), ret.begin(), f); \
1754 template <typename T0, typename T1> \
1755 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v, const T1 &y) \
1757 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
1758 auto f = [&y](const T1 &x) { return FUNC(x, y); }; \
1759 std::transform(v.begin(), v.end(), ret.begin(), f); \
1763 template <typename T0, typename T1> \
1764 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v0, const RVec<T1> &v1) \
1766 if (v0.size() != v1.size()) \
1767 throw std::runtime_error(ERROR_MESSAGE(NAME)); \
1769 RVec<PromoteTypes<T0, T1>> ret(v0.size()); \
1770 auto f = [](const T0 &x, const T1 &y) { return FUNC(x, y); }; \
1771 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), f); \
1775#define RVEC_STD_UNARY_FUNCTION(F) RVEC_UNARY_FUNCTION(F, std::F)
1776#define RVEC_STD_BINARY_FUNCTION(F) RVEC_BINARY_FUNCTION(F, std::F)
1823#undef RVEC_STD_UNARY_FUNCTION
1830#define RVEC_VDT_UNARY_FUNCTION(F) RVEC_UNARY_FUNCTION(F, vdt::F)
1832RVEC_VDT_UNARY_FUNCTION(fast_expf)
1833RVEC_VDT_UNARY_FUNCTION(fast_logf)
1834RVEC_VDT_UNARY_FUNCTION(fast_sinf)
1835RVEC_VDT_UNARY_FUNCTION(fast_cosf)
1836RVEC_VDT_UNARY_FUNCTION(fast_tanf)
1837RVEC_VDT_UNARY_FUNCTION(fast_asinf)
1838RVEC_VDT_UNARY_FUNCTION(fast_acosf)
1839RVEC_VDT_UNARY_FUNCTION(fast_atanf)
1843RVEC_VDT_UNARY_FUNCTION(fast_sin)
1844RVEC_VDT_UNARY_FUNCTION(fast_cos)
1845RVEC_VDT_UNARY_FUNCTION(fast_tan)
1846RVEC_VDT_UNARY_FUNCTION(fast_asin)
1847RVEC_VDT_UNARY_FUNCTION(fast_acos)
1848RVEC_VDT_UNARY_FUNCTION(fast_atan)
1849#undef RVEC_VDT_UNARY_FUNCTION
1853#undef RVEC_UNARY_FUNCTION
1868template <
typename T,
typename V>
1871 if (
v0.size() !=
v1.size())
1872 throw std::runtime_error(
"Cannot compute inner product of vectors of different sizes");
1899template <
typename T>
1902 return std::accumulate(
v.begin(),
v.end(), zero);
1907 return std::accumulate(
v.begin(),
v.end(), zero);
1911template <
typename T>
1914 return std::accumulate(
v.begin(),
v.end(),
init, std::multiplies<T>());
1929template <
typename T>
1932 if (
v.empty())
return 0.;
1961template <
typename T,
typename R = T>
1964 if (
v.empty())
return zero;
1965 return Sum(
v, zero) /
v.size();
1978template <
typename T>
1981 return *std::max_element(
v.begin(),
v.end());
1994template <
typename T>
1997 return *std::min_element(
v.begin(),
v.end());
2012template <
typename T>
2015 return std::distance(
v.begin(), std::max_element(
v.begin(),
v.end()));
2030template <
typename T>
2033 return std::distance(
v.begin(), std::min_element(
v.begin(),
v.end()));
2047template <
typename T>
2050 const std::size_t
size =
v.size();
2051 if (
size < std::size_t(2))
return 0.;
2052 T sum_squares(0), squared_sum(0);
2053 auto pred = [&sum_squares, &squared_sum](
const T&
x) {sum_squares+=
x*
x; squared_sum+=
x;};
2054 std::for_each(
v.begin(),
v.end(), pred);
2055 squared_sum *= squared_sum;
2057 return 1. / (dsize - 1.) * (sum_squares - squared_sum / dsize );
2071template <
typename T>
2095template <
typename... Args>
2108 constexpr auto nArgs =
sizeof...(Args);
2111 "Map: the first N-1 arguments must be RVecs or references to RVecs");
2114 std::make_index_sequence<
sizeof...(args) - 1>());
2127template <
typename T,
typename F>
2130 const auto thisSize =
v.size();
2132 w.reserve(thisSize);
2133 for (
auto &&val :
v) {
2135 w.emplace_back(val);
2150template <
typename T>
2154 if (
static_cast<bool>(
e) ==
true)
2169template <
typename T>
2173 if (
static_cast<bool>(
e) ==
false)
2178template <
typename T>
2195template <
typename T>
2201 std::sort(i.
begin(), i.
end(), [&
v](size_type i1, size_type i2) { return v[i1] < v[i2]; });
2216template <
typename T,
typename Compare>
2223 [&
v, &
c](size_type i1, size_type i2) { return c(v[i1], v[i2]); });
2240template <
typename T>
2246 std::stable_sort(i.
begin(), i.
end(), [&
v](size_type i1, size_type i2) { return v[i1] < v[i2]; });
2263template <
typename T,
typename Compare>
2269 std::stable_sort(i.
begin(), i.
end(), [&
v, &
c](size_type i1, size_type i2) { return c(v[i1], v[i2]); });
2284template <
typename T>
2288 const size_type isize = i.size();
2290 for (size_type k = 0; k < isize; k++)
2296template <
typename T>
2300 const size_type isize = i.size();
2302 for (size_type k = 0; k < isize; k++)
2330template <
typename T>
2334 const size_type
size =
v.size();
2337 std::stringstream ss;
2338 ss <<
"Try to take " << absn <<
" elements but vector has only size " <<
size <<
".";
2339 throw std::runtime_error(ss.str());
2343 for (size_type k = 0; k < absn; k++)
2344 r[k] =
v[
size - absn + k];
2346 for (size_type k = 0; k < absn; k++)
2355template <
typename T>
2359 std::sort(idxs.begin(), idxs.end());
2360 idxs.erase(std::unique(idxs.begin(), idxs.end()), idxs.end());
2363 if (
v.size() > idxs.size())
2364 r.reserve(
v.size() - idxs.size());
2366 auto discardIt = idxs.begin();
2368 for (sz_t i = 0u; i <
v.size(); ++i) {
2369 if (discardIt != idxs.end() && i == *discardIt)
2372 r.emplace_back(
v[i]);
2388template <
typename T>
2392 std::reverse(
r.begin(),
r.end());
2409template <
typename T>
2413 std::sort(
r.begin(),
r.end());
2434template <
typename T,
typename Compare>
2438 std::sort(
r.begin(),
r.end(), std::forward<Compare>(
c));
2458template <
typename T>
2462 std::stable_sort(
r.begin(),
r.end());
2494template <
typename T,
typename Compare>
2498 std::stable_sort(
r.begin(),
r.end(), std::forward<Compare>(
c));
2516 using size_type = std::size_t;
2518 r[0].resize(size1*size2);
2519 r[1].resize(size1*size2);
2521 for(size_type i=0; i<size1; i++) {
2522 for(size_type j=0; j<size2; j++) {
2545template <
typename T1,
typename T2>
2570template <
typename T>
2574 const size_type
s =
v.size();
2576 throw std::runtime_error(
"Cannot make unique combinations of size " + std::to_string(
n) +
2577 " from vector of size " + std::to_string(
s) +
".");
2581 for(size_type k=0; k<
s; k++)
2584 const auto innersize = [=] {
2585 size_type inners =
s -
n + 1;
2586 for (size_type
m =
s -
n + 2;
m <=
s; ++
m)
2589 size_type factn = 1;
2590 for (size_type i = 2; i <=
n; ++i)
2598 size_type inneridx = 0;
2599 for (size_type k = 0; k <
n; k++)
2604 bool run_through =
true;
2608 run_through =
false;
2616 for (
long j=i+1; j<(long)
n; j++)
2618 for (size_type k = 0; k <
n; k++)
2634template <
typename T>
2639 const auto size =
v.size();
2641 for(size_type i=0; i<
size; i++) {
2665template <
typename T>
2669 if (!v2_is_sorted) v2_sorted =
Sort(
v2);
2670 const auto v2_begin = v2_is_sorted ?
v2.begin() : v2_sorted.
begin();
2671 const auto v2_end = v2_is_sorted ?
v2.end() : v2_sorted.
end();
2673 const auto size =
v1.size();
2676 for(size_type i=0; i<
size; i++) {
2677 if (std::binary_search(v2_begin, v2_end,
v1[i])) {
2678 r.emplace_back(
v1[i]);
2699template <
typename T>
2703 const size_type
size =
c.size();
2706 for (size_type i=0; i<
size; i++) {
2707 r.emplace_back(
c[i] != 0 ?
v1[i] :
v2[i]);
2727template <
typename T>
2731 const size_type
size =
c.size();
2734 for (size_type i=0; i<
size; i++) {
2735 r.emplace_back(
c[i] != 0 ?
v1[i] :
v2);
2755template <
typename T>
2759 const size_type
size =
c.size();
2762 for (size_type i=0; i<
size; i++) {
2763 r.emplace_back(
c[i] != 0 ?
v1 :
v2[i]);
2781template <
typename T>
2785 const size_type
size =
c.size();
2788 for (size_type i=0; i<
size; i++) {
2789 r.emplace_back(
c[i] != 0 ?
v1 :
v2);
2809 std::copy(
v0.begin(),
v0.end(), std::back_inserter(res));
2810 std::copy(
v1.begin(),
v1.end(), std::back_inserter(res));
2820template <
typename T>
2824 "DeltaPhi must be called with floating point values.");
2841template <
typename T>
2845 const size_type
size =
v1.size();
2847 for (size_type i = 0; i <
size; i++) {
2859template <
typename T>
2863 const size_type
size =
v1.size();
2865 for (size_type i = 0; i <
size; i++) {
2877template <
typename T>
2881 const size_type
size =
v2.size();
2883 for (size_type i = 0; i <
size; i++) {
2896template <
typename T>
2899 const auto dphi =
DeltaPhi(phi1, phi2,
c);
2900 return (eta1 - eta2) * (eta1 - eta2) + dphi * dphi;
2910template <
typename T>
2923template <
typename T>
2926 const auto dphi =
DeltaPhi(phi1, phi2,
c);
2927 return std::sqrt((eta1 - eta2) * (eta1 - eta2) + dphi * dphi);
2935template <
typename T>
2947 for (std::size_t i = 0u; i <
size; ++i) {
2951 const auto z1 = pt1[i] *
std::sinh(eta1[i]);
2956 const auto z2 = pt2[i] *
std::sinh(eta2[i]);
2960 const auto e = e1 + e2;
2961 const auto x =
x1 +
x2;
2962 const auto y =
y1 +
y2;
2963 const auto z = z1 + z2;
2977template <
typename T>
2980 const std::size_t
size =
pt.size();
2989 for (std::size_t i = 0u; i <
size; ++ i) {
2997 const auto e =
std::sqrt(
x *
x +
y *
y + z * z + mass[i] * mass[i]);
3002 return std::sqrt(e_sum * e_sum - x_sum * x_sum - y_sum * y_sum - z_sum * z_sum);
3023template <
typename T,
typename... Args_t>
3029 for (
auto i = 0UL; i <
size; ++i) {
3043template <
typename T>
3046 const auto size =
v.size();
3049 for (
auto i = 0UL; i <
size; ++i) {
3066 for (
auto i = 0UL; i <
length; ++i) {
3077 ret.
reserve(begin < end ? end - begin : 0u);
3078 for (
auto i = begin; i < end; ++i)
3094 auto size =
v.size();
3096 for (std::size_t i = 0; i <
size - 1; ++i) {
3097 os << (Print_t)
v[i] <<
", ";
3099 os << (Print_t)
v[
size - 1];
3105#if (_VECOPS_USE_EXTERN_TEMPLATES)
3107#define RVEC_EXTERN_UNARY_OPERATOR(T, OP) \
3108 extern template RVec<T> operator OP<T>(const RVec<T> &);
3110#define RVEC_EXTERN_BINARY_OPERATOR(T, OP) \
3111 extern template auto operator OP<T, T>(const T &x, const RVec<T> &v) \
3112 -> RVec<decltype(x OP v[0])>; \
3113 extern template auto operator OP<T, T>(const RVec<T> &v, const T &y) \
3114 -> RVec<decltype(v[0] OP y)>; \
3115 extern template auto operator OP<T, T>(const RVec<T> &v0, const RVec<T> &v1)\
3116 -> RVec<decltype(v0[0] OP v1[0])>;
3118#define RVEC_EXTERN_ASSIGN_OPERATOR(T, OP) \
3119 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const T &); \
3120 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const RVec<T> &);
3122#define RVEC_EXTERN_LOGICAL_OPERATOR(T, OP) \
3123 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const T &); \
3124 extern template RVec<int> operator OP<T, T>(const T &, const RVec<T> &); \
3125 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const RVec<T> &);
3127#define RVEC_EXTERN_FLOAT_TEMPLATE(T) \
3128 extern template class RVec<T>; \
3129 RVEC_EXTERN_UNARY_OPERATOR(T, +) \
3130 RVEC_EXTERN_UNARY_OPERATOR(T, -) \
3131 RVEC_EXTERN_UNARY_OPERATOR(T, !) \
3132 RVEC_EXTERN_BINARY_OPERATOR(T, +) \
3133 RVEC_EXTERN_BINARY_OPERATOR(T, -) \
3134 RVEC_EXTERN_BINARY_OPERATOR(T, *) \
3135 RVEC_EXTERN_BINARY_OPERATOR(T, /) \
3136 RVEC_EXTERN_ASSIGN_OPERATOR(T, +=) \
3137 RVEC_EXTERN_ASSIGN_OPERATOR(T, -=) \
3138 RVEC_EXTERN_ASSIGN_OPERATOR(T, *=) \
3139 RVEC_EXTERN_ASSIGN_OPERATOR(T, /=) \
3140 RVEC_EXTERN_LOGICAL_OPERATOR(T, <) \
3141 RVEC_EXTERN_LOGICAL_OPERATOR(T, >) \
3142 RVEC_EXTERN_LOGICAL_OPERATOR(T, ==) \
3143 RVEC_EXTERN_LOGICAL_OPERATOR(T, !=) \
3144 RVEC_EXTERN_LOGICAL_OPERATOR(T, <=) \
3145 RVEC_EXTERN_LOGICAL_OPERATOR(T, >=) \
3146 RVEC_EXTERN_LOGICAL_OPERATOR(T, &&) \
3147 RVEC_EXTERN_LOGICAL_OPERATOR(T, ||)
3149#define RVEC_EXTERN_INTEGER_TEMPLATE(T) \
3150 extern template class RVec<T>; \
3151 RVEC_EXTERN_UNARY_OPERATOR(T, +) \
3152 RVEC_EXTERN_UNARY_OPERATOR(T, -) \
3153 RVEC_EXTERN_UNARY_OPERATOR(T, ~) \
3154 RVEC_EXTERN_UNARY_OPERATOR(T, !) \
3155 RVEC_EXTERN_BINARY_OPERATOR(T, +) \
3156 RVEC_EXTERN_BINARY_OPERATOR(T, -) \
3157 RVEC_EXTERN_BINARY_OPERATOR(T, *) \
3158 RVEC_EXTERN_BINARY_OPERATOR(T, /) \
3159 RVEC_EXTERN_BINARY_OPERATOR(T, %) \
3160 RVEC_EXTERN_BINARY_OPERATOR(T, &) \
3161 RVEC_EXTERN_BINARY_OPERATOR(T, |) \
3162 RVEC_EXTERN_BINARY_OPERATOR(T, ^) \
3163 RVEC_EXTERN_ASSIGN_OPERATOR(T, +=) \
3164 RVEC_EXTERN_ASSIGN_OPERATOR(T, -=) \
3165 RVEC_EXTERN_ASSIGN_OPERATOR(T, *=) \
3166 RVEC_EXTERN_ASSIGN_OPERATOR(T, /=) \
3167 RVEC_EXTERN_ASSIGN_OPERATOR(T, %=) \
3168 RVEC_EXTERN_ASSIGN_OPERATOR(T, &=) \
3169 RVEC_EXTERN_ASSIGN_OPERATOR(T, |=) \
3170 RVEC_EXTERN_ASSIGN_OPERATOR(T, ^=) \
3171 RVEC_EXTERN_ASSIGN_OPERATOR(T, >>=) \
3172 RVEC_EXTERN_ASSIGN_OPERATOR(T, <<=) \
3173 RVEC_EXTERN_LOGICAL_OPERATOR(T, <) \
3174 RVEC_EXTERN_LOGICAL_OPERATOR(T, >) \
3175 RVEC_EXTERN_LOGICAL_OPERATOR(T, ==) \
3176 RVEC_EXTERN_LOGICAL_OPERATOR(T, !=) \
3177 RVEC_EXTERN_LOGICAL_OPERATOR(T, <=) \
3178 RVEC_EXTERN_LOGICAL_OPERATOR(T, >=) \
3179 RVEC_EXTERN_LOGICAL_OPERATOR(T, &&) \
3180 RVEC_EXTERN_LOGICAL_OPERATOR(T, ||)
3182RVEC_EXTERN_INTEGER_TEMPLATE(
char)
3183RVEC_EXTERN_INTEGER_TEMPLATE(
short)
3184RVEC_EXTERN_INTEGER_TEMPLATE(
int)
3185RVEC_EXTERN_INTEGER_TEMPLATE(
long)
3188RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned char)
3189RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned short)
3190RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned int)
3191RVEC_EXTERN_INTEGER_TEMPLATE(
unsigned long)
3194RVEC_EXTERN_FLOAT_TEMPLATE(
float)
3195RVEC_EXTERN_FLOAT_TEMPLATE(
double)
3197#undef RVEC_EXTERN_UNARY_OPERATOR
3198#undef RVEC_EXTERN_BINARY_OPERATOR
3199#undef RVEC_EXTERN_ASSIGN_OPERATOR
3200#undef RVEC_EXTERN_LOGICAL_OPERATOR
3201#undef RVEC_EXTERN_INTEGER_TEMPLATE
3202#undef RVEC_EXTERN_FLOAT_TEMPLATE
3204#define RVEC_EXTERN_UNARY_FUNCTION(T, NAME, FUNC) \
3205 extern template RVec<PromoteType<T>> NAME(const RVec<T> &);
3207#define RVEC_EXTERN_STD_UNARY_FUNCTION(T, F) RVEC_EXTERN_UNARY_FUNCTION(T, F, std::F)
3209#define RVEC_EXTERN_BINARY_FUNCTION(T0, T1, NAME, FUNC) \
3210 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const T1 &); \
3211 extern template RVec<PromoteTypes<T0, T1>> NAME(const T0 &, const RVec<T1> &); \
3212 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const RVec<T1> &);
3214#define RVEC_EXTERN_STD_BINARY_FUNCTION(T, F) RVEC_EXTERN_BINARY_FUNCTION(T, T, F, std::F)
3216#define RVEC_EXTERN_STD_FUNCTIONS(T) \
3217 RVEC_EXTERN_STD_UNARY_FUNCTION(T, abs) \
3218 RVEC_EXTERN_STD_BINARY_FUNCTION(T, fdim) \
3219 RVEC_EXTERN_STD_BINARY_FUNCTION(T, fmod) \
3220 RVEC_EXTERN_STD_BINARY_FUNCTION(T, remainder) \
3221 RVEC_EXTERN_STD_UNARY_FUNCTION(T, exp) \
3222 RVEC_EXTERN_STD_UNARY_FUNCTION(T, exp2) \
3223 RVEC_EXTERN_STD_UNARY_FUNCTION(T, expm1) \
3224 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log) \
3225 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log10) \
3226 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log2) \
3227 RVEC_EXTERN_STD_UNARY_FUNCTION(T, log1p) \
3228 RVEC_EXTERN_STD_BINARY_FUNCTION(T, pow) \
3229 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sqrt) \
3230 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cbrt) \
3231 RVEC_EXTERN_STD_BINARY_FUNCTION(T, hypot) \
3232 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sin) \
3233 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cos) \
3234 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tan) \
3235 RVEC_EXTERN_STD_UNARY_FUNCTION(T, asin) \
3236 RVEC_EXTERN_STD_UNARY_FUNCTION(T, acos) \
3237 RVEC_EXTERN_STD_UNARY_FUNCTION(T, atan) \
3238 RVEC_EXTERN_STD_BINARY_FUNCTION(T, atan2) \
3239 RVEC_EXTERN_STD_UNARY_FUNCTION(T, sinh) \
3240 RVEC_EXTERN_STD_UNARY_FUNCTION(T, cosh) \
3241 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tanh) \
3242 RVEC_EXTERN_STD_UNARY_FUNCTION(T, asinh) \
3243 RVEC_EXTERN_STD_UNARY_FUNCTION(T, acosh) \
3244 RVEC_EXTERN_STD_UNARY_FUNCTION(T, atanh) \
3245 RVEC_EXTERN_STD_UNARY_FUNCTION(T, floor) \
3246 RVEC_EXTERN_STD_UNARY_FUNCTION(T, ceil) \
3247 RVEC_EXTERN_STD_UNARY_FUNCTION(T, trunc) \
3248 RVEC_EXTERN_STD_UNARY_FUNCTION(T, round) \
3249 RVEC_EXTERN_STD_UNARY_FUNCTION(T, erf) \
3250 RVEC_EXTERN_STD_UNARY_FUNCTION(T, erfc) \
3251 RVEC_EXTERN_STD_UNARY_FUNCTION(T, lgamma) \
3252 RVEC_EXTERN_STD_UNARY_FUNCTION(T, tgamma) \
3254RVEC_EXTERN_STD_FUNCTIONS(
float)
3255RVEC_EXTERN_STD_FUNCTIONS(
double)
3256#undef RVEC_EXTERN_STD_UNARY_FUNCTION
3257#undef RVEC_EXTERN_STD_BINARY_FUNCTION
3258#undef RVEC_EXTERN_STD_UNARY_FUNCTIONS
3262#define RVEC_EXTERN_VDT_UNARY_FUNCTION(T, F) RVEC_EXTERN_UNARY_FUNCTION(T, F, vdt::F)
3264RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_expf)
3265RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_logf)
3266RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_sinf)
3267RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_cosf)
3268RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_tanf)
3269RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_asinf)
3270RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_acosf)
3271RVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_atanf)
3273RVEC_EXTERN_VDT_UNARY_FUNCTION(
double,
fast_exp)
3274RVEC_EXTERN_VDT_UNARY_FUNCTION(
double,
fast_log)
3275RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_sin)
3276RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_cos)
3277RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_tan)
3278RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_asin)
3279RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_acos)
3280RVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_atan)
#define R__unlikely(expr)
#define R__RVEC_NODISCARD
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define R__CLING_PTRCHECK(ONOFF)
static Double_t Product(const Double_t *x, const Float_t *y)
Product.
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
Binding & operator=(OUT(*fun)(void))
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)
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)
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)
void append(size_type NumInputs, const T &Elt)
Append NumInputs copies of Elt to the end.
iterator erase(const_iterator CI)
RVecImpl & operator=(RVecImpl &&RHS)
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.
bool Owns() const
If true, the RVec is in "memory adoption" mode, i.e. it is acting as a view on a memory buffer it doe...
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 ...
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
size_t capacity() const noexcept
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
RVecN(Detail::VecOps::RVecImpl< T > &&RHS)
reference operator[](size_type idx)
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)
RVecN & operator=(RVecN &&RHS)
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(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.
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)
RVec(const RVecN< T, N > &RHS)
RVec(size_t Size, const T &Value)
RVec & operator=(RVec &&RHS)
RVec operator[](const RVec< V > &conds) const
RVec(std::initializer_list< T > IL)
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)
Type
enumeration specifying the integration types.
RVec< T > Reverse(const RVec< T > &v)
Return copy of reversed vector.
RVec< T > DeltaPhi(T v1, const RVec< T > &v2, const T c=M_PI)
Return the angle difference in radians of a scalar and a vector.
RVec< T > Where(const RVec< int > &c, T v1, T v2)
Return a vector with the value v2 if the condition c is false and sets the value v1 if the condition ...
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< RVec< typename RVec< T >::size_type > > Combinations(const RVec< T > &v, const typename RVec< T >::size_type n)
Return the indices that represent all unique combinations of the elements of a given RVec.
RVec< PromoteType< T > > asinh(const RVec< T > &v)
RVec< typename RVec< T >::size_type > Argsort(const RVec< T > &v, Compare &&c)
Return an RVec of indices that sort the input RVec based on a comparison function.
RVec< PromoteType< T > > expm1(const RVec< T > &v)
RVec< PromoteType< T > > lgamma(const RVec< T > &v)
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)
RVec< PromoteType< T > > cosh(const RVec< T > &v)
RVec< PromoteType< T > > abs(const RVec< T > &v)
#define RVEC_ASSIGNMENT_OPERATOR(OP)
RVec< PromoteType< T > > round(const RVec< T > &v)
T InvariantMass(const RVec< T > &pt, const RVec< T > &eta, const RVec< T > &phi, const RVec< T > &mass)
Return the invariant mass of multiple particles given the collections of the quantities transverse mo...
RVec< PromoteType< T > > tgamma(const RVec< T > &v)
RVec< PromoteType< T > > log2(const RVec< T > &v)
RVec< Common_t > Concatenate(const RVec< T0 > &v0, const RVec< T1 > &v1)
Return the concatenation of two RVecs.
RVec< PromoteType< T > > tan(const RVec< T > &v)
RVec< PromoteType< T > > erf(const RVec< T > &v)
RVec< T > StableSort(const RVec< T > &v, Compare &&c)
Return copy of RVec with elements sorted based on a comparison operator while keeping the order of eq...
RVec< PromoteType< T > > cos(const RVec< T > &v)
RVec< T > InvariantMasses(const RVec< T > &pt1, const RVec< T > &eta1, const RVec< T > &phi1, const RVec< T > &mass1, const RVec< T > &pt2, const RVec< T > &eta2, const RVec< T > &phi2, const RVec< T > &mass2)
Return the invariant mass of two particles given the collections of the quantities transverse momentu...
RVec< PromoteType< T > > floor(const RVec< T > &v)
RVec< std::size_t > Range(std::size_t begin, std::size_t end)
Produce RVec with entries equal to begin, begin+1, ..., end-1.
RVec< PromoteType< T > > atanh(const RVec< T > &v)
RVec< PromoteType< T > > acosh(const RVec< T > &v)
RVec< T > DeltaR2(const RVec< T > &eta1, const RVec< T > &eta2, const RVec< T > &phi1, const RVec< T > &phi2, const T c=M_PI)
Return the square of the distance on the - plane ( ) from the collections eta1, eta2,...
RVec< PromoteTypes< T0, T1 > > remainder(const RVec< T0 > &v0, const RVec< T1 > &v1)
RVec< PromoteType< T > > ceil(const RVec< T > &v)
RVec< PromoteType< T > > cbrt(const RVec< T > &v)
T Sum(const RVec< T > &v, const T zero=T(0))
Sum elements of an RVec.
RVec< PromoteType< T > > asin(const RVec< T > &v)
void swap(RVec< T > &lhs, RVec< T > &rhs)
RVec< PromoteType< T > > log(const RVec< T > &v)
RVec< T > Construct(const RVec< Args_t > &... args)
Build an RVec of objects starting from RVecs of input to their constructors.
RVec< PromoteType< T > > trunc(const RVec< T > &v)
RVec< PromoteType< T > > llround(const RVec< T > &v)
RVec< PromoteTypes< T0, T1 > > pow(const RVec< T0 > &v0, const RVec< T1 > &v1)
RVec< PromoteTypes< T0, T1 > > hypot(const RVec< T0 > &v0, const RVec< T1 > &v1)
#define RVEC_STD_BINARY_FUNCTION(F)
RVec< PromoteType< T > > lround(const RVec< T > &v)
#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< typename RVec< T >::size_type > StableArgsort(const RVec< T > &v, Compare &&c)
Return an RVec of indices that sort the input RVec based on a comparison function while keeping the o...
size_t CapacityInBytes(const RVecN< T, N > &X)
#define RVEC_LOGICAL_OPERATOR(OP)
RVec< T > Take(const RVec< T > &v, const int n)
Return first or last n elements of an RVec.
RVec< PromoteType< T > > sinh(const RVec< T > &v)
RVec< PromoteType< T > > sqrt(const RVec< T > &v)
RVec< PromoteType< T > > erfc(const RVec< T > &v)
RVec< T > Sort(const RVec< T > &v, Compare &&c)
Return copy of RVec with elements sorted based on a comparison operator.
#define RVEC_STD_UNARY_FUNCTION(F)
RVec< PromoteTypes< T0, T1 > > atan2(const RVec< T0 > &v0, const RVec< T1 > &v1)
RVec< PromoteTypes< T0, T1 > > fmod(const RVec< T0 > &v0, const RVec< T1 > &v1)
RVec< PromoteType< T > > log10(const RVec< T > &v)
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< PromoteType< T > > exp(const RVec< T > &v)
RVec< PromoteTypes< T0, T1 > > fdim(const RVec< T0 > &v0, const RVec< T1 > &v1)
double StdDev(const RVec< T > &v)
Get the standard deviation of the elements of an RVec.
auto Any(const RVec< T > &v) -> decltype(v[0]==true)
Return true if any of the elements equates to true, return false otherwise.
RVec< PromoteType< T > > tanh(const RVec< T > &v)
RVec< PromoteType< T > > acos(const RVec< T > &v)
RVec< PromoteType< T > > log1p(const RVec< T > &v)
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< PromoteType< T > > atan(const RVec< T > &v)
RVec< PromoteType< T > > sin(const RVec< T > &v)
double Var(const RVec< T > &v)
Get the variance of the elements of an RVec.
RVec< PromoteType< T > > exp2(const RVec< T > &v)
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...
T DeltaR(T eta1, T eta2, T phi1, T phi2, const T c=M_PI)
Return the distance on the - plane ( ) from the scalars eta1, eta2, phi1 and phi2.
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]...))>
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)
ROOT::VecOps::RVec< T > RVec
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)...))
std::ostream & operator<<(std::ostream &os, const RConcurrentHashColl::HashValue &h)
double inner_product(const LAVector &, const LAVector &)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
__roodevice__ double fast_exp(double x)
void init()
Inspect hardware capabilities, and load the optimal library for RooFit computations.
__roodevice__ double fast_log(double x)
RooArgSet S(Args_t &&... args)
static constexpr double s
constexpr Double_t E()
Base of natural log: .
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.