如何将numpy.matrix提高为非整数幂? [英] How to raise a numpy.matrix to non-integer power?
本文介绍了如何将numpy.matrix提高为非整数幂?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
numpy.matrix
的**
运算符不支持非整数幂:
The **
operator for numpy.matrix
does not support non-integer power:
>>> m
matrix([[ 1. , 0. ],
[ 0.5, 0.5]])
>>> m ** 2.5
TypeError: exponent must be an integer
我想要的是
octave:14> [1 0; .5 .5] ^ 2.5
ans =
1.00000 0.00000
0.82322 0.17678
我可以使用numpy
或scipy
进行此操作吗?
Can I do this with numpy
or scipy
?
这不是元素操作.如这篇文章.
this is NOT an element-wise operation. It is an matrix (in linear algebra) raised to some power, as talked in this post.
推荐答案
您可以使用 查看全文