Error Eigen: THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS
Aug 19, 2022 at 4:09am UTC
I have an iterative solver that works fine in a main script and when I move it to a function things run fine until it hits a specific line where I get the error:
error: static assertion failed: THIS_COEFFICIENT_ACCESSOR_TAKING_ONE_ACCESS_IS_ONLY_FOR_EXPRESSIONS_ALLOWING_LINEAR_ACCESS
142 | EIGEN_STATIC_ASSERT(internal::evaluator<Derived>::Flags & LinearAccessBit,
| ~~~~~~^~~~~~~~~~~~~~~~~
/mnt/c/Users/lujain/Documents/eigen-3.4.0/eigen-3.4.0/Eigen/src/Core/util/StaticAssert.h:33:54: note: in definition of macro ‘EIGEN_STATIC_ASSERT’
33 | #define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);
Which I have never seen this error before and not sure what it means.
1 2 3 4 5 6
//initializations
do {
//some calculations
for (int l = 0; l < kx.size(); l++){
L = div_x_act_on_grad_x * std::pow(ninvksqu(l),2.0) + div_y_act_on_grad_y; //ERROR
}
where here L, div_x_act_on_grad_x, div_y_act_on_grad_y, and ninvksqu are all Eigen matrices and defined as:
1 2 3 4 5 6
Eigen::Matrix< double , (ny+1), (ny+1)> L;
Eigen::SparseMatrix<double > div_x_act_on_grad_x((ny+1),(ny+1));
div_x_act_on_grad_x.setIdentity();
Eigen::Matrix< double , (ny+1), (ny+1)> div_y_act_on_grad_y;
Matrix <double , 1, nx> eninvksqu;
ninvksqu is an input to the function and that makes me think it could be throwing off the error somehow.
The code:
https://godbolt.org/z/1z5TE3TKP
Aug 19, 2022 at 4:31am UTC
I would guess it's because the type of L and the type of div_x_act_on_grad_x are incompatible. Maybe L a sparse matrix as well?
Aug 19, 2022 at 4:47am UTC
@helios
hmm, but the thing this code runs fine. This error happens when I move a portion to a function and try to test it. Kinda strange to me.
Aug 19, 2022 at 5:22am UTC
@helios
I would guess it's because the type of L and the type of div_x_act_on_grad_x are incompatible. Maybe L a sparse matrix as well?
Wait, actually, I think you accidentally fixed my issue. It's not the sparse matrix, but the
eninvksqu
was being passed as a matrix and not a vector so it should be passed as
Eigen::VectorXd
Topic archived. No new replies allowed.