8000 ENH: eigh, eigvalsh set result to nan on LAPACK error (_ssyevd, _heevd) · numpy/numpy@f2b0bdd · GitHub
[go: up one dir, main page]

Skip to content

Commit f2b0bdd

Browse files
ovillellaspv
ovillellas
authored andcommitted
ENH: eigh, eigvalsh set result to nan on LAPACK error (_ssyevd, _heevd)
1 parent 2cc6fb4 commit f2b0bdd

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

numpy/core/src/umath/umath_linalg.c.src

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,17 +1714,27 @@ static inline void
17141714
}
17151715

17161716
for (iter = 0; iter < outer_dim; ++iter) {
1717+
int not_ok;
17171718
/* copy the matrix in */
17181719
linearize_@TYPE@_matrix(eigh_params.A, args[0], &matrix_in_ld);
1719-
call_@lapack_func@(&eigh_params);
1720-
delinearize_@BASETYPE@_matrix(args[1],
1721-
eigh_params.W,
1722-
&eigenvalues_out_ld);
1723-
1724-
if ('V' == eigh_params.JOBZ) {
1725-
delinearize_@TYPE@_matrix(args[2],
1726-
eigh_params.A,
1727-
&eigenvectors_out_ld);
1720+
not_ok = call_@lapack_func@(&eigh_params);
1721+
if (!not_ok) {
1722+
/* lapack ok, copy result out */
1723+
8000 delinearize_@BASETYPE@_matrix(args[1],
1724+
eigh_params.W,
1725+
&eigenvalues_out_ld);
1726+
1727+
if ('V' == eigh_params.JOBZ) {
1728+
delinearize_@TYPE@_matrix(args[2],
1729+
eigh_params.A,
1730+
&eigenvectors_out_ld);
1731+
}
1732+
} else {
1733+
/* lapack fail, set result to nan */
1734+
nan_@BASETYPE@_matrix(args[1], &eigenvalues_out_ld);
1735+
if ('V' == eigh_params.JOBZ) {
1736+
nan_@TYPE@_matrix(args[2], &eigenvectors_out_ld);
1737+
}
17281738
}
17291739
update_pointers((npy_uint8**)args, outer_steps, op_count);
17301740
}

0 commit comments

Comments
 (0)
0