-
Notifications
You must be signed in to change notification settings - Fork 341
[Type] Introduce function to compute the determinant of any square matrix #5877
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
[Type] Introduce function to compute the determinant of any square matrix #5877
Conversation
| for (size_t j = 0; j < N; ++j) | ||
| { | ||
| if (j == p) continue; | ||
| submat(i - 1, colIndex++) = mat(i, j); |
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.
Wouldn't it be more efficient to only create a vector of col and row indices that is reduced of one element for each determinant development ? So in the end your 'submatrix' is like a view on the original matrix, instead of copying the same values multiple times ?
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.
I did not try to reach high performances because I don't have the need. Currently, I use it only in init().
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.
would your changes be easily introduced @bakpaul ?
if yes, we can add it inside this PR
else, it could be done in a later one
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.
Yes I think so, I just need to take time to do it. Give me one week ?
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.
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.
See alxbilger#9
6ad8416 to
2a4b912
Compare
* Add a version without copy of the matrix content, also works with sparse matrix * Remove unwanted header
|
@bakpaul I finally changed the algorithm for a Gaussian elimination. Neither your code or mine worked on a 12x12 matrix. It hanged infinitely. I also implemented benchmarks for this function: alxbilger/SofaBenchmark#44. Here is a possible result: For small matrices, even 3x3 we are way slower than Eigen. |
|
Well it makes sense, thinking about it now, it was in n! complexity |

By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).
Reviewers will merge this pull-request only if