We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 58d4924 commit 97f85d2Copy full SHA for 97f85d2
procrustes/generic.py
@@ -120,7 +120,15 @@ def generic(
120
weight,
121
)
122
# compute the generic solution
123
- a_inv = pinv(np.dot(new_a.T, new_a))
+ try:
124
+ a_inv = pinv(np.dot(new_a.T, new_a))
125
+ # add little bit of random noise when the matrix is ill conditioned
126
+ except np.linalg.LinAlgError:
127
+ # conver new_a to float if it is not
128
+ new_a = new_a.astype(float)
129
+ new_a += 2e-14 * np.random.random_sample((new_a.shape[0], new_a.shape[1])) - 1e-14
130
131
+ # a_inv = pinv(np.dot(new_a.T, new_a))
132
133
array_x = np.linalg.multi_dot([a_inv, new_a.T, new_b])
134
# compute one-sided error
0 commit comments