release/4.3a0
Rahul Sawhney 2010-10-21 21:12:37 +00:00
parent 0245ab06d2
commit c7248a2b13
4 changed files with 5 additions and 81 deletions

View File

@ -139,36 +139,7 @@ bool GaussianConditional::equals(const GaussianConditional &c, double tol) const
return true; return true;
} }
///* ************************************************************************* */
//void GaussianConditional::permuteWithInverse(const Permutation& inversePermutation) {
// Conditional::permuteWithInverse(inversePermutation);
// BOOST_FOREACH(Parents::value_type& parent, parents_) {
// parent.first = inversePermutation[parent.first];
// }
//#ifndef NDEBUG
// const_iterator parent = parents_.begin();
// Conditional::const_iterator baseParent = Conditional::parents_.begin();
// while(parent != parents_.end())
// assert((parent++)->first == *(baseParent++));
// assert(baseParent == Conditional::parents_.end());
//#endif
//}
//
///* ************************************************************************* */
//bool GaussianConditional::permuteSeparatorWithInverse(const Permutation& inversePermutation) {
// bool separatorChanged = Conditional::permuteSeparatorWithInverse(inversePermutation);
// BOOST_FOREACH(Parents::value_type& parent, parents_) {
// parent.first = inversePermutation[parent.first];
// }
//#ifndef NDEBUG
// const_iterator parent = parents_.begin();
// Conditional::const_iterator baseParent = Conditional::parents_.begin();
// while(parent != parents_.end())
// assert((parent++)->first == *(baseParent++));
// assert(baseParent == Conditional::parents_.end());
//#endif
// return separatorChanged;
//}
/* ************************************************************************* */ /* ************************************************************************* */
Vector GaussianConditional::solve(const VectorValues& x) const { Vector GaussianConditional::solve(const VectorValues& x) const {
@ -177,7 +148,7 @@ Vector GaussianConditional::solve(const VectorValues& x) const {
Vector rhs(get_d()); Vector rhs(get_d());
for (const_iterator parent = beginParents(); parent != endParents(); ++parent) { for (const_iterator parent = beginParents(); parent != endParents(); ++parent) {
ublas::axpy_prod(-get_S(parent), x[*parent], rhs, false); ublas::axpy_prod(-get_S(parent), x[*parent], rhs, false);
// multiplyAdd(-1.0, get_S(parent), x[*parent], rhs);
} }
if(debug) gtsam::print(get_R(), "Calling backSubstituteUpper on "); if(debug) gtsam::print(get_R(), "Calling backSubstituteUpper on ");
if(debug) gtsam::print(rhs, "rhs: "); if(debug) gtsam::print(rhs, "rhs: ");
@ -194,7 +165,7 @@ Vector GaussianConditional::solve(const Permuted<VectorValues>& x) const {
Vector rhs(get_d()); Vector rhs(get_d());
for (const_iterator parent = beginParents(); parent != endParents(); ++parent) { for (const_iterator parent = beginParents(); parent != endParents(); ++parent) {
ublas::axpy_prod(-get_S(parent), x[*parent], rhs, false); ublas::axpy_prod(-get_S(parent), x[*parent], rhs, false);
// multiplyAdd(-1.0, get_S(parent), x[*parent], rhs);
} }
return backSubstituteUpper(get_R(), rhs, false); return backSubstituteUpper(get_R(), rhs, false);
} }

View File

@ -109,15 +109,6 @@ public:
/** equals function */ /** equals function */
bool equals(const GaussianConditional &cg, double tol = 1e-9) const; bool equals(const GaussianConditional &cg, double tol = 1e-9) const;
// /** permute the variables in the conditional */
// void permuteWithInverse(const Permutation& inversePermutation);
//
// /** Permute the variables when only separator variables need to be permuted.
// * Returns true if any reordered variables appeared in the separator and
// * false if not.
// */
// bool permuteSeparatorWithInverse(const Permutation& inversePermutation);
/** dimension of multivariate variable */ /** dimension of multivariate variable */
size_t dim() const { return rsd_.size1(); } size_t dim() const { return rsd_.size1(); }

View File

@ -36,7 +36,7 @@
#include <gtsam/linear/GaussianFactorGraph.h> #include <gtsam/linear/GaussianFactorGraph.h>
using namespace std; using namespace std;
//using namespace boost::assign;
namespace ublas = boost::numeric::ublas; namespace ublas = boost::numeric::ublas;
using namespace boost::lambda; using namespace boost::lambda;
@ -247,21 +247,6 @@ double GaussianFactor::error(const VectorValues& c) const {
return 0.5 * inner_prod(weighted,weighted); return 0.5 * inner_prod(weighted,weighted);
} }
///* ************************************************************************* */
//Dimensions GaussianFactor::dimensions() const {
// Dimensions result;
// BOOST_FOREACH(const NamedMatrix& jA, As_)
// result.insert(std::pair<Index,size_t>(jA.first,jA.second.size2()));
// return result;
//}
//
///* ************************************************************************* */
//void GaussianFactor::tally_separator(Index key, set<Index>& separator) const {
// if(involves(key)) {
// BOOST_FOREACH(const NamedMatrix& jA, As_)
// if(jA.first != key) separator.insert(jA.first);
// }
//}
/* ************************************************************************* */ /* ************************************************************************* */
Vector GaussianFactor::operator*(const VectorValues& x) const { Vector GaussianFactor::operator*(const VectorValues& x) const {
@ -271,23 +256,10 @@ Vector GaussianFactor::operator*(const VectorValues& x) const {
// Just iterate over all A matrices and multiply in correct config part // Just iterate over all A matrices and multiply in correct config part
for(size_t pos=0; pos<keys_.size(); ++pos) for(size_t pos=0; pos<keys_.size(); ++pos)
Ax += ublas::prod(Ab_(pos), x[keys_[pos]]); Ax += ublas::prod(Ab_(pos), x[keys_[pos]]);
// BOOST_FOREACH(const NamedMatrix& jA, As_)
// Ax += (jA.second * x[jA.first]);
return model_->whiten(Ax); return model_->whiten(Ax);
} }
///* ************************************************************************* */
//VectorValues GaussianFactor::operator^(const Vector& e) const {
// Vector E = model_->whiten(e);
// VectorValues x;
// // Just iterate over all A matrices and insert Ai^e into VectorValues
// for(size_t pos=0; pos<keys_.size(); ++pos)
// x.insert(keys_[pos], ARange(pos)^E);
//// BOOST_FOREACH(const NamedMatrix& jA, As_)
//// x.insert(jA.first,jA.second^E);
// return x;
//}
/* ************************************************************************* */ /* ************************************************************************* */
void GaussianFactor::transposeMultiplyAdd(double alpha, const Vector& e, void GaussianFactor::transposeMultiplyAdd(double alpha, const Vector& e,
@ -296,8 +268,6 @@ void GaussianFactor::transposeMultiplyAdd(double alpha, const Vector& e,
// Just iterate over all A matrices and insert Ai^e into VectorValues // Just iterate over all A matrices and insert Ai^e into VectorValues
for(size_t pos=0; pos<keys_.size(); ++pos) for(size_t pos=0; pos<keys_.size(); ++pos)
gtsam::transposeMultiplyAdd(1.0, Ab_(pos), E, x[keys_[pos]]); gtsam::transposeMultiplyAdd(1.0, Ab_(pos), E, x[keys_[pos]]);
// BOOST_FOREACH(const NamedMatrix& jA, As_)
// gtsam::transposeMultiplyAdd(1.0, jA.second, E, x[jA.first]);
} }
/* ************************************************************************* */ /* ************************************************************************* */
@ -392,8 +362,7 @@ GaussianConditional::shared_ptr GaussianFactor::eliminateFirst() {
for(size_t j=0; j<matrix_.size2(); ++j) for(size_t j=0; j<matrix_.size2(); ++j)
for(size_t i=j+1; i<noiseModel->dim(); ++i) for(size_t i=j+1; i<noiseModel->dim(); ++i)
matrix_(i,j) = 0.0; matrix_(i,j) = 0.0;
// ublas::triangular_adaptor<matrix_type, ublas::strict_lower> AbLower(Ab_);
// fill(AbLower.begin1(), AbLower.end1(), 0.0);
} }
if(debug) gtsam::print(matrix_, "QR result: "); if(debug) gtsam::print(matrix_, "QR result: ");
@ -509,8 +478,6 @@ GaussianBayesNet::shared_ptr GaussianFactor::eliminate(size_t nrFrontals) {
for(size_t j=0; j<matrix_.size2(); ++j) for(size_t j=0; j<matrix_.size2(); ++j)
for(size_t i=j+1; i<noiseModel->dim(); ++i) for(size_t i=j+1; i<noiseModel->dim(); ++i)
matrix_(i,j) = 0.0; matrix_(i,j) = 0.0;
// ublas::triangular_adaptor<matrix_type, ublas::strict_lower> AbLower(Ab_);
// fill(AbLower.begin1(), AbLower.end1(), 0.0);
} }
if(debug) gtsam::print(matrix_, "QR result: "); if(debug) gtsam::print(matrix_, "QR result: ");

View File

@ -22,7 +22,6 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
//#include <boost/serialization/map.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/lambda/lambda.hpp> #include <boost/lambda/lambda.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
@ -110,8 +109,6 @@ public:
/** Construct from Conditional Gaussian */ /** Construct from Conditional Gaussian */
GaussianFactor(const GaussianConditional& cg); GaussianFactor(const GaussianConditional& cg);
// /** Constructor that combines a set of factors */
// GaussianFactor(const std::vector<shared_ptr> & factors);
// Implementing Testable interface // Implementing Testable interface
void print(const std::string& s = "") const; void print(const std::string& s = "") const;
@ -191,8 +188,6 @@ public:
/** Return A*x */ /** Return A*x */
Vector operator*(const VectorValues& x) const; Vector operator*(const VectorValues& x) const;
// /** Return A'*e */
// VectorValues operator^(const Vector& e) const;
/** x += A'*e */ /** x += A'*e */
void transposeMultiplyAdd(double alpha, const Vector& e, VectorValues& x) const; void transposeMultiplyAdd(double alpha, const Vector& e, VectorValues& x) const;