Below is my code, matrix is a filled 2 x 2 sparse matrix:

int size = 2

std::vector<Eigen::VectorXd> eachRow(size);

for(unsigned int i = 0 ; i < size ; ++i)

{

Eigen::VectorXd Row(2);

Row = matrix.emplace_back(Row);

}

But when i called mosek function to put linear terms to the optimizer i got the assertion error

int row_index = 0;

for(int j=0 ; j < size ; ++j)

r = MSK_putcj(task, j, eachRow[row_index][j]); // MSK_putcj(task, int, double)

Error message:

Eigen::DenseCoeffsBase::Scalar&

Eigen::DenseCoeffsBase::operator()(Eigen::Index) [with

Derived = Eigen::Matrix;

Eigen::DenseCoeffsBase::Scalar = double; Eigen::Index =

long int]: Assertion `index >= 0 && index < size()' failed.