Boost logo

Boost :

From: Joerg Walter (jhr.walter_at_[hidden])
Date: 2003-02-02 06:51:43


Hi Kresimir,

you wrote:

> >> now that sparse matrix_row's works with Joerg's latest CVS upload
> >> (thanks Joerg), a const& parameter that used to work with 1_29_0
doesn't
> >> anymore:
> >>
> >> using namespace boost::numeric;
> >> typedef ublas::matrix<double> TM;
> >>
> >> double InnerProdConst( const TM& A, const ublas::vector<double>& x )
> >> {
> >> return ublas::inner_prod( ublas::matrix_row< const TM >( A, 2 ),
> x );
> >> }
> >>
> >> VC++.NET complains that some internal conversion loses qualifiers,
> >> This does compile with a non const matrix reference parameter, the
same
> >> is true if I use a sparse_matrix or a compressed_matrix. I didn't try
> >> the other matrix types, but since this breaks with three matrix types,
> >> it looks like it has to do with matrix_row itself.
>
> ... or with VC++.NET ;o)

... or with ublas' perception of MS compilers ;-). I've just upgraded boost
on my old Win98 box from 1_25_1 to 1_29_0 and checked Julius' sample with
MSVC 6.0. He is right that it doesn't compile with the latest ublas
snapshot, but the fix is surprisingly simple. I only had to disable the
definition of

// #define BOOST_UBLAS_NO_SMART_PROXIES

in the MSVC section of config.hpp. This now seems to work due to our
migration to MPL (thanks, Aleksey!). The last compiler which doesn't support
these constructs is Borland.

> Joerg Walter wrote:
>
> > The following code compiles successfully with GCC 3.2.1:
> >
> > #include <boost/numeric/ublas/matrix.hpp>
> >
> > using namespace boost::numeric;
> > typedef ublas::matrix<double> TM;
> >
> > double InnerProdConst( const TM& A, const ublas::vector<double>& x )
> > {
> > return ublas::inner_prod( ublas::matrix_row< const TM >( A, 2 ),
x );
> > }
> >
> > int main()
> > {
> > ublas::matrix< double > A( 3, 3 );
> > ublas::vector< double > x( 3 );
> > std::cout << InnerProdConst( A, x ) << std::endl;
> > }
>
> ... and with Comeau's C++ compiler 4.3.0.1, too.

And with MSVC 6.0 now, too.

> Also with the following addition to `main()':
>
> ublas::matrix< double > const CA( A );
> std::cout << InnerProdConst( CA, x ) << std::endl;

Hopefully, too. Didn't check this yet.

Thanks,

Joerg


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk