[SciPy-User] raising a matrix to float power
Robert Kern
robert.kern@gmail....
Sat Jul 10 21:55:24 CDT 2010
On Sat, Jul 10, 2010 at 18:47, Anne Archibald
<aarchiba@physics.mcgill.ca> wrote:
> On 10 July 2010 19:26, Alexey Brazhe <brazhe@gmail.com> wrote:
>> Hi,
>> I failed to find a way to raise a matrix to a non-integer power in
>> numpy/scipy
>>
>> In Octave/Matlab, one would write M^0.5 to get the result
>> whereas in numpy
>>>>> maxtrix(M, 0.5)
>> raises the "TypeError: exponent must be an integer"
>>
>> Is there a way to do matrix exponentiation to non-integer powers in numpy or
>> scipy?
>>
>> Hope the answer is positive :)
>
> There are several, but you need to think carefully about what you're
> actually trying to do, and what matrices you're going to try to do it
> with. If you want the "matrix square root", that's obtained using the
> cholesky decomposition but only makes sense for positive definite
> matrices. If you want more general powers, scipy.linalg provides
> "expm", "expm2", and "expm3", which all calculate notionally the same
> thing (what you get by plugging a matrix into the Taylor series for
> exp) in different ways;
Actually, that will help you calculate scalar**matrix, not
matrix**scalar, which is what was being requested here.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the SciPy-User
mailing list