Boost logo

Ublas :

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


On 12/20/2010 05:55 PM, Umut Tabak wrote:
>>
>
> Compiles fine here, which version are you using?
>

Sorry for the stupid reply, see this one

#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) {
void UBlasStuff(ublas::matrix<double> A,ublas::vector<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 =

   double result_direct =
               ublas::inner_prod(B,ublas::prod(A,B));

}

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
   ublas::vector<double> B(3); // compilation error, not a runtime error
   UBlasStuff(A,B);
   return 0;
}

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