[SciPy-dev] Type handling of matrices

Nils Wagner nwagner at mecha.uni-stuttgart.de
Wed Nov 17 04:27:55 CST 2004


Pearu Peterson wrote:

>
>
> On Wed, 17 Nov 2004, Nils Wagner wrote:
>
>> Pearu Peterson wrote:
>
>
>>> Anyway, by using
>>>
>>> def gap(A)
>>>  w = linalg.eigvals(A)
>>>  mn = abs(w[0]-w[1])
>>>  for i in range(len(w))
>>>   for j in range(i):
>>>      mn = min(mn,abs(w[i]-w[j]))
>>>  return mn/2
>>>
>>> should give speedup 2x at least.
>>>
>>> Pearu
>>>
>> And how can I return the associated indices \bar{i}, \bar{j} with 
>> respect to gap(A) ?
>
>
> def gap(A):
>  w = linalg.eigvals(A)
>  l = [(abs(w[i]-w[j]),j,i) for i in range(len(w)) for j in range(i)]
>  l.sort()
>  return l[0]
>
> Pearu
>
Hi Pearu,

Is it possible to implement the gap function in scipy as a built-in 
function ?
For example, one can use this function to construct defective matrices 
from normal matrices (see attachment for details).

Nils

> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-dev



 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: alam.py
Type: text/x-python
Size: 868 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-dev/attachments/20041117/6c053ef5/attachment.py 


More information about the Scipy-dev mailing list