Skip to content
Snippets Groups Projects
Commit d0e5cad9 authored by Felix Gruber's avatar Felix Gruber
Browse files

[test] add test for Matrix::transpose()

Due to a bug in Matrix::transpose() it will give wrong results for
non-quadratic matrices. Thus the new test case fails for the moment.
parent bc2d9442
No related branches found
No related tags found
No related merge requests found
......@@ -280,6 +280,20 @@ void testSolve(const MatrixType& matrix)
DUNE_THROW(ISTLError, "Solve() method doesn't appear to produce the solution!");
}
// //////////////////////////////////////////////////////////////
// Test transposing the matrix
// //////////////////////////////////////////////////////////////
template <class MatrixType>
void testTranspose(const MatrixType& matrix)
{
MatrixType transposedMatrix = matrix.transpose();
for(size_t i = 0; i < matrix.N(); i++)
for(size_t j = 0; j < matrix.M(); j++)
if(fabs(transposedMatrix[j][i] - matrix[i][j]) > 1e-10)
DUNE_THROW(ISTLError, "transpose() method produces wrong result!");
}
int main()
{
......@@ -313,6 +327,17 @@ int main()
testSuperMatrix(matrix);
Matrix<FieldMatrix<double,1,1> > nonquadraticMatrix(1,2);
{
size_t n = 1;
for (size_t i=0; i<1; i++)
for (size_t j=0; j<2; j++)
nonquadraticMatrix[i][j] = n++;
}
testTranspose(nonquadraticMatrix);
// ////////////////////////////////////////////////////////////
// Test the BCRSMatrix class -- a sparse dynamic matrix
// ////////////////////////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment