mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 16:40:38 +08:00
CompressedRowSparseMatrix::AppendRows and DeleteRows bugfix.
CompressedRowSparseMatrix can store the row and column block structure but the AppendRows and DeleteRows methods did not pay attention to them. This meant that it was possible to get to a CompressedRowSparseMatrix whose block structure did not match the contents of the matrix. This change fixes this problem. Change-Id: I1b3c807fc03d8c049ee20511e2bc62806d211b81
This commit is contained in:
@@ -112,8 +112,15 @@ LinearSolver::Summary SparseNormalCholeskySolver::SolveImplUsingCXSparse(
|
||||
if (per_solve_options.D != NULL) {
|
||||
// Temporarily append a diagonal block to the A matrix, but undo
|
||||
// it before returning the matrix to the user.
|
||||
CompressedRowSparseMatrix D(per_solve_options.D, num_cols);
|
||||
A->AppendRows(D);
|
||||
scoped_ptr<CompressedRowSparseMatrix> regularizer;
|
||||
if (A->col_blocks().size() > 0) {
|
||||
regularizer.reset(CompressedRowSparseMatrix::CreateBlockDiagonalMatrix(
|
||||
per_solve_options.D, A->col_blocks()));
|
||||
} else {
|
||||
regularizer.reset(new CompressedRowSparseMatrix(
|
||||
per_solve_options.D, num_cols));
|
||||
}
|
||||
A->AppendRows(*regularizer);
|
||||
}
|
||||
|
||||
VectorRef(x, num_cols).setZero();
|
||||
@@ -196,8 +203,15 @@ LinearSolver::Summary SparseNormalCholeskySolver::SolveImplUsingSuiteSparse(
|
||||
if (per_solve_options.D != NULL) {
|
||||
// Temporarily append a diagonal block to the A matrix, but undo
|
||||
// it before returning the matrix to the user.
|
||||
CompressedRowSparseMatrix D(per_solve_options.D, num_cols);
|
||||
A->AppendRows(D);
|
||||
scoped_ptr<CompressedRowSparseMatrix> regularizer;
|
||||
if (A->col_blocks().size() > 0) {
|
||||
regularizer.reset(CompressedRowSparseMatrix::CreateBlockDiagonalMatrix(
|
||||
per_solve_options.D, A->col_blocks()));
|
||||
} else {
|
||||
regularizer.reset(new CompressedRowSparseMatrix(
|
||||
per_solve_options.D, num_cols));
|
||||
}
|
||||
A->AppendRows(*regularizer);
|
||||
}
|
||||
|
||||
VectorRef(x, num_cols).setZero();
|
||||
|
||||
Reference in New Issue
Block a user