How can I add an Eigen's SparseMatrix to an Eigen's Tensor?
The following code (which does not compile) explains what I am trying to do.
#include <iostream>
#include <Eigen/Sparse>
#include <unsupported/Eigen/CXX11/Tensor>
using Eigen::Tensor;
using Eigen::SparseMatrix;
int main()
{
Tensor<double, 2> tensor(10, 10);
for(int i=0; i < 10; i++) {
for(int j=0; j < 10; j++) {
tensor(i, j) = i * 10 + j;
}
}
SparseMatrix<double> sparse(10, 10);
auto tensor2 = tensor;
tensor2 += sparse;
std::cout << tensor2 << std::endl;
}