19 #define _VECOPS_USE_EXTERN_TEMPLATES false
21 #define _VECOPS_USE_EXTERN_TEMPLATES true
37#include <vdt/vdtMath.h>
53template<
typename T,
typename... Args>
57 v.emplace_back(std::forward<Args>(args)...);
61template<
typename... Args>
65 v.push_back(std::forward<Args>(args)...);
226 static constexpr const auto IsVecBool = std::is_same<bool, T>::value;
228 using Impl_t =
typename std::conditional<IsVecBool, std::vector<bool>, std::vector<T, ::ROOT::Detail::VecOps::RAdoptAllocator<T>>>
::type;
264 template <
class InputIt>
289 template <typename U, typename = std::enable_if<std::is_convertible<T, U>::value>>
306 template <typename V, typename = std::enable_if<std::is_convertible<V, bool>::value>>
312 throw std::runtime_error(
"Cannot index RVec with condition vector of different size");
354 template <
class... Args>
358 EBHelper_t::EmplaceBack(
fData, std::forward<Args>(args)...);
363 template<typename U = T, typename std::enable_if<std::is_arithmetic<U>::value,
int>* =
nullptr>
366 return fData.emplace(pos, value);
377#define TVEC_UNARY_OPERATOR(OP) \
378template <typename T> \
379RVec<T> operator OP(const RVec<T> &v) \
382 for (auto &x : ret) \
391#undef TVEC_UNARY_OPERATOR
397#define ERROR_MESSAGE(OP) \
398 "Cannot call operator " #OP " on vectors of different sizes."
400#define TVEC_BINARY_OPERATOR(OP) \
401template <typename T0, typename T1> \
402auto operator OP(const RVec<T0> &v, const T1 &y) \
403 -> RVec<decltype(v[0] OP y)> \
405 RVec<decltype(v[0] OP y)> ret(v.size()); \
406 auto op = [&y](const T0 &x) { return x OP y; }; \
407 std::transform(v.begin(), v.end(), ret.begin(), op); \
411template <typename T0, typename T1> \
412auto operator OP(const T0 &x, const RVec<T1> &v) \
413 -> RVec<decltype(x OP v[0])> \
415 RVec<decltype(x OP v[0])> ret(v.size()); \
416 auto op = [&x](const T1 &y) { return x OP y; }; \
417 std::transform(v.begin(), v.end(), ret.begin(), op); \
421template <typename T0, typename T1> \
422auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
423 -> RVec<decltype(v0[0] OP v1[0])> \
425 if (v0.size() != v1.size()) \
426 throw std::runtime_error(ERROR_MESSAGE(OP)); \
428 RVec<decltype(v0[0] OP v1[0])> ret(v0.size()); \
429 auto op = [](const T0 &x, const T1 &y) { return x OP y; }; \
430 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
442#undef TVEC_BINARY_OPERATOR
448#define TVEC_ASSIGNMENT_OPERATOR(OP) \
449template <typename T0, typename T1> \
450RVec<T0>& operator OP(RVec<T0> &v, const T1 &y) \
452 auto op = [&y](T0 &x) { return x OP y; }; \
453 std::transform(v.begin(), v.end(), v.begin(), op); \
457template <typename T0, typename T1> \
458RVec<T0>& operator OP(RVec<T0> &v0, const RVec<T1> &v1) \
460 if (v0.size() != v1.size()) \
461 throw std::runtime_error(ERROR_MESSAGE(OP)); \
463 auto op = [](T0 &x, const T1 &y) { return x OP y; }; \
464 std::transform(v0.begin(), v0.end(), v1.begin(), v0.begin(), op); \
478#undef TVEC_ASSIGNMENT_OPERATOR
484#define TVEC_LOGICAL_OPERATOR(OP) \
485template <typename T0, typename T1> \
486auto operator OP(const RVec<T0> &v, const T1 &y) \
489 RVec<int> ret(v.size()); \
490 auto op = [y](const T0 &x) -> int { return x OP y; }; \
491 std::transform(v.begin(), v.end(), ret.begin(), op); \
495template <typename T0, typename T1> \
496auto operator OP(const T0 &x, const RVec<T1> &v) \
499 RVec<int> ret(v.size()); \
500 auto op = [x](const T1 &y) -> int { return x OP y; }; \
501 std::transform(v.begin(), v.end(), ret.begin(), op); \
505template <typename T0, typename T1> \
506auto operator OP(const RVec<T0> &v0, const RVec<T1> &v1) \
509 if (v0.size() != v1.size()) \
510 throw std::runtime_error(ERROR_MESSAGE(OP)); \
512 RVec<int> ret(v0.size()); \
513 auto op = [](const T0 &x, const T1 &y) -> int { return x OP y; }; \
514 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), op); \
526#undef TVEC_LOGICAL_OPERATOR
533template <
typename T>
struct PromoteTypeImpl;
535template <>
struct PromoteTypeImpl<float> {
using Type = float; };
536template <>
struct PromoteTypeImpl<double> {
using Type = double; };
537template <>
struct PromoteTypeImpl<long double> {
using Type =
long double; };
539template <
typename T>
struct PromoteTypeImpl {
using Type = double; };
544template <
typename U,
typename V>
545using PromoteTypes =
decltype(PromoteType<U>() + PromoteType<V>());
549#define TVEC_UNARY_FUNCTION(NAME, FUNC) \
550 template <typename T> \
551 RVec<PromoteType<T>> NAME(const RVec<T> &v) \
553 RVec<PromoteType<T>> ret(v.size()); \
554 auto f = [](const T &x) { return FUNC(x); }; \
555 std::transform(v.begin(), v.end(), ret.begin(), f); \
559#define TVEC_BINARY_FUNCTION(NAME, FUNC) \
560 template <typename T0, typename T1> \
561 RVec<PromoteTypes<T0, T1>> NAME(const T0 &x, const RVec<T1> &v) \
563 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
564 auto f = [&x](const T1 &y) { return FUNC(x, y); }; \
565 std::transform(v.begin(), v.end(), ret.begin(), f); \
569 template <typename T0, typename T1> \
570 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v, const T1 &y) \
572 RVec<PromoteTypes<T0, T1>> ret(v.size()); \
573 auto f = [&y](const T1 &x) { return FUNC(x, y); }; \
574 std::transform(v.begin(), v.end(), ret.begin(), f); \
578 template <typename T0, typename T1> \
579 RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &v0, const RVec<T1> &v1) \
581 if (v0.size() != v1.size()) \
582 throw std::runtime_error(ERROR_MESSAGE(NAME)); \
584 RVec<PromoteTypes<T0, T1>> ret(v0.size()); \
585 auto f = [](const T0 &x, const T1 &y) { return FUNC(x, y); }; \
586 std::transform(v0.begin(), v0.end(), v1.begin(), ret.begin(), f); \
590#define TVEC_STD_UNARY_FUNCTION(F) TVEC_UNARY_FUNCTION(F, std::F)
591#define TVEC_STD_BINARY_FUNCTION(F) TVEC_BINARY_FUNCTION(F, std::F)
638#undef TVEC_STD_UNARY_FUNCTION
645#define TVEC_VDT_UNARY_FUNCTION(F) TVEC_UNARY_FUNCTION(F, vdt::F)
647TVEC_VDT_UNARY_FUNCTION(fast_expf)
648TVEC_VDT_UNARY_FUNCTION(fast_logf)
649TVEC_VDT_UNARY_FUNCTION(fast_sinf)
650TVEC_VDT_UNARY_FUNCTION(fast_cosf)
651TVEC_VDT_UNARY_FUNCTION(fast_tanf)
652TVEC_VDT_UNARY_FUNCTION(fast_asinf)
653TVEC_VDT_UNARY_FUNCTION(fast_acosf)
654TVEC_VDT_UNARY_FUNCTION(fast_atanf)
656TVEC_VDT_UNARY_FUNCTION(fast_exp)
657TVEC_VDT_UNARY_FUNCTION(fast_log)
658TVEC_VDT_UNARY_FUNCTION(fast_sin)
659TVEC_VDT_UNARY_FUNCTION(fast_cos)
660TVEC_VDT_UNARY_FUNCTION(fast_tan)
661TVEC_VDT_UNARY_FUNCTION(fast_asin)
662TVEC_VDT_UNARY_FUNCTION(fast_acos)
663TVEC_VDT_UNARY_FUNCTION(fast_atan)
664#undef TVEC_VDT_UNARY_FUNCTION
668#undef TVEC_UNARY_FUNCTION
683template <
typename T,
typename V>
686 if (v0.size() != v1.size())
687 throw std::runtime_error(
"Cannot compute inner product of vectors of different sizes");
688 return std::inner_product(v0.begin(), v0.end(), v1.begin(),
decltype(v0[0] * v1[0])(0));
704 return std::accumulate(
v.begin(),
v.end(),
T(0));
721 if (
v.empty())
return 0.;
722 return double(
Sum(
v)) /
v.size();
739 const std::size_t size =
v.size();
740 if (size < std::size_t(2))
return 0.;
741 T sum_squares(0), squared_sum(0);
742 auto pred = [&sum_squares, &squared_sum](
const T&
x) {sum_squares+=
x*
x; squared_sum+=
x;};
743 std::for_each(
v.begin(),
v.end(), pred);
744 squared_sum *= squared_sum;
745 const auto dsize = (double) size;
746 return 1. / (dsize - 1.) * (sum_squares - squared_sum / dsize );
776template <
typename T,
typename F>
779 RVec<
decltype(
f(
v[0]))> ret(
v.size());
780 std::transform(
v.begin(),
v.end(), ret.begin(),
f);
794template <
typename T,
typename F>
797 const auto thisSize =
v.size();
800 for (
auto &&val :
v) {
867 std::sort(i.
begin(), i.
end(), [&
v](size_type i1, size_type i2) { return v[i1] < v[i2]; });
885 const size_type isize = i.size();
887 for (size_type k = 0; k < isize; k++)
911 const size_type size =
v.size();
912 const size_type absn = std::abs(
n);
914 std::stringstream ss;
915 ss <<
"Try to take " << absn <<
" elements but vector has only size " << size <<
".";
916 throw std::runtime_error(ss.str());
920 for (size_type k = 0; k < absn; k++)
921 r[k] =
v[size - absn + k];
923 for (size_type k = 0; k < absn; k++)
943 std::reverse(
r.begin(),
r.end());
964 std::sort(
r.begin(),
r.end());
985template <
typename T,
typename Compare>
989 std::sort(
r.begin(),
r.end(), std::forward<Compare>(
c));
1007template <
typename T1,
typename T2>
1011 size_type size1 = v1.
size();
1012 size_type size2 = v2.
size();
1014 r[0].resize(size1*size2);
1015 r[1].resize(size1*size2);
1017 for(size_type i=0; i<size1; i++) {
1018 for(size_type j=0; j<size2; j++) {
1046template <
typename T>
1050 const size_type
s =
v.size();
1052 std::stringstream ss;
1053 ss <<
"Cannot make unique combinations of size " <<
n <<
" from vector of size " <<
s <<
".";
1054 throw std::runtime_error(ss.str());
1057 for(size_type k=0; k<
s; k++)
1060 for(size_type k=0; k<
n; k++)
1063 bool run_through =
true;
1067 run_through =
false;
1075 for (
long j=i+1; j<(long)
n; j++)
1077 for(size_type k=0; k<
n; k++)
1092template <
typename T>
1097 const auto size =
v.size();
1099 for(size_type i=0; i<size; i++) {
1123template <
typename T>
1127 if (!v2_is_sorted) v2_sorted =
Sort(v2);
1128 const auto v2_begin = v2_is_sorted ? v2.
begin() : v2_sorted.
begin();
1129 const auto v2_end = v2_is_sorted ? v2.
end() : v2_sorted.
end();
1131 const auto size = v1.
size();
1134 for(size_type i=0; i<size; i++) {
1135 if (std::binary_search(v2_begin, v2_end, v1[i])) {
1136 r.emplace_back(v1[i]);
1157template <
typename T>
1161 const size_type size =
c.size();
1164 for (size_type i=0; i<size; i++) {
1165 r.emplace_back(
c[i] != 0 ? v1[i] : v2[i]);
1185template <
typename T>
1189 const size_type size =
c.size();
1192 for (size_type i=0; i<size; i++) {
1193 r.emplace_back(
c[i] != 0 ? v1[i] : v2);
1213template <
typename T>
1217 const size_type size =
c.size();
1220 for (size_type i=0; i<size; i++) {
1221 r.emplace_back(
c[i] != 0 ? v1 : v2[i]);
1239template <
typename T>
1243 const size_type size =
c.size();
1246 for (size_type i=0; i<size; i++) {
1247 r.emplace_back(
c[i] != 0 ? v1 : v2);
1258 constexpr bool mustConvert = std::is_same<char, T>::value || std::is_same<signed char, T>::value ||
1259 std::is_same<unsigned char, T>::value || std::is_same<wchar_t, T>::value ||
1260 std::is_same<char16_t, T>::value || std::is_same<char32_t, T>::value;
1263 auto size =
v.size();
1265 for (std::size_t i = 0; i < size - 1; ++i) {
1266 os << (Print_t)
v[i] <<
", ";
1268 os << (Print_t)
v[size - 1];
1274#if (_VECOPS_USE_EXTERN_TEMPLATES)
1276#define TVEC_EXTERN_UNARY_OPERATOR(T, OP) \
1277 extern template RVec<T> operator OP<T>(const RVec<T> &);
1279#define TVEC_EXTERN_BINARY_OPERATOR(T, OP) \
1280 extern template auto operator OP<T, T>(const T &x, const RVec<T> &v) \
1281 -> RVec<decltype(x OP v[0])>; \
1282 extern template auto operator OP<T, T>(const RVec<T> &v, const T &y) \
1283 -> RVec<decltype(v[0] OP y)>; \
1284 extern template auto operator OP<T, T>(const RVec<T> &v0, const RVec<T> &v1)\
1285 -> RVec<decltype(v0[0] OP v1[0])>;
1287#define TVEC_EXTERN_ASSIGN_OPERATOR(T, OP) \
1288 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const T &); \
1289 extern template RVec<T> &operator OP<T, T>(RVec<T> &, const RVec<T> &);
1291#define TVEC_EXTERN_LOGICAL_OPERATOR(T, OP) \
1292 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const T &); \
1293 extern template RVec<int> operator OP<T, T>(const T &, const RVec<T> &); \
1294 extern template RVec<int> operator OP<T, T>(const RVec<T> &, const RVec<T> &);
1296#define TVEC_EXTERN_FLOAT_TEMPLATE(T) \
1297 extern template class RVec<T>; \
1298 TVEC_EXTERN_UNARY_OPERATOR(T, +) \
1299 TVEC_EXTERN_UNARY_OPERATOR(T, -) \
1300 TVEC_EXTERN_UNARY_OPERATOR(T, !) \
1301 TVEC_EXTERN_BINARY_OPERATOR(T, +) \
1302 TVEC_EXTERN_BINARY_OPERATOR(T, -) \
1303 TVEC_EXTERN_BINARY_OPERATOR(T, *) \
1304 TVEC_EXTERN_BINARY_OPERATOR(T, /) \
1305 TVEC_EXTERN_ASSIGN_OPERATOR(T, +=) \
1306 TVEC_EXTERN_ASSIGN_OPERATOR(T, -=) \
1307 TVEC_EXTERN_ASSIGN_OPERATOR(T, *=) \
1308 TVEC_EXTERN_ASSIGN_OPERATOR(T, /=) \
1309 TVEC_EXTERN_LOGICAL_OPERATOR(T, <) \
1310 TVEC_EXTERN_LOGICAL_OPERATOR(T, >) \
1311 TVEC_EXTERN_LOGICAL_OPERATOR(T, ==) \
1312 TVEC_EXTERN_LOGICAL_OPERATOR(T, !=) \
1313 TVEC_EXTERN_LOGICAL_OPERATOR(T, <=) \
1314 TVEC_EXTERN_LOGICAL_OPERATOR(T, >=) \
1315 TVEC_EXTERN_LOGICAL_OPERATOR(T, &&) \
1316 TVEC_EXTERN_LOGICAL_OPERATOR(T, ||)
1318#define TVEC_EXTERN_INTEGER_TEMPLATE(T) \
1319 extern template class RVec<T>; \
1320 TVEC_EXTERN_UNARY_OPERATOR(T, +) \
1321 TVEC_EXTERN_UNARY_OPERATOR(T, -) \
1322 TVEC_EXTERN_UNARY_OPERATOR(T, ~) \
1323 TVEC_EXTERN_UNARY_OPERATOR(T, !) \
1324 TVEC_EXTERN_BINARY_OPERATOR(T, +) \
1325 TVEC_EXTERN_BINARY_OPERATOR(T, -) \
1326 TVEC_EXTERN_BINARY_OPERATOR(T, *) \
1327 TVEC_EXTERN_BINARY_OPERATOR(T, /) \
1328 TVEC_EXTERN_BINARY_OPERATOR(T, %) \
1329 TVEC_EXTERN_BINARY_OPERATOR(T, &) \
1330 TVEC_EXTERN_BINARY_OPERATOR(T, |) \
1331 TVEC_EXTERN_BINARY_OPERATOR(T, ^) \
1332 TVEC_EXTERN_ASSIGN_OPERATOR(T, +=) \
1333 TVEC_EXTERN_ASSIGN_OPERATOR(T, -=) \
1334 TVEC_EXTERN_ASSIGN_OPERATOR(T, *=) \
1335 TVEC_EXTERN_ASSIGN_OPERATOR(T, /=) \
1336 TVEC_EXTERN_ASSIGN_OPERATOR(T, %=) \
1337 TVEC_EXTERN_ASSIGN_OPERATOR(T, &=) \
1338 TVEC_EXTERN_ASSIGN_OPERATOR(T, |=) \
1339 TVEC_EXTERN_ASSIGN_OPERATOR(T, ^=) \
1340 TVEC_EXTERN_ASSIGN_OPERATOR(T, >>=) \
1341 TVEC_EXTERN_ASSIGN_OPERATOR(T, <<=) \
1342 TVEC_EXTERN_LOGICAL_OPERATOR(T, <) \
1343 TVEC_EXTERN_LOGICAL_OPERATOR(T, >) \
1344 TVEC_EXTERN_LOGICAL_OPERATOR(T, ==) \
1345 TVEC_EXTERN_LOGICAL_OPERATOR(T, !=) \
1346 TVEC_EXTERN_LOGICAL_OPERATOR(T, <=) \
1347 TVEC_EXTERN_LOGICAL_OPERATOR(T, >=) \
1348 TVEC_EXTERN_LOGICAL_OPERATOR(T, &&) \
1349 TVEC_EXTERN_LOGICAL_OPERATOR(T, ||)
1351TVEC_EXTERN_INTEGER_TEMPLATE(
char)
1352TVEC_EXTERN_INTEGER_TEMPLATE(
short)
1353TVEC_EXTERN_INTEGER_TEMPLATE(
int)
1354TVEC_EXTERN_INTEGER_TEMPLATE(
long)
1357TVEC_EXTERN_INTEGER_TEMPLATE(
unsigned char)
1358TVEC_EXTERN_INTEGER_TEMPLATE(
unsigned short)
1359TVEC_EXTERN_INTEGER_TEMPLATE(
unsigned int)
1360TVEC_EXTERN_INTEGER_TEMPLATE(
unsigned long)
1363TVEC_EXTERN_FLOAT_TEMPLATE(
float)
1364TVEC_EXTERN_FLOAT_TEMPLATE(
double)
1366#undef TVEC_EXTERN_UNARY_OPERATOR
1367#undef TVEC_EXTERN_BINARY_OPERATOR
1368#undef TVEC_EXTERN_ASSIGN_OPERATOR
1369#undef TVEC_EXTERN_LOGICAL_OPERATOR
1370#undef TVEC_EXTERN_INTEGER_TEMPLATE
1371#undef TVEC_EXTERN_FLOAT_TEMPLATE
1373#define TVEC_EXTERN_UNARY_FUNCTION(T, NAME, FUNC) \
1374 extern template RVec<PromoteType<T>> NAME(const RVec<T> &);
1376#define TVEC_EXTERN_STD_UNARY_FUNCTION(T, F) TVEC_EXTERN_UNARY_FUNCTION(T, F, std::F)
1378#define TVEC_EXTERN_BINARY_FUNCTION(T0, T1, NAME, FUNC) \
1379 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const T1 &); \
1380 extern template RVec<PromoteTypes<T0, T1>> NAME(const T0 &, const RVec<T1> &); \
1381 extern template RVec<PromoteTypes<T0, T1>> NAME(const RVec<T0> &, const RVec<T1> &);
1383#define TVEC_EXTERN_STD_BINARY_FUNCTION(T, F) TVEC_EXTERN_BINARY_FUNCTION(T, T, F, std::F)
1385#define TVEC_EXTERN_STD_FUNCTIONS(T) \
1386 TVEC_EXTERN_STD_UNARY_FUNCTION(T, abs) \
1387 TVEC_EXTERN_STD_BINARY_FUNCTION(T, fdim) \
1388 TVEC_EXTERN_STD_BINARY_FUNCTION(T, fmod) \
1389 TVEC_EXTERN_STD_BINARY_FUNCTION(T, remainder) \
1390 TVEC_EXTERN_STD_UNARY_FUNCTION(T, exp) \
1391 TVEC_EXTERN_STD_UNARY_FUNCTION(T, exp2) \
1392 TVEC_EXTERN_STD_UNARY_FUNCTION(T, expm1) \
1393 TVEC_EXTERN_STD_UNARY_FUNCTION(T, log) \
1394 TVEC_EXTERN_STD_UNARY_FUNCTION(T, log10) \
1395 TVEC_EXTERN_STD_UNARY_FUNCTION(T, log2) \
1396 TVEC_EXTERN_STD_UNARY_FUNCTION(T, log1p) \
1397 TVEC_EXTERN_STD_BINARY_FUNCTION(T, pow) \
1398 TVEC_EXTERN_STD_UNARY_FUNCTION(T, sqrt) \
1399 TVEC_EXTERN_STD_UNARY_FUNCTION(T, cbrt) \
1400 TVEC_EXTERN_STD_BINARY_FUNCTION(T, hypot) \
1401 TVEC_EXTERN_STD_UNARY_FUNCTION(T, sin) \
1402 TVEC_EXTERN_STD_UNARY_FUNCTION(T, cos) \
1403 TVEC_EXTERN_STD_UNARY_FUNCTION(T, tan) \
1404 TVEC_EXTERN_STD_UNARY_FUNCTION(T, asin) \
1405 TVEC_EXTERN_STD_UNARY_FUNCTION(T, acos) \
1406 TVEC_EXTERN_STD_UNARY_FUNCTION(T, atan) \
1407 TVEC_EXTERN_STD_BINARY_FUNCTION(T, atan2) \
1408 TVEC_EXTERN_STD_UNARY_FUNCTION(T, sinh) \
1409 TVEC_EXTERN_STD_UNARY_FUNCTION(T, cosh) \
1410 TVEC_EXTERN_STD_UNARY_FUNCTION(T, tanh) \
1411 TVEC_EXTERN_STD_UNARY_FUNCTION(T, asinh) \
1412 TVEC_EXTERN_STD_UNARY_FUNCTION(T, acosh) \
1413 TVEC_EXTERN_STD_UNARY_FUNCTION(T, atanh) \
1414 TVEC_EXTERN_STD_UNARY_FUNCTION(T, floor) \
1415 TVEC_EXTERN_STD_UNARY_FUNCTION(T, ceil) \
1416 TVEC_EXTERN_STD_UNARY_FUNCTION(T, trunc) \
1417 TVEC_EXTERN_STD_UNARY_FUNCTION(T, round) \
1418 TVEC_EXTERN_STD_UNARY_FUNCTION(T, erf) \
1419 TVEC_EXTERN_STD_UNARY_FUNCTION(T, erfc) \
1420 TVEC_EXTERN_STD_UNARY_FUNCTION(T, lgamma) \
1421 TVEC_EXTERN_STD_UNARY_FUNCTION(T, tgamma) \
1423TVEC_EXTERN_STD_FUNCTIONS(
float)
1424TVEC_EXTERN_STD_FUNCTIONS(
double)
1425#undef TVEC_EXTERN_STD_UNARY_FUNCTION
1426#undef TVEC_EXTERN_STD_BINARY_FUNCTION
1427#undef TVEC_EXTERN_STD_UNARY_FUNCTIONS
1431#define TVEC_EXTERN_VDT_UNARY_FUNCTION(T, F) TVEC_EXTERN_UNARY_FUNCTION(T, F, vdt::F)
1433TVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_expf)
1434TVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_logf)
1435TVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_sinf)
1436TVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_cosf)
1437TVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_tanf)
1438TVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_asinf)
1439TVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_acosf)
1440TVEC_EXTERN_VDT_UNARY_FUNCTION(
float, fast_atanf)
1442TVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_exp)
1443TVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_log)
1444TVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_sin)
1445TVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_cos)
1446TVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_tan)
1447TVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_asin)
1448TVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_acos)
1449TVEC_EXTERN_VDT_UNARY_FUNCTION(
double, fast_atan)
#define TVEC_STD_UNARY_FUNCTION(F)
#define TVEC_UNARY_OPERATOR(OP)
#define TVEC_BINARY_OPERATOR(OP)
#define TVEC_STD_BINARY_FUNCTION(F)
#define TVEC_ASSIGNMENT_OPERATOR(OP)
#define TVEC_LOGICAL_OPERATOR(OP)
Int_t Compare(const void *item1, const void *item2)
double atan2(double, double)
double pow(double, double)
A "std::vector"-like collection of values implementing handy operation to analyse them.
typename std::conditional< IsVecBool, std::vector< bool >, std::vector< T, ::ROOT::Detail::VecOps::RAdoptAllocator< T > > >::type Impl_t
typename Impl_t::iterator iterator
static constexpr const auto IsVecBool
const_iterator begin() const noexcept
reverse_iterator rbegin() noexcept
const_iterator cbegin() const noexcept
typename Impl_t::value_type value_type
reference operator[](size_type pos)
iterator erase(iterator pos)
RVec< T > & operator=(std::initializer_list< T > ilist)
typename Impl_t::const_pointer const_pointer
RVec(std::initializer_list< T > init)
void resize(size_type count)
void push_back(T &&value)
const_reference back() const
typename Impl_t::difference_type difference_type
const_reverse_iterator crbegin() const noexcept
RVec operator[](const RVec< V > &conds) const
iterator erase(iterator first, iterator last)
RVec< T > & operator=(RVec< T > &&v)
const_reverse_iterator crend() const noexcept
const_reference at(size_type pos) const
typename Impl_t::const_iterator const_iterator
bool empty() const noexcept
typename Impl_t::reference reference
void push_back(const value_type &value)
size_type size() const noexcept
RVec(size_type count, const T &value)
const_iterator end() const noexcept
iterator emplace(const_iterator pos, U value)
This method is intended only for arithmetic types unlike the std::vector corresponding one which is g...
typename Impl_t::const_reference const_reference
const_iterator cend() const noexcept
typename Impl_t::const_reverse_iterator const_reverse_iterator
const_reference front() const
void reserve(size_type new_cap)
reference at(size_type pos)
const_reverse_iterator rend() const noexcept
typename std::conditional< IsVecBool, void, typename Impl_t::pointer >::type data_t
typename Impl_t::reverse_iterator reverse_iterator
const_reference operator[](size_type pos) const
typename Impl_t::pointer pointer
size_type capacity() const noexcept
reverse_iterator rend() noexcept
RVec< T > & operator=(const RVec< T > &v)
typename std::conditional< IsVecBool, void, typename Impl_t::const_pointer >::type const_data_t
const Impl_t & AsVector() const
iterator begin() noexcept
const_reverse_iterator rbegin() const noexcept
typename Impl_t::size_type size_type
void resize(size_type count, const value_type &value)
reference emplace_back(Args &&... args)
const_data_t data() const noexcept
RVec(const std::vector< T > &v)
void swap(RVec< T > &other)
RVec(InputIt first, InputIt last)
RVec(pointer p, size_type n)
size_type max_size() const noexcept
Type
enumeration specifying the integration types.
double erfc(double x)
Complementary error function.
double tgamma(double x)
The gamma function is defined to be the extension of the factorial to real numbers.
double lgamma(double x)
Calculates the logarithm of the gamma function.
double erf(double x)
Error function encountered in integrating the normal distribution.
double log1p(double x)
declarations for functions which are not implemented by some compilers
double expm1(double x)
exp(x) -1 with error cancellation when x is small
double inner_product(const LAVector &, const LAVector &)
RVec< T > Reverse(const RVec< T > &v)
Return copy of reversed vector.
RVec< T > Intersect(const RVec< T > &v1, const RVec< T > &v2, bool v2_is_sorted=false)
Return the intersection of elements of two RVecs.
auto All(const RVec< T > &v) -> decltype(v[0]==false)
Return true if all of the elements equate to true, return false otherwise.
T Sum(const RVec< T > &v)
Sum elements of an RVec.
RVec< typename RVec< T >::size_type > Nonzero(const RVec< T > &v)
Return the indices of the elements which are not zero.
RVec< T > Sort(const RVec< T > &v)
Return copy of RVec with elements sorted in ascending order.
std::ostream & operator<<(std::ostream &os, const RVec< T > &v)
Print a RVec at the prompt:
double Mean(const RVec< T > &v)
Get the mean of the elements of an RVec.
RVec< RVec< typename RVec< T1 >::size_type > > Combinations(const RVec< T1 > &v1, const RVec< T2 > &v2)
Return the indices that represent all combinations of the elements of two RVecs.
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)
auto Dot(const RVec< T > &v0, const RVec< V > &v1) -> decltype(v0[0] *v1[0])
Inner product.
RVec< T > Where(const RVec< int > &c, const RVec< T > &v1, const RVec< T > &v2)
Return the elements of v1 if the condition c is true and v2 if the condition c is false.
double StdDev(const RVec< T > &v)
Get the standard deviation of the elements of an RVec.
auto Any(const RVec< T > &v) -> decltype(v[0]==true)
Return true if any of the elements equates to true, return false otherwise.
auto Map(const RVec< T > &v, F &&f) -> RVec< decltype(f(v[0]))>
Create new collection applying a callable to the elements of the input collection.
RVec< typename RVec< T >::size_type > Argsort(const RVec< T > &v)
Return an RVec of indices that sort the input RVec.
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.
Namespace for new ROOT classes and functions.
static constexpr double s
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value and is_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
static void EmplaceBack(std::vector< bool > &v, Args &&... args)
static void EmplaceBack(T &v, Args &&... args)