Commit 08cbb9bb authored by Sander, Oliver's avatar Sander, Oliver
Browse files

Implement UnblockedDiagonalMatrix::mv and ::mtv

parent 8d26d195
Pipeline #8798 passed with stage
in 6 minutes and 53 seconds
......@@ -28,6 +28,32 @@ bool compareBehavior(TestMatrix testMatrix,
if (testMatrix.cols != referenceMatrix.cols)
DUNE_THROW(Exception, "testMatrix does not have the correct number of columns!");
// Test whether method mv computes the right thing
{
FieldVector<double, testMatrix.cols> v;
for (size_t i=0; i<v.size(); ++i)
{
v = 0;
v[i] = 1.0;
// Fill testResult with bogus values, to check whether 'mv' properly
// overwrite them.
FieldVector<double, testMatrix.rows> testResult(42);
FieldVector<double, referenceMatrix.rows> referenceResult(0);
testMatrix.mv(v,testResult);
referenceMatrix.mv(v,referenceResult);
if ( (testResult - referenceResult).infinity_norm() > 1e-6 )
{
std::cout << "Method mv did not compute the correct result!" << std::endl;
std::cout << "Result: " << testResult << std::endl;
std::cout << "Expected: " << referenceResult << std::endl;
passed = false;
}
}
}
// Test whether method umv computes the right thing
{
FieldVector<double, testMatrix.cols> v;
......@@ -76,6 +102,30 @@ bool compareBehavior(TestMatrix testMatrix,
}
}
// Test whether method mtv computes the right thing
{
FieldVector<double, testMatrix.rows> v;
for (size_t i=0; i<v.size(); ++i)
{
v = 0;
v[i] = 1.0;
FieldVector<double, testMatrix.cols> testResult(42);
FieldVector<double, referenceMatrix.cols> referenceResult(0);
testMatrix.mtv(v,testResult);
referenceMatrix.mtv(v,referenceResult);
if ( (testResult - referenceResult).infinity_norm() > 1e-6 )
{
std::cout << "Method mtv did not compute the correct result!" << std::endl;
std::cout << "Result: " << testResult << std::endl;
std::cout << "Expected: " << referenceResult << std::endl;
passed = false;
}
}
}
// Test whether method umtv computes the right thing
{
FieldVector<double, testMatrix.rows> v;
......
......@@ -68,6 +68,13 @@ namespace Dune::FracturePhasefields
// Matrix-vector products
template<class X, class Y>
void mv(const X& x, Y& y) const
{
y = 0;
umv(x,y);
}
template<class X, class Y>
void umv(const X& x, Y& y) const
{
......@@ -87,6 +94,13 @@ namespace Dune::FracturePhasefields
});
}
template<class X, class Y>
void mtv(const X& x, Y& y) const
{
y = 0;
umtv(x,y);
}
template<class X, class Y>
void umtv(const X& x, Y& y) const
{
......
Supports Markdown
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