Clearing a row or column of a matrix (depending on the storage format) can sometimes be a useful operation in finite element/difference computations, such as in setting up Dirichlet boundary conditions. Using this method, you can build your matrix without regard for boundary conditions, and then in a second step replace the rows corresponding to known values with the identity. PETSC, for example, supports this operation with the MatZeroRows command.
(In reply to comment #0) > Clearing a row or column of a matrix (depending on the storage format) can > sometimes be a useful operation in finite element/difference computations, such > as in setting up Dirichlet boundary conditions. Using this method, you can > build your matrix without regard for boundary conditions, and then in a second > step replace the rows corresponding to known values with the identity. > > PETSC, for example, supports this operation with the MatZeroRows command. Do you mean set a row/column to zero? That is actually already possible by MatrixXd m; // ... m.row(i).setZero(); // or: m.col(j).setZero(); also available are setConstant(scalar) and setOnes(). For the problem of setting a number of (unconnected) rows to zero there was a proposal once for unconnected views of matrices (not sure whether on the list/the forum/bugzilla and to lazy to search now ...) which should do the trick. For now a simple for-loop also should work.
(In reply to comment #1) > (In reply to comment #0) > > Clearing a row or column of a matrix (depending on the storage format) can > > sometimes be a useful operation in finite element/difference computations, such > > as in setting up Dirichlet boundary conditions. Using this method, you can > > build your matrix without regard for boundary conditions, and then in a second > > step replace the rows corresponding to known values with the identity. > > > > PETSC, for example, supports this operation with the MatZeroRows command. > > Do you mean set a row/column to zero? That is actually already possible by Sorry just noticed that this is about the sparse module. So I guess this does not work and sorry for the noise ...
A workaround is to use SparseMatrix::prune(KeepFunc) with a custom predicate. But surely more efficient solutions are possible.
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/273.