35 root_(new
internal::ConstantExpression<
T>(value)) {
40 root_(new
internal::LeafExpression<
T>(key)) {
45 root_(new
internal::LeafExpression<
T>(symbol)) {
63 template<
typename A1,
typename A2>
73 template<
typename A1,
typename A2,
typename A3>
79 expression2, expression3)) {
89 std::placeholders::_1,
std::placeholders::_2),
95 template<
typename A1,
typename A2>
102 std::bind(method,
std::placeholders::_1,
103 std::placeholders::_2,
std::placeholders::_3,
104 std::placeholders::_4),
105 expression1, expression2)) {
110 template<
typename A1,
typename A2,
typename A3>
112 T (
A1::*method)(
const A2&,
const A3&,
119 std::bind(method,
std::placeholders::_1,
120 std::placeholders::_2,
std::placeholders::_3,
121 std::placeholders::_4,
std::placeholders::_5,
122 std::placeholders::_6),
123 expression1, expression2, expression3)) {
128 return root_->keys();
143 std::vector<Matrix>*
H)
const {
146 const auto [
keys, dims] = keysAndDims();
147 return valueAndDerivatives(values,
keys, dims, *H);
150 return root_->value(values);
169 std::vector<Matrix>&
H)
const {
172 assert(H.size()==keys.size());
181 T result = valueAndJacobianMap(values, jacobianMap);
184 for (
DenseIndex i = 0; i < static_cast<DenseIndex>(keys.size());
i++)
199 return std::unique_ptr<internal::ExecutionTraceStorage[]>(
208 const size_t size = traceSize();
215 T value(this->traceExecution(values, trace, reinterpret_cast<char *>(traceStorage.get())));
220 }
catch (
const std::bad_alloc &
e) {
221 std::cerr <<
"valueAndJacobianMap exception: " << e.what() <<
'\n';
229 std::map<Key, int> map;
231 size_t n = map.size();
234 auto key_it = pair.first.begin();
235 auto dim_it = pair.second.begin();
236 for (
const auto& [
key,
value] : map) {
251 return x.compose(y, H1, H2);
260 if (H1) H1->setConstant(y);
261 if (H2) H2->setConstant(x);
276 std::placeholders::_2, std::placeholders::_3,
277 std::placeholders::_4),
278 expression1, expression2);
284 std::vector<Expression<T> > unknowns;
286 for (
size_t i = start;
i < start +
n;
i++)
291 template <
typename T>
296 template <
typename T>
300 template <
typename T>
302 root_ = std::make_shared<internal::BinarySumNode<T>>(*
this,
e);
const gtsam::Symbol key('X', 0)
std::pair< KeyVector, FastVector< int > > KeysAndDims
Keys and dimensions in same order.
Vector3_ operator*(const Double_ &s, const Vector3_ &v)
std::shared_ptr< internal::ExpressionNode< T > > root_
Expression< T > & operator+=(const Expression< T > &e)
Add another expression to this expression.
T operator()(const T &x, const T &y, OptionalJacobian< Dim, Dim > H1={}, OptionalJacobian< Dim, Dim > H2={}) const
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
const Matrix & matrix() const
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
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 set rrange [*:*] noreverse nowriteback set trange [*:*] noreverse nowriteback set urange [*:*] noreverse nowriteback set vrange [*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
ptrdiff_t DenseIndex
The index type for Eigen objects.
std::unique_ptr< internal::ExecutionTraceStorage[]> allocAligned(size_t size)
std::vector< Expression< T > > createUnknowns(size_t n, char c, size_t start)
Construct an array of leaves.
gtsam::enable_if_t< needs_eigen_aligned_allocator< T >::value, std::shared_ptr< T > > make_shared(Args &&... args)
void startReverseAD1(JacobianMap &jacobians) const
double operator()(const double &x, const double &y, OptionalJacobian< 1, 1 > H1={}, OptionalJacobian< 1, 1 > H2={}) const
unsigned __int64 uint64_t
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Key symbol(unsigned char c, std::uint64_t j)
std::aligned_storage< 1, TraceAlignment >::type ExecutionTraceStorage
BinarySumExpression(const Expression< T > &e1, const Expression< T > &e2)
Expression()
Default constructor, for serialization.
static const unsigned TraceAlignment
void dims(std::map< Key, int > &map) const
Return dimensions for each argument, as a map.
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
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
std::uint64_t Key
Integer nonlinear key type.
T traceExecution(const Values &values, internal::ExecutionTrace< T > &trace, char *traceStorage) const
trace execution, very unsafe
size_t traceSize() const
Return size needed for memory buffer in traceExecution.