14 #ifndef COMMONS_CHECKMATRIX_H
15 #define COMMONS_CHECKMATRIX_H
23 template<
class Derived >
24 void CheckMatrixClose(TestResults& results, gsEigen::MatrixBase<Derived>
const& expected, gsEigen::MatrixBase<Derived>
const& actual,
25 typename gsEigen::MatrixBase<Derived>::Scalar
const& tolerance, TestDetails
const& details)
28 const index_t rows = actual.rows();
29 const index_t cols = actual.cols();
31 equal &= (expected.rows() == rows);
32 equal &= (expected.cols() == cols);
33 for (
index_t i=0; equal && i<rows; ++i)
43 UnitTest::MemoryOutStream stream;
45 if (expected.rows() != rows) {
46 stream <<
"Expected rows=" << expected.rows() <<
" but was " << rows <<
"!";
47 results.OnTestFailure(details, stream.GetText());
50 if (expected.cols() != cols) {
51 stream <<
"Expected cols=" << expected.cols() <<
" but was " << cols <<
"!";
52 results.OnTestFailure(details, stream.GetText());
56 stream <<
"Expected [ ";
58 for (
int expectedRow = 0; expectedRow < rows; ++expectedRow)
61 for (
int expectedColumn = 0; expectedColumn < cols; ++expectedColumn)
62 stream << expected(expectedRow, expectedColumn) <<
" ";
66 stream <<
"] +/- " << tolerance <<
" but was [ ";
68 for (
int actualRow = 0; actualRow < rows; ++actualRow)
71 for (
int actualColumn = 0; actualColumn < cols; ++actualColumn)
72 stream << actual(actualRow,actualColumn) <<
" ";
78 results.OnTestFailure(details, stream.GetText());
83 template<
typename T >
84 void CheckMatrixPartitionOfUnitClose(TestResults& results,
gismo::gsMatrix<T> const& actual,
85 T
const& tolerance, TestDetails
const& details)
88 const index_t cols = actual.cols();
92 const real_t sum = actual.col(j).sum();
99 UnitTest::MemoryOutStream stream;
101 stream <<
"expected for all columns that sum='" << 1.0 <<
"' +/- '" << tolerance<<
"', but was [";
105 const real_t sum = actual.col(j).sum();
106 stream <<
"[expected='" << 1.0 <<
", actual.cols('";
107 stream << j <<
"').sum()='" << sum <<
"'']";
112 results.OnTestFailure(details, stream.GetText());
119 #endif // COMMONS_CHECKMATRIX_H
#define index_t
Definition: gsConfig.h:32
EIGEN_STRONG_INLINE abs_expr< E > abs(const E &u)
Absolute value.
Definition: gsExpressions.h:4486