New user self-registration is currently disabled. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Bug 1379 - Member function nonZerosEstimate() undefined for certain sparse matrix expressions
Member function nonZerosEstimate() undefined for certain sparse matrix expres...
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Sparse
3.3 (current stable)
All All
: Normal Compilation Problem
Assigned To: Nobody
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-01-21 02:58 UTC by Yixuan Qiu
Modified: 2017-01-22 00:16 UTC (History)
2 users (show)



Attachments

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 https://bitbucket.org/eigen/eigen/src/0f635ff77c5800471a308879efdf1f4312b1ff63/Eigen/src/SparseCore/SparseDenseProduct.h?at=default&fileviewer=file-view-default#SparseDenseProduct.h-49.

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

Thank you.


Best,
Yixuan
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:

Devel: https://bitbucket.org/eigen/eigen/commits/8b1a2b5b0ec9/
3.2:   https://bitbucket.org/eigen/eigen/commits/aeba495019d1/
Comment 4 Yixuan Qiu 2017-01-22 00:16:23 UTC
Great. Thank you Gael!

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