Re: [BLAS bindings] help appreciated on using trmv and gbmv
Rutger ter Borg <[email protected]>
| Newsgroups | gmane.comp.lib.boost.ublas |
|---|---|
| Message-ID | <[email protected]> |
On 2012-10-07 21:22, Florent Teichteil wrote: > I'm actually using ATLAS as a backend, so I don't understand why I get > the correct result with column_major but not with row_major (for the > first test case, since all other tests, either with transposed > triangular matrices or with banded matrices, give wrong results > anyway). > > Do you observe the same thing on your computer with the code given in > my post? (replace M(i,j) == std::rand with M(i,j) = std::rand , and dM > with M, they were copy/paste errors). > > Cheers > Florent Hello Florent, I'm not able to reproduce your column_major / row_major differences. Please find attached your first test case. I get identical results for both row_major and column_major. And, indeed, those results are also identical to a ublas::prod(). g++ 4.7.2, ATLAS 3.8.4. Am I missing something? Regards, Rutger _______________________________________________ ublas mailing list [email protected] http://lists.boost.org/mailman/listinfo.cgi/ublas Sent to: [email protected]
test.cpp
(text/x-c++src, 1.1 KB)
#include <boost/numeric/bindings/ublas.hpp>
#include <boost/numeric/bindings/blas.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
using namespace boost::numeric::ublas;
template< typename Orientation >
void run_test() {
int dim = 7;
matrix<double, Orientation> M = zero_matrix<double, Orientation>(dim, dim);
for (std::size_t i = 0 ; i < dim ; i++) {
for (std::size_t j = i ; j < dim ; j++) {
M(i, j) = double(std::rand()) / 1e9;
}
}
boost::numeric::ublas::vector<double> V(dim);
for (std::size_t i = 0 ; i < dim ; i++) {
V(i) = double(std::rand()) / 1e9;
}
boost::numeric::ublas::vector<double> R1(dim);
boost::numeric::ublas::vector<double> R2(dim);
boost::numeric::bindings::blas::gemv(1, M, V, 0, R1);
noalias(R2) = V;
boost::numeric::bindings::blas::trmv(triangular_adaptor<matrix<double,
Orientation>, upper>(M), R2);
std::cout << prod( M, V ) << std::endl;
std::cout << R1 << std::endl;
std::cout << R2 << std::endl;
}
int main() {
run_test< column_major >();
run_test< row_major>();
}