1*bf2c3715SXin Li SparseMatrix<double> A(3,3); 2*bf2c3715SXin Li A.insert(1,2) = 0; 3*bf2c3715SXin Li A.insert(0,1) = 1; 4*bf2c3715SXin Li A.insert(2,0) = 2; 5*bf2c3715SXin Li A.makeCompressed(); 6*bf2c3715SXin Li cout << "The matrix A is:" << endl << MatrixXd(A) << endl; 7*bf2c3715SXin Li cout << "it has " << A.nonZeros() << " stored non zero coefficients that are: " << A.coeffs().transpose() << endl; 8*bf2c3715SXin Li A.coeffs() += 10; 9*bf2c3715SXin Li cout << "After adding 10 to every stored non zero coefficient, the matrix A is:" << endl << MatrixXd(A) << endl; 10