Skip to content

Commit

Permalink
use np.linalg.eigh instead of np.linalg.eig when hermitian matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
philopon committed Apr 26, 2018
1 parent a485cb8 commit 76f6099
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mordred/BaryszMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class BaryszMatrixBase(Descriptor):
class Barysz(BaryszMatrixBase):
__slots__ = ("_prop",)

hermitian = True

def parameters(self):
return (self._prop,)

Expand Down
2 changes: 2 additions & 0 deletions mordred/DetourMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ class DetourMatrixBase(Descriptor):
class DetourMatrixCache(DetourMatrixBase):
__slots__ = ()

hermitian = True

def parameters(self):
return ()

Expand Down
4 changes: 4 additions & 0 deletions mordred/_graph_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
class DistanceMatrix(Descriptor):
__slots__ = ("explicit_hydrogens", "useBO", "useAtomWts")

hermitian = True

def parameters(self):
return self.explicit_hydrogens, self.useBO, self.useAtomWts

Expand Down Expand Up @@ -63,6 +65,8 @@ def calculate(self, D):
class AdjacencyMatrix(Descriptor):
__slots__ = ("explicit_hydrogens", "useBO", "order")

hermitian = True

def parameters(self):
return self.explicit_hydrogens, self.useBO, self.order

Expand Down
2 changes: 1 addition & 1 deletion mordred/_matrix_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def calculate(self, matrix):
if matrix is None:
raise ValueError("matrix is None")

w, v = np.linalg.eig(matrix)
w, v = (np.linalg.eigh if self.matrix.hermitian else np.linalg.eig)(matrix)

if np.iscomplexobj(w):
w = w.real
Expand Down

0 comments on commit 76f6099

Please sign in to comment.