From 25a53815e01664d52847eaa41ade058d216b18ff Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Tue, 22 May 2012 22:52:08 +0000 Subject: [PATCH] Initial changes to compile on windows --- gtsam/base/DerivedValue.h | 2 +- gtsam/base/Matrix.cpp | 1 + gtsam/base/Matrix.h | 3 ++- gtsam/base/Vector.cpp | 5 +++-- gtsam/base/cholesky.cpp | 13 +++++++------ gtsam/base/timing.cpp | 8 +++++--- gtsam/base/types.h | 16 +++++++++++++++- 7 files changed, 34 insertions(+), 14 deletions(-) diff --git a/gtsam/base/DerivedValue.h b/gtsam/base/DerivedValue.h index 1919f9540..83ecea510 100644 --- a/gtsam/base/DerivedValue.h +++ b/gtsam/base/DerivedValue.h @@ -50,7 +50,7 @@ public: * Destroy and deallocate this object, only if it was originally allocated using clone_(). */ virtual void deallocate_() const { - this->~Value(); + this->Value::~Value(); boost::singleton_pool::free((void*)this); } diff --git a/gtsam/base/Matrix.cpp b/gtsam/base/Matrix.cpp index 849dc3f5a..050f66ff0 100644 --- a/gtsam/base/Matrix.cpp +++ b/gtsam/base/Matrix.cpp @@ -15,6 +15,7 @@ * @author Christian Potthast */ +#include #include #include #include diff --git a/gtsam/base/Matrix.h b/gtsam/base/Matrix.h index 3a70d9b76..fd7dac1fc 100644 --- a/gtsam/base/Matrix.h +++ b/gtsam/base/Matrix.h @@ -26,6 +26,7 @@ #include #include #include +#include /** * Matrix is a typedef in the gtsam namespace @@ -87,7 +88,7 @@ bool equal_with_abs_tol(const Eigen::DenseBase& A, const Eigen::DenseBas for(size_t i=0; i tol) return false; diff --git a/gtsam/base/Vector.cpp b/gtsam/base/Vector.cpp index 27b56830c..2d319961d 100644 --- a/gtsam/base/Vector.cpp +++ b/gtsam/base/Vector.cpp @@ -35,6 +35,7 @@ #include #include +#include using namespace std; @@ -169,7 +170,7 @@ bool equal_with_abs_tol(const Vector& vec1, const Vector& vec2, double tol) { if (vec1.size()!=vec2.size()) return false; size_t m = vec1.size(); for(size_t i=0; i tol) return false; @@ -182,7 +183,7 @@ bool equal_with_abs_tol(const SubVector& vec1, const SubVector& vec2, double tol if (vec1.size()!=vec2.size()) return false; size_t m = vec1.size(); for(size_t i=0; i tol) return false; diff --git a/gtsam/base/cholesky.cpp b/gtsam/base/cholesky.cpp index 66bbbde55..84c03f78b 100644 --- a/gtsam/base/cholesky.cpp +++ b/gtsam/base/cholesky.cpp @@ -16,6 +16,10 @@ * @date Nov 5, 2010 */ +#include +#include +#include + #include #include #include @@ -23,9 +27,6 @@ #include #include -#include -#include - using namespace std; namespace gtsam { @@ -129,7 +130,7 @@ void choleskyPartial(Matrix& ABC, size_t nFrontal) { tic(1, "lld"); ABC.block(0,0,nFrontal,nFrontal).triangularView() = ABC.block(0,0,nFrontal,nFrontal).selfadjointView().llt().matrixU(); - assert(ABC.topLeftCorner(nFrontal,nFrontal).triangularView().toDenseMatrix().unaryExpr(&isfinite).all()); + assert(ABC.topLeftCorner(nFrontal,nFrontal).triangularView().toDenseMatrix().unaryExpr(ptr_fun(isfinite)).all()); toc(1, "lld"); if(debug) cout << "R:\n" << Eigen::MatrixXd(ABC.topLeftCorner(nFrontal,nFrontal).triangularView()) << endl; @@ -140,7 +141,7 @@ void choleskyPartial(Matrix& ABC, size_t nFrontal) { ABC.topLeftCorner(nFrontal,nFrontal).triangularView().transpose().solveInPlace( ABC.topRightCorner(nFrontal, n-nFrontal)); } - assert(ABC.topRightCorner(nFrontal, n-nFrontal).unaryExpr(&isfinite).all()); + assert(ABC.topRightCorner(nFrontal, n-nFrontal).unaryExpr(ptr_fun(isfinite)).all()); if(debug) cout << "S:\n" << ABC.topRightCorner(nFrontal, n-nFrontal) << endl; toc(2, "compute S"); @@ -150,7 +151,7 @@ void choleskyPartial(Matrix& ABC, size_t nFrontal) { if(n - nFrontal > 0) ABC.bottomRightCorner(n-nFrontal,n-nFrontal).selfadjointView().rankUpdate( ABC.topRightCorner(nFrontal, n-nFrontal).transpose(), -1.0); - assert(ABC.bottomRightCorner(n-nFrontal,n-nFrontal).selfadjointView().toDenseMatrix().unaryExpr(&isfinite).all()); + assert(ABC.bottomRightCorner(n-nFrontal,n-nFrontal).selfadjointView().toDenseMatrix().unaryExpr(ptr_fun(isfinite)).all()); if(debug) cout << "L:\n" << Eigen::MatrixXd(ABC.bottomRightCorner(n-nFrontal,n-nFrontal).selfadjointView()) << endl; toc(3, "compute L"); } diff --git a/gtsam/base/timing.cpp b/gtsam/base/timing.cpp index 393791e6a..305f86a74 100644 --- a/gtsam/base/timing.cpp +++ b/gtsam/base/timing.cpp @@ -241,9 +241,11 @@ void Timing::print() { /* ************************************************************************* */ double _tic_() { - struct timeval t; - gettimeofday(&t, NULL); - return ((double)t.tv_sec + ((double)t.tv_usec)/1000000.); + typedef boost::chrono::high_resolution_clock clock_t; + typedef boost::chrono::duration duration_t; + + clock_t::time_point t = clock_t::now(); + return boost::chrono::duration_cast< duration_t >(t.time_since_epoch()).count(); } /* ************************************************************************* */ diff --git a/gtsam/base/types.h b/gtsam/base/types.h index b6c5617a5..6106f49fd 100644 --- a/gtsam/base/types.h +++ b/gtsam/base/types.h @@ -19,7 +19,7 @@ #pragma once -#include +#include namespace gtsam { @@ -71,3 +71,17 @@ namespace gtsam { } +#ifdef _MSC_VER + +#include +using boost::math::isfinite; +using boost::math::isnan; +using boost::math::isinf; + +#include +#ifndef M_PI +#define M_PI (boost::math::constants::pi()) +#endif + +#endif +