Implements map and ref for both static & dynamic mode
See merge request oss/rotgen!12
This commit is contained in:
parent
aacae1cbb1
commit
6c2b260229
58 changed files with 4121 additions and 1205 deletions
73
test/unit/map/arithmetic_functions.cpp
Normal file
73
test/unit/map/arithmetic_functions.cpp
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
//==================================================================================================
|
||||
/*
|
||||
ROTGEN - Runtime Overlay for Eigen
|
||||
Copyright : CODE RECKONS
|
||||
SPDX-License-Identifier: BSL-1.0
|
||||
*/
|
||||
//==================================================================================================
|
||||
#include "unit/tests.hpp"
|
||||
#include "unit/common/arithmetic.hpp"
|
||||
#include <rotgen/rotgen.hpp>
|
||||
|
||||
TTS_CASE_TPL("Test dynamic map transposition-like operations", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_matrix_references();
|
||||
for (const auto& [rows, cols, fn] : cases)
|
||||
{
|
||||
using mat_t = rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>;
|
||||
mat_t base(rows, cols);
|
||||
rotgen::tests::prepare(rows,cols,fn,base);
|
||||
|
||||
rotgen::map<mat_t> input(base.data(),rows,cols);
|
||||
rotgen::tests::check_shape_functions(input);
|
||||
}
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test static map transposition-like operations", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_static_matrix_references();
|
||||
|
||||
auto process = []<typename D>(D const& desc)
|
||||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> base(D::rows,D::cols);
|
||||
rotgen::tests::prepare(base.rows(),base.cols(),desc.init_fn,base);
|
||||
|
||||
rotgen::map<rotgen::matrix<T,D::rows,D::cols,O::value>> input(base.data());
|
||||
rotgen::tests::check_shape_functions(input);
|
||||
};
|
||||
|
||||
std::apply([&](auto const&... d) { (process(d),...);}, cases);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test dynamic map reduction-like operations", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_matrix_references();
|
||||
for (const auto& [rows, cols, fn] : cases)
|
||||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> base(rows, cols);
|
||||
rotgen::tests::prepare(rows,cols,fn,base);
|
||||
|
||||
rotgen::map<rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>> input(base.data(),rows,cols);
|
||||
rotgen::tests::check_reduction_functions(input);
|
||||
}
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test static map reduction-like operations", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_static_matrix_references();
|
||||
|
||||
auto process = []<typename D>(D const& desc)
|
||||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> base(D::rows,D::cols);
|
||||
rotgen::tests::prepare(base.rows(),base.cols(),desc.init_fn,base);
|
||||
|
||||
rotgen::map<rotgen::matrix<T,D::rows,D::cols,O::value>> input(base.data());
|
||||
rotgen::tests::check_reduction_functions(input);
|
||||
};
|
||||
|
||||
std::apply([&](auto const&... d) { (process(d),...);}, cases);
|
||||
};
|
||||
83
test/unit/map/basic_api.cpp
Normal file
83
test/unit/map/basic_api.cpp
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
//==================================================================================================
|
||||
/*
|
||||
ROTGEN - Runtime Overlay for Eigen
|
||||
Copyright : CODE RECKONS
|
||||
SPDX-License-Identifier: BSL-1.0
|
||||
*/
|
||||
//==================================================================================================
|
||||
#include "unit/tests.hpp"
|
||||
#include <rotgen/rotgen.hpp>
|
||||
|
||||
TTS_CASE_TPL("Function size", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
T data[] = {1,2,3,4,5,6,7,8,9,10,11,12};
|
||||
|
||||
rotgen::map<rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>> dyn_map(data,1,12);
|
||||
TTS_EQUAL(dyn_map.rows(), rotgen::Index{1});
|
||||
TTS_EQUAL(dyn_map.cols(), rotgen::Index{12});
|
||||
|
||||
rotgen::map<rotgen::matrix<T,1,12,rotgen::RowMajor>> s112_map(data);
|
||||
TTS_EQUAL(s112_map.rows(), rotgen::Index{1});
|
||||
TTS_EQUAL(s112_map.cols(), rotgen::Index{12});
|
||||
TTS_EQUAL(s112_map.size(), rotgen::Index{12});
|
||||
|
||||
rotgen::map<rotgen::matrix<T,12,1,rotgen::ColMajor>> s121_map(data);
|
||||
TTS_EQUAL(s121_map.rows(), rotgen::Index{12});
|
||||
TTS_EQUAL(s121_map.cols(), rotgen::Index{1});
|
||||
TTS_EQUAL(s121_map.size(), rotgen::Index{12});
|
||||
|
||||
rotgen::map<rotgen::matrix<T,3,4,O::value>> s34_map(data);
|
||||
TTS_EQUAL(s34_map.rows(), rotgen::Index{3});
|
||||
TTS_EQUAL(s34_map.cols(), rotgen::Index{4});
|
||||
TTS_EQUAL(s34_map.size(), rotgen::Index{12});
|
||||
|
||||
rotgen::map<rotgen::matrix<T,6,2,O::value>> s62_map(data);
|
||||
TTS_EQUAL(s62_map.rows(), rotgen::Index{6});
|
||||
TTS_EQUAL(s62_map.cols(), rotgen::Index{2});
|
||||
TTS_EQUAL(s62_map.size(), rotgen::Index{12});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test coefficient accessors", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
using base = rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>;
|
||||
|
||||
T data[] = {1,2,3,4,5,6,7,8,9,10,11,12};
|
||||
|
||||
rotgen::map<base> a(data,4,3);
|
||||
for(rotgen::Index i=0;i<4;i++)
|
||||
{
|
||||
for(rotgen::Index j=0;j<3;j++)
|
||||
{
|
||||
if constexpr(O::value) TTS_EQUAL(a(i,j), data[j+3*i]);
|
||||
else TTS_EQUAL(a(i,j), data[i+4*j]);
|
||||
}
|
||||
}
|
||||
|
||||
a(1, 1) = 42;
|
||||
TTS_EQUAL(a(1,1), 42);
|
||||
|
||||
T& ref = a(2, 2);
|
||||
ref = 17;
|
||||
TTS_EQUAL(a(2, 2), 17);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test one index coefficient accessors", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
using base = rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>;
|
||||
|
||||
T data[] = {1,2,3,4,5,6,7,8,9,10,11,12};
|
||||
|
||||
rotgen::map<base> a(data,4,3);
|
||||
for(rotgen::Index i=0;i<a.size();i++)
|
||||
TTS_EQUAL(a(i), data[i]) << "Index: " << i << "\n";
|
||||
|
||||
a(1) = 42;
|
||||
TTS_EQUAL(data[1], 42);
|
||||
|
||||
T& ref = a(2);
|
||||
ref = 17;
|
||||
TTS_EQUAL(data[2], 17);
|
||||
};
|
||||
89
test/unit/map/constructors.cpp
Normal file
89
test/unit/map/constructors.cpp
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
//==================================================================================================
|
||||
/*
|
||||
ROTGEN - Runtime Overlay for Eigen
|
||||
Copyright : CODE RECKONS
|
||||
SPDX-License-Identifier: BSL-1.0
|
||||
*/
|
||||
//==================================================================================================
|
||||
#include "unit/tests.hpp"
|
||||
#include <rotgen/rotgen.hpp>
|
||||
|
||||
TTS_CASE_TPL("map constructor from pointer and single static size", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
T data[] = {1,2,3,4,5,6,7,8,9,10,11,12};
|
||||
|
||||
rotgen::map<rotgen::matrix<T,1,12,rotgen::RowMajor>> row_map(data);
|
||||
for(rotgen::Index i=0;i<12;i++)
|
||||
TTS_EQUAL(row_map(i), data[i]);
|
||||
|
||||
rotgen::map<rotgen::matrix<T,1,12,rotgen::RowMajor> const> const_row_map(data);
|
||||
for(rotgen::Index i=0;i<12;i++)
|
||||
TTS_EQUAL(const_row_map(i), data[i]);
|
||||
|
||||
rotgen::map<rotgen::matrix<T,12,1,rotgen::ColMajor>> col_map(data);
|
||||
for(rotgen::Index i=0;i<12;i++)
|
||||
TTS_EQUAL(col_map(i), data[i]);
|
||||
|
||||
rotgen::map<rotgen::matrix<T,12,1,rotgen::ColMajor> const> const_col_map(data);
|
||||
for(rotgen::Index i=0;i<12;i++)
|
||||
TTS_EQUAL(const_col_map(i), data[i]);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("map constructor from pointer and static size", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
using base = rotgen::matrix<T,4,3,O::value>;
|
||||
|
||||
T data[] = {1,2,3,4,5,6,7,8,9,10,11,12};
|
||||
|
||||
rotgen::map<base> dyn_map(data);
|
||||
for(rotgen::Index i=0;i<4;i++)
|
||||
{
|
||||
for(rotgen::Index j=0;j<3;j++)
|
||||
{
|
||||
if constexpr(O::value) TTS_EQUAL(dyn_map(i,j), data[j+3*i]);
|
||||
else TTS_EQUAL(dyn_map(i,j), data[i+4*j]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("map constructor from pointer and single dynamic size", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
T data[] = {1,2,3,4,5,6,7,8,9,10,11,12};
|
||||
|
||||
rotgen::map<rotgen::matrix<T,1,rotgen::Dynamic,rotgen::RowMajor>> row_map(data,12);
|
||||
for(rotgen::Index i=0;i<12;i++)
|
||||
TTS_EQUAL(row_map(i), data[i]);
|
||||
|
||||
rotgen::map<rotgen::matrix<T,1,rotgen::Dynamic,rotgen::RowMajor> const> const_row_map(data,12);
|
||||
for(rotgen::Index i=0;i<12;i++)
|
||||
TTS_EQUAL(const_row_map(i), data[i]);
|
||||
|
||||
rotgen::map<rotgen::matrix<T,rotgen::Dynamic,1,rotgen::ColMajor>> col_map(data,12);
|
||||
for(rotgen::Index i=0;i<12;i++)
|
||||
TTS_EQUAL(col_map(i), data[i]);
|
||||
|
||||
rotgen::map<rotgen::matrix<T,rotgen::Dynamic,1,rotgen::ColMajor> const> const_col_map(data,12);
|
||||
for(rotgen::Index i=0;i<12;i++)
|
||||
TTS_EQUAL(const_col_map(i), data[i]);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("map constructor from pointer and dynamic size", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
using base = rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>;
|
||||
|
||||
T data[] = {1,2,3,4,5,6,7,8,9,10,11,12};
|
||||
|
||||
rotgen::map<base> dyn_map(data,4,3);
|
||||
for(rotgen::Index i=0;i<4;i++)
|
||||
{
|
||||
for(rotgen::Index j=0;j<3;j++)
|
||||
{
|
||||
if constexpr(O::value) TTS_EQUAL(dyn_map(i,j), data[j+3*i]);
|
||||
else TTS_EQUAL(dyn_map(i,j), data[i+4*j]);
|
||||
}
|
||||
}
|
||||
};
|
||||
41
test/unit/map/norms.cpp
Normal file
41
test/unit/map/norms.cpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
//==================================================================================================
|
||||
/*
|
||||
ROTGEN - Runtime Overlay for Eigen
|
||||
Copyright : CODE RECKONS
|
||||
SPDX-License-Identifier: BSL-1.0
|
||||
*/
|
||||
//==================================================================================================
|
||||
#include "unit/tests.hpp"
|
||||
#include "unit/common/norms.hpp"
|
||||
#include <rotgen/rotgen.hpp>
|
||||
|
||||
TTS_CASE_TPL("Test dynamic map norm operations", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_matrix_references();
|
||||
for (const auto& [rows, cols, fn] : cases)
|
||||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> base(rows, cols);
|
||||
rotgen::tests::prepare(rows,cols,fn,base);
|
||||
|
||||
rotgen::map<rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>> input(base.data(),rows,cols);
|
||||
rotgen::tests::check_norms_functions(input);
|
||||
}
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test static map norm operations", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
auto const cases = rotgen::tests::generate_static_matrix_references();
|
||||
|
||||
auto process = []<typename D>(D const& desc)
|
||||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> base(D::rows,D::cols);
|
||||
rotgen::tests::prepare(base.rows(),base.cols(),desc.init_fn,base);
|
||||
|
||||
rotgen::map<rotgen::matrix<T,D::rows,D::cols,O::value>> input(base.data());
|
||||
rotgen::tests::check_norms_functions(input);
|
||||
};
|
||||
|
||||
std::apply([&](auto const&... d) { (process(d),...);}, cases);
|
||||
};
|
||||
202
test/unit/map/operators.cpp
Normal file
202
test/unit/map/operators.cpp
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
//==================================================================================================
|
||||
/*
|
||||
ROTGEN - Runtime Overlay for Eigen
|
||||
Copyright : CODE RECKONS
|
||||
SPDX-License-Identifier: BSL-1.0
|
||||
*/
|
||||
//==================================================================================================
|
||||
#include "unit/tests.hpp"
|
||||
#include <rotgen/rotgen.hpp>
|
||||
#include <vector>
|
||||
|
||||
template <typename MatrixType>
|
||||
void test_map_operations(rotgen::Index rows, rotgen::Index cols, auto a_init_fn, auto b_init_fn, auto ops, auto self_ops)
|
||||
{
|
||||
MatrixType a_data(rows, cols);
|
||||
MatrixType b_data(rows, cols);
|
||||
MatrixType ref_data;
|
||||
|
||||
for (rotgen::Index r = 0; r < rows; ++r)
|
||||
for (rotgen::Index c = 0; c < cols; ++c)
|
||||
{
|
||||
a_data(r,c) = a_init_fn(r, c);
|
||||
b_data(r,c) = b_init_fn(r, c);
|
||||
}
|
||||
|
||||
ref_data = ops(a_data, b_data);
|
||||
rotgen::map<MatrixType> a_map(a_data.data(), rows, cols);
|
||||
rotgen::map<MatrixType> b_map(b_data.data(), rows, cols);
|
||||
|
||||
TTS_EQUAL(ops(a_map, b_map), ref_data);
|
||||
self_ops(a_map, b_map);
|
||||
TTS_EQUAL(a_map, ref_data);
|
||||
|
||||
TTS_EXPECT(verify_rotgen_reentrance(ops(a_map, b_map)));
|
||||
TTS_EXPECT(verify_rotgen_reentrance(self_ops(a_map, b_map)));
|
||||
}
|
||||
|
||||
template <typename MatrixType>
|
||||
void test_map_scalar_operations(rotgen::Index rows, rotgen::Index cols, auto fn, auto s, auto ops, auto self_ops)
|
||||
{
|
||||
MatrixType a_data(rows, cols);
|
||||
MatrixType ref_data;
|
||||
|
||||
for (rotgen::Index r = 0; r < rows; ++r)
|
||||
for (rotgen::Index c = 0; c < cols; ++c)
|
||||
a_data(r,c) = fn(r, c);
|
||||
|
||||
ref_data = ops(a_data, s);
|
||||
rotgen::map<MatrixType> a_map(a_data.data(), rows, cols);
|
||||
|
||||
TTS_EQUAL(ops(a_map, s), ref_data);
|
||||
self_ops(a_map, s);
|
||||
TTS_EQUAL(a_map, ref_data);
|
||||
|
||||
TTS_EXPECT(verify_rotgen_reentrance(ops(a_map, s)));
|
||||
TTS_EXPECT(verify_rotgen_reentrance(self_ops(a_map, s)));
|
||||
}
|
||||
|
||||
template <typename MatrixType>
|
||||
void test_map_scalar_multiplications(rotgen::Index rows, rotgen::Index cols, auto fn, auto s)
|
||||
{
|
||||
MatrixType a_data(rows, cols);
|
||||
MatrixType ref_data;
|
||||
|
||||
for (rotgen::Index r = 0; r < rows; ++r)
|
||||
for (rotgen::Index c = 0; c < cols; ++c)
|
||||
a_data(r,c) = fn(r, c);
|
||||
|
||||
ref_data = a_data * s;
|
||||
rotgen::map<MatrixType> a_map(a_data.data(), rows, cols);
|
||||
|
||||
TTS_EQUAL(a_map * s, ref_data);
|
||||
TTS_EQUAL(s * a_map, ref_data);
|
||||
a_map *= s;
|
||||
TTS_EQUAL(a_map, ref_data);
|
||||
|
||||
TTS_EXPECT(verify_rotgen_reentrance(a_map * s));
|
||||
TTS_EXPECT(verify_rotgen_reentrance(s * a_map));
|
||||
TTS_EXPECT(verify_rotgen_reentrance(a_map *= s));
|
||||
}
|
||||
|
||||
template <typename MatrixType>
|
||||
void test_map_multiplication(rotgen::Index rows, rotgen::Index cols, auto a_init_fn, auto b_init_fn)
|
||||
{
|
||||
MatrixType a_data(rows, cols);
|
||||
MatrixType b_data(cols, rows);
|
||||
MatrixType ref_data;
|
||||
|
||||
for (rotgen::Index r = 0; r < rows; ++r)
|
||||
for (rotgen::Index c = 0; c < cols; ++c)
|
||||
{
|
||||
a_data(r,c) = a_init_fn(r,c);
|
||||
b_data(c,r) = b_init_fn(c,r);
|
||||
}
|
||||
|
||||
ref_data = a_data * b_data;
|
||||
rotgen::map<MatrixType> a_map(a_data.data(), rows, cols);
|
||||
rotgen::map<MatrixType> b_map(b_data.data(), cols, rows);
|
||||
|
||||
TTS_EQUAL(a_map * b_map, ref_data);
|
||||
TTS_EXPECT(verify_rotgen_reentrance(a_map * b_map));
|
||||
|
||||
if(rows == cols)
|
||||
{
|
||||
a_map *= b_map;
|
||||
TTS_EQUAL(a_map, ref_data);
|
||||
TTS_EXPECT(verify_rotgen_reentrance(a_map *= b_map));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline constexpr auto init_a = [](auto r, auto c) { return 9.9*r*r*r - 6*c - 12; };
|
||||
inline constexpr auto init_b = [](auto r, auto c) { return 3.1*r + 4.2*c - 12.3; };
|
||||
inline constexpr auto init_0 = [](auto , auto ) { return 0; };
|
||||
|
||||
TTS_CASE_TPL("Check map addition", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
using mat_t = rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>;
|
||||
auto op = [](auto a, auto b) { return a + b; };
|
||||
auto s_op = [](auto& a, auto b) { return a += b; };
|
||||
|
||||
test_map_operations<mat_t>(1 , 1, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(3 , 5, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 3, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_b, init_a, op, s_op);
|
||||
test_map_operations<mat_t>(10, 1, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(1 ,10, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_0, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_a, init_0, op, s_op);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check map subtraction", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
using mat_t = rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>;
|
||||
auto op = [](auto a, auto b) { return a - b; };
|
||||
auto s_op = [](auto& a, auto b) { return a -= b; };
|
||||
|
||||
test_map_operations<mat_t>(1 , 1, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(3 , 5, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 3, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_b, init_a, op, s_op);
|
||||
test_map_operations<mat_t>(10, 1, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(1 ,10, init_a, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_0, init_b, op, s_op);
|
||||
test_map_operations<mat_t>(5 , 5, init_a, init_0, op, s_op);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check map multiplications", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
using mat_t = rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>;
|
||||
auto init_id = [](auto r, auto c) { return r == c ? 1 : 0; };
|
||||
|
||||
test_map_multiplication<mat_t>(1 , 1, init_a , init_b );
|
||||
test_map_multiplication<mat_t>(3 , 5, init_a , init_b );
|
||||
test_map_multiplication<mat_t>(5 , 3, init_a , init_b );
|
||||
test_map_multiplication<mat_t>(5 , 5, init_a , init_b );
|
||||
test_map_multiplication<mat_t>(5 , 5, init_b , init_a );
|
||||
test_map_multiplication<mat_t>(5 , 5, init_a , init_a );
|
||||
test_map_multiplication<mat_t>(5 , 5, init_a , init_id);
|
||||
test_map_multiplication<mat_t>(5 , 5, init_id, init_a );
|
||||
test_map_multiplication<mat_t>(10, 1, init_a , init_b );
|
||||
test_map_multiplication<mat_t>(1 ,10, init_a , init_b );
|
||||
test_map_multiplication<mat_t>(5 , 5, init_0 , init_b );
|
||||
test_map_multiplication<mat_t>(5 , 5, init_a , init_0 );
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check map multiplication with scalar", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
using mat_t = rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>;
|
||||
|
||||
test_map_scalar_multiplications<mat_t>(1 , 1, init_a, T{ 3.5});
|
||||
test_map_scalar_multiplications<mat_t>(3 , 5, init_a, T{-2.5});
|
||||
test_map_scalar_multiplications<mat_t>(5 , 3, init_a, T{ 4. });
|
||||
test_map_scalar_multiplications<mat_t>(5 , 5, init_a, T{-5. });
|
||||
test_map_scalar_multiplications<mat_t>(5 , 5, init_a, T{ 1. });
|
||||
test_map_scalar_multiplications<mat_t>(5 , 5, init_a, T{ 6. });
|
||||
test_map_scalar_multiplications<mat_t>(10, 1, init_a, T{ 10.});
|
||||
test_map_scalar_multiplications<mat_t>(1 ,10, init_a, T{-0.5});
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Check map division with scalar", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
{
|
||||
using mat_t = rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>;
|
||||
auto op = [](auto a, auto b) { return a / b; };
|
||||
auto s_op = [](auto& a, auto b) { return a /= b; };
|
||||
|
||||
test_map_scalar_operations<mat_t>(1 , 1, init_a, T{ 3.5}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(3 , 5, init_a, T{-2.5}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(5 , 3, init_a, T{ 4. }, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(5 , 5, init_a, T{-5. }, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(5 , 5, init_a, T{ 1. }, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(5 , 5, init_a, T{ 6. }, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(10, 1, init_a, T{ 10.}, op, s_op);
|
||||
test_map_scalar_operations<mat_t>(1 ,10, init_a, T{-0.5}, op, s_op);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue