
July 25, 2008
1:33 p.m.
On Fri, Jul 25, 2008 at 1:32 PM, Keith Goodman <kwgoodman@gmail.com> wrote:
On Fri, Jul 25, 2008 at 1:24 PM, Gideon Simpson <grs2103@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]])
Sorry. I see now you're worried about under/overflow.