【发布时间】:2015-03-31 08:07:05
【问题描述】:
我正在尝试在 python/numpy 中将矩阵提升到高功率。似乎对于大指数,结果不正确(某种溢出?),高于 10000。这是 numpy.linalg.matrix_power 函数的已知行为还是我遗漏了什么? 这是我尝试输出的代码:
import numpy as np
from numpy import linalg as LA
A = np.array([1L,1L,1L,0L]).reshape(2,2)
print 'A: %s'%A
print 'A^10: %s'%LA.matrix_power(A,10)
print 'A^1000: %s'%LA.matrix_power(A,1000)
print 'A^10000: %s'%LA.matrix_power(A,10000)
输出:
A:
[[1 1]
[1 0]]
A^10:
[[89 55]
[55 34]]
A^1000:
[[9079565065540428013 817770325994397771]
[817770325994397771 8261794739546030242]]
A^10000:
[[-83367563645688771 -2872092127636481573]
[-2872092127636481573 2788724563990792802]]
【问题讨论】:
标签: python numpy matrix scipy linear-algebra