|
Ublas : |
Subject: Re: [ublas] [bindings] [lapack] geev and the type of the input matrix
From: Marco Guazzone (marco.guazzone_at_[hidden])
Date: 2010-07-14 06:30:57
On Wed, Jul 14, 2010 at 8:56 AM, Rutger ter Borg <rutger_at_[hidden]> wrote:
> Marco Guazzone wrote:
>
>> Hi,
>>
>> I've found in geev.hpp that some definition of geev takes a "const&"
>> for the input matrix.
>> For instance (the input matrix is "a"):
[cut]
>>
>> However, inside of these functions "a" is passed as-is, whithout
>> making a temporary copy.
>> Moreover, none of the "invoke" methods seems to accept a "const&" for
>> the input matrix.
>>
>> Is it correct?
>
> Yes, this is correct due to forwarding temporary views/adaptors on your
> input matrix.
>
> Consider
>
> geev( a, ... )
>
> here, you will need MatrixA& to be able to modify the matrix. But if you
> pass
>
> geev( some_operation( a ), ... )
>
> then the result of some_operation will be a temporary. The current solution
> accepts a RValue for this. The matrix itself will be stored as a mutable
> reference inside the structure returned by some_operation.
>
But this is for C++0x code, it it?
I've tried with:
--- [snip] ---
ublas::matrix<double, ublas::column_major> A(5,5);
ublas::matrix<double, ublas::column_major> LV;
ublas::matrix<double, ublas::column_major> RV;
ublas::vector<double> wr;
ublas::vector<double> wi;
// fill A ...
bindings::lapack::geev('V', 'V', ublas::trans(A), wr, wi, LV, RV);
--- [/snip] ---
but I get errors:
--- [error] ---
/home/marco/tmp/boost-numeric_bindings/boost/numeric/bindings/value_type.hpp:20:
instantiated from
boost::numeric::bindings::value_type<boost::numeric::ublas::matrix_unary2<boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_column_major<long unsigned int, long
int>, boost::numeric::ublas::unbounded_array<double,
std::allocator<double> > >,
boost::numeric::ublas::scalar_identity<double> > >
/home/marco/tmp/boost-numeric_bindings/boost/numeric/bindings/lapack/driver/geev.hpp:461:
instantiated from typename
boost::disable_if<boost::numeric::bindings::lapack::detail::is_workspace<MatrixVR>,
long int>::type boost::numeric::bindings::lapack::geev(char, char,
const MatrixA&, VectorWR&, VectorWI&, MatrixVL&, MatrixVR&) [with
MatrixA = boost::numeric::ublas::matrix_unary2<boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_column_major<long unsigned int, long
int>, boost::numeric::ublas::unbounded_array<double,
std::allocator<double> > >,
boost::numeric::ublas::scalar_identity<double> >, VectorWR =
main()::out_vector_type, VectorWI = main()::out_vector_type, MatrixVL
= main()::out_matrix_type, MatrixVR = main()::out_matrix_type]
lapack_geev.cpp:48: instantiated from here
/home/marco/tmp/boost-numeric_bindings/boost/numeric/bindings/detail/property_map.hpp:30:
error: no type named property_map in struct
boost::numeric::bindings::detail::adaptor_access<boost::numeric::ublas::matrix_unary2<boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_column_major<long unsigned int, long
int>, boost::numeric::ublas::unbounded_array<double,
std::allocator<double> > >,
boost::numeric::ublas::scalar_identity<double> >, void>
--- [/error] ---
Compiled with GCC 4.4.4
g++ -Wall -Wextra -pedantic -ansi -g -O0 -lm -llapack ...
> Having said this, this overloaf will probably be removed due to a different
> solution to the same problem -- see the Perfect Forwarding stuff Thomas has
> been writing about.
>
Interesting, thank you for pointing it out!!
Cheers,
-- Marco