Skip to content
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

Bug: arena_matrix traits aren't specialized properly for sparse matrices #3135

Open
dpsimpson opened this issue Dec 26, 2024 · 3 comments
Open

Comments

@dpsimpson
Copy link
Contributor

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.

@SteveBronder
Copy link
Collaborator

Yes that's a bug 🪲 I'll add that to arena_matrix.hpp

@SteveBronder
Copy link
Collaborator

@dpsimpson
Copy link
Contributor Author

Cool! Finally thought to pick up the sparse matrix stuff again today and couldn’t remember why I’d stopped last time. Sadly it’s just a bit too deep in the “how eigen actually works” mines for me to fix it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants