Skip to content

Commit

Permalink
Add test for matrix wo diag entry
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikvn committed Jan 22, 2024
1 parent d18de70 commit e243cf0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions reference/test/matrix/batch_csr_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,22 @@ TYPED_TEST(Csr, CanAddScaledIdentity)
}


TYPED_TEST(Csr, AddScaledIdentityFailsOnMatrixWithoutDiagonal)
{
using BMtx = typename TestFixture::BMtx;
using BMVec = typename TestFixture::BMVec;
auto alpha = gko::batch::initialize<BMVec>({{2.0}, {-1.0}}, this->exec);
auto beta = gko::batch::initialize<BMVec>({{3.0}, {-2.0}}, this->exec);
auto mat = gko::batch::initialize<BMtx>(
{{{0.0, 2.0, 0.0}, {3.0, 1.0, 1.0}, {0.0, 1.0, 1.0}},
{{0.0, -2.0, 0.0}, {1.0, -1.0, 2.0}, {0.0, 2.0, 1.0}}},
this->exec, 6);

ASSERT_THROW(mat->add_scaled_identity(alpha, beta),
gko::UnsupportedMatrixProperty);
}


TYPED_TEST(Csr, ApplyFailsOnWrongNumberOfResultCols)
{
using BMVec = typename TestFixture::BMVec;
Expand Down
16 changes: 16 additions & 0 deletions reference/test/matrix/batch_ell_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,22 @@ TYPED_TEST(Ell, CanAddScaledIdentity)
}


TYPED_TEST(Ell, AddScaledIdentityFailsOnMatrixWithoutDiagonal)
{
using BMtx = typename TestFixture::BMtx;
using BMVec = typename TestFixture::BMVec;
auto alpha = gko::batch::initialize<BMVec>({{2.0}, {-1.0}}, this->exec);
auto beta = gko::batch::initialize<BMVec>({{3.0}, {-2.0}}, this->exec);
auto mat = gko::batch::initialize<BMtx>(
{{{0.0, 2.0, 1.0}, {0.0, 1.0, 1.0}, {0.0, 1.0, 1.0}},
{{0.0, -2.0, 2.0}, {0.0, -1.0, 2.0}, {0.0, 2.0, 1.0}}},
this->exec, 2);

ASSERT_THROW(mat->add_scaled_identity(alpha, beta),
gko::UnsupportedMatrixProperty);
}


TYPED_TEST(Ell, ApplyFailsOnWrongNumberOfResultCols)
{
using BMVec = typename TestFixture::BMVec;
Expand Down

0 comments on commit e243cf0

Please sign in to comment.