[Numpy-discussion] matrix multiply

Anne Archibald peridot.faceted at gmail.com
Sun Apr 6 13:49:49 EDT 2008


On 06/04/2008, Alan G Isaac <aisaac at american.edu> wrote:

> Just checking:
>  it's important to me that this won't change
>  the behavior of boolean matrices, but I don't
>  see a test for this.  E.g., ::
>
>     >>> import numpy as N
>     >>> A = N.mat('1 0;1 1',dtype='bool')
>     >>> A**2
>     matrix([[ True, False],
>             [ True,  True]], dtype=bool)

I have no desire to change the behaviour of boolean matrices, and I'll
write a test, but what is it supposed to do with them? Just produce
reduce(dot,[A]*n)? For zero it will give the identity, and for
negative powers some sort of floating-point inverse. Currently for
positive powers it should produce the right answer provided
multiplication is associative (which I think it is).

The inverse actually poses a problem: should it return (A**(-1))**n or
(A**n)**(-1)? (No, they're not the same for boolean matrices.)


Anne



More information about the NumPy-Discussion mailing list