add a null model for comparison

release/4.3a0
Yong-Dian Jian 2011-08-29 04:51:17 +00:00
parent 22cce59f2c
commit e9504bd470
2 changed files with 18 additions and 1 deletions

View File

@ -490,6 +490,12 @@ void Base::reweight(Matrix &A1, Matrix &A2, Matrix &A3, Vector &error) const {
} }
} }
void Null::print(const std::string &s) const
{ cout << s << ": null ()" << endl; }
Null::shared_ptr Null::Create()
{ return shared_ptr(new Null()); }
Fair::Fair(const double c, const ReweightScheme reweight) Fair::Fair(const double c, const ReweightScheme reweight)
: Base(reweight), c_(c) { : Base(reweight), c_(c) {
if ( c_ <= 0 ) { if ( c_ <= 0 ) {

View File

@ -514,7 +514,7 @@ namespace gtsam {
ReweightScheme reweight_; ReweightScheme reweight_;
public: public:
Base():reweight_(Block) {} Base(): reweight_(Block) {}
Base(const ReweightScheme reweight):reweight_(reweight) {} Base(const ReweightScheme reweight):reweight_(reweight) {}
virtual ~Base() {} virtual ~Base() {}
virtual double weight(const double &error) const = 0; virtual double weight(const double &error) const = 0;
@ -526,6 +526,17 @@ namespace gtsam {
void reweight(Matrix &A1, Matrix &A2, Matrix &A3, Vector &error) const; void reweight(Matrix &A1, Matrix &A2, Matrix &A3, Vector &error) const;
}; };
class Null : public Base {
public:
typedef boost::shared_ptr<Null> shared_ptr;
Null(const ReweightScheme reweight = Block) : Base(reweight) {}
virtual ~Null() {}
virtual double weight(const double &error) const { return 1.0; }
virtual void print(const std::string &s) const ;
virtual bool equals(const Base& expected, const double tol=1e-8) const { return true; }
static shared_ptr Create() ;
};
class Fair : public Base { class Fair : public Base {
public: public:
typedef boost::shared_ptr<Fair> shared_ptr; typedef boost::shared_ptr<Fair> shared_ptr;