Commit 7729d3f4 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

fix a small bug in eye, ones and zeros

parent f30e8d5d
......@@ -346,7 +346,7 @@ namespace Dec
* \brief Returns an expression representing a unit matrix
**/
template <class T, std::size_t N>
expression::Eye<T, N> eye(index_<N> = {})
expression::Eye<T, N> eye(index_t<N> = {})
{
return {};
}
......@@ -355,7 +355,7 @@ namespace Dec
* \brief Returns an expression representing a constant matrix = 1
**/
template <class T, std::size_t N, std::size_t M=N>
expression::Constant<T, N, M> ones(index_<N> = {}, index_<M> = {})
expression::Constant<T, N, M> ones(index_t<N> = {}, index_t<M> = {})
{
return {T(1)};
}
......@@ -364,7 +364,7 @@ namespace Dec
* \brief Returns an expression representing a constant matrix = 0
**/
template <class T, std::size_t N, std::size_t M=N>
expression::Constant<T, N, M> zeros(index_<N> = {}, index_<M> = {})
expression::Constant<T, N, M> zeros(index_t<N> = {}, index_t<M> = {})
{
return {T(0)};
}
......
......@@ -99,6 +99,17 @@ void test2()
DEC_TEST_EQ( inv(C), adj(C)/det(C) );
DEC_TEST_APPROX( frobenius_norm( inv(C)*C ), frobenius_norm(eye<double, 3>()) );
auto I = eye<double>(index_<3>);
auto one = ones<double>(index_<4>,index_<5>);
auto zero = zeros<double>(index_<3>, index_<3>);
DEC_TEST_EQ( I(1,1), 1 );
DEC_TEST_EQ( I(1,0), 0 );
DEC_TEST_EQ( one(1,0), 1 );
DEC_TEST_EQ( zero(1,1), 0 );
DEC_TEST_EQ( zero(1,0), 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