That worked but only with a boost::ublas::numeric::compressed_vector and not a simple boost::ublas::numeric::vector. Thanks, Vipin On Sun, 28 Oct 2012, Oswin Krause wrote:
Hi,
without knowing what CLN should be (would have been nice to know beforehand, that you are using an unusual value_typ for vectors/matrics...)
I suspect you are compiling in debug mode and the error goes away in release. This is because the debug test for numeric stability fails.
Try to define this before including anything from ublas (or set as compile flag): BOOST_UBLAS_TYPE_CHECK=0
On 2012-10-27 11:47, Vipin Varma wrote:
Yes, in fact I just realised that I can do all the usual algebra for standard data types like double, float etc. But when I try to use CLN rational numbers - which is what I want - the below step fails with the following compile error: <ERROR> /usr/include/boost/numeric/ublas/traits.hpp:97: error: no matching function for call to 'sqrt(const cln::cl_RA&)' /usr/include/bits/mathcalls.h:157: note: candidates are: double sqrt(double) /usr/include/c++/4.3/cmath:434: note: long double std::sqrt(long double) /usr/include/c++/4.3/cmath:430: note: float std::sqrt(float) <ERROR>
However I can still multiply a scalar CLN number with a CLN matrix and assign it to a new CLN matrix; it's multiplication of a CLN vector with a CLN matrix that gives the problem.
Thanks, Vipin
On Fri, 26 Oct 2012, Oswin Krause wrote:
Have you tried:
vector z = prod(m,x);
On 2012-10-26 13:08, Vipin Varma wrote:
Dear all, My basic requirement is to multiply a matrix and a vector and then to store it into a vector using Boost's UBLAS. When I multiply a boost::numeric::ublas::compressed_matrix with a boost::numeric::ublas::vector using prod(matrix, vector), the output is a boost::numeric::ublas::matrix_vector_binary1. E.g. <PSEUDOCODE> boost::numeric::ublas::compressed_matrix m; boost::numeric::ublas::vector x; boost::numeric::ublas::matrix_vector_binary1
tmp; tmp = prod(m,x); <PSEUDOCODE> The problem is that in the third field --- which expects the operation type --- in line 3, I do not know what to enter or how to specify the type of operation; I tried '*' and 'prod' and 'vector' and 'compressed_matrix' but none work. Alternatively, I can avoid the tmp variable altogether and get a working program to copy the result of matrix-vector multiplication onto a new vector y but then I would need two multiplications. E.g. <CODE> std::copy(prod(m,x).begin(), prod(m,x).end(), y.begin()); <CODE> Any suggestions on how to declare a matrix_vector_binary1 correctly or how to get the finaly result efficiently onto a vector will be appreciated. Regards, Vipin
Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users