小编Dae*_*ung的帖子

为什么通过 Cholesky 分解对正定矩阵求逆比用 numpy 进行常规求逆要慢?

从数学上来说,通过 Cholesky 分解对正定矩阵求逆比仅使用 更快np.linalg.inv(X)。然而,当我对两者进行实验时,发现 Cholesky 分解的性能更差!

\n\n
# Inversion through Cholesky\np = X.shape[0]\nIp = np.eye(p)\n%timeit scipy.linalg.cho_solve(scipy.linalg.cho_factor(X,lower=True), Ip)\n\nThe slowest run took 17.96 times longer than the fastest. This could mean that an intermediate result is being cached.\n10000 loops, best of 3: 107 \xc2\xb5s per loop\n\n\n# Simple inversion\n%timeit np.linalg.inv(X)\n\nThe slowest run took 58.81 times longer than the fastest. This could mean that an intermediate result is being cached.\n10000 loops, best of 3: 25.9 \xc2\xb5s per loop\n
Run Code Online (Sandbox Code Playgroud)\n\n

后者花费的时间更短。为什么是这样?在 中R …

python numpy r scipy matrix-inverse

5
推荐指数
1
解决办法
2561
查看次数

标签 统计

matrix-inverse ×1

numpy ×1

python ×1

r ×1

scipy ×1