I am trying to asign a block of a sparse matrix and canot get it to work. It seems a function used by eigen is deprecated and I could fix it with some definitions. However, I am usure whether or not I SHOULD add these definitions to a project or wait for a newer version of Eigen. Could you guys advice on the side-effects of the definitions.
The program I wrote looks like this
#include <Eigen/Sparse>
int main()
{
Eigen::SparseMatrix<double> m(4, 4);
m.block(0, 0, 2, 2) << 1, 2, 3, 4;
}
and this is the warning:
1>d:\eigen_3.3.4\eigen\src\core\functors\stlfunctors.h(87): error C4996: 'std::unary_negate<_Fn>': warning STL4008: std::not1(), std::not2(), std::unary_negate, and std::binary_negate are deprecated in C++17. They are superseded by std::not_fn(). You can define _SILENCE_CXX17_NEGATORS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning. 1>d:\eigen_3.3.4\eigen\src\core\functors\stlfunctors.h(91): error C4996: 'std::binary_negate<_Fn>': warning STL4008: std::not1(), std::not2(), std::unary_negate, and std::binary_negate are deprecated in C++17. They are superseded by std::not_fn(). You can define _SILENCE_CXX17_NEGATORS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning. 1>d:\sandbox\sandbox.cpp(25): error C2678: binary '<<': no operator found which takes a left-hand operand of type 'Eigen::Block' (or there is no acceptable conversion) 1> with 1> [ 1> Derived=Eigen::SparseMatrix 1>
Thanks in advance!
There are two very different issues here. Firstly, you should either compile in C++14 mode or define _SILENCE_CXX17_NEGATORS_DEPRECATION_WARNING
as told.
Secondly, the line m.block(0, 0, 2, 2) << 1, 2, 3, 4;
is not valid for a SparseMatrix
. I don't know what you want to achieve, but unless you really known what you are doing (i.e., what your code will imply in terms of memory reallocation and re-copies), you should stick with assembling a SparseMatrix
through a triplet list as recommended by the doc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With