Boost logo

Boost Users :

Subject: Re: [Boost-users] [units][uBlas] Problems using matrix operations with dimension constraints
From: Matthias Schabel (boost_at_[hidden])
Date: 2011-04-27 12:37:58


> I'm currently trying to use the uBlas library with the units library and I'm running into some problems. The matrix and vector classes I've instantiated with unit constraints don't seem to play well with uBlas methods. Has anyone found ways of using the two libraries together? I've included some lines of what I'm trying to do and would really appreciate some help.
>
> Ryan
>
> using namespace boost::numeric::ublas;
> using namespace boost::units;
>
> //Works fine. This is expected though since dimensionless quantity can accept
> //regular built in types.
> bounded_matrix<quantity<si::dimensionless, 3, 3> rotate = identity_matrix<double>(3);
>
> //How do I initialize a vector of dimension lengths with something like the zero_matrix?
> bounded_vector<quantity<si::length>, 3> diff = zero_matrix<double>(3) * si::meter; //???
>
> //Lets pretend the diff variable has values in it. This line doesn't compile.
> //The compiler is saying it can't deduce the template argument.
> //What can I do to help the compiler out so I can get the correct result?
> bounded_vector<quantity<si::length>, 3> result = prod(rotate, diff);

uBlas doesn't currently support value types that have unconventional algebra (i.e. typeof(X*Y) != typeof(X)). It could be fixed, but would require injection of the XXX_typeof_helper operators (or decltype) throughout the library. I don't use uBlas and I'm not aware of any effort to do this as yet. Would be a good project, though...

Matthias



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net