dimforge / dimforge/nalgebra

try_inverse and ownership

Open
#1,564 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
4.8k
Forks
565
PR merge metrics
No merged PRs in 30d

Description

Hi, I noticed in the [docs for `try_inverse_mut`](https://docs.rs/nalgebra/latest/nalgebra/base/struct.Matrix.html#method.try_inverse_mut):

> If you need to preserve the original matrix regardless of success or failure, consider using [Self::try_inverse](https://docs.rs/nalgebra/latest/nalgebra/base/struct.Matrix.html#method.try_inverse) instead.

But `try_inverse` takes `self`, not `&self`, and consumes the matrix. So, two points:

1. Should the docs be reworded? To me, the implication that `try_inverse` preserves the original matrix seems to be false. Or is something else meant by "preserved"?
2. Is there a possible performance optimization here, to make`try_inverse` not take ownership of the matrix, and thus allow the end-user to avoid `.clone()`? We still have to allocate memory for the LU decomposition, but we can at least save CPU cycles copying all the values, right?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.