Boost logo

Ublas :

From: Max Weinberg (max.weinberg_at_[hidden])
Date: 2005-05-03 09:00:28

> Can you give an example, in which situation you check the equality of two
> matrices? I never needed it in my codes.

It happens quite often in my code, since I "misuse" the sparse matrices as
containers for non-numeric objects.

> BTW: Using norm_1(A-B) or norm_inf(A-B) is a O(n*m) or O(nnz) operation.
> a elementwise comparison (optionally with short circuit) is O(n*m) or O(nnz),
> too. So there is no difference regarding the algorithmic complexity.

Well, this is worst case complexity which doesn't have so much meaning. Average
complexity would include as parameter the mean number D of elements that
differ. That would give something like O(nnz/(1+D)) [roughly] for the element-
wise comparison, while the norm variant is stuck to O(nnz).