24 #include <boost/tuple/tuple.hpp> 25 #include <boost/range/adaptor/map.hpp> 26 #include <boost/range/algorithm.hpp> 32 root_(new
internal::ConstantExpression<
T>(value)) {
60 template<
typename A1,
typename A2>
70 template<
typename A1,
typename A2,
typename A3>
76 expression2, expression3)) {
91 template<
typename A1,
typename A2>
97 new
internal::BinaryExpression<
T, A1, A2>(
98 boost::bind(method, _1, _2, _3, _4), expression1, expression2)) {
103 template<
typename A1,
typename A2,
typename A3>
105 T (A1::*method)(
const A2&,
const A3&,
111 new
internal::TernaryExpression<
T, A1, A2, A3>(
112 boost::bind(method, _1, _2, _3, _4, _5, _6), expression1,
113 expression2, expression3)) {
118 return root_->keys();
133 boost::optional<std::vector<Matrix>&>
H)
const {
143 return root_->value(values);
153 return root_->traceSize();
161 std::vector<Matrix>&
H)
const {
164 assert(H.size()==keys.size());
176 for (
DenseIndex i = 0; i < static_cast<DenseIndex>(keys.size());
i++)
185 return root_->traceExecution(values, trace,
186 static_cast<internal::ExecutionTraceStorage*>(traceStorage));
213 _aligned_free(traceStorage);
221 std::map<Key, int> map;
223 size_t n = map.size();
225 boost::copy(map | boost::adaptors::map_keys, pair.first.begin());
226 boost::copy(map | boost::adaptors::map_values, pair.second.begin());
238 return x.compose(y, H1, H2);
257 std::vector<Expression<T> > unknowns;
259 for (
size_t i = start;
i < start +
n;
i++)
264 template <
typename T>
269 template <
typename T>
273 template <
typename T>
275 root_ = boost::make_shared<internal::BinarySumNode<T>>(*
this,
e);
std::pair< KeyVector, FastVector< int > > KeysAndDims
Keys and dimensions in same order.
gtsam::enable_if_t< needs_eigen_aligned_allocator< T >::value, boost::shared_ptr< T > > make_shared(Args &&...args)
boost::function< T(const A1 &, typename MakeOptionalJacobian< T, A1 >::type)> type
T operator()(const T &x, const T &y, OptionalJacobian< Dim, Dim > H1=boost::none, OptionalJacobian< Dim, Dim > H2=boost::none) const
const boost::shared_ptr< internal::ExpressionNode< T > > & root() const
Return root.
T valueAndDerivatives(const Values &values, const KeyVector &keys, const FastVector< int > &dims, std::vector< Matrix > &H) const
private version that takes keys and dimensions, returns derivatives
const Matrix & matrix() const
Expression< T > & operator+=(const Expression< T > &e)
Add another expression to this expression.
std::vector< Expression< T > > createUnknowns(size_t n, char c, size_t start)
Construct an array of leaves.
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
Point2 operator*(double s, const Point2 &p)
multiply with scalar
boost::aligned_storage< 1, TraceAlignment >::type ExecutionTraceStorage
ptrdiff_t DenseIndex
The index type for Eigen objects.
void print(const std::string &s) const
Print.
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
T valueAndJacobianMap(const Values &values, internal::JacobianMap &jacobians) const
brief Return value and derivatives, reverse AD version
KeysAndDims keysAndDims() const
boost::shared_ptr< internal::ExpressionNode< T > > root_
unsigned __int64 uint64_t
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Key symbol(unsigned char c, std::uint64_t j)
void dims(std::map< Key, int > &map) const
Return dimensions for each argument, as a map.
std::set< Key > keys() const
Return keys that play in this expression.
ScalarMultiplyExpression(double s, const Expression< T > &e)
BinarySumExpression(const Expression< T > &e1, const Expression< T > &e2)
void startReverseAD1(JacobianMap &jacobians) const
boost::function< T(const A1 &, const A2 &, const A3 &, typename MakeOptionalJacobian< T, A1 >::type, typename MakeOptionalJacobian< T, A2 >::type, typename MakeOptionalJacobian< T, A3 >::type)> type
T traceExecution(const Values &values, internal::ExecutionTrace< T > &trace, void *traceStorage) const
trace execution, very unsafe
T value(const Values &values, boost::optional< std::vector< Matrix > & > H=boost::none) const
Return value and optional derivatives, reverse AD version Notes: this is not terribly efficient...
Expression()
Default constructor, for serialization.
boost::function< T(const A1 &, const A2 &, typename MakeOptionalJacobian< T, A1 >::type, typename MakeOptionalJacobian< T, A2 >::type)> type
size_t traceSize() const
Return size needed for memory buffer in traceExecution.
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
static const unsigned TraceAlignment
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.