Skip to content

Commit 68cdfaf

Browse files
authored
Merge pull request #24777 from lucascolley/array-api-cholesky-fix
BUG: `numpy.array_api`: fix `linalg.cholesky` upper decomp for complex dtypes Original NumPy Commit: 98c39aeedf816c0d3faf6f4460efb1863c6ce695
2 parents 136bdd7 + 20c70f1 commit 68cdfaf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

array_api_strict/linalg.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
complex128
1010
)
1111
from ._manipulation_functions import reshape
12+
from ._elementwise_functions import conj
1213
from ._array_object import Array
1314

1415
from numpy._core.numeric import normalize_axis_tuple
@@ -53,7 +54,10 @@ def cholesky(x: Array, /, *, upper: bool = False) -> Array:
5354
raise TypeError('Only floating-point dtypes are allowed in cholesky')
5455
L = np.linalg.cholesky(x._array)
5556
if upper:
56-
return Array._new(L).mT
57+
U = Array._new(L).mT
58+
if U.dtype in [complex64, complex128]:
59+
U = conj(U)
60+
return U
5761
return Array._new(L)
5862

5963
# Note: cross is the numpy top-level namespace, not np.linalg

0 commit comments

Comments
 (0)