Commit d5638d0f authored by Samer Afach's avatar Samer Afach
Browse files

Many fixes and tests of the initial release of Polymath.

parent 03ff1f63
This diff is collapsed.
......@@ -2,6 +2,7 @@
#define STDADAPTERS_H
#include <functional>
#include <algorithm>
namespace Poly
{
......@@ -12,7 +13,7 @@ class Matrix;
namespace std
{
#ifndef _CONCAT
#define _CONCAT(A, B) A ## B
#define _CONCAT(A, B) A ## B
#endif
#define _UNARY_STD_ADAPTER(func_name) \
......@@ -20,7 +21,7 @@ template <typename T, int M> \
Poly::Matrix<T,M> func_name(const Poly::Matrix<T,M>& mat) \
{ \
Poly::Matrix<T,M> res(mat.rows(), mat.columns()); \
std::transform(mat.begin(),mat.end(),res.begin(),std::pointer_to_unary_function<T,T>(std::ceil)); \
std::transform(mat.begin(),mat.end(),res.begin(),std::pointer_to_unary_function<T,T>(std::func_name)); \
return res; \
}
......@@ -28,7 +29,7 @@ Poly::Matrix<T,M> func_name(const Poly::Matrix<T,M>& mat) \
template <typename T, int M> \
void _CONCAT(func_name, _inplace)(Poly::Matrix<T,M>& mat) \
{ \
std::transform(mat.begin(),mat.end(),mat.begin(),std::pointer_to_unary_function<T,T>(std::ceil)); \
std::transform(mat.begin(),mat.end(),mat.begin(),std::pointer_to_unary_function<T,T>(std::func_name)); \
}
#define _BINARY_STD_ADAPTER(func_name) \
......@@ -158,6 +159,7 @@ _UNARY_STD_ADAPTER(isinf)
_UNARY_STD_ADAPTER(isnormal)
_UNARY_STD_ADAPTER(signbit)
_UNARY_STD_ADAPTER_INPLACE(abs)
_UNARY_STD_ADAPTER_INPLACE(acos)
_UNARY_STD_ADAPTER_INPLACE(acosh)
......
#include "StdAdapters.h"
#include "internal/StdAdapters.h"
......@@ -2,7 +2,6 @@
#include <locale>
#include "tests.h"
int RunTests()
{
// Py_SetProgramName("MatricesTest"); /* optional but recommended */
......@@ -44,9 +43,6 @@ int RunTests()
int main()
{
int len = 3;
Poly::Matrix<double> mat_d = Poly::RandomMatrix<double>(len,len,0,10,std::random_device{}());
Poly::Matrix<double> mat_e = Poly::RandomMatrix<double>(len,len,0,10,std::random_device{}());
RunTests();
std::cout<<"Tests program exited with no errors."<<std::endl;
return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment