|
Boost : |
From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2002-02-13 02:47:14
Walter, Jorg wrote:
>>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.
>>
>
> We have no problem with a circular dependency, but subscription is the last
> (and nonessential) operation, which makes it necessary to reference a
> matrix_row<> type.
>
But is the reference to a matrix_row type a bad thing. I suppose you
want to prohibit matrix.h having to include matrix_pr.h. Correct ?
But basically I'm not convinced yet that row(matrix,2) is as intuitive
as matrix[2]. As mentioned in earlier discussions, making it intuitive
is a big issue.
I would suggest to maybe support square brackets some time longer
(possibly using a DEPRECATED ifdef) to get some experience with both
approaches.
> [snip]
>
>
>>>>>>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)
>>
>
> Sorry, you've lost me. I expect the following code
>
> template<class T>
> matrix<double> compute_real_part (const matrix<T> &m) {
> return real (m);
> }
>
> to work for at least float, double, std::complex<float> and
> std::complex<double>. What am I missing?
>
what about
template < typename T1, typename T2 >
void assign(matrix< T1 >& m, const matrix_row< T2 >& row) {
m[0] = row ;
}
this is a very simplified version of a real scenario in my code.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk