29 for(
const Key&
key: gaussian->keys()) {
45 :
Base(jacobian, lin_points) {
48 size_t *dims = (
size_t *)alloca(
sizeof(
size_t) * (jacobian->size() + 1));
51 dims[index++] = jacobian->getDim(
iter);
58 Ab_.
matrix() = jacobian->augmentedJacobian();
64 std::cout << s << std::endl;
66 std::cout <<
"Nonlinear Keys: ";
68 std::cout << keyFormatter(
key) <<
" ";
69 std::cout << std::endl;
72 std::cout <<
"A[" << keyFormatter(*
key) <<
"]=\n" <<
A(*
key) << std::endl;
74 std::cout <<
"b=\n" <<
b() << std::endl;
99 return 0.5 * errorVector.dot(errorVector);
103 std::shared_ptr<GaussianFactor>
107 std::vector<std::pair<Key, Matrix> > terms;
109 terms.push_back(std::make_pair(
key, this->
A(
key)));
128 errorVector += A *
d;
143 :
Base(hessian, lin_points), info_(hessian->
info()) {}
148 std::cout << s << std::endl;
150 std::cout <<
"Nonlinear Keys: ";
152 std::cout << keyFormatter(
key) <<
" ";
153 std::cout << std::endl;
167 thisMatrix(thisMatrix.rows()-1, thisMatrix.cols()-1) = 0.0;
168 Matrix rhsMatrix = e->info_.selfadjointView();
169 rhsMatrix(rhsMatrix.rows()-1, rhsMatrix.cols()-1) = 0.0;
185 for(
unsigned int i = 0;
i < this->
size(); ++
i){
187 const Value& newPt = c.
at(key);
190 index += linPt.
dim();
198 return 0.5 * (f - 2.0 * xtg + xGx);
202 std::shared_ptr<GaussianFactor>
208 for(
unsigned int i = 0;
i < this->
size(); ++
i){
210 const Value& newPt = c.
at(key);
213 index += linPt.
dim();
223 std::vector<Vector> gs;
227 gs.push_back(g.segment(offset, dim));
233 std::vector<Matrix> Gs;
void print(const Matrix &A, const string &s, ostream &stream)
const gtsam::Symbol key('X', 0)
std::shared_ptr< This > shared_ptr
A shared_ptr to this class.
DenseIndex nBlocks() const
Block count.
const ValueType at(Key j) const
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
Vector error_vector(const Values &c) const
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 y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate offset
const Matrix & matrix() const
iterator iter(handle obj)
LinearizedHessianFactor()
constColumn linearTerm() const
std::shared_ptr< GaussianFactor > linearize(const Values &c) const override
size_t dim() const override
virtual Vector localCoordinates_(const Value &value) const =0
LinearizedJacobianFactor()
ptrdiff_t DenseIndex
The index type for Eigen objects.
void g(const string &key, int i)
static shared_ptr Create(size_t dim)
virtual bool equals(const NonlinearFactor &f, double tol=1e-9) const
const_iterator end() const
void print(const std::string &str="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Eigen::SelfAdjointView< constBlock, Eigen::Upper > selfadjointView(DenseIndex I, DenseIndex J) const
Return the square sub-matrix that contains blocks(i:j, i:j).
DenseIndex nBlocks() const
Block count.
double error(const Values &c) const override
size_t dim() const override
A dummy factor that allows a linear factor to act as a nonlinear factor.
const constBVector b() const
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
LinearizedGaussianFactor()=default
bool equals(const Values &other, double tol=1e-9) const
std::shared_ptr< This > shared_ptr
shared_ptr to this class
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
virtual size_t dim() const =0
std::shared_ptr< This > shared_ptr
shared_ptr to this class
bool equal_with_abs_tol(const Eigen::DenseBase< MATRIX > &A, const Eigen::DenseBase< MATRIX > &B, double tol=1e-9)
Block range(DenseIndex startBlock, DenseIndex endBlock)
const constABlock A() const
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
Expression of a fixed-size or dynamic-size block.
std::shared_ptr< GaussianFactor > linearize(const Values &c) const override
Eigen::SelfAdjointView< constBlock, Eigen::Upper > squaredTerm() const
double error(const Values &c) const override
double constantTerm() const
A Gaussian factor using the canonical parameters (information form)
const KeyVector & keys() const
Access the factor's involved variable keys.
void insert(Key j, const Value &val)
Eigen::SelfAdjointView< Block, Eigen::Upper > diagonalBlock(DenseIndex J)
Return the J'th diagonal block as a self adjoint view.
KeyVector::const_iterator const_iterator
Const iterator over keys.
DenseIndex getDim(DenseIndex block) const
Number of dimensions for variable on this diagonal block.
const_iterator begin() const
SymmetricBlockMatrix info_
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
std::uint64_t Key
Integer nonlinear key type.
constBlock aboveDiagonalBlock(DenseIndex I, DenseIndex J) const
Get block above the diagonal (I, J).