Bug: `arena_matrix` traits aren't specialized properly for sparse matrices
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 839
- Forks
- 220
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 14
Description
Description
This is one of those things where I can't tell if it's a bug or a user error, but I'm trying to use an arena_matrix<Eigen::SparseMatrix<double>> type and I'm getting an error related to the setting of the internal Eigen traits. In particular, I'm getting
/home/dan-simpson/Documents/math/stan/math/rev/core/arena_matrix.hpp:490:38: error: ‘PlainObjectTypeInnerSize’ is not a member of ‘Eigen::internal::traits<stan::math::arena_matrix<Eigen::SparseMatrix<double> > >::base’ {aka ‘Eigen::internal::traits<Eigen::Map<Eigen::SparseMatrix<double>, 0, Eigen::Stride<0, 0> > >’}
490 | PlainObjectTypeInnerSize = base::PlainObjectTypeInnerSize,
| ^~~~~~~~~~~~~~~~~~~~~~~~
/home/dan-simpson/Documents/math/stan/math/rev/core/arena_matrix.hpp:491:38: error: ‘InnerStrideAtCompileTime’ is not a member of ‘Eigen::internal::traits<stan::math::arena_matrix<Eigen::SparseMatrix<double> > >::base’ {aka ‘Eigen::internal::traits<Eigen::Map<Eigen::SparseMatrix<double>, 0, Eigen::Stride<0, 0> > >’}
491 | InnerStrideAtCompileTime = base::InnerStrideAtCompileTime,
| ^~~~~~~~~~~~~~~~~~~~~~~~
/home/dan-simpson/Documents/math/stan/math/rev/core/arena_matrix.hpp:492:38: error: ‘OuterStrideAtCompileTime’ is not a member of ‘Eigen::internal::traits<stan::math::arena_matrix<Eigen::SparseMatrix<double> > >::base’ {aka ‘Eigen::internal::traits<Eigen::Map<Eigen::SparseMatrix<double>, 0, Eigen::Stride<0, 0> > >’}
492 | OuterStrideAtCompileTime = base::OuterStrideAtCompileTime,
| ^~~~~~~~~~~~~~~~~~~~~~~~
/home/dan-simpson/Documents/math/stan/math/rev/core/arena_matrix.hpp:493:23: error: ‘Alignment’ is not a member of ‘Eigen::internal::traits<stan::math::arena_matrix<Eigen::SparseMatrix<double> > >::base’ {aka ‘Eigen::internal::traits<Eigen::Map<Eigen::SparseMatrix<double>, 0, Eigen::Stride<0, 0> > >’}
493 | Alignment = base::Alignment,
I strongly suspect this is because the traits defined in SpraseCore/SparseMap.h don't line up with those in Core/Map.h, so the template defining them for arena_matrix needs to be specialized.
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 in stan/math/rev/core/arena_matrix.hpp around the arena_matrix traits definition at line 483, then compare the trait definitions in lib/eigen_3.4.0/Eigen/src/SparseCore/SparseMap.h and Core/Map.h. Reproduce the reported arena_matrix<Eigen::SparseMatrix> compilation error and determine which sparse traits are missing or incompatible. Done means the sparse arena_matrix type compiles without the reported trait errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100