|
Boost : |
From: Joerg Walter (jhr.walter_at_[hidden])
Date: 2003-02-01 15:52:47
Hi Julius,
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:
Ouch ;-(
> 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.
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;
}
I'll try to check this with MSVC 6.0 tomorrow.
> I think this should work with const&'s since inner_prod is non mutating.
> I'd like to keep the const&'s.
>
> Joerg: You suggested using compressed_matrix instead of sparse_matrix in
> your recent response to my matrix_row access problem. I couldn't find much
> in the documentation about the pros and cons of either type. Can you give
> me hint where to look for more information? Thanks.
Alexei Novakov's benchmarks show that Fortran like CRS/CCS schemes are more
efficient in most cases.
Best,
Joerg
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk