Boost logo

Boost :

From: jhrwalter (walter_at_[hidden])
Date: 2002-02-12 03:46:25


--- In boost_at_y..., Toon Knapen <toon.knapen_at_s...> wrote:
> Currently, real matrices can be assigned to complex matrices due to
the
> automatic conversion from double to complex. The other direction
however
> is not supported. To make following code work :
>
> numerics::matrix< std::complex< double > > complex_matrix(8,3);
> numerics::matrix< double > double_matrix(8,3);
> double_matrix[0] = complex_matrix[0] ;

Couldn't this be done with
 
double_matrix[0] = complex_matrix[0].real() ;
 
or
 
double_matrix[0] = numerics::detail::real(complex_matrix[0]) ;
 
already?
 
>
> I patched following files (2 patches follow):

[Patch snipped]
 
Based on our earlier discussion
(http://groups.yahoo.com/group/boost/message/21527) we've recently
added expression templates for real(vector/matrix) and imag
(vector/matrix). You'll find the changes in boost CVS. If I've
understood your problem correctly, this should help also.

>
> I also noticed the use of the iterating_assign in vector_assign.
Would
> you also consider a specialisation to use a memcpy when the
value_types
> are equal and POD types ?
 
This only would work if the rhs in vector_assign would be simple
(i.e. another vector). But such an assignment should be handled by
the corresponding assignment operator in the the vector class
already. IMO the first place to use memcpy as an optimization would
be in storage.h for example.
 
Regards
 
Joerg


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