Boost logo

Ublas :

Subject: Re: [ublas] Problem with nested products
From: Umut Tabak (u.tabak_at_[hidden])
Date: 2010-12-20 11:55:58


On 12/20/2010 05:49 PM, Michael Wand wrote:
> #include<boost/numeric/ublas/matrix.hpp>
> #include<boost/numeric/ublas/vector.hpp>
> #include<boost/numeric/ublas/io.hpp>
>
> namespace ublas = boost::numeric::ublas;
>
> // Take a matrix A and a row vector B
> void UBlasStuff(ublas::matrix<double> A,ublas::matrix<double> B) {
> ublas::matrix<double> BTrans = ublas::trans(B);
>
> // the next two lines work
> ublas::matrix<double> intermediate_result = ublas::prod(B,A);
> ublas::matrix<double> result = ublas::prod(intermediate_result,BTrans);
>
> // the next two lines do not compile if uncommented
> /// ublas::matrix<double> result_direct =
> /// ublas::prod(B,ublas::prod(A,BTrans));
>
> }
>
> int main(int argc,char** argv) {
> ublas::matrix<double> A(3,3); // uninitialized since we're looking for a
> ublas::matrix<double> B(1,3); // compilation error, not a runtime error
> UBlasStuff(A,B);
> return 0;
> }
>
>
Compiles fine here, which version are you using?

-- 
  - Hope is a good thing, maybe the best of things
    and no good thing ever dies...
  The Shawshank Redemption, replique of Tim Robbins