# [SciPy-User] raising a matrix to float power

Alexey Brazhe brazhe@gmail....
Sun Jul 11 02:24:22 CDT 2010

```Did I get it right that W(W^TW)^(-1/2)
reduces to UV, where U,V come from svd of W?

As for the application: I'm trying to translate a piece of Matlab code to
numpy+scipy+matplotlib that does simple independent component analysis
on stacks of images. The code:
http://www.mathworks.nl/matlabcentral/fx_files/25405/2/content/CellSort%201.1/doc/CellsortICA.htmland
the line
with ^(1/2) is number 137.

On Sun, Jul 11, 2010 at 4:35 AM, Charles R Harris <charlesr.harris@gmail.com
> wrote:

>
>
> On Sat, Jul 10, 2010 at 6:15 PM, Charles R Harris <
> charlesr.harris@gmail.com> wrote:
>
>>
>>
>> On Sat, Jul 10, 2010 at 5:57 PM, Alexey Brazhe <brazhe@gmail.com> wrote:
>>
>>> >Sure, M**0.5 is cho_factor(M). For other non-integers I am not sure what
>>>
>>> >matrix exponentiation could possibly mean.
>>>
>>> >Are you sure you don't mean array exponentiation?
>>>
>>> Indeed, I needed to raise a matrix (not array) to power 1/2 (in fact,
>>> -1/2).
>>> More precisely, I need to compute W(W^TW)^(-1/2).
>>> cho_factor fails with "matrix not positive definite", and I don't know
>>> how to avoid that
>>>
>>
>> Well, the question remains as to the precise meaning of the square root
>> (what is the application?), but my guess is that if you use eigh to
>> decompose  (W^TW) into u*d*u^T then form u*(d^{-1/2}*u^T you will get what
>> you need. Maybe ;) Zero elements of d, if any, will be a problem.
>>
>> You can also use the svd if the previous interpretation is correct, since
>> if W = u*d*v the whole expression above reduces to u*d^(.5)*v.
>>
>>
> Oops, it is even simpler than that, it reduces to u*v.
>
> Chuck
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100711/ddd369ed/attachment.html
```