This bugzilla service is closed. All entries have been migrated to
Bug 1379 - Member function nonZerosEstimate() undefined for certain sparse matrix expressions
Summary: Member function nonZerosEstimate() undefined for certain sparse matrix expres...
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Compilation Problem
Assignee: Nobody
Depends on:
Reported: 2017-01-21 02:58 UTC by Yixuan Qiu
Modified: 2019-12-04 16:44 UTC (History)
2 users (show)


Description Yixuan Qiu 2017-01-21 02:58:48 UTC
Hi All,

I found that certain sparse matrix expressions had compilation errors for Eigen 3.3.x. A minimal example is given below:


#include <Eigen/Core>
#include <Eigen/SparseCore>

typedef Eigen::SparseMatrix<double> SpMat;
using Eigen::VectorXd;

int main()
    SpMat m(10, 10);
    VectorXd v(10);
    VectorXd res1 = (m * v.asDiagonal()) * v;            // fine
    VectorXd res2 = (m.adjoint() * v.asDiagonal()) * v;  // fails on Eigen 3.3.x, OK with Eigen 3.2.y
    return 0;


OS: Fedora 25 64-bit
Compiler: GCC 6.2

Note that to reproduce this error one needs to turn on OpenMP with more than one thread. The error message is


./Eigen/src/SparseCore/SparseDenseProduct.h:49:31: error: ‘Eigen::internal::sparse_time_dense_product_impl<Eigen::Product<Eigen::Transpose<const Eigen::SparseMatrix<double> >, Eigen::DiagonalWrapper<const Eigen::Matrix<double, -1, 1> >, 0>, Eigen::Matrix<double, -1, 1>, Eigen::Matrix<double, -1, 1>, double, 1, true>::LhsEval {aka struct Eigen::internal::evaluator<Eigen::Product<Eigen::Transpose<const Eigen::SparseMatrix<double> >, Eigen::DiagonalWrapper<const Eigen::Matrix<double, -1, 1> >, 0> >}’ has no member named ‘nonZerosEstimate’
       if(threads>1 && lhsEval.nonZerosEstimate() > 20000)


, which points to

It seems that for some reason the "adjoint" version lacks the necessary member function.

Thank you.

Comment 1 Gael Guennebaud 2017-01-21 21:08:00 UTC
Works for me using gcc 4.9, 5, 6, clang 3.4 to 3.9, Apple's clang. Using either 3.3.0, 3.3.1, 3.3.2. Please make sure you are not mixing two different versions of Eigen.
Comment 2 Yixuan Qiu 2017-01-21 21:50:36 UTC
Oh, did you compile with the -fopenmp flag? At least Clang<3.8 has no OpenMP support, right?
Comment 3 Gael Guennebaud 2017-01-21 22:28:11 UTC
I missed this details. Fixed:

Comment 4 Yixuan Qiu 2017-01-22 00:16:23 UTC
Great. Thank you Gael!
Comment 5 Nobody 2019-12-04 16:44:20 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

Note You need to log in before you can comment on or make changes to this bug.