CERES_DONT_HAVE_PROTOCOL_BUFFERS -> CERES_NO_PROTOCOL_BUFFERS.

Change-Id: I6c9f50e4c006faf4e75a8f417455db18357f3187
This commit is contained in:
Sameer Agarwal
2012-08-16 19:34:57 -07:00
committed by ceres-solver code review
parent 8b4cb7aa2c
commit dd2b17d7dd
20 changed files with 35 additions and 36 deletions
+2 -3
View File
@@ -390,10 +390,10 @@ IF (${PROTOBUF})
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/internal) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/internal)
ELSE (${PROTOBUF_FOUND}) ELSE (${PROTOBUF_FOUND})
ADD_DEFINITIONS(-DCERES_DONT_HAVE_PROTOCOL_BUFFERS) ADD_DEFINITIONS(-DCERES_NO_PROTOCOL_BUFFERS)
ENDIF (${PROTOBUF_FOUND}) ENDIF (${PROTOBUF_FOUND})
ELSE (${PROTOBUF}) ELSE (${PROTOBUF})
ADD_DEFINITIONS(-DCERES_DONT_HAVE_PROTOCOL_BUFFERS) ADD_DEFINITIONS(-DCERES_NO_PROTOCOL_BUFFERS)
ENDIF (${PROTOBUF}) ENDIF (${PROTOBUF})
@@ -528,4 +528,3 @@ ENDIF (MSVC)
ADD_SUBDIRECTORY(internal/ceres) ADD_SUBDIRECTORY(internal/ceres)
ADD_SUBDIRECTORY(examples) ADD_SUBDIRECTORY(examples)
+2 -2
View File
@@ -81,7 +81,7 @@ BlockSparseMatrix::BlockSparseMatrix(
CHECK_NOTNULL(values_.get()); CHECK_NOTNULL(values_.get());
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
BlockSparseMatrix::BlockSparseMatrix(const SparseMatrixProto& outer_proto) { BlockSparseMatrix::BlockSparseMatrix(const SparseMatrixProto& outer_proto) {
CHECK(outer_proto.has_block_matrix()); CHECK(outer_proto.has_block_matrix());
@@ -244,7 +244,7 @@ const CompressedRowBlockStructure* BlockSparseMatrix::block_structure()
return block_structure_.get(); return block_structure_.get();
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
void BlockSparseMatrix::ToProto(SparseMatrixProto* outer_proto) const { void BlockSparseMatrix::ToProto(SparseMatrixProto* outer_proto) const {
outer_proto->Clear(); outer_proto->Clear();
+2 -2
View File
@@ -96,7 +96,7 @@ class BlockSparseMatrix : public BlockSparseMatrixBase {
explicit BlockSparseMatrix(CompressedRowBlockStructure* block_structure); explicit BlockSparseMatrix(CompressedRowBlockStructure* block_structure);
// Construct a block sparse matrix from a protocol buffer. // Construct a block sparse matrix from a protocol buffer.
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
explicit BlockSparseMatrix(const SparseMatrixProto& proto); explicit BlockSparseMatrix(const SparseMatrixProto& proto);
#endif #endif
@@ -110,7 +110,7 @@ class BlockSparseMatrix : public BlockSparseMatrixBase {
virtual void SquaredColumnNorm(double* x) const; virtual void SquaredColumnNorm(double* x) const;
virtual void ScaleColumns(const double* scale); virtual void ScaleColumns(const double* scale);
virtual void ToDenseMatrix(Matrix* dense_matrix) const; virtual void ToDenseMatrix(Matrix* dense_matrix) const;
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
virtual void ToProto(SparseMatrixProto* proto) const; virtual void ToProto(SparseMatrixProto* proto) const;
#endif #endif
virtual void ToTextFile(FILE* file) const; virtual void ToTextFile(FILE* file) const;
+1 -1
View File
@@ -109,7 +109,7 @@ TEST_F(BlockSparseMatrixTest, ToDenseMatrixTest) {
EXPECT_LT((m_a - m_b).norm(), 1e-12); EXPECT_LT((m_a - m_b).norm(), 1e-12);
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
TEST_F(BlockSparseMatrixTest, Serialization) { TEST_F(BlockSparseMatrixTest, Serialization) {
// Roundtrip through serialization and check for equality. // Roundtrip through serialization and check for equality.
SparseMatrixProto proto; SparseMatrixProto proto;
+1 -1
View File
@@ -38,7 +38,7 @@ bool CellLessThan(const Cell& lhs, const Cell& rhs) {
return (lhs.block_id < rhs.block_id); return (lhs.block_id < rhs.block_id);
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
void ProtoToBlockStructure(const BlockStructureProto &proto, void ProtoToBlockStructure(const BlockStructureProto &proto,
CompressedRowBlockStructure *block_structure) { CompressedRowBlockStructure *block_structure) {
// Decode the column blocks. // Decode the column blocks.
@@ -135,7 +135,7 @@ CompressedRowSparseMatrix::CompressedRowSparseMatrix(
CHECK_EQ(num_nonzeros(), m.num_nonzeros()); CHECK_EQ(num_nonzeros(), m.num_nonzeros());
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
CompressedRowSparseMatrix::CompressedRowSparseMatrix( CompressedRowSparseMatrix::CompressedRowSparseMatrix(
const SparseMatrixProto& outer_proto) { const SparseMatrixProto& outer_proto) {
CHECK(outer_proto.has_compressed_row_matrix()); CHECK(outer_proto.has_compressed_row_matrix());
@@ -248,7 +248,7 @@ void CompressedRowSparseMatrix::ToDenseMatrix(Matrix* dense_matrix) const {
} }
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
void CompressedRowSparseMatrix::ToProto(SparseMatrixProto* outer_proto) const { void CompressedRowSparseMatrix::ToProto(SparseMatrixProto* outer_proto) const {
CHECK_NOTNULL(outer_proto); CHECK_NOTNULL(outer_proto);
@@ -57,7 +57,7 @@ class CompressedRowSparseMatrix : public SparseMatrix {
// //
// We assume that m does not have any repeated entries. // We assume that m does not have any repeated entries.
explicit CompressedRowSparseMatrix(const TripletSparseMatrix& m); explicit CompressedRowSparseMatrix(const TripletSparseMatrix& m);
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
explicit CompressedRowSparseMatrix(const SparseMatrixProto& proto); explicit CompressedRowSparseMatrix(const SparseMatrixProto& proto);
#endif #endif
@@ -90,7 +90,7 @@ class CompressedRowSparseMatrix : public SparseMatrix {
virtual void ScaleColumns(const double* scale); virtual void ScaleColumns(const double* scale);
virtual void ToDenseMatrix(Matrix* dense_matrix) const; virtual void ToDenseMatrix(Matrix* dense_matrix) const;
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
virtual void ToProto(SparseMatrixProto* proto) const; virtual void ToProto(SparseMatrixProto* proto) const;
#endif #endif
virtual void ToTextFile(FILE* file) const; virtual void ToTextFile(FILE* file) const;
@@ -146,7 +146,7 @@ TEST_F(CompressedRowSparseMatrixTest, AppendRows) {
} }
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
TEST_F(CompressedRowSparseMatrixTest, Serialization) { TEST_F(CompressedRowSparseMatrixTest, Serialization) {
SparseMatrixProto proto; SparseMatrixProto proto;
crsm->ToProto(&proto); crsm->ToProto(&proto);
+3 -3
View File
@@ -67,7 +67,7 @@ DenseSparseMatrix::DenseSparseMatrix(const Matrix& m)
has_diagonal_reserved_(false) { has_diagonal_reserved_(false) {
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
DenseSparseMatrix::DenseSparseMatrix(const SparseMatrixProto& outer_proto) DenseSparseMatrix::DenseSparseMatrix(const SparseMatrixProto& outer_proto)
: m_(Eigen::MatrixXd::Zero( : m_(Eigen::MatrixXd::Zero(
outer_proto.dense_matrix().num_rows(), outer_proto.dense_matrix().num_rows(),
@@ -108,7 +108,7 @@ void DenseSparseMatrix::ToDenseMatrix(Matrix* dense_matrix) const {
*dense_matrix = m_; *dense_matrix = m_;
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
void DenseSparseMatrix::ToProto(SparseMatrixProto* outer_proto) const { void DenseSparseMatrix::ToProto(SparseMatrixProto* outer_proto) const {
CHECK(!has_diagonal_appended_) << "Not supported."; CHECK(!has_diagonal_appended_) << "Not supported.";
outer_proto->Clear(); outer_proto->Clear();
@@ -183,7 +183,7 @@ void DenseSparseMatrix::ToTextFile(FILE* file) const {
CHECK_NOTNULL(file); CHECK_NOTNULL(file);
const int active_rows = const int active_rows =
(has_diagonal_reserved_ && !has_diagonal_appended_) (has_diagonal_reserved_ && !has_diagonal_appended_)
? (m_.rows() - m_.cols()) ? (m_.rows() - m_.cols())
: m_.rows(); : m_.rows();
for (int r = 0; r < active_rows; ++r) { for (int r = 0; r < active_rows; ++r) {
+2 -2
View File
@@ -52,7 +52,7 @@ class DenseSparseMatrix : public SparseMatrix {
// m. This assumes that m does not have any repeated entries. // m. This assumes that m does not have any repeated entries.
explicit DenseSparseMatrix(const TripletSparseMatrix& m); explicit DenseSparseMatrix(const TripletSparseMatrix& m);
explicit DenseSparseMatrix(const Matrix& m); explicit DenseSparseMatrix(const Matrix& m);
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
explicit DenseSparseMatrix(const SparseMatrixProto& proto); explicit DenseSparseMatrix(const SparseMatrixProto& proto);
#endif #endif
@@ -67,7 +67,7 @@ class DenseSparseMatrix : public SparseMatrix {
virtual void SquaredColumnNorm(double* x) const; virtual void SquaredColumnNorm(double* x) const;
virtual void ScaleColumns(const double* scale); virtual void ScaleColumns(const double* scale);
virtual void ToDenseMatrix(Matrix* dense_matrix) const; virtual void ToDenseMatrix(Matrix* dense_matrix) const;
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
virtual void ToProto(SparseMatrixProto* proto) const; virtual void ToProto(SparseMatrixProto* proto) const;
#endif #endif
virtual void ToTextFile(FILE* file) const; virtual void ToTextFile(FILE* file) const;
+2 -2
View File
@@ -155,7 +155,7 @@ TEST_F(DenseSparseMatrixTest, Scale) {
CompareMatrices(tsm.get(), dsm.get()); CompareMatrices(tsm.get(), dsm.get());
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
TEST_F(DenseSparseMatrixTest, Serialization) { TEST_F(DenseSparseMatrixTest, Serialization) {
SparseMatrixProto proto; SparseMatrixProto proto;
dsm->ToProto(&proto); dsm->ToProto(&proto);
@@ -182,7 +182,7 @@ TEST_F(DenseSparseMatrixTest, ToDenseMatrix) {
} }
// TODO(keir): Make this work without protocol buffers. // TODO(keir): Make this work without protocol buffers.
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
TEST_F(DenseSparseMatrixTest, AppendDiagonal) { TEST_F(DenseSparseMatrixTest, AppendDiagonal) {
DenseSparseMatrixProto proto; DenseSparseMatrixProto proto;
proto.set_num_rows(3); proto.set_num_rows(3);
@@ -64,7 +64,7 @@ LinearLeastSquaresProblem* CreateLinearLeastSquaresProblemFromId(int id) {
return NULL; return NULL;
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
LinearLeastSquaresProblem* CreateLinearLeastSquaresProblemFromFile( LinearLeastSquaresProblem* CreateLinearLeastSquaresProblemFromFile(
const string& filename) { const string& filename) {
LinearLeastSquaresProblemProto problem_proto; LinearLeastSquaresProblemProto problem_proto;
@@ -130,7 +130,7 @@ LinearLeastSquaresProblem* CreateLinearLeastSquaresProblemFromFile(
<< "Ceres to be built with Protocol Buffers support."; << "Ceres to be built with Protocol Buffers support.";
return NULL; return NULL;
} }
#endif // CERES_DONT_HAVE_PROTOCOL_BUFFERS #endif // CERES_NO_PROTOCOL_BUFFERS
/* /*
A = [1 2] A = [1 2]
@@ -600,7 +600,7 @@ bool DumpLinearLeastSquaresProblemToConsole(const string& directory,
return true; return true;
}; };
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
bool DumpLinearLeastSquaresProblemToProtocolBuffer(const string& directory, bool DumpLinearLeastSquaresProblemToProtocolBuffer(const string& directory,
int iteration, int iteration,
const SparseMatrix* A, const SparseMatrix* A,
+1 -1
View File
@@ -33,7 +33,7 @@
#ifndef CERES_INTERNAL_MATRIX_PROTO_H_ #ifndef CERES_INTERNAL_MATRIX_PROTO_H_
#define CERES_INTERNAL_MATRIX_PROTO_H_ #define CERES_INTERNAL_MATRIX_PROTO_H_
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
#include "ceres/matrix.pb.h" #include "ceres/matrix.pb.h"
#endif #endif
+2 -2
View File
@@ -214,7 +214,7 @@ TEST_F(SchurEliminatorTest, ScalarProblem) {
EliminateSolveAndCompare(VectorRef(D.get(), A->num_cols()), false, 1e-14); EliminateSolveAndCompare(VectorRef(D.get(), A->num_cols()), false, 1e-14);
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
TEST_F(SchurEliminatorTest, BlockProblem) { TEST_F(SchurEliminatorTest, BlockProblem) {
const string input_file = TestFileAbsolutePath("problem-6-1384-000.lsqp"); const string input_file = TestFileAbsolutePath("problem-6-1384-000.lsqp");
@@ -223,7 +223,7 @@ TEST_F(SchurEliminatorTest, BlockProblem) {
EliminateSolveAndCompare(VectorRef(D.get(), A->num_cols()), true, 1e-10); EliminateSolveAndCompare(VectorRef(D.get(), A->num_cols()), true, 1e-10);
EliminateSolveAndCompare(VectorRef(D.get(), A->num_cols()), false, 1e-10); EliminateSolveAndCompare(VectorRef(D.get(), A->num_cols()), false, 1e-10);
} }
#endif // CERES_DONT_HAVE_PROTOCOL_BUFFERS #endif // CERES_NO_PROTOCOL_BUFFERS
} // namespace internal } // namespace internal
} // namespace ceres } // namespace ceres
+1 -1
View File
@@ -86,7 +86,7 @@ class SparseMatrix : public LinearOperator {
// sparse matrix. // sparse matrix.
virtual void ToDenseMatrix(Matrix* dense_matrix) const = 0; virtual void ToDenseMatrix(Matrix* dense_matrix) const = 0;
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
// Dump the sparse matrix to a proto. Destroys the contents of proto. // Dump the sparse matrix to a proto. Destroys the contents of proto.
virtual void ToProto(SparseMatrixProto* proto) const = 0; virtual void ToProto(SparseMatrixProto* proto) const = 0;
#endif #endif
+2 -2
View File
@@ -82,7 +82,7 @@ TripletSparseMatrix::TripletSparseMatrix(const TripletSparseMatrix& orig)
CopyData(orig); CopyData(orig);
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
TripletSparseMatrix::TripletSparseMatrix(const SparseMatrixProto& outer_proto) { TripletSparseMatrix::TripletSparseMatrix(const SparseMatrixProto& outer_proto) {
CHECK(outer_proto.has_triplet_matrix()); CHECK(outer_proto.has_triplet_matrix());
@@ -214,7 +214,7 @@ void TripletSparseMatrix::ToDenseMatrix(Matrix* dense_matrix) const {
} }
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
void TripletSparseMatrix::ToProto(SparseMatrixProto *proto) const { void TripletSparseMatrix::ToProto(SparseMatrixProto *proto) const {
proto->Clear(); proto->Clear();
+2 -2
View File
@@ -50,7 +50,7 @@ class TripletSparseMatrix : public SparseMatrix {
TripletSparseMatrix(); TripletSparseMatrix();
TripletSparseMatrix(int num_rows, int num_cols, int max_num_nonzeros); TripletSparseMatrix(int num_rows, int num_cols, int max_num_nonzeros);
explicit TripletSparseMatrix(const TripletSparseMatrix& orig); explicit TripletSparseMatrix(const TripletSparseMatrix& orig);
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
explicit TripletSparseMatrix(const SparseMatrixProto& proto); explicit TripletSparseMatrix(const SparseMatrixProto& proto);
#endif #endif
@@ -65,7 +65,7 @@ class TripletSparseMatrix : public SparseMatrix {
virtual void SquaredColumnNorm(double* x) const; virtual void SquaredColumnNorm(double* x) const;
virtual void ScaleColumns(const double* scale); virtual void ScaleColumns(const double* scale);
virtual void ToDenseMatrix(Matrix* dense_matrix) const; virtual void ToDenseMatrix(Matrix* dense_matrix) const;
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
virtual void ToProto(SparseMatrixProto *proto) const; virtual void ToProto(SparseMatrixProto *proto) const;
#endif #endif
virtual void ToTextFile(FILE* file) const; virtual void ToTextFile(FILE* file) const;
+1 -1
View File
@@ -318,7 +318,7 @@ TEST(TripletSparseMatrix, Resize) {
} }
} }
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
TEST(TripletSparseMatrix, Serialization) { TEST(TripletSparseMatrix, Serialization) {
TripletSparseMatrix m(2, 5, 4); TripletSparseMatrix m(2, 5, 4);
@@ -232,7 +232,7 @@ class VisibilityBasedPreconditionerTest : public ::testing::Test {
scoped_ptr<BlockRandomAccessDenseMatrix> schur_complement_; scoped_ptr<BlockRandomAccessDenseMatrix> schur_complement_;
}; };
#ifndef CERES_DONT_HAVE_PROTOCOL_BUFFERS #ifndef CERES_NO_PROTOCOL_BUFFERS
TEST_F(VisibilityBasedPreconditionerTest, SchurJacobiStructure) { TEST_F(VisibilityBasedPreconditionerTest, SchurJacobiStructure) {
options_.preconditioner_type = SCHUR_JACOBI; options_.preconditioner_type = SCHUR_JACOBI;
preconditioner_.reset( preconditioner_.reset(
@@ -352,7 +352,7 @@ TEST_F(VisibilityBasedPreconditionerTest, ClusterTridiagonal) {
EXPECT_TRUE(IsSparsityStructureValid()); EXPECT_TRUE(IsSparsityStructureValid());
EXPECT_TRUE(PreconditionerValuesMatch()); EXPECT_TRUE(PreconditionerValuesMatch());
} }
#endif // CERES_DONT_HAVE_PROTOCOL_BUFFERS #endif // CERES_NO_PROTOCOL_BUFFERS
} // namespace internal } // namespace internal
} // namespace ceres } // namespace ceres
+1 -1
View File
@@ -82,7 +82,7 @@ LOCAL_C_INCLUDES += $(EIGEN_PATH)
LOCAL_CPP_EXTENSION := .cc LOCAL_CPP_EXTENSION := .cc
LOCAL_CFLAGS := $(CERES_EXTRA_DEFINES) \ LOCAL_CFLAGS := $(CERES_EXTRA_DEFINES) \
-DCERES_DONT_HAVE_PROTOCOL_BUFFERS \ -DCERES_NO_PROTOCOL_BUFFERS \
-DCERES_NO_SUITESPARSE \ -DCERES_NO_SUITESPARSE \
-DCERES_NO_GFLAGS \ -DCERES_NO_GFLAGS \
-DCERES_NO_THREADS \ -DCERES_NO_THREADS \