Commit f580145
Release Manager
gh-40493: Euclidean norm crashfix sparse matrices
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes #12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes #12345". -->
Fixes #40492.
The call to `.norm()` or `norm()` with default parameter (`p = 2` for
euclidean norm) crashes for sparse matrices.
I go around it by checking if the matrix is sparse and if so, copy it
into a dense matrix internally to compute the norm. This must be done
since the euclidean norm uses the `.SVD()` method which is not exposed
for sparse matrices.
### 📝 Checklist
<!-- Put an `x` in all the boxes that apply. -->
- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.
### ⌛ Dependencies
<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - #12345: short description why this is a dependency -->
<!-- - #34567: ... -->
URL: #40493
Reported by: grnx
Reviewer(s): grnx, user202729
1 file changed
+10
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16484 | 16484 | | |
16485 | 16485 | | |
16486 | 16486 | | |
| 16487 | + | |
| 16488 | + | |
| 16489 | + | |
| 16490 | + | |
| 16491 | + | |
16487 | 16492 | | |
16488 | 16493 | | |
16489 | 16494 | | |
| |||
16494 | 16499 | | |
16495 | 16500 | | |
16496 | 16501 | | |
16497 | | - | |
16498 | | - | |
| 16502 | + | |
| 16503 | + | |
| 16504 | + | |
| 16505 | + | |
| 16506 | + | |
16499 | 16507 | | |
16500 | 16508 | | |
16501 | 16509 | | |
| |||
0 commit comments