I would like to know if there is any way to define a sparse matrix as Eigen::SparseMatrix< StructElem >, which means each element of the matrix is an struct.
I tried the following code, but I got the error of "no suitable constructor exists to convert from int to StructElem".
// the structure of element:
struct StructElem
{
unsigned int mInd;
bool mIsValid;
double mVec[ 4 ];
};
// define the matrix:
Eigen::SparseMatrix< StructElem > lA( m, n);
// work with the matrix
for( unsigned int i = 0; i < m; i++)
{
StructElem lElem;
lElem.mInd = i;
lElem.mIsValid = true;
lElem.mVec= {0.0, 0.1, 0.2, 0.4};
lA.coeffRef(i, i) = lElem; // got the error here!
}
I was wondering if you would have any sort of ideas to solve this error?