The following expression used to compile with 3.2, but fails to compile with the dev branch (I am synced at commit 6203649a0399): rotation_matrix_ = (encoder_matrix_ * decoder_matrix_).sparseView(kReference, kEpsilon); encoded and decoder matrices are fixed-size dense matrices. I get the following error message: In file included from XXX.cc:1: In file included from YYY.h:7: In file included from ZZZ/Eigen/SparseCore:42: ZZZ/Eigen/src/SparseCore/SparseMatrix.h:1075:36: error: no type named 'InnerIterator' in 'Eigen::internal::evaluator<Eigen::SparseView<Eigen::Product<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, -1, 0, -1, -1>, 0> > >' for (typename OtherCopyEval::InnerIterator it(otherCopyEval, j); it; ++it) ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ XXX.cc:53:20: note: in instantiation of function template specialization 'Eigen::SparseMatrix<float, 0, int>::operator=<Eigen::SparseView<Eigen::Product<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, -1, 0, -1, -1>, 0> > >' requested here rotation_matrix_ = (encoder_matrix_ * decoder_matrix_).sparseView(kReference, kEpsilon); ^ In file included from XXX.cc:1: In file included from YYY.h:7: In file included from ZZZ/Eigen/SparseCore:42: ZZZ/Eigen/src/SparseCore/SparseMatrix.h:1094:36: error: no type named 'InnerIterator' in 'Eigen::internal::evaluator<Eigen::SparseView<Eigen::Product<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, -1, 0, -1, -1>, 0> > >' for (typename OtherCopyEval::InnerIterator it(otherCopyEval, j); it; ++it) ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ In file included from XXX.cc:1: In file included from YYY.h:7: In file included from ZZZ/Eigen/SparseCore:57: ZZZ/Eigen/src/SparseCore/SparseProduct.h:145:12: error: static_cast from 'Eigen::internal::evaluator<Eigen::SparseView<Eigen::Product<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, -1, 0, -1, -1>, 0> > > *' to 'Base *' (aka 'evaluator<SparseMatrix<float, Flags & RowMajorBit ? RowMajor : ColMajor, long> > *'), which are not related by inheritance, is not allowed ::new (static_cast<Base*>(this)) Base(m_result); ^~~~~~~~~~~~~~~~~~~~~~~~ ZZZ/Eigen/src/SparseCore/SparseMatrix.h:1067:19: note: in instantiation of member function 'Eigen::internal::evaluator<Eigen::SparseView<Eigen::Product<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, -1, 0, -1, -1>, 0> > >::evaluator' requested here OtherCopyEval otherCopyEval(otherCopy); ^ XXX.cc:53:20: note: in instantiation of function template specialization 'Eigen::SparseMatrix<float, 0, int>::operator=<Eigen::SparseView<Eigen::Product<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, -1, 0, -1, -1>, 0> > >' requested here rotation_matrix_ = (encoder_matrix_ * decoder_matrix_).sparseView(kReference, kEpsilon); ^
BTW: Changing the code to Eigen::Matrix<MyScalarType, Eigen::Dynamic, Eigen::Dynamic> tmp = (encoder_matrix_ * decoder_matrix_); rotation_matrix_ = tmp.sparseView(kReference, kEpsilon); is a functioning workaround, but it seems like an unnecessary regression.
This also fails for dynamic matrix-products. An easier workaround is to write: res = (A*B).eval().sparseView(); The regression is not entirely unmotivated, since it is generally not good to access products coefficient-wise. However, A.lazyProduct(B) should be accessible coefficient-wise (and thus have an inner iterator), and we should certainly let sparseView() evaluate its argument when necessary (even though this is actually not good, if the matrix is big).
I agree that this is to be discouraged in the documentation, but breaking legacy code is not good.
It also fails with lazyProduct. I had a hard time finding the origin of the problem. It actually comes from the following specialization: struct evaluator<SparseView<Product<Lhs, Rhs, Options> > > which is supposed to handle (sparse*sparse).prune()... Of course, it should be enabled for sparse products only. I'll fix it.
Fixed: https://bitbucket.org/eigen/eigen/commits/376c43a09a7c
Thanks!
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com'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: https://gitlab.com/libeigen/eigen/issues/1224.