Fixed indentation

release/4.3a0
Richard Roberts 2010-02-08 22:21:56 +00:00
parent ed338300a1
commit ea9b44ea15
1 changed files with 345 additions and 345 deletions

View File

@ -15,23 +15,23 @@
namespace gtsam {
class SharedDiagonal; // forward declare, defined at end
class SharedDiagonal; // forward declare, defined at end
namespace noiseModel {
namespace noiseModel {
/**
/**
* noiseModel::Base is the abstract base class for all noise models.
*
* Noise models must implement a 'whiten' function to normalize an error vector,
* and an 'unwhiten' function to unnormalize an error vector.
*/
class Base : public Testable<Base> {
class Base : public Testable<Base> {
protected:
protected:
size_t dim_;
public:
public:
Base(size_t dim):dim_(dim) {}
virtual ~Base() {}
@ -60,9 +60,9 @@ public:
virtual void unwhitenInPlace(Vector& v) const {
v = unwhiten(v);
}
};
};
/**
/**
* Gaussian implements the mathematical model
* |R*x|^2 = |y|^2 with R'*R=inv(Sigma)
* where
@ -72,9 +72,9 @@ public:
* |y|^2 = y'*y = x'*R'*R*x
* Various derived classes are available that are more efficient.
*/
struct Gaussian: public Base {
struct Gaussian: public Base {
private:
private:
// TODO: store as boost upper-triangular or whatever is passed from above
/* Matrix square root of information matrix (R) */
@ -83,50 +83,50 @@ private:
/**
* Return R itself, but note that Whiten(H) is cheaper than R*H
*/
const Matrix& thisR() const {
const Matrix& thisR() const {
// should never happen
if (!sqrt_information_) throw std::runtime_error("Gaussian: has no R matrix");
return *sqrt_information_;
}
protected:
protected:
/** protected constructor takes square root information matrix */
Gaussian(size_t dim, const boost::optional<Matrix>& sqrt_information = boost::none) :
Base(dim), sqrt_information_(sqrt_information) {
}
public:
public:
typedef boost::shared_ptr<Gaussian> shared_ptr;
/**
/**
* A Gaussian noise model created by specifying a square root information matrix.
* @param smart, check if can be simplified to derived class
*/
static shared_ptr SqrtInformation(const Matrix& R) {
static shared_ptr SqrtInformation(const Matrix& R) {
return shared_ptr(new Gaussian(R.size1(),R));
}
}
/**
/**
* A Gaussian noise model created by specifying a covariance matrix.
* @param smart, check if can be simplified to derived class
*/
static shared_ptr Covariance(const Matrix& covariance, bool smart=false);
static shared_ptr Covariance(const Matrix& covariance, bool smart=false);
/**
/**
* A Gaussian noise model created by specifying an information matrix.
*/
static shared_ptr Information(const Matrix& Q) {
static shared_ptr Information(const Matrix& Q) {
return shared_ptr(new Gaussian(Q.size1(),square_root_positive(Q)));
}
}
virtual void print(const std::string& name) const;
virtual bool equals(const Base& expected, double tol) const;
virtual Vector whiten(const Vector& v) const;
virtual Vector whiten(const Vector& v) const;
virtual Vector unwhiten(const Vector& v) const;
/**
/**
* Mahalanobis distance v'*R'*R*v = <R*v,R*v>
*/
virtual double Mahalanobis(const Vector& v) const;
@ -142,46 +142,46 @@ virtual Vector whiten(const Vector& v) const;
*/
virtual void WhitenInPlace(Matrix& H) const;
/**
/**
* Whiten a system, in place as well
*/
inline void WhitenSystem(Matrix& A, Vector& b) const {
inline void WhitenSystem(Matrix& A, Vector& b) const {
WhitenInPlace(A);
whitenInPlace(b);
}
}
/**
/**
* Apply appropriately weighted QR factorization to the system [A b]
* Q' * [A b] = [R d]
* Dimensions: (r*m) * m*(n+1) = r*(n+1)
* @param Ab is the m*(n+1) augmented system matrix [A b]
* @return in-place QR factorization [R d]. Below-diagonal is undefined !!!!!
*/
virtual SharedDiagonal QR(Matrix& Ab) const;
virtual SharedDiagonal QR(Matrix& Ab) const;
/**
* Return R itself, but note that Whiten(H) is cheaper than R*H
*/
virtual Matrix R() const { return thisR();}
virtual Matrix R() const { return thisR();}
/**
/**
* Simple check for constrained-ness
*/
virtual bool isConstrained() const {return false;}
virtual bool isConstrained() const {return false;}
}; // Gaussian
}; // Gaussian
// FD: does not work, ambiguous overload :-(
// inline Vector operator*(const Gaussian& R, const Vector& v) {return R.whiten(v);}
// FD: does not work, ambiguous overload :-(
// inline Vector operator*(const Gaussian& R, const Vector& v) {return R.whiten(v);}
/**
/**
* A diagonal noise model implements a diagonal covariance matrix, with the
* elements of the diagonal specified in a Vector. This class has no public
* constructors, instead, use the static constructor functions Sigmas etc...
*/
class Diagonal : public Gaussian {
protected:
class Diagonal : public Gaussian {
protected:
/** sigmas and reciprocal */
Vector sigmas_, invsigmas_;
@ -189,7 +189,7 @@ protected:
/** protected constructor takes sigmas */
Diagonal(const Vector& sigmas);
public:
public:
typedef boost::shared_ptr<Diagonal> shared_ptr;
@ -237,9 +237,9 @@ public:
virtual Matrix R() const {
return diag(invsigmas_);
}
}; // Diagonal
}; // Diagonal
/**
/**
* A Constrained constrained model is a specialization of Diagonal which allows
* some or all of the sigmas to be zero, forcing the error to be zero there.
* All other Gaussian models are guaranteed to have a non-singular square-root
@ -247,8 +247,8 @@ public:
* singular noise models, specifically: whiten will return zero on those
* components that have zero sigma *and* zero error, infinity otherwise.
*/
class Constrained : public Diagonal {
protected:
class Constrained : public Diagonal {
protected:
// Constrained does not have member variables
// Instead (possibly zero) sigmas are stored in Diagonal Base class
@ -256,7 +256,7 @@ protected:
/** protected constructor takes sigmas */
Constrained(const Vector& sigmas) :Diagonal(sigmas) {}
public:
public:
typedef boost::shared_ptr<Constrained> shared_ptr;
@ -311,21 +311,21 @@ public:
*/
virtual bool isConstrained() const {return true;}
}; // Constrained
}; // Constrained
/**
/**
* An isotropic noise model corresponds to a scaled diagonal covariance
* To construct, use one of the static methods
*/
class Isotropic : public Diagonal {
protected:
class Isotropic : public Diagonal {
protected:
double sigma_, invsigma_;
/** protected constructor takes sigma */
Isotropic(size_t dim, double sigma) :
Diagonal(repeat(dim, sigma)),sigma_(sigma),invsigma_(1.0/sigma) {}
public:
public:
typedef boost::shared_ptr<Isotropic> shared_ptr;
@ -366,17 +366,17 @@ public:
*/
virtual Vector sample() const;
};
};
/**
/**
* Unit: i.i.d. unit-variance noise on all m dimensions.
*/
class Unit : public Isotropic {
protected:
class Unit : public Isotropic {
protected:
Unit(size_t dim): Isotropic(dim,1.0) {}
public:
public:
typedef boost::shared_ptr<Unit> shared_ptr;
@ -393,9 +393,9 @@ public:
virtual Vector unwhiten(const Vector& v) const { return v; }
virtual Matrix Whiten(const Matrix& H) const { return H; }
virtual void WhitenInPlace(Matrix& H) const {}
};
};
} // namespace noiseModel
} // namespace noiseModel
using namespace noiseModel;
using namespace noiseModel;
} // namespace gtsam