[Numpy-discussion] exponentiation q.
Keith Goodman
kwgoodman at gmail.com
Fri Jul 25 16:32:47 EDT 2008
On Fri, Jul 25, 2008 at 1:24 PM, Gideon Simpson <grs2103 at columbia.edu> wrote:
> How does python (or numpy/scipy) do exponentiation? If I do x**p,
> where p is some positive integer, will it compute x*x*...*x (p times),
> or will it use logarithms?
Here are some examples:
>> np.array([[1,2], [3,4]])**2
array([[ 1, 4],
[ 9, 16]])
>> np.matrix([[1,2], [3,4]])**2
matrix([[ 7, 10],
[15, 22]])
>> np.power(np.matrix([[1,2], [3,4]]), 2)
matrix([[ 1, 4],
[ 9, 16]])
More information about the NumPy-Discussion
mailing list