15void vo002_VectorCalculations()
28 std::cout <<
"v1 = " << v1 <<
"\n"
29 <<
"v2 = " << v2 <<
"\n"
30 <<
"v1 + v2 = " << v_sum <<
"\n"
31 <<
"v1 * v2 = " << v_mul << std::endl;
34 auto v_diff_s_0 = v1 - 2;
35 auto v_diff_s_1 = 2 - v1;
36 auto v_div_s_0 = v1 / 2.;
37 auto v_div_s_1 = 2. / v1;
39 std::cout << v1 <<
" - 2 = " << v_diff_s_0 <<
"\n"
40 <<
"2 - " << v1 <<
" = " << v_diff_s_1 <<
"\n"
41 << v1 <<
" / 2 = " << v_div_s_0 <<
"\n"
42 <<
"2 / " << v1 <<
" = " << v_div_s_1 << std::endl;
47 auto v1_mean =
Mean(v1);
48 auto v1_dot_v2 =
Dot(v1, v2);
50 std::cout <<
"Mean of " << v1 <<
" is " << v1_mean <<
"\n"
51 <<
"Dot product of " << v1 <<
" and " << v2 <<
" is " << v1_dot_v2 << std::endl;
58 std::cout <<
"exp(" << v1 <<
") = " << v_exp <<
"\n"
59 <<
"log(" << v1 <<
") = " << v_log <<
"\n"
60 <<
"sin(" << v1 <<
") = " << v_sin << std::endl;
65 auto v_fast_exp = fast_exp(v1);
66 auto v_fast_log = fast_log(v1);
67 auto v_fast_sin = fast_sin(v1);
69 std::cout <<
"fast_exp(" << v1 <<
") = " << v_fast_exp <<
"\n"
70 <<
"fast_log(" << v1 <<
") = " << v_fast_log <<
"\n"
71 <<
"fast_sin(" << v1 <<
") = " << v_fast_sin << std::endl;
75 auto v_transf =
Map(v1, [](
double x) {
return x * 2 / 3; });
77 std::cout <<
"Applying [](double x){return x * 2 / 3;} to " << v1 <<
" leads to " << v_transf <<
"\n";
Double_t Dot(const TGLVector3 &v1, const TGLVector3 &v2)
auto Map(Args &&... args) -> decltype(ROOT::Detail::VecOps::MapFromTuple(std::forward_as_tuple(args...), std::make_index_sequence< sizeof...(args) - 1 >()))
Create new collection applying a callable to the elements of the input collection.
Double_t Mean(Long64_t n, const T *a, const Double_t *w=0)
Return the weighted mean of an array a with length n.