Deprecated norm_2() in Vector.h

release/4.3a0
Alex Hagiopol 2016-03-11 19:34:49 -05:00
parent 2f146e85ef
commit 5502691022
7 changed files with 7 additions and 19 deletions

View File

@ -204,11 +204,6 @@ Vector ediv_(const Vector &a, const Vector &b) {
return c; return c;
} }
/* ************************************************************************* */
double norm_2(const Vector& v) {
return v.norm();
}
/* ************************************************************************* */ /* ************************************************************************* */
// imperative version, pass in x // imperative version, pass in x
double houseInPlace(Vector &v) { double houseInPlace(Vector &v) {

View File

@ -228,14 +228,6 @@ GTSAM_EXPORT Vector ediv(const Vector &a, const Vector &b);
*/ */
GTSAM_EXPORT Vector ediv_(const Vector &a, const Vector &b); GTSAM_EXPORT Vector ediv_(const Vector &a, const Vector &b);
/**
* Calculates L2 norm for a vector
* modeled after boost.ublas for compatibility
* @param v vector
* @return the L2 norm
*/
GTSAM_EXPORT double norm_2(const Vector& v);
/** /**
* Dot product * Dot product
*/ */
@ -317,6 +309,7 @@ GTSAM_EXPORT inline Vector abs(const Vector& v){return v.cwiseAbs();}
GTSAM_EXPORT inline Vector esqrt(const Vector& v) { return v.cwiseSqrt();} GTSAM_EXPORT inline Vector esqrt(const Vector& v) { return v.cwiseSqrt();}
GTSAM_EXPORT inline Vector emul(const Vector &a, const Vector &b) {assert (b.size()==a.size()); return a.cwiseProduct(b);} GTSAM_EXPORT inline Vector emul(const Vector &a, const Vector &b) {assert (b.size()==a.size()); return a.cwiseProduct(b);}
GTSAM_EXPORT inline double max(const Vector &a){return a.maxCoeff();} GTSAM_EXPORT inline double max(const Vector &a){return a.maxCoeff();}
GTSAM_EXPORT inline double norm_2(const Vector& v) {return v.norm();}
GTSAM_EXPORT inline Vector reciprocal(const Vector &a) {return a.array().inverse();} GTSAM_EXPORT inline Vector reciprocal(const Vector &a) {return a.array().inverse();}
GTSAM_EXPORT inline double sum(const Vector &a){return a.sum();} GTSAM_EXPORT inline double sum(const Vector &a){return a.sum();}
#endif #endif

View File

@ -148,7 +148,7 @@ TEST(Pose3, Adjoint_full)
Pose3 Agrawal06iros(const Vector& xi) { Pose3 Agrawal06iros(const Vector& xi) {
Vector w = xi.head(3); Vector w = xi.head(3);
Vector v = xi.tail(3); Vector v = xi.tail(3);
double t = norm_2(w); double t = w.norm();
if (t < 1e-5) if (t < 1e-5)
return Pose3(Rot3(), Point3(v)); return Pose3(Rot3(), Point3(v));
else { else {

View File

@ -96,7 +96,7 @@ TEST( Rot3, equals)
/* ************************************************************************* */ /* ************************************************************************* */
// Notice this uses J^2 whereas fast uses w*w', and has cos(t)*I + .... // Notice this uses J^2 whereas fast uses w*w', and has cos(t)*I + ....
Rot3 slow_but_correct_Rodrigues(const Vector& w) { Rot3 slow_but_correct_Rodrigues(const Vector& w) {
double t = norm_2(w); double t = w.norm();
Matrix3 J = skewSymmetric(w / t); Matrix3 J = skewSymmetric(w / t);
if (t < 1e-5) return Rot3(); if (t < 1e-5) return Rot3();
Matrix3 R = I_3x3 + sin(t) * J + (1.0 - cos(t)) * (J * J); Matrix3 R = I_3x3 + sin(t) * J + (1.0 - cos(t)) * (J * J);
@ -130,7 +130,7 @@ TEST( Rot3, Rodrigues2)
TEST( Rot3, Rodrigues3) TEST( Rot3, Rodrigues3)
{ {
Vector w = Vector3(0.1, 0.2, 0.3); Vector w = Vector3(0.1, 0.2, 0.3);
Rot3 R1 = Rot3::AxisAngle(w / norm_2(w), norm_2(w)); Rot3 R1 = Rot3::AxisAngle(w / w.norm(), w.norm());
Rot3 R2 = slow_but_correct_Rodrigues(w); Rot3 R2 = slow_but_correct_Rodrigues(w);
CHECK(assert_equal(R2,R1)); CHECK(assert_equal(R2,R1));
} }

View File

@ -268,7 +268,7 @@ TEST( AHRSFactor, PartialDerivativeLogmap ) {
const Vector3 x = thetahat; // parametrization of so(3) const Vector3 x = thetahat; // parametrization of so(3)
const Matrix3 X = skewSymmetric(x); // element of Lie algebra so(3): X = x^ const Matrix3 X = skewSymmetric(x); // element of Lie algebra so(3): X = x^
double normx = norm_2(x); double normx = x.norm();
const Matrix3 actualDelFdeltheta = I_3x3 + 0.5 * X const Matrix3 actualDelFdeltheta = I_3x3 + 0.5 * X
+ (1 / (normx * normx) - (1 + cos(normx)) / (2 * normx * sin(normx))) * X + (1 / (normx * normx) - (1 + cos(normx)) / (2 * normx * sin(normx))) * X
* X; * X;

View File

@ -652,7 +652,7 @@ TEST( SmartProjectionCameraFactor, comparisonGeneralSfMFactor ) {
Vector e1 = sfm1.evaluateError(values.at<Camera>(c1), values.at<Point3>(l1)); Vector e1 = sfm1.evaluateError(values.at<Camera>(c1), values.at<Point3>(l1));
Vector e2 = sfm2.evaluateError(values.at<Camera>(c2), values.at<Point3>(l1)); Vector e2 = sfm2.evaluateError(values.at<Camera>(c2), values.at<Point3>(l1));
double actualError = 0.5 double actualError = 0.5
* (norm_2(e1) * norm_2(e1) + norm_2(e2) * norm_2(e2)); * (e1.norm() * e1.norm() + e2.norm() * e2.norm());
double actualErrorGraph = generalGraph.error(values); double actualErrorGraph = generalGraph.error(values);
DOUBLES_EQUAL(expectedErrorGraph, actualErrorGraph, 1e-7); DOUBLES_EQUAL(expectedErrorGraph, actualErrorGraph, 1e-7);

View File

@ -33,7 +33,7 @@ Mechanization_bRn2 Mechanization_bRn2::initialize(const Matrix& U,
if(g_e == 0) { if(g_e == 0) {
if (flat) if (flat)
// acceleration measured is along the z-axis. // acceleration measured is along the z-axis.
b_g = (Vector3(3) << 0.0, 0.0, norm_2(meanF)).finished(); b_g = (Vector3(3) << 0.0, 0.0, meanF.norm()).finished();
else else
// acceleration measured is the opposite of gravity (10.13) // acceleration measured is the opposite of gravity (10.13)
b_g = -meanF; b_g = -meanF;