[Numpy-discussion] matrix problem: float to matrix power
Timothy Hochberg
tim.hochberg@ieee....
Wed Oct 31 11:55:26 CDT 2007
On Oct 30, 2007 11:40 PM, Alan G Isaac <aisaac@american.edu> wrote:
> >>> 1.0**numpy.array([1,2,3])
> array([ 1., 1., 1.])
> >>> 1.0**numpy.mat([1,2,3])
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: unsupported operand type(s) for ** or pow(): 'float' and 'matrix'
>
> Why the restriction for matrices?
>
> Same question for matrices conformable for broadcasting:
> why not produce the equivalent of the array result?
With the caveat that I don't use the matrix class: I believe it's
because M**n results in the matrix power of n. It would be confusing
if n**M did a broadcast element wise power.
--
. __
. |-\
.
. tim.hochberg@ieee.org
More information about the Numpy-discussion
mailing list