Skip to content
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

ch.linalg.svd not working in stacked mode #20

Closed
thmoa opened this issue Apr 19, 2018 · 0 comments
Closed

ch.linalg.svd not working in stacked mode #20

thmoa opened this issue Apr 19, 2018 · 0 comments

Comments

@thmoa
Copy link

thmoa commented Apr 19, 2018

Moved to chumpy Issues!

From numpy doc:

If a has more than two dimensions, then broadcasting rules apply [...]. This means that SVD is working in “stacked” mode: it iterates over all indices of the first a.ndim - 2 dimensions and for each combination SVD is applied to the last two indices.

https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.svd.html

When calculating the derivatives for SVD chumpy assumes 2D arrays:

line 196 of linalg.py:

result = np.einsum('ik,jk->kij', u, v)

line 214ff of linalg.py

mxsz = max(shp[0], shp[1])
D = np.zeros(mxsz)
D[:_D.size] = _D

The only workaround I see right now is looping over the dimensions outside of SVD (slow).

@thmoa thmoa closed this as completed Apr 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant