Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2004-07-06 10:08:57


Hi Aleksey,

On Jul 5, 2004, at 9:34 PM, Aleksey Gurtovoy wrote:
>> A *linear algebra* algorithm will never need to be generalized
>> in the fashion you advocate below.
>
> On the contrary, I think one can come up with numerous examples proving
> the opposite. For instance:

The below algorithm is not a linear algebra algorithm in the sense that
it is not defined in terms of linear algebra operations, such as
addition and multiplication.

The below algorithm operates at a slightly lower level of abstraction.
I agree that for that level, it is sometimes convenient to ignore the
row/column
distinction. MTL-2 provides an alternative interface that provides for
this capability. Note however, you've still only got 2 dimensions.

>
> template< int i, int j, typename M >
> bool is_triangular( M const& m )
> {
> for ( typename index_type<M,i>::type k(0); k <
> m.size(int_<i>()); ++k )
> for ( typename index_type<M,j>::type l(0); l < value(k);
> ++l )
> if ( m[k][l] != 0 )
> return false;
>
> return true;
> }
>
> template< typename M >
> bool is_upper_triangular( M const& m )
> {
> return is_triangular<0,1>( m );
> }
>
> template< typename M >
> bool is_lower_triangular( M const& m )
> {
> return is_triangular<1,0>( m );
> }
>
> --
> Aleksey Gurtovoy
> MetaCommunications Engineering
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
_______________________________________________
Jeremy Siek <jsiek_at_[hidden]>
http://www.osl.iu.edu/~jsiek
Ph.D. Student, Indiana University Bloomington
C++ Booster (http://www.boost.org)
_______________________________________________


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