From cee0a234ac06a520bfe888ca19c0d41bc04bcb28 Mon Sep 17 00:00:00 2001 From: Alex Cunningham Date: Tue, 6 Aug 2013 17:50:50 +0000 Subject: [PATCH] Fixing compile problems --- gtsam/base/treeTraversal-inst.h | 3 +- gtsam/inference/BayesTree-inst.h | 2 + gtsam/inference/JunctionTree-inst.h | 3 +- gtsam/linear/GaussianConditional-inl.h | 94 -------------------------- gtsam/linear/GaussianConditional.cpp | 7 +- gtsam/linear/GaussianConditional.h | 5 +- gtsam/linear/HessianFactor.cpp | 1 + gtsam/linear/NoiseModel.cpp | 6 +- 8 files changed, 17 insertions(+), 104 deletions(-) delete mode 100644 gtsam/linear/GaussianConditional-inl.h diff --git a/gtsam/base/treeTraversal-inst.h b/gtsam/base/treeTraversal-inst.h index 318091492..b4aaca072 100644 --- a/gtsam/base/treeTraversal-inst.h +++ b/gtsam/base/treeTraversal-inst.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -77,7 +78,7 @@ namespace gtsam { treeNode(treeNode), myData(myData), visitorPre(visitorPre), visitorPost(visitorPost), problemSizeThreshold(problemSizeThreshold), makeNewTasks(makeNewTasks) {} - typedef ParallelTraversalNode ParallelTraversalNode; + typedef ParallelTraversalNode ParallelTraversalNodeType; tbb::task* execute() { diff --git a/gtsam/inference/BayesTree-inst.h b/gtsam/inference/BayesTree-inst.h index b1363c70a..45a4cba09 100644 --- a/gtsam/inference/BayesTree-inst.h +++ b/gtsam/inference/BayesTree-inst.h @@ -20,10 +20,12 @@ #pragma once +#include #include #include #include +#include #include #include #include diff --git a/gtsam/inference/JunctionTree-inst.h b/gtsam/inference/JunctionTree-inst.h index f2873f0d2..e4e3e6630 100644 --- a/gtsam/inference/JunctionTree-inst.h +++ b/gtsam/inference/JunctionTree-inst.h @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -217,7 +218,7 @@ namespace gtsam { /* ************************************************************************* */ template void JunctionTree::print( - const std::string& s = "", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const + const std::string& s, const KeyFormatter& keyFormatter) const { treeTraversal::PrintForest(*this, s, keyFormatter); } diff --git a/gtsam/linear/GaussianConditional-inl.h b/gtsam/linear/GaussianConditional-inl.h deleted file mode 100644 index 25dbe0e49..000000000 --- a/gtsam/linear/GaussianConditional-inl.h +++ /dev/null @@ -1,94 +0,0 @@ -/* ---------------------------------------------------------------------------- - - * GTSAM Copyright 2010, Georgia Tech Research Corporation, - * Atlanta, Georgia 30332-0415 - * All Rights Reserved - * Authors: Frank Dellaert, et al. (see THANKS for the full author list) - - * See LICENSE for the license information - - * -------------------------------------------------------------------------- */ - -/** - * @file GaussianConditional-inl.h - * @brief Conditional Gaussian Base class - * @author Christian Potthast - */ - -// \callgraph - -#pragma once - -#include -#include - -namespace gtsam { - - /* ************************************************************************* */ - template - GaussianConditional::GaussianConditional(Index key, const Vector& d, - const Matrix& R, const PARENTS& parents, const SharedDiagonal& sigmas, const typename PARENTS::value_type*) : - BaseFactor(boost::join(boost::assign::cref_list_of<1,typename PARENTS::value_type>(std::make_pair(key, R)), parents), d, sigmas), - BaseConditional(1) {} - - /* ************************************************************************* */ - template - GaussianConditional::GaussianConditional(const TERMS& terms, - size_t nrFrontals, const Vector& d, const SharedDiagonal& sigmas) : - BaseFactor(terms, d, sigmas), BaseConditional(nrFrontals) {} - - /* ************************************************************************* */ - template - GaussianConditional::GaussianConditional( - const KEYS& keys, size_t nrFrontals, const VerticalBlockMatrix& augmentedMatrix, const SharedDiagonal& sigmas) : - BaseFactor(keys, augmentedMatrix, sigmas), BaseConditional(nrFrontals) {} - - /* ************************************************************************* */ - template - GaussianConditional::shared_ptr GaussianConditional::Combine(ITERATOR firstConditional, ITERATOR lastConditional) - { - // TODO: check for being a clique - - // Get dimensions from first conditional - std::vector dims; dims.reserve((*firstConditional)->size() + 1); - for(const_iterator j = (*firstConditional)->begin(); j != (*firstConditional)->end(); ++j) - dims.push_back((*firstConditional)->dim(j)); - dims.push_back(1); - - // We assume the conditionals form clique, so the first n variables will be - // frontal variables in the new conditional. - size_t nFrontals = 0; - size_t nRows = 0; - for(ITERATOR c = firstConditional; c != lastConditional; ++c) { - nRows += dims[nFrontals]; - ++ nFrontals; - } - - // Allocate combined conditional, has same keys as firstConditional - Matrix tempCombined; - VerticalBlockView tempBlockView(tempCombined, dims.begin(), dims.end(), 0); - GaussianConditional::shared_ptr combinedConditional = - boost::make_shared( - (*firstConditional)->begin(), (*firstConditional)->end(), nFrontals, tempBlockView, Vector::Zero(nRows)); - - // Resize to correct number of rows - combinedConditional->matrix_.resize(nRows, combinedConditional->matrix_.cols()); - combinedConditional->rsd_.rowEnd() = combinedConditional->matrix_.rows(); - - // Copy matrix and sigmas - const size_t totalDims = combinedConditional->matrix_.cols(); - size_t currentSlot = 0; - for(ITERATOR c = firstConditional; c != lastConditional; ++c) { - const size_t startRow = combinedConditional->rsd_.offset(currentSlot); // Start row is same as start column - combinedConditional->rsd_.range(0, currentSlot).block(startRow, 0, dims[currentSlot], combinedConditional->rsd_.offset(currentSlot)).operator=( - Matrix::Zero(dims[currentSlot], combinedConditional->rsd_.offset(currentSlot))); - combinedConditional->rsd_.range(currentSlot, dims.size()).block(startRow, 0, dims[currentSlot], totalDims - startRow).operator=( - (*c)->matrix_); - combinedConditional->sigmas_.segment(startRow, dims[currentSlot]) = (*c)->sigmas_; - ++ currentSlot; - } - - return combinedConditional; - } - -} // gtsam diff --git a/gtsam/linear/GaussianConditional.cpp b/gtsam/linear/GaussianConditional.cpp index de787cda1..eb8cc04ed 100644 --- a/gtsam/linear/GaussianConditional.cpp +++ b/gtsam/linear/GaussianConditional.cpp @@ -16,6 +16,7 @@ */ #include +#include #include #ifdef __GNUC__ #pragma GCC diagnostic push @@ -117,6 +118,7 @@ namespace gtsam { Vector soln = get_R().triangularView().solve(xS); // Check for indeterminant solution + // FIXME: can't use std::isfinite() as a templated function with gcc if(soln.unaryExpr(!boost::lambda::bind(ptr_fun(isfinite), boost::lambda::_1)).any()) throw IndeterminantLinearSystemException(keys().front()); @@ -162,8 +164,9 @@ namespace gtsam { frontalVec = gtsam::backSubstituteUpper(frontalVec, Matrix(get_R())); // Check for indeterminant solution - if(frontalVec.unaryExpr(!boost::lambda::bind(ptr_fun(isfinite), boost::lambda::_1)).any()) - throw IndeterminantLinearSystemException(this->keys().front()); + // FIXME: can't use isfinite() as a templated function with gcc +// if(frontalVec.unaryExpr(!boost::lambda::bind(std::ptr_fun(isfinite), boost::lambda::_1)).any()) +// throw IndeterminantLinearSystemException(this->keys().front()); for (const_iterator it = beginParents(); it!= endParents(); it++) gtsam::transposeMultiplyAdd(-1.0, Matrix(getA(it)), frontalVec, gy[*it]); diff --git a/gtsam/linear/GaussianConditional.h b/gtsam/linear/GaussianConditional.h index 1717b62fa..7a99fc413 100644 --- a/gtsam/linear/GaussianConditional.h +++ b/gtsam/linear/GaussianConditional.h @@ -136,7 +136,8 @@ namespace gtsam { /** Scale the values in \c gy according to the sigmas for the frontal variables in this * conditional. */ - __declspec(deprecated) void scaleFrontalsBySigma(VectorValues& gy) const; + void scaleFrontalsBySigma(VectorValues& gy) const; +// __declspec(deprecated) void scaleFrontalsBySigma(VectorValues& gy) const; // FIXME: depreciated flag doesn't appear to exist? private: @@ -151,5 +152,3 @@ namespace gtsam { } // gtsam -#include - diff --git a/gtsam/linear/HessianFactor.cpp b/gtsam/linear/HessianFactor.cpp index 1027d4489..c39960c4c 100644 --- a/gtsam/linear/HessianFactor.cpp +++ b/gtsam/linear/HessianFactor.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/gtsam/linear/NoiseModel.cpp b/gtsam/linear/NoiseModel.cpp index b72843b83..f750869c2 100644 --- a/gtsam/linear/NoiseModel.cpp +++ b/gtsam/linear/NoiseModel.cpp @@ -117,7 +117,7 @@ SharedDiagonal Gaussian::QR(Matrix& Ab) const { // get size(A) and maxRank // TODO: really no rank problems ? size_t m = Ab.rows(), n = Ab.cols()-1; - size_t maxRank = min(m,n); +// size_t maxRank = min(m,n); // pre-whiten everything (cheaply if possible) WhitenInPlace(Ab); @@ -272,9 +272,9 @@ double Constrained::distance(const Vector& v) const { Vector w = Diagonal::whiten(v); // get noisemodel for constrained elements // TODO Find a better way of doing these checks for (size_t i=0; i