23 if ( strcmp(
typeid(
T).
name(),
"f" ) == 0 )
25 else if ( strcmp(
typeid(
T).
name(),
"d" ) == 0 )
28 type =
typeid(
T).
name();
32 cout <<
"NormCross(const " << type <<
" v1[3],const " 33 << type <<
" v2[3]," << type <<
" out[3]): out = [" 34 << fout[0] <<
", " << fout[1] <<
", " << fout[2] <<
"]" 39 template <
typename T,
typename U>
47 T sa[
n] = { 2, 55 ,23, 57, -9, 24, 6, 82, -4, 10};
51 cout <<
"Vector a[] = {" << sa[0];
52 for (
Int_t i = 1; i <
n; ++i )
53 cout <<
", " << sa[i];
54 cout <<
"}\n" << endl;
60 <<
" Mean: " <<
Mean(n, sa)
62 <<
" RMS: " <<
RMS(n, sa)
63 <<
" Median: " <<
Median(n, sa)
64 <<
" KOrdStat(3): " <<
KOrdStat(n, sa, k)
68 cout <<
"Sorted a[] = {" << sa[index[0]];
69 for (
Int_t i = 1; i <
n; ++i )
70 cout <<
", " << sa[index[i]];
75 cout <<
"BinarySearch(n, a, 57) = " << is <<
"\n" << endl;
82 vector<Int_t> index(n);
85 T tsa[
n] = { 2, 55 ,23, 57, -9, 24, 6, 82, -4, 10};
87 for (
int i = 0; i <
n; ++i ) sa[i] = tsa[i];
91 cout <<
"\nVector a[] = {" << sa[0];
92 for (
Int_t i = 1; i <
n; ++i )
93 cout <<
", " << sa[i];
94 cout <<
"}\n" << endl;
98 cout <<
"Min: " << *
LocMin(sa.begin(), sa.end())
99 <<
" Max: " << *
LocMax(sa.begin(), sa.end())
100 <<
" Mean: " <<
Mean(sa.begin(), sa.end())
101 <<
" GeomMean: " <<
GeomMean(sa.begin(), sa.end())
102 <<
" RMS: " <<
RMS(sa.begin(), sa.end())
106 cout <<
"Sorted a[] = {" << sa[ index[0] ];
107 for (
Int_t i = 1; i <
n; ++i )
108 cout <<
", " << sa[ index[i] ];
111 sort(&sa[0], &sa[0]+n);
113 cout <<
"BinarySearch(n, a, 57) = " << is <<
"\n" << endl;
116 template <
typename T>
121 T dx[4] = {0, 0, 2, 2};
122 T dy[4] = {0, 2, 2, 0};
123 cout <<
"Point(" << x <<
"," << y <<
") IsInside?: " 124 <<
IsInside( x, y, n, dx, dy) << endl;
128 template <
typename T>
145 cout <<
"Starting tests on TMath..." << endl;
147 cout <<
"\nNormCross tests: " << endl;
149 testNormCross<Float_t>();
150 testNormCross<Double_t>();
152 cout <<
"\nArray functions tests: " << endl;
154 testArrayFunctions<Short_t,Long64_t>();
155 testArrayFunctions<Int_t,Long64_t>();
156 testArrayFunctions<Float_t,Long64_t>();
157 testArrayFunctions<Double_t,Long64_t>();
158 testArrayFunctions<Double_t,Int_t>();
159 testArrayFunctions<Long_t,Long64_t>();
160 testArrayFunctions<Long64_t,Long64_t>();
162 cout <<
"\nIterator functions tests: " << endl;
164 testIteratorFunctions<Short_t>();
165 testIteratorFunctions<Int_t>();
166 testIteratorFunctions<Float_t>();
167 testIteratorFunctions<Double_t>();
168 testIteratorFunctions<Long_t>();
169 testIteratorFunctions<Long64_t>();
171 cout <<
"\nPoint functions tests: " << endl;
173 testPoints<Double_t>(1.3, 0.5);
174 testPoints<Float_t>(-0.2, 1.7);
175 testPoints<Int_t>(1, 1);
177 cout <<
"\nPLane functions tests: " << endl;
179 testPlane<Double_t>();
180 testPlane<Float_t>();
Long64_t LocMax(Long64_t n, const T *a)
void testIteratorFunctions()
Double_t GeomMean(Long64_t n, const T *a)
T * Normal2Plane(const T v1[3], const T v2[3], const T v3[3], T normal[3])
Double_t RMS(Long64_t n, const T *a, const Double_t *w=0)
void testArrayFunctions()
T NormCross(const T v1[3], const T v2[3], T out[3])
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Bool_t IsInside(T xp, T yp, Int_t np, T *x, T *y)
Double_t Mean(Long64_t n, const T *a, const Double_t *w=0)
Double_t Median(Long64_t n, const T *a, const Double_t *w=0, Long64_t *work=0)
T MaxElement(Long64_t n, const T *a)
Element KOrdStat(Size n, const Element *a, Size k, Size *work=0)
void testPoints(T x, T y)
Long64_t LocMin(Long64_t n, const T *a)
Long64_t BinarySearch(Long64_t n, const T *array, T value)
void SortItr(Iterator first, Iterator last, IndexIterator index, Bool_t down=kTRUE)
T MinElement(Long64_t n, const T *a)