I am using bazel to build some code. The code gives compilation error while doing dome matrix assignments.
typedef Eigen::Matrix<double,44,44> stateMat_t;
typedef Eigen::Matrix<double,44,44> stateTens_t[44]; //44 x 44 x 44
// bunch of other code...
typedef std::vector<stateMat_t> stateTensTab_t;
// bunch of other code...
stateTensTab_t fxxList;
stateTens_t fxx;
// bunch of other code
fxxList[j][k] = fxx[j];
//bunch of other code
I expect the code to compile successfully, but it gives the following error:
error: cannot convert 'Eigen::Matrix<double, 44, 44>' to 'Eigen::DenseCoeffsBase<Eigen::Matrix<double, 44, 44>, 1>::Scalar {aka double}' in assignment
fxxList[j][k] = fxx[j];
You are trying to assign a Matrix<double,44,44>
to a double&
, since that is what Matrix::operator[]
returns (the operator where you pass k
). Calling that operator alone should also fail, since stateMat_t
is not a vector at compile time.