Skip to content

Commit

Permalink
Update indexing eigenvectors
Browse files Browse the repository at this point in the history
  • Loading branch information
moble authored Mar 12, 2024
1 parent 9a295d2 commit 01f23d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions quaternionic/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,15 @@ def from_rotation_matrix(cls, rot, nonorthogonal=True):
if not shape:
q = np.empty((4,), dtype=rot.dtype)
eigvals, eigvecs = linalg.eigh(K3.T, subset_by_index=(3, 3))
q[0] = eigvecs[-1]
q[0] = eigvecs[-1, 0]
q[1:] = -eigvecs[:-1].flatten()
return cls(q)
else:
q = np.empty(shape+(4,), dtype=rot.dtype)
for flat_index in range(reduce(mul, shape)):
multi_index = np.unravel_index(flat_index, shape)
eigvals, eigvecs = linalg.eigh(K3[multi_index], subset_by_index=(3, 3))
q[multi_index+(0,)] = eigvecs[-1]
q[multi_index+(0,)] = eigvecs[-1, 0]
q[multi_index+(slice(1,None),)] = -eigvecs[:-1].flatten()
return cls(q)

Expand Down

0 comments on commit 01f23d6

Please sign in to comment.