Skip to content

Commit

Permalink
Merge pull request #11 from kingjr/fix_eigen_convergence
Browse files Browse the repository at this point in the history
scipy for eigh
  • Loading branch information
alexandrebarachant committed Jun 19, 2015
2 parents 79fa31d + cc32da2 commit ebe9900
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pyriemann/utils/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy
import scipy

###############################################################
# Basic Functions
Expand All @@ -18,7 +19,7 @@ def sqrtm(Ci):
:returns: the matrix square root
"""
D, V = numpy.linalg.eigh(Ci)
D, V = scipy.linalg.eigh(Ci)
D = numpy.matrix(numpy.diag(numpy.sqrt(D)))
V = numpy.matrix(V)
Out = numpy.matrix(V * D * V.T)
Expand All @@ -38,7 +39,7 @@ def logm(Ci):
:returns: the matrix logarithm
"""
D, V = numpy.linalg.eigh(Ci)
D, V = scipy.linalg.eigh(Ci)
Out = numpy.dot(numpy.multiply(V, numpy.log(D)), V.T)
return Out

Expand All @@ -56,7 +57,7 @@ def expm(Ci):
:returns: the matrix exponential
"""
D, V = numpy.linalg.eigh(Ci)
D, V = scipy.linalg.eigh(Ci)
D = numpy.matrix(numpy.diag(numpy.exp(D)))
V = numpy.matrix(V)
Out = numpy.matrix(V * D * V.T)
Expand All @@ -76,7 +77,7 @@ def invsqrtm(Ci):
:returns: the inverse matrix square root
"""
D, V = numpy.linalg.eigh(Ci)
D, V = scipy.linalg.eigh(Ci)
D = numpy.matrix(numpy.diag(1.0 / numpy.sqrt(D)))
V = numpy.matrix(V)
Out = numpy.matrix(V * D * V.T)
Expand All @@ -97,7 +98,7 @@ def powm(Ci, alpha):
:returns: the matrix power
"""
D, V = numpy.linalg.eigh(Ci)
D, V = scipy.linalg.eigh(Ci)
D = numpy.matrix(numpy.diag(D**alpha))
V = numpy.matrix(V)
Out = numpy.matrix(V * D * V.T)
Expand Down

0 comments on commit ebe9900

Please sign in to comment.