-
Notifications
You must be signed in to change notification settings - Fork 23
Implement dpnp.linalg.lu_factor
2D inputs
#2557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7128c6b
8d491a0
0d4a33a
86381ca
6e3ad57
63138e9
8a17f67
6fe2fe4
e781beb
506d24d
a3d31c8
08f5ca3
c2f2971
74f6c63
25f7ab3
3276f92
4cf630d
2f21467
66c0803
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ | |
dpnp_eigh, | ||
dpnp_inv, | ||
dpnp_lstsq, | ||
dpnp_lu_factor, | ||
dpnp_matrix_power, | ||
dpnp_matrix_rank, | ||
dpnp_multi_dot, | ||
|
@@ -79,6 +80,7 @@ | |
"eigvalsh", | ||
"inv", | ||
"lstsq", | ||
"lu_factor", | ||
"matmul", | ||
"matrix_norm", | ||
"matrix_power", | ||
|
@@ -901,6 +903,68 @@ def lstsq(a, b, rcond=None): | |
return dpnp_lstsq(a, b, rcond=rcond) | ||
|
||
|
||
def lu_factor(a, overwrite_a=False, check_finite=True): | ||
ndgrigorian marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The documentation for the function is not rendering |
||
""" | ||
Compute the pivoted LU decomposition of a matrix. | ||
|
||
The decomposition is:: | ||
|
||
A = P @ L @ U | ||
|
||
where `P` is a permutation matrix, `L` is lower triangular with unit | ||
diagonal elements, and `U` is upper triangular. | ||
|
||
Parameters | ||
---------- | ||
a : (M, N) {dpnp.ndarray, usm_ndarray} | ||
Input array to decompose. | ||
overwrite_a : {None, bool}, optional | ||
Whether to overwrite data in `a` (may increase performance) | ||
Default: ``False``. | ||
Comment on lines
+922
to
+923
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whether to overwrite data in `a` (may increase performance).
Default: ``False``. |
||
check_finite : {None, bool}, optional | ||
Whether to check that the input matrix contains only finite numbers. | ||
Disabling may give a performance gain, but may result in problems | ||
(crashes, non-termination) if the inputs do contain infinities or NaNs. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
Returns | ||
------- | ||
lu :(M, N) dpnp.ndarray | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sems space is missing: |
||
Matrix containing U in its upper triangle, and L in its lower triangle. | ||
The unit diagonal elements of L are not stored. | ||
piv (K, ): dpnp.ndarray | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Pivot indices representing the permutation matrix P: | ||
row i of matrix was interchanged with row piv[i]. | ||
``K = min(M, N)``. | ||
|
||
Warning | ||
------- | ||
This function synchronizes in order to validate array elements | ||
when ``check_finite=True``. | ||
|
||
Limitations | ||
----------- | ||
Only two-dimensional input matrices are supported. | ||
Otherwise, the function raises ``NotImplementedError`` exception. | ||
|
||
Examples | ||
-------- | ||
>>> import dpnp as np | ||
>>> a = np.array([[4., 3.], [6., 3.]]) | ||
>>> lu, piv = np.linalg.lu_factor(a) | ||
>>> lu | ||
array([[6. , 3. ], | ||
[0.66666667, 1. ]]) | ||
>>> piv | ||
array([1, 1]) | ||
|
||
""" | ||
|
||
dpnp.check_supported_arrays_type(a) | ||
assert_stacked_2d(a) | ||
|
||
return dpnp_lu_factor(a, overwrite_a=overwrite_a, check_finite=check_finite) | ||
|
||
|
||
def matmul(x1, x2, /): | ||
""" | ||
Computes the matrix product. | ||
|
Uh oh!
There was an error while loading. Please reload this page.