Boost logo

Ublas :

Subject: Re: [ublas] view row vector as column vector
From: sguazt (marco.guazzone_at_[hidden])
Date: 2011-02-18 15:15:04


On Fri, Feb 18, 2011 at 8:42 PM, Matwey V. Kornilov
<matwey.kornilov_at_[hidden]> wrote:
>
> prod( M, row( A, 1 ) )
> prod( M, column( A, 1 ) )
>
> because both column and row are vectors.
>
> Neal Becker wrote:
>
>> I need to multiply a matrix by a vector.  What would be an efficient way
>> to do
>>
>> H * v^t (v transpose).
>>

In ublas, when you want to multiply a matrix by a vector, there's no
difference between a vector and its transpose.
So you can use the "prod" function directly on v [1]-
The "prod" function is efficient because makes use of "expression
templates" [2]; so the product is done only on the element you really
use

References:
[1] http://www.boost.org/doc/libs/1_45_0/libs/numeric/ublas/doc/operations_overview.htm#23innerouterandotherproducts
[2] http://www.angelikalanger.com/Articles/Cuj/ExpressionTemplates/ExpressionTemplates.htm

Best,

-- Marco