mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 16:40:38 +08:00
Lint cleanup from William Rucklidge.
Change-Id: I745810f5496a1b93263b20ff140f8883da61995e
This commit is contained in:
@@ -316,9 +316,9 @@ Non-monotonic Steps
|
||||
-------------------
|
||||
|
||||
Note that the basic trust-region algorithm described in
|
||||
:ref:`section-trust-region-methods` is a descent algorithm in that
|
||||
they only accepts a point if it strictly reduces the value of the
|
||||
objective function.
|
||||
:ref:`section-trust-region-methods` is a descent algorithm in that it
|
||||
only accepts a point if it strictly reduces the value of the objective
|
||||
function.
|
||||
|
||||
Relaxing this requirement allows the algorithm to be more efficient in
|
||||
the long term at the cost of some local increase in the value of the
|
||||
|
||||
@@ -470,7 +470,7 @@ bool CovarianceImpl::ComputeCovarianceValuesUsingSparseCholesky() {
|
||||
LOG(ERROR) << "Cholesky factorization of J'J is not reliable. "
|
||||
<< "Reciprocal condition number: "
|
||||
<< reciprocal_condition_number << " "
|
||||
<< "min_reciprocal_condition_number : "
|
||||
<< "min_reciprocal_condition_number: "
|
||||
<< options_.min_reciprocal_condition_number;
|
||||
ss.Free(factor);
|
||||
return false;
|
||||
@@ -822,7 +822,7 @@ bool CovarianceImpl::ComputeCovarianceValuesUsingDenseSVD() {
|
||||
LOG(ERROR) << "Cholesky factorization of J'J is not reliable. "
|
||||
<< "Reciprocal condition number: "
|
||||
<< singular_value_ratio * singular_value_ratio << " "
|
||||
<< "min_reciprocal_condition_number : "
|
||||
<< "min_reciprocal_condition_number: "
|
||||
<< options_.min_reciprocal_condition_number;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ int LAPACK::EstimateWorkSizeForQR(int num_rows, int num_cols) {
|
||||
LOG(FATAL) << "Congratulations, you found a bug in Ceres."
|
||||
<< "Please report it."
|
||||
<< "LAPACK::dgels fatal error."
|
||||
<< "Argument: " << info << " is invalid.";
|
||||
<< "Argument: " << -info << " is invalid.";
|
||||
}
|
||||
return static_cast<int>(work);
|
||||
#endif
|
||||
|
||||
@@ -99,11 +99,12 @@ TEST(SolverImpl, RemoveFixedBlocksNothingConstant) {
|
||||
inner_iteration_ordering.AddElementToGroup(&z, 0);
|
||||
|
||||
Program program(*problem.mutable_program());
|
||||
EXPECT_TRUE(SolverImpl::RemoveFixedBlocksFromProgram(&program,
|
||||
&linear_solver_ordering,
|
||||
&inner_iteration_ordering,
|
||||
NULL,
|
||||
&error));
|
||||
EXPECT_TRUE(SolverImpl::RemoveFixedBlocksFromProgram(
|
||||
&program,
|
||||
&linear_solver_ordering,
|
||||
&inner_iteration_ordering,
|
||||
NULL,
|
||||
&error));
|
||||
EXPECT_EQ(program.NumParameterBlocks(), 3);
|
||||
EXPECT_EQ(program.NumResidualBlocks(), 3);
|
||||
EXPECT_EQ(linear_solver_ordering.NumElements(), 3);
|
||||
@@ -127,11 +128,12 @@ TEST(SolverImpl, RemoveFixedBlocksAllParameterBlocksConstant) {
|
||||
|
||||
Program program(problem.program());
|
||||
string error;
|
||||
EXPECT_TRUE(SolverImpl::RemoveFixedBlocksFromProgram(&program,
|
||||
&linear_solver_ordering,
|
||||
&inner_iteration_ordering,
|
||||
NULL,
|
||||
&error));
|
||||
EXPECT_TRUE(SolverImpl::RemoveFixedBlocksFromProgram(
|
||||
&program,
|
||||
&linear_solver_ordering,
|
||||
&inner_iteration_ordering,
|
||||
NULL,
|
||||
&error));
|
||||
EXPECT_EQ(program.NumParameterBlocks(), 0);
|
||||
EXPECT_EQ(program.NumResidualBlocks(), 0);
|
||||
EXPECT_EQ(linear_solver_ordering.NumElements(), 0);
|
||||
@@ -160,11 +162,12 @@ TEST(SolverImpl, RemoveFixedBlocksNoResidualBlocks) {
|
||||
|
||||
Program program(problem.program());
|
||||
string error;
|
||||
EXPECT_TRUE(SolverImpl::RemoveFixedBlocksFromProgram(&program,
|
||||
&linear_solver_ordering,
|
||||
&inner_iteration_ordering,
|
||||
NULL,
|
||||
&error));
|
||||
EXPECT_TRUE(SolverImpl::RemoveFixedBlocksFromProgram(
|
||||
&program,
|
||||
&linear_solver_ordering,
|
||||
&inner_iteration_ordering,
|
||||
NULL,
|
||||
&error));
|
||||
EXPECT_EQ(program.NumParameterBlocks(), 0);
|
||||
EXPECT_EQ(program.NumResidualBlocks(), 0);
|
||||
EXPECT_EQ(linear_solver_ordering.NumElements(), 0);
|
||||
@@ -198,11 +201,12 @@ TEST(SolverImpl, RemoveFixedBlocksOneParameterBlockConstant) {
|
||||
|
||||
Program program(problem.program());
|
||||
string error;
|
||||
EXPECT_TRUE(SolverImpl::RemoveFixedBlocksFromProgram(&program,
|
||||
&linear_solver_ordering,
|
||||
&inner_iteration_ordering,
|
||||
NULL,
|
||||
&error));
|
||||
EXPECT_TRUE(SolverImpl::RemoveFixedBlocksFromProgram(
|
||||
&program,
|
||||
&linear_solver_ordering,
|
||||
&inner_iteration_ordering,
|
||||
NULL,
|
||||
&error));
|
||||
EXPECT_EQ(program.NumParameterBlocks(), 1);
|
||||
EXPECT_EQ(program.NumResidualBlocks(), 1);
|
||||
EXPECT_EQ(linear_solver_ordering.NumElements(), 1);
|
||||
@@ -235,11 +239,12 @@ TEST(SolverImpl, RemoveFixedBlocksNumEliminateBlocks) {
|
||||
|
||||
Program program(problem.program());
|
||||
string error;
|
||||
EXPECT_TRUE(SolverImpl::RemoveFixedBlocksFromProgram(&program,
|
||||
&linear_solver_ordering,
|
||||
&inner_iteration_ordering,
|
||||
NULL,
|
||||
&error));
|
||||
EXPECT_TRUE(SolverImpl::RemoveFixedBlocksFromProgram(
|
||||
&program,
|
||||
&linear_solver_ordering,
|
||||
&inner_iteration_ordering,
|
||||
NULL,
|
||||
&error));
|
||||
EXPECT_EQ(program.NumParameterBlocks(), 2);
|
||||
EXPECT_EQ(program.NumResidualBlocks(), 2);
|
||||
EXPECT_EQ(linear_solver_ordering.NumElements(), 2);
|
||||
@@ -283,11 +288,12 @@ TEST(SolverImpl, RemoveFixedBlocksFixedCost) {
|
||||
scratch.get());
|
||||
|
||||
string error;
|
||||
EXPECT_TRUE(SolverImpl::RemoveFixedBlocksFromProgram(&program,
|
||||
&linear_solver_ordering,
|
||||
NULL,
|
||||
&fixed_cost,
|
||||
&error));
|
||||
EXPECT_TRUE(SolverImpl::RemoveFixedBlocksFromProgram(
|
||||
&program,
|
||||
&linear_solver_ordering,
|
||||
NULL,
|
||||
&fixed_cost,
|
||||
&error));
|
||||
EXPECT_EQ(program.NumParameterBlocks(), 2);
|
||||
EXPECT_EQ(program.NumResidualBlocks(), 2);
|
||||
EXPECT_EQ(linear_solver_ordering.NumElements(), 2);
|
||||
|
||||
@@ -122,7 +122,7 @@ cholmod_dense* SuiteSparse::CreateDenseVector(const double* x,
|
||||
}
|
||||
|
||||
cholmod_factor* SuiteSparse::AnalyzeCholesky(cholmod_sparse* A,
|
||||
string* status) {
|
||||
string* message) {
|
||||
// Cholmod can try multiple re-ordering strategies to find a fill
|
||||
// reducing ordering. Here we just tell it use AMD with automatic
|
||||
// matrix dependence choice of supernodal versus simplicial
|
||||
@@ -137,7 +137,7 @@ cholmod_factor* SuiteSparse::AnalyzeCholesky(cholmod_sparse* A,
|
||||
}
|
||||
|
||||
if (cc_.status != CHOLMOD_OK) {
|
||||
*status = StringPrintf("cholmod_analyze failed. error code: %d",
|
||||
*message = StringPrintf("cholmod_analyze failed. error code: %d",
|
||||
cc_.status);
|
||||
return NULL;
|
||||
}
|
||||
@@ -149,18 +149,18 @@ cholmod_factor* SuiteSparse::BlockAnalyzeCholesky(
|
||||
cholmod_sparse* A,
|
||||
const vector<int>& row_blocks,
|
||||
const vector<int>& col_blocks,
|
||||
string* status) {
|
||||
string* message) {
|
||||
vector<int> ordering;
|
||||
if (!BlockAMDOrdering(A, row_blocks, col_blocks, &ordering)) {
|
||||
return NULL;
|
||||
}
|
||||
return AnalyzeCholeskyWithUserOrdering(A, ordering, status);
|
||||
return AnalyzeCholeskyWithUserOrdering(A, ordering, message);
|
||||
}
|
||||
|
||||
cholmod_factor* SuiteSparse::AnalyzeCholeskyWithUserOrdering(
|
||||
cholmod_sparse* A,
|
||||
const vector<int>& ordering,
|
||||
string* status) {
|
||||
string* message) {
|
||||
CHECK_EQ(ordering.size(), A->nrow);
|
||||
|
||||
cc_.nmethods = 1;
|
||||
@@ -172,7 +172,7 @@ cholmod_factor* SuiteSparse::AnalyzeCholeskyWithUserOrdering(
|
||||
cholmod_print_common(const_cast<char*>("Symbolic Analysis"), &cc_);
|
||||
}
|
||||
if (cc_.status != CHOLMOD_OK) {
|
||||
*status = StringPrintf("cholmod_analyze failed. error code: %d",
|
||||
*message = StringPrintf("cholmod_analyze failed. error code: %d",
|
||||
cc_.status);
|
||||
return NULL;
|
||||
}
|
||||
@@ -182,7 +182,7 @@ cholmod_factor* SuiteSparse::AnalyzeCholeskyWithUserOrdering(
|
||||
|
||||
cholmod_factor* SuiteSparse::AnalyzeCholeskyWithNaturalOrdering(
|
||||
cholmod_sparse* A,
|
||||
string* status) {
|
||||
string* message) {
|
||||
cc_.nmethods = 1;
|
||||
cc_.method[0].ordering = CHOLMOD_NATURAL;
|
||||
cc_.postorder = 0;
|
||||
@@ -192,7 +192,7 @@ cholmod_factor* SuiteSparse::AnalyzeCholeskyWithNaturalOrdering(
|
||||
cholmod_print_common(const_cast<char*>("Symbolic Analysis"), &cc_);
|
||||
}
|
||||
if (cc_.status != CHOLMOD_OK) {
|
||||
*status = StringPrintf("cholmod_analyze failed. error code: %d",
|
||||
*message = StringPrintf("cholmod_analyze failed. error code: %d",
|
||||
cc_.status);
|
||||
return NULL;
|
||||
}
|
||||
@@ -244,7 +244,7 @@ bool SuiteSparse::BlockAMDOrdering(const cholmod_sparse* A,
|
||||
|
||||
LinearSolverTerminationType SuiteSparse::Cholesky(cholmod_sparse* A,
|
||||
cholmod_factor* L,
|
||||
string* status) {
|
||||
string* message) {
|
||||
CHECK_NOTNULL(A);
|
||||
CHECK_NOTNULL(L);
|
||||
|
||||
@@ -268,35 +268,35 @@ LinearSolverTerminationType SuiteSparse::Cholesky(cholmod_sparse* A,
|
||||
// (e.g. out of memory).
|
||||
switch (cc_.status) {
|
||||
case CHOLMOD_NOT_INSTALLED:
|
||||
*status = "CHOLMOD failure: Method not installed.";
|
||||
*message = "CHOLMOD failure: Method not installed.";
|
||||
return LINEAR_SOLVER_FATAL_ERROR;
|
||||
case CHOLMOD_OUT_OF_MEMORY:
|
||||
*status = "CHOLMOD failure: Out of memory.";
|
||||
*message = "CHOLMOD failure: Out of memory.";
|
||||
return LINEAR_SOLVER_FATAL_ERROR;
|
||||
case CHOLMOD_TOO_LARGE:
|
||||
*status = "CHOLMOD failure: Integer overflow occured.";
|
||||
*message = "CHOLMOD failure: Integer overflow occured.";
|
||||
return LINEAR_SOLVER_FATAL_ERROR;
|
||||
case CHOLMOD_INVALID:
|
||||
*status = "CHOLMOD failure: Invalid input.";
|
||||
*message = "CHOLMOD failure: Invalid input.";
|
||||
return LINEAR_SOLVER_FATAL_ERROR;
|
||||
case CHOLMOD_NOT_POSDEF:
|
||||
*status = "CHOLMOD warning: Matrix not positive definite.";
|
||||
*message = "CHOLMOD warning: Matrix not positive definite.";
|
||||
return LINEAR_SOLVER_FAILURE;
|
||||
case CHOLMOD_DSMALL:
|
||||
*status = "CHOLMOD warning: D for LDL' or diag(L) or "
|
||||
*message = "CHOLMOD warning: D for LDL' or diag(L) or "
|
||||
"LL' has tiny absolute value.";
|
||||
return LINEAR_SOLVER_FAILURE;
|
||||
case CHOLMOD_OK:
|
||||
if (cholmod_status != 0) {
|
||||
if (cholmod_message != 0) {
|
||||
return LINEAR_SOLVER_SUCCESS;
|
||||
}
|
||||
|
||||
*status = "CHOLMOD failure: cholmod_factorize returned false "
|
||||
*message = "CHOLMOD failure: cholmod_factorize returned false "
|
||||
"but cholmod_common::status is CHOLMOD_OK."
|
||||
"Please report this to ceres-solver@googlegroups.com.";
|
||||
return LINEAR_SOLVER_FATAL_ERROR;
|
||||
default:
|
||||
*status =
|
||||
*message =
|
||||
StringPrintf("Unknown cholmod return code: %d. "
|
||||
"Please report this to ceres-solver@googlegroups.com.",
|
||||
cc_.status);
|
||||
@@ -308,9 +308,9 @@ LinearSolverTerminationType SuiteSparse::Cholesky(cholmod_sparse* A,
|
||||
|
||||
cholmod_dense* SuiteSparse::Solve(cholmod_factor* L,
|
||||
cholmod_dense* b,
|
||||
string* status) {
|
||||
string* message) {
|
||||
if (cc_.status != CHOLMOD_OK) {
|
||||
*status = "cholmod_solve failed. CHOLMOD status is not CHOLMOD_OK";
|
||||
*message = "cholmod_solve failed. CHOLMOD status is not CHOLMOD_OK";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Ceres Solver - A fast non-linear least squares minimizer
|
||||
s// Ceres Solver - A fast non-linear least squares minimizer
|
||||
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/ceres-solver/
|
||||
//
|
||||
@@ -139,15 +139,15 @@ class SuiteSparse {
|
||||
// A is not modified, only the pattern of non-zeros of A is used,
|
||||
// the actual numerical values in A are of no consequence.
|
||||
//
|
||||
// status contains an explanation of the failures if any.
|
||||
// message contains an explanation of the failures if any.
|
||||
//
|
||||
// Caller owns the result.
|
||||
cholmod_factor* AnalyzeCholesky(cholmod_sparse* A, string* status);
|
||||
cholmod_factor* AnalyzeCholesky(cholmod_sparse* A, string* message);
|
||||
|
||||
cholmod_factor* BlockAnalyzeCholesky(cholmod_sparse* A,
|
||||
const vector<int>& row_blocks,
|
||||
const vector<int>& col_blocks,
|
||||
string* status);
|
||||
string* message);
|
||||
|
||||
// If A is symmetric, then compute the symbolic Cholesky
|
||||
// factorization of A(ordering, ordering). If A is unsymmetric, then
|
||||
@@ -157,38 +157,38 @@ class SuiteSparse {
|
||||
// A is not modified, only the pattern of non-zeros of A is used,
|
||||
// the actual numerical values in A are of no consequence.
|
||||
//
|
||||
// status contains an explanation of the failures if any.
|
||||
// message contains an explanation of the failures if any.
|
||||
//
|
||||
// Caller owns the result.
|
||||
cholmod_factor* AnalyzeCholeskyWithUserOrdering(cholmod_sparse* A,
|
||||
const vector<int>& ordering,
|
||||
string* status);
|
||||
string* message);
|
||||
|
||||
// Perform a symbolic factorization of A without re-ordering A. No
|
||||
// postordering of the elimination tree is performed. This ensures
|
||||
// that the symbolic factor does not introduce an extra permutation
|
||||
// on the matrix. See the documentation for CHOLMOD for more details.
|
||||
//
|
||||
// status contains an explanation of the failures if any.
|
||||
// message contains an explanation of the failures if any.
|
||||
cholmod_factor* AnalyzeCholeskyWithNaturalOrdering(cholmod_sparse* A,
|
||||
string* status);
|
||||
string* message);
|
||||
|
||||
// Use the symbolic factorization in L, to find the numerical
|
||||
// factorization for the matrix A or AA^T. Return true if
|
||||
// successful, false otherwise. L contains the numeric factorization
|
||||
// on return.
|
||||
//
|
||||
// status contains an explanation of the failures if any.
|
||||
// message contains an explanation of the failures if any.
|
||||
LinearSolverTerminationType Cholesky(cholmod_sparse* A,
|
||||
cholmod_factor* L,
|
||||
string* status);
|
||||
string* message);
|
||||
|
||||
// Given a Cholesky factorization of a matrix A = LL^T, solve the
|
||||
// linear system Ax = b, and return the result. If the Solve fails
|
||||
// NULL is returned. Caller owns the result.
|
||||
//
|
||||
// status contains an explanation of the failures if any.
|
||||
cholmod_dense* Solve(cholmod_factor* L, cholmod_dense* b, string* solve);
|
||||
// message contains an explanation of the failures if any.
|
||||
cholmod_dense* Solve(cholmod_factor* L, cholmod_dense* b, string* message);
|
||||
|
||||
// By virtue of the modeling layer in Ceres being block oriented,
|
||||
// all the matrices used by Ceres are also block oriented. When
|
||||
|
||||
Reference in New Issue
Block a user