only call alpha calls if CBLAS version will be called.

release/4.3a0
Frank Dellaert 2010-02-26 03:23:48 +00:00
parent 044ea1348d
commit 17bd59ec80
1 changed files with 25 additions and 20 deletions

View File

@ -181,17 +181,20 @@ void multiplyAdd(double alpha, const Matrix& A, const Vector& x, Vector& e) {
/* ************************************************************************* */ /* ************************************************************************* */
void multiplyAdd(const Matrix& A, const Vector& x, Vector& e) { void multiplyAdd(const Matrix& A, const Vector& x, Vector& e) {
multiplyAdd(1.0, A, x, e);
// ublas e += prod(A,x) is terribly slow // ublas e += prod(A,x) is terribly slow
// size_t m = A.size1(), n = A.size2(); #ifdef CBLAS
// double * ei = e.data().begin(); multiplyAdd(1.0, A, x, e);
// const double * aij = A.data().begin(); #else
// for (int i = 0; i < m; i++, ei++) { size_t m = A.size1(), n = A.size2();
// const double * xj = x.data().begin(); double * ei = e.data().begin();
// for (int j = 0; j < n; j++, aij++, xj++) const double * aij = A.data().begin();
// (*ei) += (*aij) * (*xj); for (int i = 0; i < m; i++, ei++) {
// } const double * xj = x.data().begin();
} for (int j = 0; j < n; j++, aij++, xj++)
(*ei) += (*aij) * (*xj);
}
#endif
}
/* ************************************************************************* */ /* ************************************************************************* */
Vector operator^(const Matrix& A, const Vector & v) { Vector operator^(const Matrix& A, const Vector & v) {
@ -242,17 +245,19 @@ void transposeMultiplyAdd(double alpha, const Matrix& A, const Vector& e, Vector
/* ************************************************************************* */ /* ************************************************************************* */
void transposeMultiplyAdd(const Matrix& A, const Vector& e, Vector& x) { void transposeMultiplyAdd(const Matrix& A, const Vector& e, Vector& x) {
transposeMultiplyAdd(1.0, A, e, x);
// ublas x += prod(trans(A),e) is terribly slow // ublas x += prod(trans(A),e) is terribly slow
// TODO: use BLAS #ifdef CBLAS
// size_t m = A.size1(), n = A.size2(); transposeMultiplyAdd(1.0, A, e, x);
// double * xj = x.data().begin(); #else
// for (int j = 0; j < n; j++,xj++) { size_t m = A.size1(), n = A.size2();
// const double * ei = e.data().begin(); double * xj = x.data().begin();
// const double * aij = A.data().begin() + j; for (int j = 0; j < n; j++,xj++) {
// for (int i = 0; i < m; i++, aij+=n, ei++) const double * ei = e.data().begin();
// (*xj) += (*aij) * (*ei); const double * aij = A.data().begin() + j;
// } for (int i = 0; i < m; i++, aij+=n, ei++)
(*xj) += (*aij) * (*ei);
}
#endif
} }
/* ************************************************************************* */ /* ************************************************************************* */