diff --git a/cpp/Matrix.cpp b/cpp/Matrix.cpp index 7ce0c95dc..b68f97712 100644 --- a/cpp/Matrix.cpp +++ b/cpp/Matrix.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -504,6 +505,19 @@ Matrix collect(const std::vector& matrices, size_t m, size_t n) dimA1 = M->size1(); // TODO: should check if all the same ! dimA2 += M->size2(); } + + // matrix_range version + // Result: slower +// Matrix A(dimA1, dimA2); +// size_t hindex = 0; +// BOOST_FOREACH(const Matrix* M, matrices) { +// ublas::matrix_range mr(A, ublas::range(0, dimA1), +// ublas::range(hindex, hindex+M->size2())); +// mr = *M; +// hindex += M->size2(); +// } + + // memcpy version Matrix A(dimA1, dimA2); double * Aptr = A.data().begin(); size_t hindex = 0; @@ -561,9 +575,14 @@ Matrix vector_scale(const Vector& v, const Matrix& A) { // column scaling Matrix vector_scale(const Matrix& A, const Vector& v) { Matrix M(A); - for (int i=0; i