-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Linear Algebra routines as generalized ufuncs #2954
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 1 commit
1613e09
be911e8
9a70cfd
b5c7733
12be5b7
fa9dbef
cac3de5
153e02e
06613da
0ab4a14
e6d08ea
a3baf1c
e53b3d3
6ad2738
1276782
ee4138d
b1c3e09
c229ba0
4b5f777
b29fa3c
56d70ff
3cde140
f26444d
839e597
4f2a508
b7d0f7b
6100e8a
fdeafbd
3bfb914
c4a2cff
23a6380
0735c95
6e0ea34
250786b
8565a63
f9372ab
d8ed21d
a5e5833
f2c81b4
c25e0b7
a4f540d
6a09b5c
e7b6a2b
05d0146
32b0617
22b163c
6e1b48c
69f6464
48c4ab4
a5a1b83
40d3746
01186ca
d7b2a58
a6c51c6
89083d4
e538255
f008fdb
fa1c5f8
3a970dc
6cf6586
b686a76
2b334c6
7ad0b50
19240e0
38c2de2
7d8396e
1fc7a3a
3e15fa8
adcad92
3fe3ea3
5efdd41
41b51bd
b6f6d85
0e23dbb
d31d830
83556f6
a344d47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
import numpy.core._umath_linalg as _impl | ||
import numpy as np | ||
|
||
|
||
def inner1d(a, b, **kwargs): | ||
""" | ||
Compute the inner product, with broadcasting | ||
|
@@ -65,6 +66,7 @@ def inner1d(a, b, **kwargs): | |
(2,) | ||
>>> print res | ||
[ 7. 43.] | ||
|
||
""" | ||
return _impl.inner1d(a, b, **kwargs) | ||
|
||
|
@@ -103,6 +105,7 @@ def innerwt(a, b, c, **kwargs): | |
(2,) | ||
>>> res | ||
array([ 3.25, 39.25]) | ||
|
||
""" | ||
return _impl.innerwt(a, b, c, **kwargs) | ||
|
||
|
@@ -146,8 +149,8 @@ def matrix_multiply(a,b,**kwargs): | |
<BLANKLINE> | ||
[[ 750., 792., 834.], | ||
[ 1030., 1088., 1146.]]]) | ||
""" | ||
|
||
""" | ||
return _impl.matrix_multiply(a,b,**kwargs) | ||
|
||
|
||
|
@@ -191,6 +194,7 @@ def det(a, **kwargs): | |
>>> a = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]] ]) | ||
>>> np.allclose(-2.0, det(a)) | ||
True | ||
|
||
""" | ||
return _impl.det(a, **kwargs) | ||
|
||
|
@@ -260,6 +264,7 @@ def slogdet(a, **kwargs): | |
(2,) | ||
>>> np.allclose(-2.0, sign * np.exp(logdet)) | ||
True | ||
|
||
""" | ||
return _impl.slogdet(a, **kwargs) | ||
|
||
|
@@ -303,6 +308,7 @@ def inv(a, **kwargs): | |
True | ||
>>> np.allclose(matrix_multiply(ainv, a), np.eye(2)) | ||
True | ||
|
||
""" | ||
return _impl.inv(a, **kwargs) | ||
|
||
|
@@ -359,6 +365,7 @@ def cholesky(a, UPLO='L', **kwargs): | |
>>> L | ||
array([[ 1.+0.j, 0.+0.j], | ||
[ 0.+2.j, 1.+0.j]]) | ||
|
||
""" | ||
if 'L' == UPLO: | ||
gufunc = _impl.cholesky_lo | ||
|
@@ -452,6 +459,7 @@ def eig(a, **kwargs): | |
""" | ||
return _impl.eig(a, **kwargs) | ||
|
||
|
||
def eigvals(a, **kwargs): | ||
""" | ||
Compute the eigenvalues of general matrices, with broadcasting. | ||
|
@@ -520,6 +528,7 @@ def eigvals(a, **kwargs): | |
""" | ||
return _impl.eigvals(a, **kwargs) | ||
|
||
|
||
def quadratic_form(u,Q,v, **kwargs): | ||
""" | ||
Compute the quadratic form uQv, with broadcasting | ||
|
@@ -566,9 +575,11 @@ def quadratic_form(u,Q,v, **kwargs): | |
|
||
>>> np.dot(u, np.dot(Q,v)) | ||
12.0 | ||
|
||
""" | ||
return _impl.quadratic_form(u, Q, v, **kwargs) | ||
|
||
|
||
def add3(a, b, c, **kwargs): | ||
""" | ||
Element-wise addition of 3 arrays: a + b + c. | ||
|
@@ -602,9 +613,11 @@ def add3(a, b, c, **kwargs): | |
Examples | ||
-------- | ||
<Some example in doctest format> | ||
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. I would recommend either filling this out or removing the section before merging the PR. 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. On Thu, Jan 31, 2013 at 5:52 PM, Robert Kern notifications@github.comwrote:
That's also why I split the two pull-request. I imagine that a new module
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. Great. I just wanted to make sure it was explicitly on the TODO list. :-) |
||
|
||
""" | ||
return _impl.add3(a, b, c, **kwargs) | ||
|
||
|
||
def multiply3(a, b, c, **kwargs): | ||
""" | ||
Element-wise multiplication of 3 arrays: a*b*c. | ||
|
@@ -638,9 +651,11 @@ def multiply3(a, b, c, **kwargs): | |
Examples | ||
-------- | ||
<Some example in doctest format> | ||
|
||
""" | ||
return _impl.multiply3(a, b, c, **kwargs) | ||
|
||
|
||
def multiply3_add(a, b, c, d, **kwargs): | ||
""" | ||
Element-wise multiplication of 3 arrays adding an element | ||
|
@@ -679,9 +694,11 @@ def multiply3_add(a, b, c, d, **kwargs): | |
Examples | ||
-------- | ||
<Some example in doctest format> | ||
|
||
""" | ||
return _impl.multiply3_add(a, b, c, d, **kwargs) | ||
|
||
|
||
def multiply_add(a, b, c, **kwargs): | ||
""" | ||
Element-wise addition of 3 arrays | ||
|
@@ -716,9 +733,11 @@ def multiply_add(a, b, c, **kwargs): | |
Examples | ||
-------- | ||
<Some example in doctest format> | ||
|
||
""" | ||
return _impl.multiply_add(a, b, c, **kwargs) | ||
|
||
|
||
def multiply_add2(a, b, c, d, **kwargs): | ||
""" | ||
Element-wise addition of 3 arrays | ||
|
@@ -753,9 +772,11 @@ def multiply_add2(a, b, c, d, **kwargs): | |
Examples | ||
-------- | ||
<Some example in doctest format> | ||
|
||
""" | ||
return _impl.multiply_add2(a, b, c, d, **kwargs) | ||
|
||
|
||
def multiply4(a, b, c, d, **kwargs): | ||
""" | ||
Element-wise addition of 3 arrays | ||
|
@@ -790,9 +811,11 @@ def multiply4(a, b, c, d, **kwargs): | |
Examples | ||
-------- | ||
<Some example in doctest format> | ||
|
||
""" | ||
return _impl.multiply4(a, b, c, d, **kwargs) | ||
|
||
|
||
def multiply4_add(a, b, c, d, e, **kwargs): | ||
""" | ||
Element-wise addition of 3 arrays | ||
|
@@ -827,9 +850,11 @@ def multiply4_add(a, b, c, d, e, **kwargs): | |
Examples | ||
-------- | ||
<Some example in doctest format> | ||
|
||
""" | ||
return _impl.multiply4_add(a, b, c, d, e,**kwargs) | ||
|
||
|
||
def eigh(A, UPLO='L', **kw_args): | ||
""" | ||
Computes the eigenvalues and eigenvectors for the square matrices | ||
|
@@ -877,6 +902,7 @@ def eigh(A, UPLO='L', **kw_args): | |
Examples | ||
-------- | ||
<Some example in doctest format> | ||
|
||
""" | ||
if 'L' == UPLO: | ||
gufunc = _impl.eigh_lo | ||
|
@@ -927,6 +953,7 @@ def eigvalsh(A, UPLO='L', **kw_args): | |
Examples | ||
-------- | ||
<Some example in doctest format> | ||
|
||
""" | ||
if ('L' == UPLO): | ||
gufunc = _impl.eigvalsh_lo | ||
|
@@ -975,6 +1002,7 @@ def solve(A,B,**kw_args): | |
Examples | ||
-------- | ||
<Some example in doctest format> | ||
|
||
""" | ||
if len(B.shape) == (len(A.shape) - 1): | ||
gufunc = _impl.solve1 | ||
|
@@ -1030,6 +1058,7 @@ def svd(a, full_matrices=1, compute_uv=1 ,**kw_args): | |
Examples | ||
-------- | ||
<Some example in doctest format> | ||
|
||
""" | ||
m = a.shape[-2] | ||
n = a.shape[-1] | ||
|
@@ -1097,6 +1126,7 @@ def chosolve(A, B, UPLO='L', **kw_args): | |
Examples | ||
-------- | ||
<Some example in doctest format> | ||
|
||
""" | ||
if len(B.shape) == (len(A.shape) - 1): | ||
if 'L' == UPLO: | ||
|
@@ -1150,36 +1180,11 @@ def poinv(A, UPLO='L', **kw_args): | |
Examples | ||
-------- | ||
<Some example in doctest format> | ||
|
||
""" | ||
if 'L' == UPLO: | ||
gufunc = _impl.poinv_lo | ||
else: | ||
gufunc = _impl.poinv_up | ||
|
||
return gufunc(A, **kw_args); | ||
|
||
|
||
""" doc template (23 lines)""" | ||
""" | ||
<Description> | ||
|
||
Parameters | ||
---------- | ||
<insert parameters + explanations> | ||
|
||
Returns | ||
------- | ||
<insert return values> | ||
|
||
Notes | ||
----- | ||
<insert any notes that may be interesting, optional> | ||
|
||
See Also | ||
-------- | ||
<reference related functions> | ||
|
||
Examples | ||
-------- | ||
<Some example in doctest format> | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8