diff options
Diffstat (limited to 'eigen/doc/snippets/SparseMatrix_coeffs.cpp')
-rw-r--r-- | eigen/doc/snippets/SparseMatrix_coeffs.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/eigen/doc/snippets/SparseMatrix_coeffs.cpp b/eigen/doc/snippets/SparseMatrix_coeffs.cpp new file mode 100644 index 0000000..f71a69b --- /dev/null +++ b/eigen/doc/snippets/SparseMatrix_coeffs.cpp @@ -0,0 +1,9 @@ +SparseMatrix<double> A(3,3); +A.insert(1,2) = 0; +A.insert(0,1) = 1; +A.insert(2,0) = 2; +A.makeCompressed(); +cout << "The matrix A is:" << endl << MatrixXd(A) << endl; +cout << "it has " << A.nonZeros() << " stored non zero coefficients that are: " << A.coeffs().transpose() << endl; +A.coeffs() += 10; +cout << "After adding 10 to every stored non zero coefficient, the matrix A is:" << endl << MatrixXd(A) << endl; |