#include #include #include #include #include using namespace boost::numeric::ublas; template< typename Orientation > void run_test() { int dim = 7; matrix M = zero_matrix(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 V(dim); for (std::size_t i = 0 ; i < dim ; i++) { V(i) = double(std::rand()) / 1e9; } boost::numeric::ublas::vector R1(dim); boost::numeric::ublas::vector R2(dim); boost::numeric::bindings::blas::gemv(1, M, V, 0, R1); noalias(R2) = V; boost::numeric::bindings::blas::trmv(triangular_adaptor, 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>(); }