8 #include "Protium/Math/MathFunctions.h"
16 using namespace Protium;
18 template<
typename T,
int n>
20 std::cout<<
"Vector of Length: "<<n<<std::endl;
21 for(
int i=0; i<n;i++)std::cout<<
" "<<vector.
At(i);
25 template<
typename T,
int n,
int m>
27 std::cout<<
"Matrix of Dimensions: "<<n<<
" X "<<m<<std::endl;
28 for(
int i=0; i<n;i++){
30 std::cout<<
" "<<matrix.
At(i,j);
39 std::cout<<
"Getting Histogram of "<<nBins<<
" bins"<<std::endl;
40 for(
unsigned i=0;i<nBins;i++){
47 int main(
int argc,
char* argv[]){
51 std::cout<<
"Starting Basic Unit Tests"<<std::endl;
52 std::cout<<
"\tMath tests"<<std::setprecision(16)<<std::endl;
55 std::cout<<
"\t\tInt factorial (6): "<<
56 factorial<unsigned>(3)<<
"\t"<<factorial<int>(3)<<
57 "\t"<<factorial<long>(3)<<std::endl;
59 std::cout<<
"\t\tFloat/Double factorial (6): "<<
60 factorial<float>(3)<<
"\t"<<factorial<double>(3)<<
61 "\t"<<factorial<long double>(3)<<std::endl;
63 std::cout<<
"\t\tEuler\'s Number (2.71828182845904523536028747135266249775724709369995): "<<nat<<std::endl;
64 std::cout<<
"\t\t\tError: "<<2.71828182845904523536028747135266249775724709369995-nat<<std::endl;
65 std::cout<<
"\t\tPowers: "<<std::endl;
66 for(
double i=0; i<15;i++)
for(
double j=0; j<15; j++)
67 std::cout<<
"\t"<<power(i,j)<<
"\t";
71 std::cout<<
"\tLinear Algebra Tests"<<std::endl;
73 using namespace LinearAlgebra;
74 std::cout<<
"Testing Vectors"<<std::endl;
94 PrintVector(vec.GetSubVector(1).GetSubVector(1).GetSubVector(1));
161 std::cout<<
"Testing Matrices"<<std::endl;
196 for(
int i=0; i<7;i++)
for(
int j=0; j<7;j++) copy[i][j]=1+(i-j)*(i-j)*(i-j)*(i-j)*(i-j);
199 PrintMatrix(copy.GetSubMatrix(0,0).GetSubMatrix(0,0) );
200 PrintMatrix(copy.GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0) );
201 PrintMatrix(copy.GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0) );
202 PrintMatrix(copy.GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0) );
203 PrintMatrix(copy.GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0) );
206 std::cout<<copy.GetSubMatrix(0,0).GetDeterminant()<<std::endl;
207 std::cout<<copy.GetSubMatrix(0,0).GetSubMatrix(0,0).GetDeterminant()<<std::endl;
208 std::cout<<copy.GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetDeterminant()<<std::endl;
209 std::cout<<copy.GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetDeterminant()<<std::endl;
210 std::cout<<copy.GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetDeterminant()<<std::endl;
211 std::cout<<copy.GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetSubMatrix(0,0).GetDeterminant()<<std::endl;
215 std::cout<<
"Vector Times Matrix Multiplication"<<std::endl;
217 for(
int i=0; i<7;i++)vec[i]=i;
219 for(
int i=0; i<7;i++)mat[0][i]=i;
223 std::cout<<
"Testing Histogram Classes"<<std::endl;
225 using namespace Containers;
229 h.SetNewBin(98.75, 1.0);
232 std::cout<<
"Testing Time Functions"<<std::endl;
234 using namespace Time;
239 std::cout<<
"Single Clock Output"<<clk.GetTime()<<std::endl;
241 std::cout<<
"Single Clock Output"<<clk.GetTime()<<std::endl;
243 std::cout<<
"Single Clock Output"<<clk.GetTime()<<std::endl;
245 for(
int i=0; i<100;i++)
247 std::cout<<
"Testing RepeatClocker: Start Time: "<<rpt.GetStart();
248 for(
int i=0; i<rpt.GetNClocks();i++)
249 std::cout<<
" Clock: "<<rpt.Get(i)<<
" Offset: "<<rpt.GetOffset(i)<<std::endl;
251 std::cout<<
"Testing Time..."<<std::endl;
254 std::cout<<
"The Time now is: "<<t.AsFormat()<<std::endl;
256 std::cout<<
"Other Time is: "<<other.AsFormat()<<std::endl;
Vector< double, 10 > TenVector
unsigned GetNBins() const
static Matrix< T, n, m > Unit()
Vector< double, 13 > ThirteenVector
Vector< double, 5 > FiveVector
Vector< T, n > At(const int &row) const
Vector< double, 12 > TwelveVector
Vector< double, 6 > SixVector
static SignalCatcher & Instance()
Matrix< double, 6, 6 > SixMatrix
BinType GetBinWidthByI(const int &i) const
Vector< double, 11 > ElevenVector
Histogram< double > Histo1D
Vector< double, 14 > FourteenVector
int main(int argc, char *argv[])
static TimePrimitive Now()
Vector< double, 7 > SevenVector
unsigned GetBinContentByI(const int &i) const
void PrintVector(const LinearAlgebra::Vector< T, n > &vector)
Matrix< double, 7, 7 > SevenMatrix
void PrintHistogram(const Containers::Histo1D &h)
Vector< double, 8 > EightVector
Matrix< double, 5, 5 > FiveMatrix
Vector< double, 15 > FifteenVector
Vector< double, 9 > NineVector
static Vector< T, n > UnitVector(int dim=0)
Constructs a unit vector in the given dimension.
Matrix< double, 2, 2 > TwoMatrix
Implements matrix addition, subtraction, multiplication.
Implementation of vector to be used in Linear Algebra.
Matrix< double, 4, 4 > FourMatrix
const T & At(const int &index) const
Vector< double, 3 > ThreeVector
Convenience typedef of a double three vector.
void PrintMatrix(const LinearAlgebra::Matrix< T, n, m > &matrix)
static TimeDate FromFormat(const std::string &t, const std::string &fmt="%d/%m/%Y %H:%M:%S")
Matrix< double, 3, 3 > ThreeMatrix
Vector< double, 4 > FourVector
Convenience typedef of a double four vector.
Vector< double, 2 > TwoVector
Convenience Typedef of a double twovector.
BinType GetLowerEdgeByI(const int &i) const