Skip to content

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

@dpsimpson

Description

@dpsimpson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions