Polymath/tests/tests.cpp

50 lines
1.6 KiB
C++
Raw Normal View History

2016-10-17 16:11:29 +00:00
#include <string>
#include <locale>
#include "tests.h"
int RunTests()
{
// Py_SetProgramName("MatricesTest"); /* optional but recommended */
Py_Initialize();
PyRun_SimpleString("import numpy as np");
PyRun_SimpleString("def compare_floats(f1,f2,tol):\n return np.isclose(f1,f2,rtol=tol)");
bool print = 0;
for(int i = 0; i < 10; i++)
{
// std::cout<<TestInverse<float>(2,print)<<std::endl;
for(long j = 2; j < 20; j++)
{
if(!TestInverse<float>(j,print))
{
std::cerr<<"Error testing float inverse. Try again to verify that this is not a statistical error."<<std::endl;
std::exit(1);
}
if(!TestInverse<double>(j,print))
{
std::cerr<<"Error testing double inverse. Try again to verify that this is not a statistical error."<<std::endl;
std::exit(1);
}
if(!TestInverse<std::complex<float>>(j,print))
{
std::cerr<<"Error testing complex float inverse. Try again to verify that this is not a statistical error."<<std::endl;
std::exit(1);
}
if(!TestInverse<std::complex<double>>(j,print))
{
std::cerr<<"Error testing complex double inverse. Try again to verify that this is not a statistical error."<<std::endl;
std::exit(1);
}
}
}
Py_Finalize();
return 0;
}
int main()
{
RunTests();
std::cout<<"Tests program exited with no errors."<<std::endl;
return 0;
}