30 #include <boost/assign/list_of.hpp> 31 #include <boost/assign/std/vector.hpp> 32 #include <boost/range/iterator_range.hpp> 33 #include <boost/range/adaptor/map.hpp> 38 using namespace gtsam;
41 const Matrix26
F0 = Matrix26::Ones();
42 const Matrix26
F1 = 2 * Matrix26::Ones();
43 const Matrix26
F3 = 3 * Matrix26::Ones();
44 const vector<Matrix26, Eigen::aligned_allocator<Matrix26> >
FBlocks {
F0,
F1,
F3};
50 TEST( regularImplicitSchurFactor, creation ) {
53 E.block<2,2>(0, 0) = I_2x2;
54 E.block<2,3>(2, 0) = 2 * Matrix::Ones(2, 3);
55 Matrix3
P = (E.transpose() *
E).
inverse();
62 TEST( regularImplicitSchurFactor, addHessianMultiply ) {
65 E.block<2,2>(0, 0) = I_2x2;
66 E.block<2,3>(2, 0) = 2 * Matrix::Ones(2, 3);
67 E.block<2,2>(4, 1) = I_2x2;
68 Matrix3
P = (E.transpose() *
E).
inverse();
72 (0, Vector::Constant(6, 2))
73 (1, Vector::Constant(6, 4))
74 (2, Vector::Constant(6, 0))
75 (3, Vector::Constant(6, 8));
78 (0, Vector::Constant(6, 27))
79 (1, Vector::Constant(6, -40))
80 (2, Vector::Constant(6, 0))
81 (3, Vector::Constant(6, 279));
84 size_t M=4,
m = 3,
d = 6;
86 F <<
F0, Matrix::Zero(2,
d * 3), Matrix::Zero(2,
d),
F1, Matrix::Zero(2,
d*2), Matrix::Zero(2,
d * 3),
F3;
111 double*
y =
new double[24];
112 double* xdata = x.data();
115 std::fill(y, y + 24, 0);
129 double expectedError = 11875.083333333334;
162 std::fill(y, y + 24, 0);
172 expectedVV.
insert(0,-3.5*Vector::Ones(6));
173 expectedVV.
insert(1,10*Vector::Ones(6)/3);
174 expectedVV.
insert(3,-19.5*Vector::Ones(6));
197 std::fill(y, y + 24, 0);
209 TEST(regularImplicitSchurFactor, hessianDiagonal)
222 E.block<2,3>(0, 0) << 1,2,3,4,5,6;
223 E.block<2,3>(2, 0) << 1,2,3,4,5,6;
224 E.block<2,3>(4, 0) << 0.5,1,2,3,4,5;
225 Matrix3
P = (E.transpose() *
E).
inverse();
230 expected.
insert(0, 1.195652*Vector::Ones(6));
231 expected.
insert(1, 4.782608*Vector::Ones(6));
232 expected.
insert(3, 7.043478*Vector::Ones(6));
238 Matrix FtE0 =
F0.transpose() * E.block<2,3>(0, 0);
239 Matrix FtE1 =
F1.transpose() * E.block<2,3>(2, 0);
240 Matrix FtE3 =
F3.transpose() * E.block<2,3>(4, 0);
249 Matrix E0 = E.block<2,3>(0, 0);
260 Matrix M1b = F0t*(E0*P*E0.transpose()*
F0);
261 Matrix M2b = F0t*E0*P*E0.transpose()*
F0;
Matrix< RealScalar, Dynamic, Dynamic > M
double errorJF(const VectorValues &x) const
static int runAllTests(TestResult &result)
TEST(regularImplicitSchurFactor, creation)
noiseModel::Diagonal::shared_ptr model
A matrix or vector expression mapping an existing array of data.
static void multiplyHessianAdd(const Matrix &F, const Matrix &E, const Matrix &PointCovariance, double alpha, const Vector &x, Vector &y)
EIGEN_DONT_INLINE Scalar zero()
A factor with a quadratic error function - a Gaussian.
std::map< Key, Matrix > hessianBlockDiagonal() const override
Return the block diagonal of the Hessian for this factor.
void hessianDiagonal(double *d) const override
add the contribution of this factor to the diagonal of the hessian d(output) = d(input) + deltaHessia...
const vector< Matrix26, Eigen::aligned_allocator< Matrix26 > > FBlocks
void multiplyHessianAdd(double alpha, const VectorValues &x, VectorValues &y) const override
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
double error(const VectorValues &x) const override
VectorValues gradientAtZero() const override
Expose base class gradientAtZero.
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12;Map< MatrixXf > M2(M1.data(), 6, 2)
#define EXPECT(condition)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Calibrated camera for which only pose is unknown.
#define LONGS_EQUAL(expected, actual)
noiseModel::Diagonal::shared_ptr SharedDiagonal
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
A new type of linear factor (GaussianFactor), which is subclass of GaussianFactor.
VectorValues gradientAtZero() const override
Matrix information() const override
Compute full information matrix
double error(const VectorValues &c) const override
std::map< Key, Matrix > hessianBlockDiagonal() const override
Return the block diagonal of the Hessian for this factor.
The matrix class, also used for vectors and row-vectors.
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
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
iterator insert(const std::pair< Key, Vector > &key_value)
const Matrix & getPointCovariance() const
EIGEN_DEVICE_FUNC const InverseReturnType inverse() const
Matrix augmentedInformation() const override
Compute full augmented information matrix
void hessianDiagonal(double *d) const override
Raw memory access version of hessianDiagonal.