Adding clang-format configuration file and formatting all source files
Co-authored-by: Jules Pénuchot <jules@penuchot.com> Co-authored-by: Joel FALCOU <jfalcou@codereckons.com> See merge request oss/rotgen!41
This commit is contained in:
parent
e92e824a18
commit
648dd768ee
94 changed files with 6778 additions and 4722 deletions
|
|
@ -9,101 +9,109 @@
|
|||
#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>> )
|
||||
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)
|
||||
for (auto const& [rows, cols, fn] : cases)
|
||||
{
|
||||
using mat_t = rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value>;
|
||||
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::tests::prepare(rows, cols, fn, base);
|
||||
|
||||
rotgen::map<mat_t> input(base.data(),rows,cols);
|
||||
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>> )
|
||||
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);
|
||||
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::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);
|
||||
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>> )
|
||||
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)
|
||||
for (auto const& [rows, cols, fn] : cases)
|
||||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> base(rows, cols);
|
||||
rotgen::tests::prepare(rows,cols,fn,base);
|
||||
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::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>> )
|
||||
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);
|
||||
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::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);
|
||||
std::apply([&](auto const&... d) { (process(d), ...); }, cases);
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test dot product", float, double)
|
||||
<typename T>( tts::type<T> )
|
||||
TTS_CASE_TPL("Test dot product", float, double)<typename T>(tts::type<T>){
|
||||
{auto v = rotgen::setConstant<rotgen::matrix<T, 1, rotgen::Dynamic>>(1,
|
||||
16,
|
||||
2);
|
||||
auto a = rotgen::map<decltype(v)>(v.data(), 1, 8);
|
||||
auto b = rotgen::map<decltype(v)>(v.data() + 8, 1, 8);
|
||||
|
||||
TTS_EQUAL(rotgen::dot(a, b), 32);
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
auto v = rotgen::setConstant<rotgen::matrix<T,1,rotgen::Dynamic>>(1,16,2);
|
||||
auto a = rotgen::map<decltype(v)>(v.data(),1,8);
|
||||
auto b = rotgen::map<decltype(v)>(v.data()+8,1,8);
|
||||
auto v = rotgen::setConstant<rotgen::matrix<T, rotgen::Dynamic, 1>>(16, 1, 2);
|
||||
auto a = rotgen::map<decltype(v)>(v.data(), 8, 1);
|
||||
auto b = rotgen::map<decltype(v)>(v.data() + 8, 8, 1);
|
||||
|
||||
TTS_EQUAL(rotgen::dot(a,b), 32);
|
||||
}
|
||||
TTS_EQUAL(rotgen::dot(a, b), 32);
|
||||
}
|
||||
|
||||
{
|
||||
auto v = rotgen::setConstant<rotgen::matrix<T,rotgen::Dynamic,1>>(16,1,2);
|
||||
auto a = rotgen::map<decltype(v)>(v.data(),8,1);
|
||||
auto b = rotgen::map<decltype(v)>(v.data()+8,8,1);
|
||||
{
|
||||
auto v = rotgen::setConstant<rotgen::matrix<T, 1, rotgen::Dynamic>>(1, 16, 2);
|
||||
auto a = rotgen::map<rotgen::matrix<T, 1, 8>>(v.data());
|
||||
auto b = rotgen::map<rotgen::matrix<T, 1, 8>>(v.data() + 8);
|
||||
|
||||
TTS_EQUAL(rotgen::dot(a,b), 32);
|
||||
}
|
||||
TTS_EQUAL(rotgen::dot(a, b), 32);
|
||||
}
|
||||
|
||||
{
|
||||
auto v = rotgen::setConstant<rotgen::matrix<T,1,rotgen::Dynamic>>(1,16,2);
|
||||
auto a = rotgen::map<rotgen::matrix<T,1,8>>(v.data());
|
||||
auto b = rotgen::map<rotgen::matrix<T,1,8>>(v.data()+8);
|
||||
{
|
||||
auto v = rotgen::setConstant<rotgen::matrix<T, 1, rotgen::Dynamic>>(1, 16, 2);
|
||||
auto a = rotgen::map<rotgen::matrix<T, 8, 1>>(v.data());
|
||||
auto b = rotgen::map<rotgen::matrix<T, 8, 1>>(v.data() + 8);
|
||||
|
||||
TTS_EQUAL(rotgen::dot(a,b), 32);
|
||||
}
|
||||
|
||||
{
|
||||
auto v = rotgen::setConstant<rotgen::matrix<T,1,rotgen::Dynamic>>(1,16,2);
|
||||
auto a = rotgen::map<rotgen::matrix<T,8,1>>(v.data());
|
||||
auto b = rotgen::map<rotgen::matrix<T,8,1>>(v.data()+8);
|
||||
|
||||
TTS_EQUAL(rotgen::dot(a,b), 32);
|
||||
}
|
||||
};
|
||||
TTS_EQUAL(rotgen::dot(a, b), 32);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
|
|
|||
|
|
@ -8,88 +8,90 @@
|
|||
#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>> )
|
||||
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};
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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>> )
|
||||
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>;
|
||||
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};
|
||||
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++)
|
||||
rotgen::map<base> a(data, 4, 3);
|
||||
for (rotgen::Index i = 0; i < 4; i++)
|
||||
{
|
||||
for(rotgen::Index j=0;j<3;j++)
|
||||
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]);
|
||||
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);
|
||||
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>> )
|
||||
TTS_CASE_TPL("Test one index coefficient accessors",
|
||||
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};
|
||||
T data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
|
||||
|
||||
auto m = [&]()
|
||||
{
|
||||
if constexpr(O::value == rotgen::ColMajor)
|
||||
auto m = [&]() {
|
||||
if constexpr (O::value == rotgen::ColMajor)
|
||||
{
|
||||
using base = rotgen::matrix<T,1,rotgen::Dynamic>;
|
||||
rotgen::map<base> a(data,12);
|
||||
using base = rotgen::matrix<T, 1, rotgen::Dynamic>;
|
||||
rotgen::map<base> a(data, 12);
|
||||
return a;
|
||||
}
|
||||
else
|
||||
{
|
||||
using base = rotgen::matrix<T,rotgen::Dynamic,1>;
|
||||
rotgen::map<base> a(data,12);
|
||||
using base = rotgen::matrix<T, rotgen::Dynamic, 1>;
|
||||
rotgen::map<base> a(data, 12);
|
||||
return a;
|
||||
}
|
||||
}();
|
||||
|
||||
TTS_EXPECT(m.IsVectorAtCompileTime);
|
||||
|
||||
for(rotgen::Index i=0;i<m.size();i++)
|
||||
for (rotgen::Index i = 0; i < m.size(); i++)
|
||||
TTS_EQUAL(m(i), data[i]) << "Index: " << i << "\n";
|
||||
|
||||
for(rotgen::Index i=0;i<m.size();i++)
|
||||
for (rotgen::Index i = 0; i < m.size(); i++)
|
||||
TTS_EQUAL(m[i], data[i]) << "Index: " << i << "\n";
|
||||
|
||||
m(1) = 42;
|
||||
|
|
|
|||
|
|
@ -8,82 +8,84 @@
|
|||
#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>> )
|
||||
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};
|
||||
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>> 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, 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>> 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]);
|
||||
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>> )
|
||||
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>;
|
||||
using base = rotgen::matrix<T, 4, 3, O::value>;
|
||||
|
||||
T data[] = {1,2,3,4,5,6,7,8,9,10,11,12};
|
||||
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 i = 0; i < 4; i++)
|
||||
{
|
||||
for(rotgen::Index j=0;j<3;j++)
|
||||
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]);
|
||||
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>> )
|
||||
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};
|
||||
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>> 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, 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>> 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]);
|
||||
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>> )
|
||||
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>;
|
||||
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};
|
||||
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++)
|
||||
rotgen::map<base> dyn_map(data, 4, 3);
|
||||
for (rotgen::Index i = 0; i < 4; i++)
|
||||
{
|
||||
for(rotgen::Index j=0;j<3;j++)
|
||||
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]);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,33 +9,38 @@
|
|||
#include "unit/common/cwise.hpp"
|
||||
#include <rotgen/rotgen.hpp>
|
||||
|
||||
TTS_CASE_TPL("Test dynamic map cwise operations", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
TTS_CASE_TPL("Test dynamic map cwise 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)
|
||||
for (auto const& [rows, cols, fn] : cases)
|
||||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> base(rows, cols);
|
||||
rotgen::tests::prepare(rows,cols,fn,base);
|
||||
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::map<rotgen::matrix<T, rotgen::Dynamic, rotgen::Dynamic, O::value>>
|
||||
input(base.data(), rows, cols);
|
||||
rotgen::tests::check_cwise_functions(input);
|
||||
}
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test static map cwise operations", rotgen::tests::types)
|
||||
<typename T, typename O>( tts::type< tts::types<T,O>> )
|
||||
TTS_CASE_TPL("Test static map cwise 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);
|
||||
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::map<rotgen::matrix<T, D::rows, D::cols, O::value>> input(
|
||||
base.data());
|
||||
rotgen::tests::check_cwise_functions(input);
|
||||
};
|
||||
|
||||
std::apply([&](auto const&... d) { (process(d),...);}, cases);
|
||||
};
|
||||
std::apply([&](auto const&... d) { (process(d), ...); }, cases);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,33 +9,38 @@
|
|||
#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>> )
|
||||
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)
|
||||
for (auto const& [rows, cols, fn] : cases)
|
||||
{
|
||||
rotgen::matrix<T,rotgen::Dynamic,rotgen::Dynamic,O::value> base(rows, cols);
|
||||
rotgen::tests::prepare(rows,cols,fn,base);
|
||||
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::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>> )
|
||||
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);
|
||||
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::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);
|
||||
};
|
||||
std::apply([&](auto const&... d) { (process(d), ...); }, cases);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,8 +9,13 @@
|
|||
#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)
|
||||
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);
|
||||
|
|
@ -19,8 +24,8 @@ void test_map_operations(rotgen::Index rows, rotgen::Index cols, auto a_init_fn,
|
|||
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);
|
||||
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);
|
||||
|
|
@ -35,15 +40,19 @@ void test_map_operations(rotgen::Index rows, rotgen::Index cols, auto a_init_fn,
|
|||
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)
|
||||
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);
|
||||
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);
|
||||
|
|
@ -56,15 +65,17 @@ void test_map_scalar_operations(rotgen::Index rows, rotgen::Index cols, auto fn,
|
|||
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)
|
||||
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);
|
||||
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);
|
||||
|
|
@ -79,8 +90,11 @@ void test_map_scalar_multiplications(rotgen::Index rows, rotgen::Index cols, aut
|
|||
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)
|
||||
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);
|
||||
|
|
@ -89,8 +103,8 @@ void test_map_multiplication(rotgen::Index rows, rotgen::Index cols, auto a_init
|
|||
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);
|
||||
a_data(r, c) = a_init_fn(r, c);
|
||||
b_data(c, r) = b_init_fn(c, r);
|
||||
}
|
||||
|
||||
ref_data = a_data * b_data;
|
||||
|
|
@ -100,103 +114,111 @@ void test_map_multiplication(rotgen::Index rows, rotgen::Index cols, auto a_init
|
|||
TTS_EQUAL(a_map * b_map, ref_data);
|
||||
TTS_EXPECT(verify_rotgen_reentrance(a_map * b_map));
|
||||
|
||||
if(rows == cols)
|
||||
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; };
|
||||
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>> )
|
||||
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; };
|
||||
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>(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);
|
||||
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>> )
|
||||
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; };
|
||||
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>(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);
|
||||
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>> )
|
||||
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>;
|
||||
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 );
|
||||
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>> )
|
||||
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>;
|
||||
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});
|
||||
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>> )
|
||||
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; };
|
||||
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);
|
||||
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);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,132 +15,138 @@ auto generate_data(int rows, int cols)
|
|||
std::vector<float> buffer(rows * cols * 3);
|
||||
|
||||
for (size_t i = 0; i < buffer.size(); ++i)
|
||||
buffer[i] = static_cast<float>(1+i);
|
||||
buffer[i] = static_cast<float>(1 + i);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
template<int O>
|
||||
using r_mat_t = rotgen::matrix<float,rotgen::Dynamic,rotgen::Dynamic,O>;
|
||||
using r_mat_t = rotgen::matrix<float, rotgen::Dynamic, rotgen::Dynamic, O>;
|
||||
|
||||
template<int O>
|
||||
using e_mat_t = Eigen::Matrix<float,Eigen::Dynamic,Eigen::Dynamic,O>;
|
||||
using e_mat_t = Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, O>;
|
||||
|
||||
template<typename M, typename S = rotgen::stride> using r_map_t = rotgen::map<M,0,S>;
|
||||
template<typename M, typename S = Eigen::Stride<0,0>> using e_map_t = Eigen::Map<M,0,S>;
|
||||
template<typename M, typename S = rotgen::stride>
|
||||
using r_map_t = rotgen::map<M, 0, S>;
|
||||
template<typename M, typename S = Eigen::Stride<0, 0>>
|
||||
using e_map_t = Eigen::Map<M, 0, S>;
|
||||
|
||||
TTS_CASE("Validate Column Major Map with regular stride behavior")
|
||||
{
|
||||
auto rows = 3;
|
||||
auto cols = 4;
|
||||
auto buffer = generate_data(rows,cols);
|
||||
auto rows = 3;
|
||||
auto cols = 4;
|
||||
auto buffer = generate_data(rows, cols);
|
||||
|
||||
r_map_t<r_mat_t<rotgen::ColMajor>> r_map(buffer.data(), rows, cols);
|
||||
|
||||
TTS_EQUAL(r_map.innerStride(), 1);
|
||||
TTS_EQUAL(r_map.outerStride(), 3);
|
||||
|
||||
e_map_t<e_mat_t<Eigen::ColMajor>> e_map(buffer.data(), rows, cols);
|
||||
e_map_t<e_mat_t<Eigen::ColMajor>> e_map(buffer.data(), rows, cols);
|
||||
|
||||
for(std::ptrdiff_t r=0;r<rows;r++)
|
||||
for(std::ptrdiff_t c=0;c<cols;c++)
|
||||
TTS_EQUAL(r_map(r,c), e_map(r,c));
|
||||
for (std::ptrdiff_t r = 0; r < rows; r++)
|
||||
for (std::ptrdiff_t c = 0; c < cols; c++)
|
||||
TTS_EQUAL(r_map(r, c), e_map(r, c));
|
||||
};
|
||||
|
||||
TTS_CASE("Validate Column Major Map with specific outer stride behavior")
|
||||
{
|
||||
auto rows = 3;
|
||||
auto cols = 4;
|
||||
auto buffer = generate_data(rows,cols);
|
||||
auto rows = 3;
|
||||
auto cols = 4;
|
||||
auto buffer = generate_data(rows, cols);
|
||||
|
||||
r_map_t<r_mat_t<rotgen::ColMajor>, rotgen::outer_stride<>>
|
||||
r_map(buffer.data(), rows, cols, rotgen::outer_stride(rows + 1));
|
||||
r_map_t<r_mat_t<rotgen::ColMajor>, rotgen::outer_stride<>> r_map(
|
||||
buffer.data(), rows, cols, rotgen::outer_stride(rows + 1));
|
||||
|
||||
TTS_EQUAL(r_map.innerStride(), 1);
|
||||
TTS_EQUAL(r_map.outerStride() , 4);
|
||||
TTS_EQUAL(r_map.innerStride(), 1);
|
||||
TTS_EQUAL(r_map.outerStride(), 4);
|
||||
|
||||
e_map_t<e_mat_t<Eigen::ColMajor>, Eigen::OuterStride<>>
|
||||
e_map(buffer.data(), rows, cols, Eigen::OuterStride<>(rows + 1));
|
||||
e_map_t<e_mat_t<Eigen::ColMajor>, Eigen::OuterStride<>> e_map(
|
||||
buffer.data(), rows, cols, Eigen::OuterStride<>(rows + 1));
|
||||
|
||||
for(std::ptrdiff_t r=0;r<rows;r++)
|
||||
for(std::ptrdiff_t c=0;c<cols;c++)
|
||||
TTS_EQUAL(r_map(r,c), e_map(r,c));
|
||||
for (std::ptrdiff_t r = 0; r < rows; r++)
|
||||
for (std::ptrdiff_t c = 0; c < cols; c++)
|
||||
TTS_EQUAL(r_map(r, c), e_map(r, c));
|
||||
};
|
||||
|
||||
TTS_CASE("Validate Column Major Map with specific inner stride behavior")
|
||||
{
|
||||
auto rows = 3;
|
||||
auto cols = 4;
|
||||
auto buffer = generate_data(rows,cols);
|
||||
auto rows = 3;
|
||||
auto cols = 4;
|
||||
auto buffer = generate_data(rows, cols);
|
||||
|
||||
r_map_t<r_mat_t<rotgen::ColMajor>>
|
||||
r_map(buffer.data(), rows, cols, rotgen::stride(rows, 2));
|
||||
r_map_t<r_mat_t<rotgen::ColMajor>> r_map(buffer.data(), rows, cols,
|
||||
rotgen::stride(rows, 2));
|
||||
|
||||
TTS_EQUAL(r_map.innerStride(), 2);
|
||||
TTS_EQUAL(r_map.outerStride() , 3);
|
||||
TTS_EQUAL(r_map.innerStride(), 2);
|
||||
TTS_EQUAL(r_map.outerStride(), 3);
|
||||
|
||||
e_map_t<e_mat_t<Eigen::ColMajor>,Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic>>
|
||||
e_map(buffer.data(), rows, cols, Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic>(rows,2));
|
||||
e_map_t<e_mat_t<Eigen::ColMajor>,
|
||||
Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>>
|
||||
e_map(buffer.data(), rows, cols,
|
||||
Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>(rows, 2));
|
||||
|
||||
for(std::ptrdiff_t r=0;r<rows;r++)
|
||||
for(std::ptrdiff_t c=0;c<cols;c++)
|
||||
TTS_EQUAL(r_map(r,c), e_map(r,c));
|
||||
for (std::ptrdiff_t r = 0; r < rows; r++)
|
||||
for (std::ptrdiff_t c = 0; c < cols; c++)
|
||||
TTS_EQUAL(r_map(r, c), e_map(r, c));
|
||||
};
|
||||
|
||||
TTS_CASE("Validate Row Major Map with regular stride behavior")
|
||||
{
|
||||
auto rows = 3;
|
||||
auto cols = 4;
|
||||
auto buffer = generate_data(rows,cols);
|
||||
auto rows = 3;
|
||||
auto cols = 4;
|
||||
auto buffer = generate_data(rows, cols);
|
||||
|
||||
r_map_t<r_mat_t<rotgen::RowMajor>> r_map(buffer.data(), rows, cols);
|
||||
|
||||
TTS_EQUAL(r_map.innerStride(), 1);
|
||||
TTS_EQUAL(r_map.outerStride(), 4);
|
||||
|
||||
e_map_t<e_mat_t<Eigen::RowMajor>> e_map(buffer.data(), rows, cols);
|
||||
e_map_t<e_mat_t<Eigen::RowMajor>> e_map(buffer.data(), rows, cols);
|
||||
|
||||
for(std::ptrdiff_t r=0;r<rows;r++)
|
||||
for(std::ptrdiff_t c=0;c<cols;c++)
|
||||
TTS_EQUAL(r_map(r,c), e_map(r,c));
|
||||
for (std::ptrdiff_t r = 0; r < rows; r++)
|
||||
for (std::ptrdiff_t c = 0; c < cols; c++)
|
||||
TTS_EQUAL(r_map(r, c), e_map(r, c));
|
||||
};
|
||||
|
||||
TTS_CASE("Validate Row Major Map with specific outer stride behavior")
|
||||
{
|
||||
auto rows = 3;
|
||||
auto cols = 4;
|
||||
auto buffer = generate_data(rows,cols);
|
||||
auto rows = 3;
|
||||
auto cols = 4;
|
||||
auto buffer = generate_data(rows, cols);
|
||||
|
||||
r_map_t<r_mat_t<rotgen::RowMajor>, rotgen::outer_stride<>>
|
||||
r_map(buffer.data(), rows, cols, rotgen::outer_stride(cols + 1));
|
||||
r_map_t<r_mat_t<rotgen::RowMajor>, rotgen::outer_stride<>> r_map(
|
||||
buffer.data(), rows, cols, rotgen::outer_stride(cols + 1));
|
||||
|
||||
TTS_EQUAL(r_map.innerStride(), 1);
|
||||
TTS_EQUAL(r_map.outerStride() , 5);
|
||||
TTS_EQUAL(r_map.innerStride(), 1);
|
||||
TTS_EQUAL(r_map.outerStride(), 5);
|
||||
|
||||
e_map_t<e_mat_t<Eigen::RowMajor>, Eigen::OuterStride<>>
|
||||
e_map(buffer.data(), rows, cols, Eigen::OuterStride<>(cols + 1));
|
||||
e_map_t<e_mat_t<Eigen::RowMajor>, Eigen::OuterStride<>> e_map(
|
||||
buffer.data(), rows, cols, Eigen::OuterStride<>(cols + 1));
|
||||
|
||||
for(std::ptrdiff_t r=0;r<rows;r++)
|
||||
for(std::ptrdiff_t c=0;c<cols;c++)
|
||||
TTS_EQUAL(r_map(r,c), e_map(r,c));
|
||||
for (std::ptrdiff_t r = 0; r < rows; r++)
|
||||
for (std::ptrdiff_t c = 0; c < cols; c++)
|
||||
TTS_EQUAL(r_map(r, c), e_map(r, c));
|
||||
};
|
||||
|
||||
TTS_CASE("Validate Row Major Map with specific inner stride behavior")
|
||||
{
|
||||
auto rows = 3;
|
||||
auto cols = 4;
|
||||
auto buffer = generate_data(rows,cols);
|
||||
auto rows = 3;
|
||||
auto cols = 4;
|
||||
auto buffer = generate_data(rows, cols);
|
||||
|
||||
r_map_t<r_mat_t<rotgen::RowMajor>,rotgen::stride>
|
||||
r_map(buffer.data(), rows, cols, rotgen::stride(2, cols));
|
||||
r_map_t<r_mat_t<rotgen::RowMajor>, rotgen::stride> r_map(
|
||||
buffer.data(), rows, cols, rotgen::stride(2, cols));
|
||||
|
||||
TTS_EQUAL(r_map.innerStride(), 4);
|
||||
TTS_EQUAL(r_map.outerStride() , 2);
|
||||
TTS_EQUAL(r_map.innerStride(), 4);
|
||||
TTS_EQUAL(r_map.outerStride(), 2);
|
||||
|
||||
e_map_t<e_mat_t<Eigen::RowMajor>,Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic>>
|
||||
e_map(buffer.data(), rows, cols, Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic>(2,cols));
|
||||
e_map_t<e_mat_t<Eigen::RowMajor>,
|
||||
Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>>
|
||||
e_map(buffer.data(), rows, cols,
|
||||
Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>(2, cols));
|
||||
|
||||
for(std::ptrdiff_t r=0;r<rows;r++)
|
||||
for(std::ptrdiff_t c=0;c<cols;c++)
|
||||
TTS_EQUAL(r_map(r,c), e_map(r,c));
|
||||
};
|
||||
for (std::ptrdiff_t r = 0; r < rows; r++)
|
||||
for (std::ptrdiff_t c = 0; c < cols; c++)
|
||||
TTS_EQUAL(r_map(r, c), e_map(r, c));
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue