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
  • #1001
Closed
Open
Created Dec 04, 2019 by Eigen Bugzilla@eigenbzReporter

infer dimensions of Dynamic-sized temporaries from the entire expression (if possible)

Submitted by Emily

Assigned to Nobody

Link to original bugzilla bug (#1001)
Version: 3.4 (development)

Description

I'm calculating "scalar = vector1.transpose() * matrix * vector2". This is the inner most time critical portion of my code, the expression is evaluated using a temporary matrix on the heap. Vectors 1 & 2 are compile-time fixed size, and the matrix is a block to a dynamically allocated matrix. There should be no need to allocate a temporary on the heap in this case. The heap allocation attributes to over 50% of my total runtime.

I would very much like if this could be optimized to not cause a temporary on the heap.

The following code illustrates my use case:

Eigen::internal::set_is_malloc_allowed(true);  
Eigen::ArrayXXd data(1000, 1000);  
data.setRandom();  

Eigen::internal::set_is_malloc_allowed(false);  

Eigen::Ref<const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic>> m_coeff(data.block(30,30,4, 4));  

double x0 = 0.5;  
double x1 = 0.5;  

Eigen::Vector4d X0;  
X0[0] = x0*(4 - 3 * x0) - 1;  
X0[1] = x0*(9 * x0 - 10);  
X0[2] = x0*(8 - 9 * x0) + 1;  
X0[3] = x0*(3 * x0 - 2);  

Eigen::Vector4d X1;  
X1[0] = x1*((2 - x1)*x1 - 1);  
X1[1] = x1*x1*(3 * x1 - 5) + 2;  
X1[2] = x1*((4 - 3 * x1)*x1 + 1);  
X1[3] = x1*x1*(x1 - 1);  

// Will trigger assert as transpose() is evaluated to a temporary on the heap.  
double ans = double(X0.transpose() * (m_coeff.matrix() * X1)) / 4.0;  

Depends on

#99 (closed)

Blocking

#814 (closed)

Edited Dec 05, 2019 by Eigen Bugzilla
Assignee
Assign to
Time tracking