Fixed a bunch of compiler warnings

release/4.3a0
Richard Roberts 2013-04-05 21:34:04 +00:00
parent 18f417581a
commit 547323cc79
22 changed files with 83 additions and 25 deletions

View File

@ -145,6 +145,10 @@ include_directories(
${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS})
if(MSVC)
add_definitions(/wd4251 /wd4275 /wd4251) # Disable non-DLL-exported base class warnings
endif()
###############################################################################
# Add components

View File

@ -113,7 +113,6 @@ if (GTSAM_BUILD_SHARED_LIBRARY)
PREFIX ""
DEFINE_SYMBOL GTSAM_EXPORTS
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
add_definitions(/wd4251 /wd4275) # Disable non-DLL-exported base class warnings
endif()
install(TARGETS gtsam-shared EXPORT GTSAM-exports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam-shared)

View File

@ -682,7 +682,7 @@ void svd(const Matrix& A, Matrix& U, Vector& S, Matrix& V) {
boost::tuple<int, double, Vector> DLT(const Matrix& A, double rank_tol) {
// Check size of A
int n = A.rows(), p = A.cols(), m = min(n,p);
size_t n = A.rows(), p = A.cols(), m = min(n,p);
// Do SVD on A
Eigen::JacobiSVD<Matrix> svd(A, Eigen::ComputeFullV);
@ -690,20 +690,20 @@ boost::tuple<int, double, Vector> DLT(const Matrix& A, double rank_tol) {
Matrix V = svd.matrixV();
// Find rank
int rank = 0;
for (int j = 0; j < m; j++)
size_t rank = 0;
for (size_t j = 0; j < m; j++)
if (s(j) > rank_tol) rank++;
// Return rank, error, and corresponding column of V
double error = m<p ? 0 : s(m-1);
return boost::tuple<int, double, Vector>(rank, error, Vector(column(V, p-1)));
return boost::tuple<int, double, Vector>((int)rank, error, Vector(column(V, p-1)));
}
/* ************************************************************************* */
Matrix expm(const Matrix& A, size_t K) {
Matrix E = eye(A.rows()), A_k = eye(A.rows());
for(size_t k=1;k<=K;k++) {
A_k = A_k*A/k;
A_k = A_k*A/double(k);
E = E + A_k;
}
return E;
@ -711,7 +711,7 @@ Matrix expm(const Matrix& A, size_t K) {
/* ************************************************************************* */
Matrix Cayley(const Matrix& A) {
int n = A.cols();
size_t n = A.cols();
assert(A.rows() == n);
// original

View File

@ -477,9 +477,9 @@ GTSAM_EXPORT Matrix Cayley(const Matrix& A);
/// Implementation of Cayley transform using fixed size matrices to let
/// Eigen do more optimization
template<int N>
Matrix Cayley(const Eigen::Matrix<double, N, N>& A) {
Eigen::Matrix<double, N, N> Cayley(const Eigen::Matrix<double, N, N>& A) {
typedef Eigen::Matrix<double, N, N> FMat;
return Matrix((FMat::Identity() - A)*(FMat::Identity() + A).inverse());
return Eigen::Matrix<double, N, N> = (FMat::Identity() - A)*(FMat::Identity() + A).inverse();
}
} // namespace gtsam

View File

@ -20,10 +20,14 @@
#pragma once
#include <boost/function.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include <boost/bind.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include <gtsam/base/LieVector.h>
#include <gtsam/base/Matrix.h>

View File

@ -84,6 +84,9 @@ namespace gtsam {
double R21, double R22, double R23,
double R31, double R32, double R33);
/** constructor from a rotation matrix */
Rot3(const Matrix3& R);
/** constructor from a rotation matrix */
Rot3(const Matrix& R);

View File

@ -49,10 +49,15 @@ Rot3::Rot3(double R11, double R12, double R13,
R31, R32, R33;
}
/* ************************************************************************* */
Rot3::Rot3(const Matrix3& R) {
rot_ = R;
}
/* ************************************************************************* */
Rot3::Rot3(const Matrix& R) {
if (R.rows()!=3 || R.cols()!=3)
throw invalid_argument("Rot3 constructor expects 3*3 matrix");
if (R.rows()!=3 || R.cols()!=3)
throw invalid_argument("Rot3 constructor expects 3*3 matrix");
rot_ = R;
}
@ -288,7 +293,7 @@ Vector3 Rot3::localCoordinates(const Rot3& T, Rot3::CoordinatesMode mode) const
// Create a fixed-size matrix
Eigen::Matrix3d A(between(T).matrix());
// using templated version of Cayley
Matrix Omega = Cayley<3>(A);
Eigen::Matrix3d Omega = Cayley<3>(A);
return -2*Vector3(Omega(2,1),Omega(0,2),Omega(1,0));
} else {
assert(false);

View File

@ -45,9 +45,13 @@ namespace gtsam {
R21, R22, R23,
R31, R32, R33).finished()) {}
/* ************************************************************************* */
Rot3::Rot3(const Matrix3& R) :
quaternion_(R) {}
/* ************************************************************************* */
Rot3::Rot3(const Matrix& R) :
quaternion_(Eigen::Matrix3d(R)) {}
quaternion_(R) {}
// /* ************************************************************************* */
// Rot3::Rot3(const Matrix3& R) :

View File

@ -17,10 +17,14 @@
#include <gtsam/base/FastSet.h>
#include <gtsam/inference/IndexConditional.h>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include <boost/lambda/lambda.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
namespace gtsam {

View File

@ -19,11 +19,15 @@
#include <stdexcept>
#include <boost/foreach.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunneeded-internal-declaration"
#endif
#include <boost/graph/breadth_first_search.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include <boost/graph/prim_minimum_spanning_tree.hpp>
#include <gtsam/inference/graph.h>

View File

@ -38,7 +38,7 @@ Permutation::shared_ptr PermutationCOLAMD_(const VariableIndex& variableIndex, s
gttic(Prepare);
size_t nEntries = variableIndex.nEntries(), nFactors = variableIndex.nFactors(), nVars = variableIndex.size();
// Convert to compressed column major format colamd wants it in (== MATLAB format!)
int Alen = ccolamd_recommended(nEntries, nFactors, nVars); /* colamd arg 3: size of the array A */
int Alen = ccolamd_recommended((int)nEntries, (int)nFactors, (int)nVars); /* colamd arg 3: size of the array A */
vector<int> A = vector<int>(Alen); /* colamd arg 4: row indices of A, of size Alen */
vector<int> p = vector<int>(nVars + 1); /* colamd arg 5: column pointers of A, of size n_col+1 */
@ -49,10 +49,10 @@ Permutation::shared_ptr PermutationCOLAMD_(const VariableIndex& variableIndex, s
for(Index var = 0; var < variableIndex.size(); ++var) {
const VariableIndex::Factors& column(variableIndex[var]);
size_t lastFactorId = numeric_limits<size_t>::max();
BOOST_FOREACH(const size_t& factorIndex, column) {
BOOST_FOREACH(size_t factorIndex, column) {
if(lastFactorId != numeric_limits<size_t>::max())
assert(factorIndex > lastFactorId);
A[count++] = factorIndex; // copy sparse column
A[count++] = (int)factorIndex; // copy sparse column
if(debug) cout << "A[" << count-1 << "] = " << factorIndex << endl;
}
p[var+1] = count; // column j (base 1) goes from A[j-1] to A[j]-1
@ -78,7 +78,7 @@ Permutation::shared_ptr PermutationCOLAMD_(const VariableIndex& variableIndex, s
/* returns (1) if successful, (0) otherwise*/
if(nVars > 0) {
gttic(ccolamd);
int rv = ccolamd(nFactors, nVars, Alen, &A[0], &p[0], knobs, stats, &cmember[0]);
int rv = ccolamd((int)nFactors, nVars, Alen, &A[0], &p[0], knobs, stats, &cmember[0]);
if(rv != 1)
throw runtime_error((boost::format("ccolamd failed with return value %1%")%rv).str());
}

View File

@ -17,11 +17,15 @@
#include <string.h>
#include <boost/format.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include <gtsam/linear/linearExceptions.h>
#include <gtsam/linear/GaussianConditional.h>

View File

@ -160,8 +160,8 @@ namespace gtsam {
Matrix IJS(3,nzmax);
for (size_t k = 0; k < result.size(); k++) {
const triplet& entry = result[k];
IJS(0,k) = entry.get<0>() + 1;
IJS(1,k) = entry.get<1>() + 1;
IJS(0,k) = double(entry.get<0>() + 1);
IJS(1,k) = double(entry.get<1>() + 1);
IJS(2,k) = entry.get<2>();
}
return IJS;

View File

@ -21,10 +21,14 @@
#include <boost/format.hpp>
#include <boost/make_shared.hpp>
#include <boost/tuple/tuple.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include <boost/bind.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include <gtsam/base/debug.h>
#include <gtsam/base/timing.h>

View File

@ -30,17 +30,20 @@
#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <boost/make_shared.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include <boost/bind.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include <cmath>
#include <sstream>
#include <stdexcept>
using namespace std;
//using namespace boost::lambda;
namespace gtsam {

View File

@ -427,7 +427,7 @@ namespace gtsam {
template<typename ITERATOR>
const Vector extractVectorValuesSlices(const VectorValues& values, ITERATOR first, ITERATOR last, bool allowNonexistant = false) {
// Find total dimensionality
int dim = 0;
size_t dim = 0;
for(ITERATOR j = first; j != last; ++j)
// If allowNonexistant is true, skip nonexistent indices (otherwise dim will throw an error on nonexistent)
if(!allowNonexistant || values.exists(*j))
@ -435,7 +435,7 @@ namespace gtsam {
// Copy vectors
Vector ret(dim);
int varStart = 0;
size_t varStart = 0;
for(ITERATOR j = first; j != last; ++j) {
// If allowNonexistant is true, skip nonexistent indices (otherwise dim will throw an error on nonexistent)
if(!allowNonexistant || values.exists(*j)) {
@ -453,7 +453,7 @@ namespace gtsam {
template<class VECTOR, typename ITERATOR>
void writeVectorValuesSlices(const VECTOR& vector, VectorValues& values, ITERATOR first, ITERATOR last) {
// Copy vectors
int varStart = 0;
size_t varStart = 0;
for(ITERATOR j = first; j != last; ++j) {
values[*j] = vector.segment(varStart, values[*j].rows());
varStart += values[*j].rows();

View File

@ -22,11 +22,15 @@
#include <boost/format.hpp>
#include <boost/function.hpp>
#include <boost/lambda/construct.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include <limits.h>
#include <list>

View File

@ -27,10 +27,14 @@
#include <list>
#include <boost/foreach.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include <boost/bind.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include <boost/iterator/transform_iterator.hpp>
using namespace std;

View File

@ -35,10 +35,14 @@
#include <boost/iterator/transform_iterator.hpp>
#include <boost/iterator/filter_iterator.hpp>
#include <boost/function.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include <boost/bind.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include <boost/ptr_container/serialize_ptr_map.hpp>
#include <boost/iterator_adaptors.hpp>

View File

@ -26,10 +26,14 @@
#include <CppUnitLite/TestHarness.h>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include <boost/bind.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include <boost/assign/list_of.hpp> // for 'list_of()'
#include <functional>
#include <boost/iterator/counting_iterator.hpp>

View File

@ -28,11 +28,15 @@
#include <boost/spirit/include/classic_confix.hpp>
#include <boost/spirit/include/classic_clear_actor.hpp>
#include <boost/spirit/include/classic_insert_at_actor.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include <boost/lambda/construct.hpp>
#include <boost/foreach.hpp>
#include <boost/filesystem.hpp>

View File

@ -97,7 +97,7 @@ void StaticMethod::proxy_wrapper_fragments(FileWriter& proxyFile, FileWriter& wr
const ReturnValue& returnVal = returnVals[overload];
size_t nrArgs = args.size();
const int id = functionNames.size();
const int id = (int)functionNames.size();
// Output proxy matlab code
@ -126,7 +126,7 @@ void StaticMethod::proxy_wrapper_fragments(FileWriter& proxyFile, FileWriter& wr
// Output C++ wrapper code
const string wrapFunctionName = wrapper_fragment(
wrapperFile, cppClassName, matlabUniqueName, overload, id, typeAttributes);
wrapperFile, cppClassName, matlabUniqueName, (int)overload, id, typeAttributes);
// Add to function list
functionNames.push_back(wrapFunctionName);