Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2004-07-05 21:34:34


Jeremy Graham Siek writes:
> Hi Aleksey,

Hi Jeremy,

>
> You are confusing the matrix abstraction with the multi-dimensional
> array abstraction.

I don't think so :).

>
> 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:

    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

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