assert_equal for a list of matrices

release/4.3a0
Kai Ni 2010-02-28 00:48:42 +00:00
parent 4604cbce05
commit d894e23a06
2 changed files with 18 additions and 0 deletions

View File

@ -142,6 +142,19 @@ bool assert_equal(const Matrix& expected, const Matrix& actual, double tol) {
return false;
}
/* ************************************************************************* */
bool assert_equal(const std::list<Matrix>& As, const std::list<Matrix>& Bs, double tol) {
if (As.size() != Bs.size()) return false;
list<Matrix>::const_iterator itA, itB;
itA = As.begin(); itB = Bs.begin();
for (; itA != As.end(); itA++, itB++)
if (!assert_equal(*itB, *itA, tol))
return false;
return true;
}
/* ************************************************************************* */
void multiplyAdd(double alpha, const Matrix& A, const Vector& x, Vector& e) {
#if defined CBLAS

View File

@ -81,6 +81,11 @@ inline bool operator!=(const Matrix& A, const Matrix& B) {
*/
bool assert_equal(const Matrix& A, const Matrix& B, double tol = 1e-9);
/**
* equals with an tolerance, prints out message if unequal
*/
bool assert_equal(const std::list<Matrix>& As, const std::list<Matrix>& Bs, double tol = 1e-9);
/**
* overload * for matrix-vector multiplication (as BOOST does not)
*/