Boost logo

Ublas :

From: Michael Stevens (mail_at_[hidden])
Date: 2005-05-03 07:38:24


On Tuesday 03 May 2005 12:29, Gunter Winkler wrote:
> On Tuesday 03 May 2005 11:22, Max Weinberg wrote:
> > Well, I don't care if it's called operator==, but there definitely should
> > be a way to compare matrices. Call it equal if you like and give it a
> > functor parameter that handles the element comparison.
> > Isn't that an easy exercise using the "matrix expressions"?
>
> BTW: Using norm_1(A-B) or norm_inf(A-B) is a O(n*m) or O(nnz) operation.
> Doing a elementwise comparison (optionally with short circuit) is O(n*m) or
> O(nnz), too. So there is no difference regarding the algorithmic
> complexity.

I think I see what Max wants: An 'equality' that uses a uBLAS "matrix
expressions".
Gunters suggests norm_inf(A-B) seems to fit the bill perfectly. In user code I
think
        if (norm_inf(A-B) == 0)
                .. equal

is nice linear algebra expression.

Has two small drawbacks.
a) norm_inf(A-B) !=0 does not short circuit
b) Requires operator- instead of operator == for elements. Only an issue if
you store non algebraic elements!

Is this good Max?

Michael