determinant algorithm
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 839
- Forks
- 220
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 14
Description
Description
I was benchmarking determinant and log_determinant today.
For reverse mode for each of these functions you need to evaluate the determinant, and to get the gradients you need the inverse (it's actually the inverse -- no solves to be done -- here's a link to the math).
For the current implementation of determinant(m), we use m.determinant() and m.inverse() separately in the Eigen code.
For the current implementation of log determinant(m), we do m_piv = m.fullPivHouseholderQr() first and then m_piv.determinant() and m_piv.inverse().
The second is slower than the first I think because fullPivHouseholderQr is so conservative.
partialPivotLU however is faster than both methods. The limitation in the Eigen docs is it's only stable it if the inverse exists (https://eigen.tuxfamily.org/dox/classEigen_1_1PartialPivLU.html).
Anyone see any problem with switching to partialPivotLU for both since if the inverse doesn't exist our reverse mode autodiff fails anyway?
@bgoodri
Current Version:
v3.3.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the determinant(m) and log determinant(m) implementations in the Eigen code and compare their current determinant, inverse, and fullPivHouseholderQr calls with partialPivotLU. Benchmark the alternatives and verify that reverse-mode autodiff still behaves correctly when the matrix is invertible; done means a justified, tested implementation choice for both functions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100