diff --git a/cpp/GaussianConditional.cpp b/cpp/GaussianConditional.cpp index f838b310b..1f929bc27 100644 --- a/cpp/GaussianConditional.cpp +++ b/cpp/GaussianConditional.cpp @@ -63,11 +63,13 @@ bool GaussianConditional::equals(const Conditional &c, double tol) const { // check if the size of the parents_ map is the same if (parents_.size() != p->parents_.size()) return false; - // check if R_ is equal - if (!(equal_with_abs_tol(R_, p->R_, tol))) return false; + bool equal_R1 = equal_with_abs_tol(R_, p->R_, tol); + bool equal_R2 = equal_with_abs_tol(R_*(-1), p->R_, tol); + bool equal_d1 = ::equal_with_abs_tol(d_, p->d_, tol); + bool equal_d2 = ::equal_with_abs_tol(d_*(-1), p->d_, tol); - // check if d_ is equal - if (!(::equal_with_abs_tol(d_, p->d_, tol))) return false; + // check if R_ and d_ are equal up to a sign + if (!((equal_R1 && equal_d1) || (equal_R2 && equal_d2))) return false; // check if sigmas are equal if (!(::equal_with_abs_tol(sigmas_, p->sigmas_, tol))) return false; @@ -77,7 +79,9 @@ bool GaussianConditional::equals(const Conditional &c, double tol) const { for (it = parents_.begin(); it != parents_.end(); it++) { Parents::const_iterator it2 = p->parents_.find(it->first); if (it2 != p->parents_.end()) { - if (!(equal_with_abs_tol(it->second, it2->second, tol))) return false; + if (!(equal_with_abs_tol(it->second, it2->second, tol)) && + !(equal_with_abs_tol(it->second*(-1), it2->second, tol))) + return false; } else return false; } diff --git a/cpp/Matrix.cpp b/cpp/Matrix.cpp index b295ae6a8..319c1d0ab 100644 --- a/cpp/Matrix.cpp +++ b/cpp/Matrix.cpp @@ -13,6 +13,7 @@ #ifdef GT_USE_CBLAS #ifdef YA_BLAS #include +#include #else #include #endif @@ -650,6 +651,42 @@ void householder(Matrix &A, size_t k) { A(i,j) = 0.0; } +/* ************************************************************************* */ +/** in-place householder */ +/* ************************************************************************* */ +#ifdef GT_USE_CBLAS +void householder(Matrix &A) { + int m = A.size1(); + int n = A.size2(); + + // convert from row major to column major + double a[m*n]; int k = 0; + for(int j=0; j