John Edmiston
2009-09-04 18:28:20 UTC
Hello,
Very green user here (brought up from python so I'm pretty weak when it comes to C++, and I'm not any sort of programmer by education), I appreciate the easy installation setup for PyUblas and the documentation, unlike for Boost/Python, ugh.
I'm just trying to do some simple things with PyUblas/Boost I was just wondering what the best way to do things like matrix-vector multiplication with numpy_vector and numpy_matrix would be - I had been using your numpy_vector's as_ublas() function to convert them to boost::numeric::ublas::vector/matrix individually, then using boost::numeric::ublas::prod(amatrix,avector) - and then in order to output the result back to python I used the boost::numeric::ublas::vector which resulted from the matrix-vector product as the constructor argument for a new numpy_vector object in order to send back to python.
e.g. something like:
boost::numeric::ublas::vector<double> v = a_numpy_vector.as_ublas();
boost::numeric::ublas::matrix<double> R = a_numpy_matrix.as_ublas();
boost::numeric::ublas::vector<double> Rv = boost::numeric::ublas::prod(R,v);
pyublas::numpy_vector<double> return_val(Rv);
Is this what you would recommend for this sort of operation or would it be at all more efficient at all to implement the matrix vector multiplication myself. Im not concerned with 'optimimum' performance at all really, I just thought maybe there was an even simpler way to do matrix-vector product without needing the as_ublas() function to and then converting back to numpy_vector.
Thanks
John
_________________________________________________________________
Windows Live: Keep your friends up to date with what you do online.
http://windowslive.com/Campaign/SocialNetworking?ocid=PID23285::T:WLMTAGL:ON:WL:en-US:SI_SB_online:082009
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.tiker.net/pipermail/pyublas/attachments/20090904/68980a74/attachment.htm>
Very green user here (brought up from python so I'm pretty weak when it comes to C++, and I'm not any sort of programmer by education), I appreciate the easy installation setup for PyUblas and the documentation, unlike for Boost/Python, ugh.
I'm just trying to do some simple things with PyUblas/Boost I was just wondering what the best way to do things like matrix-vector multiplication with numpy_vector and numpy_matrix would be - I had been using your numpy_vector's as_ublas() function to convert them to boost::numeric::ublas::vector/matrix individually, then using boost::numeric::ublas::prod(amatrix,avector) - and then in order to output the result back to python I used the boost::numeric::ublas::vector which resulted from the matrix-vector product as the constructor argument for a new numpy_vector object in order to send back to python.
e.g. something like:
boost::numeric::ublas::vector<double> v = a_numpy_vector.as_ublas();
boost::numeric::ublas::matrix<double> R = a_numpy_matrix.as_ublas();
boost::numeric::ublas::vector<double> Rv = boost::numeric::ublas::prod(R,v);
pyublas::numpy_vector<double> return_val(Rv);
Is this what you would recommend for this sort of operation or would it be at all more efficient at all to implement the matrix vector multiplication myself. Im not concerned with 'optimimum' performance at all really, I just thought maybe there was an even simpler way to do matrix-vector product without needing the as_ublas() function to and then converting back to numpy_vector.
Thanks
John
_________________________________________________________________
Windows Live: Keep your friends up to date with what you do online.
http://windowslive.com/Campaign/SocialNetworking?ocid=PID23285::T:WLMTAGL:ON:WL:en-US:SI_SB_online:082009
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.tiker.net/pipermail/pyublas/attachments/20090904/68980a74/attachment.htm>