Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • eigen eigen
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 653
    • Issues 653
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Custom issue tracker
    • Custom issue tracker
  • Merge requests 17
    • Merge requests 17
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • libeigen
  • eigeneigen
  • Issues
  • #1815
Closed
Open
Created Feb 03, 2020 by Christopher Moore@crmooreContributor

IndexedView of a vector should allow linear access

At least I think that's what the compiler error means. Can be worked-around by an extra call to reshaped.

/opt/compiler-explorer/libs/eigen/vtrunk/Eigen/src/Core/DenseCoeffsBase.h:142:7: error: static assertion failed: THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS

  142 |       EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags & LinearAccessBit,

      |       ^~~~~~~~~~~~~~~~~~~
#include <iostream>
#include <Eigen/Dense>
int main(){

    auto a = Eigen::VectorXi(10);
    auto b = Eigen::VectorXi(5);
    auto c = Eigen::VectorXi(3);

    a << 10,11,12,13,14,15,16,17,18,19;
    b << 0, 1, 2, 3, 4;
    c << 3, 2, 2;

    std::cout << a << std::endl;
    std::cout << b << std::endl;
    std::cout << c << std::endl;

    std::cout << a(b(c)) << std::endl; // does not work: b(c) does not allow linear access

    std::cout << a(b(c).reshaped()) << std::endl; // works

}

https://gcc.godbolt.org/z/7vHSuZ

Assignee
Assign to
Time tracking