mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 08:34:37 +08:00
Replace NULL by nullptr
Change-Id: I200a40678091b984a01635d8637a487b7ad5cc13
This commit is contained in:
@@ -104,8 +104,8 @@ template <typename Pose,
|
||||
bool ReadG2oFile(const std::string& filename,
|
||||
std::map<int, Pose, std::less<int>, MapAllocator>* poses,
|
||||
std::vector<Constraint, VectorAllocator>* constraints) {
|
||||
CHECK(poses != NULL);
|
||||
CHECK(constraints != NULL);
|
||||
CHECK(poses != nullptr);
|
||||
CHECK(constraints != nullptr);
|
||||
|
||||
poses->clear();
|
||||
constraints->clear();
|
||||
|
||||
@@ -137,7 +137,7 @@ class CERES_DEPRECATED_WITH_MSG("Use AutoDiffManifold instead.")
|
||||
}
|
||||
|
||||
const double* parameter_ptrs[2] = {x, zero_delta};
|
||||
double* jacobian_ptrs[2] = {NULL, jacobian};
|
||||
double* jacobian_ptrs[2] = {nullptr, jacobian};
|
||||
return internal::AutoDifferentiate<
|
||||
kGlobalSize,
|
||||
internal::StaticParameterDims<kGlobalSize, kLocalSize>>(
|
||||
|
||||
@@ -76,7 +76,7 @@ class CERES_EXPORT ConditionedCostFunction : public CostFunction {
|
||||
// Builds a cost function based on a wrapped cost function, and a
|
||||
// per-residual conditioner. Takes ownership of all of the wrapped cost
|
||||
// functions, or not, depending on the ownership parameter. Conditioners
|
||||
// may be NULL, in which case the corresponding residual is not modified.
|
||||
// may be nullptr, in which case the corresponding residual is not modified.
|
||||
//
|
||||
// The conditioners can repeat.
|
||||
ConditionedCostFunction(CostFunction* wrapped_cost_function,
|
||||
|
||||
@@ -92,8 +92,8 @@ class CERES_EXPORT CostFunction {
|
||||
// jacobians[i][r*parameter_block_size_[i] + c] =
|
||||
// d residual[r] / d parameters[i][c]
|
||||
//
|
||||
// If jacobians is NULL, then no derivatives are returned; this is
|
||||
// the case when computing cost only. If jacobians[i] is NULL, then
|
||||
// If jacobians is nullptr, then no derivatives are returned; this is
|
||||
// the case when computing cost only. If jacobians[i] is nullptr, then
|
||||
// the jacobian block corresponding to the i'th parameter block must
|
||||
// not to be returned.
|
||||
//
|
||||
|
||||
@@ -59,8 +59,8 @@ namespace ceres {
|
||||
// http://en.wikipedia.org/wiki/Cubic_Hermite_spline
|
||||
// http://en.wikipedia.org/wiki/Bicubic_interpolation
|
||||
//
|
||||
// f if not NULL will contain the interpolated function values.
|
||||
// dfdx if not NULL will contain the interpolated derivative values.
|
||||
// f if not nullptr will contain the interpolated function values.
|
||||
// dfdx if not nullptr will contain the interpolated derivative values.
|
||||
template <int kDataDimension>
|
||||
void CubicHermiteSpline(const Eigen::Matrix<double, kDataDimension, 1>& p0,
|
||||
const Eigen::Matrix<double, kDataDimension, 1>& p1,
|
||||
@@ -79,12 +79,12 @@ void CubicHermiteSpline(const Eigen::Matrix<double, kDataDimension, 1>& p0,
|
||||
// derivative.
|
||||
|
||||
// f = ax^3 + bx^2 + cx + d
|
||||
if (f != NULL) {
|
||||
if (f != nullptr) {
|
||||
Eigen::Map<VType>(f, kDataDimension) = d + x * (c + x * (b + x * a));
|
||||
}
|
||||
|
||||
// dfdx = 3ax^2 + 2bx + c
|
||||
if (dfdx != NULL) {
|
||||
if (dfdx != nullptr) {
|
||||
Eigen::Map<VType>(dfdx, kDataDimension) = c + x * (2.0 * b + 3.0 * a * x);
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ class CubicInterpolator {
|
||||
// The following two Evaluate overloads are needed for interfacing
|
||||
// with automatic differentiation. The first is for when a scalar
|
||||
// evaluation is done, and the second one is for when Jets are used.
|
||||
void Evaluate(const double& x, double* f) const { Evaluate(x, f, NULL); }
|
||||
void Evaluate(const double& x, double* f) const { Evaluate(x, f, nullptr); }
|
||||
|
||||
template <typename JetT>
|
||||
void Evaluate(const JetT& x, JetT* f) const {
|
||||
@@ -317,10 +317,10 @@ class BiCubicInterpolator {
|
||||
// Interpolate vertically the interpolated value from each row and
|
||||
// compute the derivative along the columns.
|
||||
CubicHermiteSpline<Grid::DATA_DIMENSION>(f0, f1, f2, f3, r - row, f, dfdr);
|
||||
if (dfdc != NULL) {
|
||||
if (dfdc != nullptr) {
|
||||
// Interpolate vertically the derivative along the columns.
|
||||
CubicHermiteSpline<Grid::DATA_DIMENSION>(
|
||||
df0dc, df1dc, df2dc, df3dc, r - row, dfdc, NULL);
|
||||
df0dc, df1dc, df2dc, df3dc, r - row, dfdc, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ class BiCubicInterpolator {
|
||||
// with automatic differentiation. The first is for when a scalar
|
||||
// evaluation is done, and the second one is for when Jets are used.
|
||||
void Evaluate(const double& r, const double& c, double* f) const {
|
||||
Evaluate(r, c, f, NULL, NULL);
|
||||
Evaluate(r, c, f, nullptr, nullptr);
|
||||
}
|
||||
|
||||
template <typename JetT>
|
||||
|
||||
@@ -105,7 +105,7 @@ class DynamicAutoDiffCostFunction : public DynamicCostFunction {
|
||||
<< "You must call DynamicAutoDiffCostFunction::SetNumResiduals() "
|
||||
<< "before DynamicAutoDiffCostFunction::Evaluate().";
|
||||
|
||||
if (jacobians == NULL) {
|
||||
if (jacobians == nullptr) {
|
||||
return (*functor_)(parameters, residuals);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class DynamicAutoDiffCostFunction : public DynamicCostFunction {
|
||||
jet_parameters[i] = &input_jets[parameter_cursor];
|
||||
|
||||
const int parameter_block_size = parameter_block_sizes()[i];
|
||||
if (jacobians[i] != NULL) {
|
||||
if (jacobians[i] != nullptr) {
|
||||
if (!in_derivative_section) {
|
||||
start_derivative_section.push_back(parameter_cursor);
|
||||
in_derivative_section = true;
|
||||
@@ -209,7 +209,7 @@ class DynamicAutoDiffCostFunction : public DynamicCostFunction {
|
||||
parameter_cursor >=
|
||||
(start_derivative_section[current_derivative_section] +
|
||||
current_derivative_section_cursor)) {
|
||||
if (jacobians[i] != NULL) {
|
||||
if (jacobians[i] != nullptr) {
|
||||
input_jets[parameter_cursor].v[active_parameter_count] = 1.0;
|
||||
++active_parameter_count;
|
||||
++current_derivative_section_cursor;
|
||||
@@ -238,7 +238,7 @@ class DynamicAutoDiffCostFunction : public DynamicCostFunction {
|
||||
parameter_cursor >=
|
||||
(start_derivative_section[current_derivative_section] +
|
||||
current_derivative_section_cursor)) {
|
||||
if (jacobians[i] != NULL) {
|
||||
if (jacobians[i] != nullptr) {
|
||||
for (int k = 0; k < num_residuals(); ++k) {
|
||||
jacobians[i][k * parameter_block_sizes()[i] + j] =
|
||||
output_jets[k].v[active_parameter_count];
|
||||
|
||||
@@ -110,7 +110,7 @@ class DynamicCostFunctionToFunctor {
|
||||
}
|
||||
|
||||
bool operator()(double const* const* parameters, double* residuals) const {
|
||||
return cost_function_->Evaluate(parameters, residuals, NULL);
|
||||
return cost_function_->Evaluate(parameters, residuals, nullptr);
|
||||
}
|
||||
|
||||
template <typename JetT>
|
||||
|
||||
@@ -111,7 +111,7 @@ class DynamicNumericDiffCostFunction : public DynamicCostFunction {
|
||||
const bool status =
|
||||
internal::VariadicEvaluate<internal::DynamicParameterDims>(
|
||||
*functor_.get(), parameters, residuals);
|
||||
if (jacobians == NULL || !status) {
|
||||
if (jacobians == nullptr || !status) {
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ class DynamicNumericDiffCostFunction : public DynamicCostFunction {
|
||||
}
|
||||
|
||||
for (size_t block = 0; block < block_sizes.size(); ++block) {
|
||||
if (jacobians[block] != NULL &&
|
||||
if (jacobians[block] != nullptr &&
|
||||
!NumericDiff<CostFunctor,
|
||||
method,
|
||||
ceres::DYNAMIC,
|
||||
|
||||
@@ -151,7 +151,7 @@ class CERES_EXPORT GradientChecker {
|
||||
// Jacobians. If the Jacobians differ by more than this amount, then the
|
||||
// probe fails.
|
||||
// results: On return, the Jacobians (and other information) will be stored
|
||||
// here. May be NULL.
|
||||
// here. May be nullptr.
|
||||
//
|
||||
// Returns true if no problems are detected and the difference between the
|
||||
// Jacobians is less than error_tolerance.
|
||||
|
||||
@@ -78,7 +78,7 @@ class FirstOrderFunction;
|
||||
// const double y = parameters[1];
|
||||
//
|
||||
// cost[0] = (1.0 - x) * (1.0 - x) + 100.0 * (y - x * x) * (y - x * x);
|
||||
// if (gradient != NULL) {
|
||||
// if (gradient != nullptr) {
|
||||
// gradient[0] = -2.0 * (1.0 - x) - 200.0 * (y - x * x) * 2.0 * x;
|
||||
// gradient[1] = 200.0 * (y - x * x);
|
||||
// }
|
||||
|
||||
@@ -132,10 +132,10 @@
|
||||
// respectively. This is how autodiff works for functors taking multiple vector
|
||||
// valued arguments (up to 6).
|
||||
//
|
||||
// Jacobian NULL pointers
|
||||
// ----------------------
|
||||
// In general, the functions below will accept NULL pointers for all or some of
|
||||
// the Jacobian parameters, meaning that those Jacobians will not be computed.
|
||||
// Jacobian null pointers (nullptr)
|
||||
// --------------------------------
|
||||
// In general, the functions below will accept nullptr for all or some of the
|
||||
// Jacobian parameters, meaning that those Jacobians will not be computed.
|
||||
|
||||
#ifndef CERES_PUBLIC_INTERNAL_AUTODIFF_H_
|
||||
#define CERES_PUBLIC_INTERNAL_AUTODIFF_H_
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
//
|
||||
// For least squares problem where there are no outliers and standard
|
||||
// squared loss is expected, it is not necessary to create a loss
|
||||
// function; instead passing a NULL to the problem when adding
|
||||
// function; instead passing a nullptr to the problem when adding
|
||||
// residuals implies a standard squared loss.
|
||||
//
|
||||
// For least squares problems where the minimization may encounter
|
||||
@@ -125,7 +125,7 @@ class CERES_EXPORT LossFunction {
|
||||
//
|
||||
// At s = 0: rho = [0, 1, 0].
|
||||
//
|
||||
// It is not normally necessary to use this, as passing NULL for the
|
||||
// It is not normally necessary to use this, as passing nullptr for the
|
||||
// loss function when building the problem accomplishes the same
|
||||
// thing.
|
||||
class CERES_EXPORT TrivialLoss : public LossFunction {
|
||||
@@ -294,7 +294,7 @@ class CERES_EXPORT TukeyLoss : public ceres::LossFunction {
|
||||
|
||||
// Composition of two loss functions. The error is the result of first
|
||||
// evaluating g followed by f to yield the composition f(g(s)).
|
||||
// The loss functions must not be NULL.
|
||||
// The loss functions must not be nullptr.
|
||||
class CERES_EXPORT ComposedLoss : public LossFunction {
|
||||
public:
|
||||
explicit ComposedLoss(const LossFunction* f,
|
||||
@@ -322,8 +322,8 @@ class CERES_EXPORT ComposedLoss : public LossFunction {
|
||||
// s -> a * rho'(s)
|
||||
// s -> a * rho''(s)
|
||||
//
|
||||
// Since we treat the a NULL Loss function as the Identity loss
|
||||
// function, rho = NULL is a valid input and will result in the input
|
||||
// Since we treat the a nullptr Loss function as the Identity loss
|
||||
// function, rho = nullptr is a valid input and will result in the input
|
||||
// being scaled by a. This provides a simple way of implementing a
|
||||
// scaled ResidualBlock.
|
||||
class CERES_EXPORT ScaledLoss : public LossFunction {
|
||||
@@ -361,8 +361,8 @@ class CERES_EXPORT ScaledLoss : public LossFunction {
|
||||
// whose scale can be mutated after an optimization problem has been
|
||||
// constructed.
|
||||
//
|
||||
// Since we treat the a NULL Loss function as the Identity loss
|
||||
// function, rho = NULL is a valid input.
|
||||
// Since we treat the a nullptr Loss function as the Identity loss
|
||||
// function, rho = nullptr is a valid input.
|
||||
//
|
||||
// Example usage
|
||||
//
|
||||
@@ -403,7 +403,7 @@ class CERES_EXPORT LossFunctionWrapper : public LossFunction {
|
||||
}
|
||||
|
||||
void Evaluate(double sq_norm, double out[3]) const override {
|
||||
if (rho_.get() == NULL) {
|
||||
if (rho_.get() == nullptr) {
|
||||
out[0] = sq_norm;
|
||||
out[1] = 1.0;
|
||||
out[2] = 0.0;
|
||||
|
||||
@@ -219,7 +219,7 @@ class NumericDiffCostFunction : public SizedCostFunction<kNumResiduals, Ns...> {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (jacobians == NULL) {
|
||||
if (jacobians == nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -423,7 +423,7 @@ class CERES_EXPORT Solver {
|
||||
// each group, Ceres is free to order the parameter blocks as it
|
||||
// chooses.
|
||||
//
|
||||
// If NULL, then all parameter blocks are assumed to be in the
|
||||
// If nullptr, then all parameter blocks are assumed to be in the
|
||||
// same group and the solver is free to decide the best
|
||||
// ordering.
|
||||
//
|
||||
|
||||
@@ -127,7 +127,7 @@ class TinySolverAutoDiffFunction {
|
||||
// This is similar to AutoDifferentiate(), but since there is only one
|
||||
// parameter block it is easier to inline to avoid overhead.
|
||||
bool operator()(const T* parameters, T* residuals, T* jacobian) const {
|
||||
if (jacobian == NULL) {
|
||||
if (jacobian == nullptr) {
|
||||
// No jacobian requested, so just directly call the cost function with
|
||||
// doubles, skipping jets and derivatives.
|
||||
return cost_functor_(parameters, residuals);
|
||||
|
||||
@@ -108,7 +108,7 @@ class TinySolverCostFunctionAdapter {
|
||||
double* residuals,
|
||||
double* jacobian) const {
|
||||
if (!jacobian) {
|
||||
return cost_function_.Evaluate(¶meters, residuals, NULL);
|
||||
return cost_function_.Evaluate(¶meters, residuals, nullptr);
|
||||
}
|
||||
|
||||
double* jacobians[1] = {row_major_jacobian_.data()};
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
// The following CHECK macros are defined:
|
||||
//
|
||||
// CHECK(condition) - fails if condition is false and logs condition.
|
||||
// CHECK_NOTNULL(variable) - fails if the variable is NULL.
|
||||
// CHECK_NOTNULL(variable) - fails if the variable is nullptr.
|
||||
//
|
||||
// The following binary check macros are also defined :
|
||||
//
|
||||
@@ -406,7 +406,7 @@ void LogMessageFatal(const char* file, int line, const T& message) {
|
||||
// and smart pointers.
|
||||
template <typename T>
|
||||
T& CheckNotNullCommon(const char* file, int line, const char* names, T& t) {
|
||||
if (t == NULL) {
|
||||
if (t == nullptr) {
|
||||
LogMessageFatal(file, line, std::string(names));
|
||||
}
|
||||
return t;
|
||||
@@ -424,17 +424,17 @@ T& CheckNotNull(const char* file, int line, const char* names, T& t) {
|
||||
|
||||
// Check that a pointer is not null.
|
||||
#define CHECK_NOTNULL(val) \
|
||||
CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val))
|
||||
CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non nullptr", (val))
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Debug only version of CHECK_NOTNULL
|
||||
#define DCHECK_NOTNULL(val) \
|
||||
CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val))
|
||||
CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non nullptr", (val))
|
||||
#else
|
||||
// Optimized version - generates no code.
|
||||
#define DCHECK_NOTNULL(val) \
|
||||
if (false) \
|
||||
CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val))
|
||||
CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non nullptr", (val))
|
||||
#endif // NDEBUG
|
||||
|
||||
#include "ceres/internal/reenable_warnings.h"
|
||||
|
||||
Reference in New Issue
Block a user