Skip to content

Conversation

benkay86
Copy link
Contributor

The trace of a matrix can only be computed for square matrices. The implementation of ndarray_linalg::trace::Trace::trace() calls ndarray_linalg::layout::AllocatedArray::square_layout() to verify the matrix is square, but this call also requires the matrix layout to be contiguous. Calling trace on an array view or slice that is not laid out contiguously in memory will generate an ndarray_linalg::error::LinalgError::InvalidStride.

This commit uses ndarray::ArrayBase::is_square() to check that the matrix is square independent of layout.

@codecov
Copy link

codecov bot commented Feb 13, 2021

Codecov Report

Merging #263 (256e5f7) into master (1e4ee3e) will decrease coverage by 0.07%.
The diff coverage is 40.00%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #263 +/- ## ========================================== - Coverage 89.10% 89.02% -0.08%  ========================================== Files 71 71 Lines 3578 3582 +4 ========================================== + Hits 3188 3189 +1  - Misses 390 393 +3 
Impacted Files Coverage Δ
ndarray-linalg/src/trace.rs 57.14% <40.00%> (-42.86%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e4ee3e...256e5f7. Read the comment docs.

@termoshtt termoshtt merged commit cd0189b into rust-ndarray:master Feb 20, 2021
@termoshtt
Copy link
Member

It makes sense. Thanks!

termoshtt added a commit that referenced this pull request Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants