Deprecated reciprocal() in Vector.h

release/4.3a0
Alex Hagiopol 2016-03-11 13:31:57 -05:00
parent 68c8bcc5e8
commit b3dfb6d978
5 changed files with 10 additions and 20 deletions

View File

@ -339,7 +339,7 @@ weighted_eliminate(Matrix& A, Vector& b, const Vector& sigmas) {
list<boost::tuple<Vector, double, double> > results;
Vector pseudo(m); // allocate storage for pseudo-inverse
Vector weights = reciprocal(sigmas.array().square()); // calculate weights once
Vector weights = sigmas.array().square().inverse(); // 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

View File

@ -214,11 +214,6 @@ double norm_2(const Vector& v) {
return v.norm();
}
/* ************************************************************************* */
Vector reciprocal(const Vector &a) {
return a.array().inverse();
}
/* ************************************************************************* */
Vector esqrt(const Vector& v) {
return v.cwiseSqrt();

View File

@ -243,13 +243,6 @@ GTSAM_EXPORT double sum(const Vector &a);
*/
GTSAM_EXPORT double norm_2(const Vector& v);
/**
* Elementwise reciprocal of vector elements
* @param a vector
* @return [1/a(i)]
*/
GTSAM_EXPORT Vector reciprocal(const Vector &a);
/**
* Elementwise sqrt of vector elements
* @param v is a vector
@ -349,8 +342,10 @@ GTSAM_EXPORT Vector concatVectors(size_t nrVectors, ...);
#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V4
GTSAM_EXPORT inline Vector emul(const Vector &a, const Vector &b) {assert (b.size()==a.size()); return a.cwiseProduct(b);}
GTSAM_EXPORT inline Vector reciprocal(const Vector &a) {return a.array().inverse();}
#endif
} // namespace gtsam
#include <boost/serialization/nvp.hpp>

View File

@ -198,7 +198,7 @@ TEST(Vector, weightedPseudoinverse )
// create sigmas
Vector sigmas(2);
sigmas(0) = 0.1; sigmas(1) = 0.2;
Vector weights = reciprocal(sigmas.array().square());
Vector weights = sigmas.array().square().inverse();
// perform solve
Vector actual; double precision;
@ -224,7 +224,7 @@ TEST(Vector, weightedPseudoinverse_constraint )
// create sigmas
Vector sigmas(2);
sigmas(0) = 0.0; sigmas(1) = 0.2;
Vector weights = reciprocal(sigmas.array().square());
Vector weights = sigmas.array().square().inverse();
// perform solve
Vector actual; double precision;
boost::tie(actual, precision) = weightedPseudoinverse(x, weights);
@ -243,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(sigmas.array().square());
Vector weights = sigmas.array().square().inverse();
Vector pseudo; double precision;
boost::tie(pseudo, precision) = weightedPseudoinverse(a, weights);
@ -306,7 +306,7 @@ TEST(Vector, greater_than )
TEST(Vector, reciprocal )
{
Vector v = Vector3(1.0, 2.0, 4.0);
EXPECT(assert_equal(Vector3(1.0, 0.5, 0.25),reciprocal(v)));
EXPECT(assert_equal(Vector3(1.0, 0.5, 0.25), (Vector) v.array().inverse()));
}
/* ************************************************************************* */

View File

@ -309,7 +309,7 @@ namespace gtsam {
* i.e. the diagonal of the information matrix, i.e., weights
*/
static shared_ptr Precisions(const Vector& precisions, bool smart = true) {
return Variances(reciprocal(precisions), smart);
return Variances(precisions.array().inverse(), smart);
}
virtual void print(const std::string& name) const;
@ -443,10 +443,10 @@ namespace gtsam {
* precisions, some of which might be inf
*/
static shared_ptr MixedPrecisions(const Vector& mu, const Vector& precisions) {
return MixedVariances(mu, reciprocal(precisions));
return MixedVariances(mu, precisions.array().inverse());
}
static shared_ptr MixedPrecisions(const Vector& precisions) {
return MixedVariances(reciprocal(precisions));
return MixedVariances(precisions.array().inverse());
}
/**