parent
3313e257c8
commit
ddf8816c5b
12 changed files with 165 additions and 46 deletions
|
|
@ -72,3 +72,41 @@ TTS_CASE_TPL("Test static block reduction-like operations", rotgen::tests::types
|
|||
|
||||
std::apply([&](auto const&... d) { (process(d),...);}, cases);
|
||||
};
|
||||
|
||||
|
||||
|
||||
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::head(v,8);
|
||||
auto b = rotgen::tail(v,8);
|
||||
|
||||
TTS_EQUAL(rotgen::dot(a,b), 32);
|
||||
}
|
||||
|
||||
{
|
||||
auto v = rotgen::setConstant<rotgen::matrix<T,rotgen::Dynamic,1>>(16,1,2);
|
||||
auto a = rotgen::head(v,8);
|
||||
auto b = rotgen::tail(v,8);
|
||||
|
||||
TTS_EQUAL(rotgen::dot(a,b), 32);
|
||||
}
|
||||
|
||||
{
|
||||
auto v = rotgen::setConstant<rotgen::matrix<T,1,rotgen::Dynamic>>(1,16,2);
|
||||
auto a = rotgen::head<8>(v);
|
||||
auto b = rotgen::tail<8>(v);
|
||||
|
||||
TTS_EQUAL(rotgen::dot(a,b), 32);
|
||||
}
|
||||
|
||||
{
|
||||
auto v = rotgen::setConstant<rotgen::matrix<T,rotgen::Dynamic,1>>(16,1,2);
|
||||
auto a = rotgen::head<8>(v);
|
||||
auto b = rotgen::tail<8>(v);
|
||||
|
||||
TTS_EQUAL(rotgen::dot(a,b), 32);
|
||||
}
|
||||
};
|
||||
|
|
@ -20,10 +20,6 @@ namespace rotgen::tests
|
|||
mat_t result(original.cols(), original.rows());
|
||||
prepare([&](auto r, auto c) { return original(c,r); },result);
|
||||
|
||||
TTS_EQUAL(original.transpose(), result );
|
||||
TTS_EQUAL(original.conjugate(), original);
|
||||
TTS_EQUAL(original.adjoint() , result );
|
||||
|
||||
TTS_EQUAL(transpose(original) , result );
|
||||
TTS_EQUAL(conjugate(original) , original);
|
||||
TTS_EQUAL(adjoint(original) , result );
|
||||
|
|
@ -33,12 +29,6 @@ namespace rotgen::tests
|
|||
if constexpr(T::RowsAtCompileTime == T::ColsAtCompileTime)
|
||||
{
|
||||
mat_t ref = original;
|
||||
original.transposeInPlace();
|
||||
TTS_EQUAL(original, result);
|
||||
|
||||
original.adjointInPlace();
|
||||
TTS_EQUAL(original, ref);
|
||||
|
||||
transposeInPlace(original);
|
||||
TTS_EQUAL(original, result);
|
||||
|
||||
|
|
@ -51,12 +41,6 @@ namespace rotgen::tests
|
|||
if (original.rows() == original.cols())
|
||||
{
|
||||
mat_t ref = original;
|
||||
original.transposeInPlace();
|
||||
TTS_EQUAL(original, result);
|
||||
|
||||
original.adjointInPlace();
|
||||
TTS_EQUAL(original, ref);
|
||||
|
||||
transposeInPlace(original);
|
||||
TTS_EQUAL(original, result);
|
||||
|
||||
|
|
@ -81,36 +65,13 @@ namespace rotgen::tests
|
|||
EigenMatrix ref(input.rows(), input.cols());
|
||||
prepare([&](auto r, auto c) { return input(r,c); }, ref);
|
||||
|
||||
TTS_ULP_EQUAL(input.sum(), ref.sum() , 2);
|
||||
TTS_ULP_EQUAL(sum(input) , ref.sum() , 2);
|
||||
|
||||
TTS_ULP_EQUAL(input.prod(), ref.prod(), 2);
|
||||
TTS_ULP_EQUAL(prod(input) , ref.prod(), 2);
|
||||
|
||||
TTS_ULP_EQUAL(input.mean(), ref.mean(), 2);
|
||||
TTS_ULP_EQUAL(mean(input) , ref.mean(), 2);
|
||||
|
||||
TTS_EQUAL(input.trace(), ref.trace());
|
||||
TTS_EQUAL(trace(input) , ref.trace());
|
||||
|
||||
TTS_EQUAL(input.minCoeff(), ref.minCoeff());
|
||||
TTS_EQUAL(minCoeff(input) , ref.minCoeff());
|
||||
|
||||
TTS_EQUAL(input.maxCoeff(), ref.maxCoeff());
|
||||
TTS_EQUAL(maxCoeff(input) , ref.maxCoeff());
|
||||
|
||||
{
|
||||
int row, col, ref_row, ref_col;
|
||||
|
||||
TTS_EQUAL(input.minCoeff(&row, &col), ref.minCoeff(&ref_row, &ref_col));
|
||||
TTS_EQUAL(row, ref_row);
|
||||
TTS_EQUAL(col, ref_col);
|
||||
|
||||
TTS_EQUAL(input.maxCoeff(&row, &col), ref.maxCoeff(&ref_row, &ref_col));
|
||||
TTS_EQUAL(row, ref_row);
|
||||
TTS_EQUAL(col, ref_col);
|
||||
}
|
||||
|
||||
{
|
||||
int row, col, ref_row, ref_col;
|
||||
|
||||
|
|
|
|||
|
|
@ -70,4 +70,40 @@ TTS_CASE_TPL("Test static map reduction-like operations", rotgen::tests::types)
|
|||
};
|
||||
|
||||
std::apply([&](auto const&... d) { (process(d),...);}, cases);
|
||||
};
|
||||
|
||||
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,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);
|
||||
}
|
||||
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
{
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
|
@ -61,4 +61,36 @@ TTS_CASE_TPL("Test static matrix reduction-like operations", rotgen::tests::type
|
|||
};
|
||||
|
||||
std::apply([&](auto const&... d) { (process(d),...);}, cases);
|
||||
};
|
||||
};
|
||||
|
||||
TTS_CASE_TPL("Test dot product", float, double)
|
||||
<typename T>( tts::type<T> )
|
||||
{
|
||||
{
|
||||
auto a = rotgen::setConstant<rotgen::matrix<T,1,rotgen::Dynamic>>(1,8,2);
|
||||
auto b = rotgen::setConstant<rotgen::matrix<T,1,rotgen::Dynamic>>(1,8,2);
|
||||
|
||||
TTS_EQUAL(rotgen::dot(a,b), 32);
|
||||
}
|
||||
|
||||
{
|
||||
auto a = rotgen::setConstant<rotgen::matrix<T,rotgen::Dynamic,1>>(8,1,2);
|
||||
auto b = rotgen::setConstant<rotgen::matrix<T,rotgen::Dynamic,1>>(8,1,2);
|
||||
|
||||
TTS_EQUAL(rotgen::dot(a,b), 32);
|
||||
}
|
||||
|
||||
{
|
||||
auto a = rotgen::setConstant<rotgen::matrix<T,1,8>>(2);
|
||||
auto b = rotgen::setConstant<rotgen::matrix<T,1,8>>(2);
|
||||
|
||||
TTS_EQUAL(rotgen::dot(a,b), 32);
|
||||
}
|
||||
|
||||
{
|
||||
auto a = rotgen::setConstant<rotgen::matrix<T,8,1>>(2);
|
||||
auto b = rotgen::setConstant<rotgen::matrix<T,8,1>>(2);
|
||||
|
||||
TTS_EQUAL(rotgen::dot(a,b), 32);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue