From 22c3af906e23a53e182b2c553bb443264e543339 Mon Sep 17 00:00:00 2001 From: Alex Hagiopol Date: Sat, 5 Mar 2016 18:49:34 -0500 Subject: [PATCH] Deprecated emul() in Vector.h. --- gtsam/base/Matrix.cpp | 2 +- gtsam/base/Vector.h | 3 ++- gtsam/base/tests/testVector.cpp | 7 +++---- gtsam/linear/tests/testKalmanFilter.cpp | 2 +- gtsam_unstable/slam/AHRS.cpp | 5 +++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/gtsam/base/Matrix.cpp b/gtsam/base/Matrix.cpp index d92be12f5..3542d06d9 100644 --- a/gtsam/base/Matrix.cpp +++ b/gtsam/base/Matrix.cpp @@ -339,7 +339,7 @@ weighted_eliminate(Matrix& A, Vector& b, const Vector& sigmas) { list > results; Vector pseudo(m); // allocate storage for pseudo-inverse - Vector weights = reciprocal(emul(sigmas,sigmas)); // calculate weights once + Vector weights = reciprocal(sigmas.cwiseProduct(sigmas)); // calculate weights once // We loop over all columns, because the columns that can be eliminated // are not necessarily contiguous. For each one, estimate the corresponding diff --git a/gtsam/base/Vector.h b/gtsam/base/Vector.h index f87703e2b..527068a6d 100644 --- a/gtsam/base/Vector.h +++ b/gtsam/base/Vector.h @@ -20,7 +20,6 @@ #pragma once - #ifndef MKL_BLAS #define MKL_BLAS MKL_DOMAIN_BLAS #endif @@ -213,6 +212,7 @@ GTSAM_EXPORT ConstSubVector sub(const Vector &v, size_t i1, size_t i2); */ GTSAM_EXPORT void subInsert(Vector& fullVector, const Vector& subVector, size_t i); +#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V4 /** * elementwise multiplication * @param a first vector @@ -220,6 +220,7 @@ GTSAM_EXPORT void subInsert(Vector& fullVector, const Vector& subVector, size_t * @return vector [a(i)*b(i)] */ GTSAM_EXPORT Vector emul(const Vector &a, const Vector &b); +#endif /** * elementwise division diff --git a/gtsam/base/tests/testVector.cpp b/gtsam/base/tests/testVector.cpp index 00e40039b..dd3527b46 100644 --- a/gtsam/base/tests/testVector.cpp +++ b/gtsam/base/tests/testVector.cpp @@ -198,7 +198,7 @@ TEST(Vector, weightedPseudoinverse ) // create sigmas Vector sigmas(2); sigmas(0) = 0.1; sigmas(1) = 0.2; - Vector weights = reciprocal(emul(sigmas,sigmas)); + Vector weights = reciprocal(sigmas.cwiseProduct(sigmas)); // perform solve Vector actual; double precision; @@ -224,8 +224,7 @@ TEST(Vector, weightedPseudoinverse_constraint ) // create sigmas Vector sigmas(2); sigmas(0) = 0.0; sigmas(1) = 0.2; - Vector weights = reciprocal(emul(sigmas,sigmas)); - + Vector weights = reciprocal(sigmas.cwiseProduct(sigmas)); // perform solve Vector actual; double precision; boost::tie(actual, precision) = weightedPseudoinverse(x, weights); @@ -244,7 +243,7 @@ TEST(Vector, weightedPseudoinverse_nan ) { Vector a = (Vector(4) << 1., 0., 0., 0.).finished(); Vector sigmas = (Vector(4) << 0.1, 0.1, 0., 0.).finished(); - Vector weights = reciprocal(emul(sigmas,sigmas)); + Vector weights = reciprocal(sigmas.cwiseProduct(sigmas)); Vector pseudo; double precision; boost::tie(pseudo, precision) = weightedPseudoinverse(a, weights); diff --git a/gtsam/linear/tests/testKalmanFilter.cpp b/gtsam/linear/tests/testKalmanFilter.cpp index 999541ff5..c14f88129 100644 --- a/gtsam/linear/tests/testKalmanFilter.cpp +++ b/gtsam/linear/tests/testKalmanFilter.cpp @@ -270,7 +270,7 @@ TEST( KalmanFilter, QRvsCholesky ) { EXPECT(assert_equal(expected2, pb2->covariance(), 1e-7)); // do the above update again, this time with a full Matrix Q - Matrix modelQ = diag(emul(sigmas,sigmas)); + Matrix modelQ = diag(sigmas.cwiseProduct(sigmas)); KalmanFilter::State pa3 = kfa.updateQ(pa, H, z, modelQ); KalmanFilter::State pb3 = kfb.updateQ(pb, H, z, modelQ); diff --git a/gtsam_unstable/slam/AHRS.cpp b/gtsam_unstable/slam/AHRS.cpp index 2a27730f4..9ea923ebc 100644 --- a/gtsam_unstable/slam/AHRS.cpp +++ b/gtsam_unstable/slam/AHRS.cpp @@ -171,7 +171,7 @@ std::pair AHRS::aid( // calculate residual gravity measurement z = n_g_ - trans(bRn) * measured_b_g; H = collect(3, &n_g_cross_, &Z_3x3, &bRn); - R = trans(bRn) * diag(emul(sigmas_v_a_, sigmas_v_a_)) * bRn; + R = trans(bRn) * diag(sigmas_v_a_.cwiseProduct(sigmas_v_a_)) * bRn; } else { // my measurement prediction (in body frame): // F(:,k) = bias - b_g @@ -186,7 +186,8 @@ std::pair AHRS::aid( Matrix b_g = bRn * n_g_cross_; H = collect(3, &b_g, &Z_3x3, &I_3x3); // And the measurement noise, TODO: should be created once where sigmas_v_a is given - R = diag(emul(sigmas_v_a_, sigmas_v_a_)); + R = diag(sigmas_v_a_.cwiseQuotient(sigmas_v_a_)); + } // update the Kalman filter