mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 08:34:37 +08:00
Minor fixes
Based on William Rucklidge's review, including a nasty bug in parameter block removal. Change-Id: I3a692e589f600ff560ecae9fa85bb0b76063d403
This commit is contained in:
@@ -51,13 +51,19 @@
|
||||
|
||||
namespace ceres {
|
||||
|
||||
// Trivial wrapper to index linear arrays as matrices, given a fixed column and
|
||||
// row stride. When an array "T* arr" is wrapped by a
|
||||
// "(const) MatrixAdapter<T, row_stride, col_stride> M", the expression "M(i, j)" is
|
||||
// equivalent to "arr[i * row_stride + j * col_stride]".
|
||||
// Conversion functions to and from rotation matrices accept MatrixAdapters to
|
||||
// permit using row-major and column-major layouts, and rotation matrices embedded in
|
||||
// larger matrices (such as a 3x4 projection matrix).
|
||||
// Trivial wrapper to index linear arrays as matrices, given a fixed
|
||||
// column and row stride. When an array "T* array" is wrapped by a
|
||||
//
|
||||
// (const) MatrixAdapter<T, row_stride, col_stride> M"
|
||||
//
|
||||
// the expression M(i, j) is equivalent to
|
||||
//
|
||||
// arrary[i * row_stride + j * col_stride]
|
||||
//
|
||||
// Conversion functions to and from rotation matrices accept
|
||||
// MatrixAdapters to permit using row-major and column-major layouts,
|
||||
// and rotation matrices embedded in larger matrices (such as a 3x4
|
||||
// projection matrix).
|
||||
template <typename T, int row_stride, int col_stride>
|
||||
struct MatrixAdapter;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class LinearOperator;
|
||||
class BlockJacobiPreconditioner : public Preconditioner {
|
||||
public:
|
||||
// A must remain valid while the BlockJacobiPreconditioner is.
|
||||
BlockJacobiPreconditioner(const BlockSparseMatrixBase& A);
|
||||
explicit BlockJacobiPreconditioner(const BlockSparseMatrixBase& A);
|
||||
virtual ~BlockJacobiPreconditioner();
|
||||
|
||||
// Preconditioner interface
|
||||
|
||||
@@ -110,12 +110,6 @@ LinearSolver::Summary IterativeSchurComplementSolver::SolveImpl(
|
||||
case IDENTITY:
|
||||
break;
|
||||
case JACOBI:
|
||||
// We need to strip the constness of the block_diagonal_FtF_inverse
|
||||
// matrix here because the only other way to initialize the struct
|
||||
// cg_solve_options would be to add a constructor to it. We know
|
||||
// that the only method ever called on the preconditioner is the
|
||||
// RightMultiply which is a const method so we don't need to worry
|
||||
// about the object getting modified.
|
||||
preconditioner_.reset(
|
||||
new SparseMatrixPreconditionerWrapper(
|
||||
schur_complement_->block_diagonal_FtF_inverse()));
|
||||
|
||||
@@ -73,7 +73,7 @@ class ParameterBlock {
|
||||
|
||||
// Create a parameter block with the user state, size, and index specified.
|
||||
// The size is the size of the parameter block and the index is the position
|
||||
// if the parameter block inside a Program (if any).
|
||||
// of the parameter block inside a Program (if any).
|
||||
ParameterBlock(double* user_state, int size, int index) {
|
||||
Init(user_state, size, index, NULL);
|
||||
}
|
||||
|
||||
@@ -69,11 +69,11 @@ class Preconditioner : public LinearOperator {
|
||||
//
|
||||
// For example if elimination_groups is a vector of size k, then
|
||||
// the linear solver is informed that it should eliminate the
|
||||
// parameter blocks 0 - elimination_groups[0] - 1 first, and then
|
||||
// elimination_groups[0] - elimination_groups[1] and so on. Within
|
||||
// each elimination group, the linear solver is free to choose how
|
||||
// the parameter blocks are ordered. Different linear solvers have
|
||||
// differing requirements on elimination_groups.
|
||||
// parameter blocks 0 ... elimination_groups[0] - 1 first, and
|
||||
// then elimination_groups[0] ... elimination_groups[1] and so
|
||||
// on. Within each elimination group, the linear solver is free to
|
||||
// choose how the parameter blocks are ordered. Different linear
|
||||
// solvers have differing requirements on elimination_groups.
|
||||
//
|
||||
// The most common use is for Schur type solvers, where there
|
||||
// should be at least two elimination groups and the first
|
||||
@@ -130,7 +130,7 @@ class Preconditioner : public LinearOperator {
|
||||
class SparseMatrixPreconditionerWrapper : public Preconditioner {
|
||||
public:
|
||||
// Wrapper does NOT take ownership of the matrix pointer.
|
||||
SparseMatrixPreconditionerWrapper(const SparseMatrix* matrix);
|
||||
explicit SparseMatrixPreconditionerWrapper(const SparseMatrix* matrix);
|
||||
virtual ~SparseMatrixPreconditionerWrapper();
|
||||
|
||||
// Preconditioner interface
|
||||
|
||||
@@ -177,7 +177,7 @@ ProblemImpl::ProblemImpl(const Problem::Options& options)
|
||||
|
||||
ProblemImpl::~ProblemImpl() {
|
||||
// Collect the unique cost/loss functions and delete the residuals.
|
||||
const int num_residual_blocks = program_->residual_blocks_.size();
|
||||
const int num_residual_blocks = program_->residual_blocks_.size();
|
||||
cost_functions_to_delete_.reserve(num_residual_blocks);
|
||||
loss_functions_to_delete_.reserve(num_residual_blocks);
|
||||
for (int i = 0; i < program_->residual_blocks_.size(); ++i) {
|
||||
@@ -486,8 +486,8 @@ void ProblemImpl::RemoveParameterBlock(double* values) {
|
||||
ResidualBlock* residual_block =
|
||||
(*(program_->mutable_residual_blocks()))[i];
|
||||
const int num_parameter_blocks = residual_block->NumParameterBlocks();
|
||||
for (int i = 0; i < num_parameter_blocks; ++i) {
|
||||
if (residual_block->parameter_blocks()[i] == parameter_block) {
|
||||
for (int j = 0; j < num_parameter_blocks; ++j) {
|
||||
if (residual_block->parameter_blocks()[j] == parameter_block) {
|
||||
RemoveResidualBlock(residual_block);
|
||||
// The parameter blocks are guaranteed unique.
|
||||
break;
|
||||
|
||||
@@ -311,7 +311,7 @@ string Solver::Summary::FullReport() const {
|
||||
|
||||
StringAppendF(&report, "\n");
|
||||
|
||||
StringAppendF(&report, "%45s %21s\n", "Given", "Used");
|
||||
StringAppendF(&report, "%45s %21s\n", "Given", "Used");
|
||||
StringAppendF(&report, "Threads: % 25d% 25d\n",
|
||||
num_threads_given, num_threads_used);
|
||||
|
||||
|
||||
@@ -53,6 +53,8 @@ void STLDeleteContainerPointers(ForwardIterator begin,
|
||||
}
|
||||
}
|
||||
|
||||
// Variant of STLDeleteContainerPointers which allows the container to
|
||||
// contain duplicates.
|
||||
template <class ForwardIterator>
|
||||
void STLDeleteUniqueContainerPointers(ForwardIterator begin,
|
||||
ForwardIterator end) {
|
||||
|
||||
@@ -38,7 +38,7 @@ import glob
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
print "make_docs.py src_root destination_root"
|
||||
sys.exit(1);
|
||||
sys.exit(1)
|
||||
|
||||
src_dir = sys.argv[1] + "/docs/source"
|
||||
build_root = sys.argv[2]
|
||||
@@ -58,8 +58,10 @@ output_pattern = """config=TeX-AMS_HTML">
|
||||
</script>"""
|
||||
|
||||
# By default MathJax uses does not use TeX fonts. This simple search
|
||||
# an replace fixes that.
|
||||
# and replace fixes that.
|
||||
for name in glob.glob("%s/*.html" % html_dir):
|
||||
print "Postprocessing: ", name
|
||||
out = open(name).read().replace(input_pattern, output_pattern)
|
||||
fptr = open(name)
|
||||
out = fptr.read().replace(input_pattern, output_pattern)
|
||||
open(name, "w").write(out)
|
||||
fptr.close();
|
||||
|
||||
Reference in New Issue
Block a user