Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2007-03-28 17:04:35

Am Mittwoch, 28. März 2007 19:31 schrieb Matthias Schabel:

> This is a type deduction flaw in ublas - if ublas was updated to use
> Boost.Typeof, this issue would presumably go away. Basically, they're
> using operator+ to deduce the promoted type in this operation
> (likely, though I don't know this for sure, so an integer ublas
> vector times a double precision scalar will give a double precision
> ublas vector)... The best solution for this is clearly to use
> Boost.Typeof in ublas rather than the existing type deduction
> machinery, at least for compilers that support it. Compilers that
> don't work with Boost.Typeof will almost certainly not be able to
> compile the proposed Boost.Units library anyway... The way we do it
> in the units library is to have typeof helpers
> (add_typeof_helper<T,U>, subtract_typeof_helper<T,U>, etc...) that
> will do reasonable promotion for built in types and correctly handle
> UDTs as well...

The implementation of type deduction of uBLAS is really complicated, so
we are still looking for a simpler version. The use of result_type of
operator+ was already a big advantage. However the current
implementation assumes that all operation (+,-,*,/) follow the same
rules. A modification of this assumption would mean a big redesign of
many classes. Any help is welcome.

> > 3. Boost.uBLAS (zero_vector)
> > ublas::zero_vector< quantity< SI::length > > v(3); // Fails to
> > compile
> >
> > Visual Studio balks down in <boost/numeric/ublas/vector.hpp> line
> > 762 (zero_(0)). It looks like it's trying to construct a quantity<
> > SI::length > with the protected constructor:
> > C2248: 'boost::units::quantity<Unit>::quantity' : cannot access
> > protected member declared in class 'boost::units::quantity<Unit>'

This "construction from zero" should already be replaced by
value_type(/*zero*/) everywhere. (Do you use CVS Head or 1.33.x?)