20 #include <boost/make_shared.hpp> 21 #include <boost/format.hpp> 28 std::cout << s <<
" keys = { ";
30 std::cout << keyFormatter(
key) <<
" ";
32 std::cout <<
"}" << std::endl;
42 const std::map<Key, Key>& rekey_mapping)
const {
44 for (
size_t i = 0;
i < new_factor->size(); ++
i) {
45 Key& cur_key = new_factor->keys()[
i];
46 std::map<Key, Key>::const_iterator mapping = rekey_mapping.find(cur_key);
47 if (mapping != rekey_mapping.end())
48 cur_key = mapping->second;
56 assert(new_keys.size() ==
keys().size());
58 new_factor->keys() = new_keys;
67 noiseModel_->print(
" noise model: ");
89 if (noiseModel && m != noiseModel->dim())
90 throw std::invalid_argument(
93 "NoiseModelFactor: NoiseModel has dimension %1% instead of %2%.")
94 % noiseModel->dim() %
m));
99 const Vector b = unwhitenedError(c);
100 check(noiseModel_, b.size());
101 return noiseModel_ ? noiseModel_->whiten(b) :
b;
106 const Vector b = unwhitenedError(c);
107 check(noiseModel_, b.size());
108 return noiseModel_ ? noiseModel_->unweightedWhiten(b) :
b;
115 const Vector b = unwhitenedError(c);
116 check(noiseModel_, b.size());
117 return 0.5 * noiseModel_->weight(b);
129 const Vector b = unwhitenedError(c);
130 check(noiseModel_, b.size());
132 return noiseModel_->loss(noiseModel_->squaredMahalanobisDistance(b));
134 return 0.5 * b.squaredNorm();
146 return boost::shared_ptr<JacobianFactor>();
149 std::vector<Matrix>
A(
size());
150 Vector b = -unwhitenedError(x, A);
151 check(noiseModel_, b.size());
155 noiseModel_->WhitenSystem(A, b);
158 std::vector<std::pair<Key, Matrix> > terms(
size());
159 for (
size_t j = 0;
j <
size(); ++
j) {
160 terms[
j].first =
keys()[
j];
161 terms[
j].second.swap(A[
j]);
166 if (noiseModel_ && noiseModel_->isConstrained())
169 boost::static_pointer_cast<Constrained>(noiseModel_)->unit()));
bool equals(const This &other, double tol=1e-9) const
check equality
boost::shared_ptr< GaussianFactor > linearize(const Values &x) const override
double error(const Values &c) const override
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
virtual bool active(const Values &) const
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
double weight(const Values &c) const
Vector unweightedWhitenedError(const Values &c) const
boost::shared_ptr< This > shared_ptr
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
virtual void print(const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
print
virtual bool equals(const NonlinearFactor &f, double tol=1e-9) const
boost::shared_ptr< This > shared_ptr
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
boost::shared_ptr< Factor > shared_ptr
A shared_ptr to this class.
SharedNoiseModel noiseModel_
Non-linear factor base classes.
const KeyVector & keys() const
Access the factor's involved variable keys.
shared_ptr cloneWithNewNoiseModel(const SharedNoiseModel newNoise) const
shared_ptr rekey(const std::map< Key, Key > &rekey_mapping) const
Vector whitenedError(const Values &c) const
virtual shared_ptr clone() const
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
static void check(const SharedNoiseModel &noiseModel, size_t m)
std::uint64_t Key
Integer nonlinear key type.
noiseModel::Base::shared_ptr SharedNoiseModel