Boost logo

Boost :

From: jhrwalter (walter_at_[hidden])
Date: 2002-01-08 05:57:58


--- In boost_at_y..., Toon Knapen <toon.knapen_at_s...> wrote:
> How can I compare individual rows of different matrices ?
> Following code fails ;-(
>
> typedef numerics::matrix< double > DMatrix;
>
> DMatrix m (size, size);
> for (int i = 0; i < m.size1 (); ++ i)
> for (int j = 0; j < m.size2 (); ++ j)
> m (i, j) = size * i + j;
>
> DMatrix::matrix_row_type mr1 = m[1];
> DMatrix::matrix_row_type mr2 = m[2];
> std::cout << "equal ? " << ( mr1 == mr2 )<< std::endl;
 
You could use one of the supported norm functions norm_1, norm_2 or
norm_inf instead:
 
std::cout << "equal ? " << (norm_1 ( mr1, mr2 ) <
std::numeric_limits<double>::epsilon ()) << std::endl;
 
HTH
 
Joerg
 
P.S.: It is an interesting question, if it makes sense to support
operator == and operator != for finite fields like rational<>.

 


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