Boost logo

Boost :

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2002-02-13 01:18:35


Walter, Jorg wrote:

> Hi Toon,
>
> you wrote:
>>I've been thinking about this. I actually find the square brackets very
>>intuitive. On the other hand, using the free functions it's more clear
>>if you're using a row or a column. Finally I would like to have both
>>(the square brackets and the free functions).
>>
>
> OTOH our rationale (for trying ?) to deprecate subscripting was to further
> reduce class interdependencies ...
>

But was there a problem with circular dependencies ? For the square
brackets, I suppose Matrix is dependent on Vector. But I guess there's
no dependency in the other direction.

>
>>>>>>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.
>>>>>
>>>>Great if had added the functionality already. Can you provide a small
>>>>example to show me how to use it ?
>>>>
>>>Given your example, the corrected solution should be:
>>>
>>>double_matrix[0] = numerics::real(complex_matrix[0]) ;
>>>
>>But here you suppose that you now that the RHS is a complex. I also have
>>generic algorithms where I don't know the value_type's of the matrices
>>so they need to be converted automatically.
>>
>
> No, numerics::real and numerics::imag should accept real matrices, too,
> computing the matrix itself or a zero matrix respective.
>
But I can't now if the LHS is a real or complex matrix.

The conversion (if necessary) is thus dependent on the type of the LHS and the RHS.

Another solutions would e.g. be to something like :
typedef matrix< double > LHS;
LHS lhs;
matrix< complex > rhs ;

lhs = matrix_cast< LHS::value_type >( rhs );

But also here is no generic way to specify if you want to take the real
or imag part of the RHS (as in my current solution)


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