27 namespace noiseModel {
33 namespace mEstimator {
36 const size_t n = error.rows();
38 for (
size_t i = 0;
i <
n; ++
i)
44 return weight(error).cwiseSqrt();
51 if (reweight_ == Block) {
52 const double w = sqrtWeight(error.norm());
55 error.array() *= weight(error).cwiseSqrt().array();
61 if ( reweight_ == Block ) {
62 const double w = sqrtWeight(error.norm());
69 const Vector W = sqrtWeight(error);
73 error = W.cwiseProduct(error);
79 if ( reweight_ == Block ) {
80 const double w = sqrtWeight(error.norm());
85 const Vector W = sqrtWeight(error);
87 error = W.cwiseProduct(error);
93 if ( reweight_ == Block ) {
94 const double w = sqrtWeight(error.norm());
100 const Vector W = sqrtWeight(error);
103 error = W.cwiseProduct(error);
109 if ( reweight_ == Block ) {
110 const double w = sqrtWeight(error.norm());
117 const Vector W = sqrtWeight(error);
121 error = W.cwiseProduct(error);
130 { cout <<
s <<
"null ()" << endl; }
141 throw runtime_error(
"mEstimator Fair takes only positive double in constructor.");
150 const double absError =
std::abs(distance);
151 const double normalizedError = absError /
c_;
152 const double c_2 =
c_ *
c_;
153 return c_2 * (normalizedError -
std::log1p(normalizedError));
157 { cout <<
s <<
"fair (" <<
c_ <<
")" << endl; }
161 if (p ==
nullptr)
return false;
174 throw runtime_error(
"mEstimator Huber takes only positive double in constructor.");
179 const double absError =
std::abs(distance);
180 return (absError <=
k_) ? (1.0) : (
k_ / absError);
184 const double absError =
std::abs(distance);
185 if (absError <=
k_) {
186 return distance*distance / 2;
188 return k_ * (absError - (
k_/2));
193 cout <<
s <<
"huber (" <<
k_ <<
")" << endl;
198 if (p ==
nullptr)
return false;
212 throw runtime_error(
"mEstimator Cauchy takes only positive double in constructor.");
226 cout <<
s <<
"cauchy (" <<
k_ <<
")" << endl;
231 if (p ==
nullptr)
return false;
245 throw runtime_error(
"mEstimator Tukey takes only positive double in constructor.");
251 const double one_minus_xc2 = 1.0 - distance*distance/
csquared_;
252 return one_minus_xc2 * one_minus_xc2;
258 double absError =
std::abs(distance);
259 if (absError <=
c_) {
260 const double one_minus_xc2 = 1.0 - distance*distance/
csquared_;
261 const double t = one_minus_xc2*one_minus_xc2*one_minus_xc2;
269 std::cout <<
s <<
": Tukey (" <<
c_ <<
")" << std::endl;
274 if (p ==
nullptr)
return false;
299 std::cout <<
s <<
": Welsch (" <<
c_ <<
")" << std::endl;
304 if (p ==
nullptr)
return false;
320 const double c2 =
c_*
c_;
321 const double c4 = c2*c2;
322 const double c2error = c2 + distance*
distance;
323 return c4/(c2error*c2error);
327 const double c2 =
c_*
c_;
328 const double error2 = distance*
distance;
329 return 0.5 * (c2 * error2) / (c2 + error2);
333 std::cout <<
s <<
": Geman-McClure (" <<
c_ <<
")" << std::endl;
338 if (p ==
nullptr)
return false;
354 const double e2 = distance*
distance;
357 const double w = 2.0*
c_/(
c_ + e2);
367 const double e2 = distance*
distance;
368 const double e4 = e2*e2;
369 const double c2 =
c_*
c_;
371 return (c2*e2 + c_*e4) / ((e2 +
c_)*(e2 + c_));
375 std::cout <<
s <<
": DCS (" <<
c_ <<
")" << std::endl;
380 if (p ==
nullptr)
return false;
393 :
Base(reweight), k_(k) {
395 throw runtime_error(
"mEstimator L2WithDeadZone takes only positive double in constructor.");
409 const double abs_error =
std::abs(distance);
410 return (abs_error <
k_) ? 0.0 : 0.5*(
k_-abs_error)*(
k_-abs_error);
414 std::cout <<
s <<
": L2WithDeadZone (" <<
k_ <<
")" << std::endl;
419 if (p ==
nullptr)
return false;
EIGEN_DEVICE_FUNC const Log1pReturnType log1p() const
static shared_ptr Create(double k, const ReweightScheme reweight=Block)
static shared_ptr Create(double k, const ReweightScheme reweight=Block)
DCS(double c=1.0, const ReweightScheme reweight=Block)
std::shared_ptr< L2WithDeadZone > shared_ptr
std::shared_ptr< DCS > shared_ptr
Tukey(double c=4.6851, const ReweightScheme reweight=Block)
std::shared_ptr< Tukey > shared_ptr
double loss(double distance) const override
std::shared_ptr< Null > shared_ptr
std::shared_ptr< Base > shared_ptr
bool equals(const Base &expected, double tol=1e-8) const override
bool equals(const Base &expected, double tol=1e-8) const override
Double_ distance(const OrientedPlane3_ &p)
double weight(double distance) const override
double weight(double distance) const override
L2WithDeadZone(double k=1.0, const ReweightScheme reweight=Block)
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
double loss(double distance) const override
double loss(double distance) const override
void print(const std::string &s) const override
bool equals(const Base &expected, double tol=1e-8) const override
Welsch(double c=2.9846, const ReweightScheme reweight=Block)
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
double loss(double distance) const override
bool equals(const Base &expected, double tol=1e-8) const override
void print(const std::string &s) const override
bool equals(const Base &expected, double tol=1e-8) const override
EIGEN_DEVICE_FUNC const Expm1ReturnType expm1() const
double loss(double distance) const override
double loss(double distance) const override
double weight(double distance) const override
static shared_ptr Create(double k, const ReweightScheme reweight=Block)
Fair(double c=1.3998, const ReweightScheme reweight=Block)
Cauchy(double k=0.1, const ReweightScheme reweight=Block)
double weight(double distance) const override
double weight(double distance) const override
void print(const std::string &s) const override
bool equals(const Base &expected, double tol=1e-8) const override
static shared_ptr Create(double k, const ReweightScheme reweight=Block)
void print(const std::string &s) const override
std::shared_ptr< Welsch > shared_ptr
double weight(double distance) const override
void reweight(Vector &error) const
std::shared_ptr< Fair > shared_ptr
void print(const std::string &s) const override
double loss(double distance) const override
static shared_ptr Create(double c, const ReweightScheme reweight=Block)
double weight(double distance) const override
std::shared_ptr< GemanMcClure > shared_ptr
static shared_ptr Create(double k, const ReweightScheme reweight=Block)
void print(const std::string &s) const override
static shared_ptr Create(double k, const ReweightScheme reweight=Block)
std::shared_ptr< Huber > shared_ptr
void print(const std::string &s) const override
Huber(double k=1.345, const ReweightScheme reweight=Block)
void vector_scale_inplace(const Vector &v, Matrix &A, bool inf_mask)
bool equals(const Base &expected, double tol=1e-8) const override
std::shared_ptr< Cauchy > shared_ptr
bool equals(const Base &expected, double tol=1e-8) const override
GemanMcClure(double c=1.0, const ReweightScheme reweight=Block)
double loss(double distance) const override
void print(const std::string &s) const override
static shared_ptr Create(double k, const ReweightScheme reweight=Block)
double weight(double distance) const override