g2o
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
g2o::ceres::internal Namespace Reference

Classes

struct  ArraySelector
 
struct  ArraySelector< T, num_elements, max_num_elements_on_stack, false, false >
 
struct  ArraySelector< T, NumElements, MaxNumElementsOnStack, false, true >
 
struct  ArraySelector< T, NumElements, MaxNumElementsOnStack, true, FitsOnStack >
 
struct  ExclusiveScanImpl
 
struct  ExclusiveScanImpl< T, Sum, std::integer_sequence< T >, SeqOut >
 
struct  ExclusiveScanImpl< T, Sum, std::integer_sequence< T, N, Ns... >, std::integer_sequence< T, Rs... > >
 
class  ExclusiveScanT
 
class  FixedArray
 
struct  Make1stOrderPerturbation
 
struct  Make1stOrderPerturbation< N, N, Offset, T, JetT >
 
struct  Make1stOrderPerturbations
 
struct  Make1stOrderPerturbations< std::integer_sequence< int >, ParameterIdx, Total >
 
struct  Make1stOrderPerturbations< std::integer_sequence< int, N, Ns... >, ParameterIdx, Offset >
 
class  ParameterDims
 
class  Sum
 
struct  SumImpl
 
struct  SumImpl< std::integer_sequence< T > >
 
struct  SumImpl< std::integer_sequence< T, N > >
 
struct  SumImpl< std::integer_sequence< T, N, Ns... > >
 
struct  SumImpl< std::integer_sequence< T, N1, N2, N3, N4, Ns... > >
 
struct  SumImpl< std::integer_sequence< T, N1, N2, Ns... > >
 
struct  Take1stOrderParts
 
struct  Take1stOrderParts< std::integer_sequence< int >, ParameterIdx, Offset >
 
struct  Take1stOrderParts< std::integer_sequence< int, N, Ns... >, ParameterIdx, Offset >
 

Typedefs

template<typename T >
using FixedArrayDefaultAllocator = typename std::conditional< std::is_trivial< T >::value, std::allocator< T >, Eigen::aligned_allocator< T > >::type
 
template<typename Seq >
using ExclusiveScan = typename ExclusiveScanT< Seq >::Type
 
template<int... Ns>
using StaticParameterDims = ParameterDims< false, Ns... >
 
using DynamicParameterDims = ParameterDims< true >
 

Functions

template<typename JetT , typename T >
void Take0thOrderPart (int M, const JetT *src, T dst)
 
template<int N0, int N, typename JetT , typename T >
void Take1stOrderPart (const int M, const JetT *src, T *dst)
 
template<int kNumResiduals, typename ParameterDims , typename Functor , typename T >
bool AutoDifferentiate (const Functor &functor, T const *const *parameters, int dynamic_num_outputs, T *function_value, T **jacobians)
 
template<typename Allocator , typename Iterator , typename... Args>
void ConstructRange (Allocator &alloc, Iterator first, Iterator last, const Args &... args)
 
template<typename Allocator , typename Iterator , typename InputIterator >
void CopyRange (Allocator &alloc, Iterator destination, InputIterator first, InputIterator last)
 
constexpr bool IsValidParameterDimensionSequence (std::integer_sequence< int >)
 
template<int N, int... Ts>
constexpr bool IsValidParameterDimensionSequence (std::integer_sequence< int, N, Ts... >)
 
template<typename Functor , typename T , int... Indices>
bool VariadicEvaluateImpl (const Functor &functor, T const *const *input, T *output, std::false_type, std::integer_sequence< int, Indices... >)
 
template<typename Functor , typename T >
bool VariadicEvaluateImpl (const Functor &functor, T const *const *input, T *output, std::true_type, std::integer_sequence< int >)
 
template<typename ParameterDims , typename Functor , typename T >
bool VariadicEvaluateImpl (const Functor &functor, T const *const *input, T *output, const void *)
 
template<typename ParameterDims , typename Functor , typename T >
bool VariadicEvaluate (const Functor &functor, T const *const *input, T *output)
 

Variables

static constexpr auto kFixedArrayUseDefault = static_cast<size_t>(-1)
 

Typedef Documentation

◆ DynamicParameterDims

Definition at line 120 of file parameter_dims.h.

◆ ExclusiveScan

template<typename Seq >
using g2o::ceres::internal::ExclusiveScan = typedef typename ExclusiveScanT<Seq>::Type

Definition at line 162 of file integer_sequence_algorithm.h.

◆ FixedArrayDefaultAllocator

template<typename T >
using g2o::ceres::internal::FixedArrayDefaultAllocator = typedef typename std::conditional<std::is_trivial<T>::value, std::allocator<T>, Eigen::aligned_allocator<T> >::type

Definition at line 56 of file fixed_array.h.

◆ StaticParameterDims

template<int... Ns>
using g2o::ceres::internal::StaticParameterDims = typedef ParameterDims<false, Ns...>

Definition at line 119 of file parameter_dims.h.

Function Documentation

◆ AutoDifferentiate()

template<int kNumResiduals, typename ParameterDims , typename Functor , typename T >
bool g2o::ceres::internal::AutoDifferentiate ( const Functor &  functor,
T const *const *  parameters,
int  dynamic_num_outputs,
T *  function_value,
T **  jacobians 
)
inline

Definition at line 295 of file autodiff.h.

298 {
300 using Parameters = typename ParameterDims::Parameters;
301
302 ArraySelector<JetT, ParameterDims::kNumParameters,
304 parameters_as_jets(ParameterDims::kNumParameters);
305
306 // Pointers to the beginning of each parameter block
307 std::array<JetT*, ParameterDims::kNumParameterBlocks> unpacked_parameters =
308 ParameterDims::GetUnpackedParameters(parameters_as_jets.data());
309
310 // If the number of residuals is fixed, we use the template argument as the
311 // number of outputs. Otherwise we use the num_outputs parameter. Note: The
312 // ?-operator here is compile-time evaluated, therefore num_outputs is also
313 // a compile-time constant for functors with fixed residuals.
314 const int num_outputs =
315 kNumResiduals == kDynamic ? dynamic_num_outputs : kNumResiduals;
316
318 residuals_as_jets(num_outputs);
319
320 // Invalidate the output Jets, so that we can detect if the user
321 // did not assign values to all of them.
322 for (int i = 0; i < num_outputs; ++i) {
323 residuals_as_jets[i].a = kImpossibleValue;
324 residuals_as_jets[i].v.setConstant(kImpossibleValue);
325 }
326
327 Make1stOrderPerturbations<Parameters>::Apply(parameters,
328 parameters_as_jets.data());
329
330 if (!VariadicEvaluate<ParameterDims>(functor, unpacked_parameters.data(),
331 residuals_as_jets.data())) {
332 return false;
333 }
334
335 Take0thOrderPart(num_outputs, residuals_as_jets.data(), function_value);
336 Take1stOrderParts<Parameters>::Apply(num_outputs, residuals_as_jets.data(),
337 jacobians);
338
339 return true;
340}
#define G2O_CERES_AUTODIFF_MAX_PARAMETERS_ON_STACK
Definition autodiff.h:160
std::integer_sequence< int, Ns... > Parameters
@ kDynamic
Definition types.h:51
const double kImpossibleValue
Definition types.h:59

References G2O_CERES_AUTODIFF_MAX_PARAMETERS_ON_STACK, g2o::ceres::internal::ParameterDims< IsDynamic, Ns >::GetUnpackedParameters(), g2o::ceres::kDynamic, g2o::ceres::kImpossibleValue, g2o::ceres::internal::ParameterDims< IsDynamic, Ns >::kNumParameters, and Take0thOrderPart().

Referenced by g2o::AutoDifferentiation< Edge, EstimateAccess >::linearizeOplusNs().

◆ ConstructRange()

template<typename Allocator , typename Iterator , typename... Args>
void g2o::ceres::internal::ConstructRange ( Allocator &  alloc,
Iterator  first,
Iterator  last,
const Args &...  args 
)

Definition at line 48 of file memory.h.

49 {
50 for (Iterator cur = first; cur != last; ++cur) {
52 std::allocator_traits<Allocator>::construct(alloc, std::addressof(*cur),
53 args...);
54 }
56 while (cur != first) {
57 --cur;
58 std::allocator_traits<Allocator>::destroy(alloc, std::addressof(*cur));
59 }
61 }
62 }
63}
#define G2O_CERES_INTERNAL_RETHROW
Definition memory.h:38
#define G2O_CERES_INTERNAL_TRY
Definition memory.h:36
#define G2O_CERES_INTERNAL_CATCH_ANY
Definition memory.h:37

References G2O_CERES_INTERNAL_CATCH_ANY, G2O_CERES_INTERNAL_RETHROW, and G2O_CERES_INTERNAL_TRY.

Referenced by g2o::ceres::internal::FixedArray< T, N, A >::FixedArray(), and g2o::ceres::internal::FixedArray< T, N, A >::FixedArray().

◆ CopyRange()

template<typename Allocator , typename Iterator , typename InputIterator >
void g2o::ceres::internal::CopyRange ( Allocator &  alloc,
Iterator  destination,
InputIterator  first,
InputIterator  last 
)

Definition at line 66 of file memory.h.

67 {
68 for (Iterator cur = destination; first != last;
69 static_cast<void>(++cur), static_cast<void>(++first)) {
71 std::allocator_traits<Allocator>::construct(alloc, std::addressof(*cur),
72 *first);
73 }
75 while (cur != destination) {
76 --cur;
77 std::allocator_traits<Allocator>::destroy(alloc, std::addressof(*cur));
78 }
80 }
81 }
82}

References G2O_CERES_INTERNAL_CATCH_ANY, G2O_CERES_INTERNAL_RETHROW, and G2O_CERES_INTERNAL_TRY.

Referenced by g2o::ceres::internal::FixedArray< T, N, A >::FixedArray().

◆ IsValidParameterDimensionSequence() [1/2]

constexpr bool g2o::ceres::internal::IsValidParameterDimensionSequence ( std::integer_sequence< int >  )
constexpr

Definition at line 45 of file parameter_dims.h.

45 {
46 return true;
47}

Referenced by IsValidParameterDimensionSequence().

◆ IsValidParameterDimensionSequence() [2/2]

template<int N, int... Ts>
constexpr bool g2o::ceres::internal::IsValidParameterDimensionSequence ( std::integer_sequence< int, N, Ts... >  )
constexpr

Definition at line 50 of file parameter_dims.h.

51 {
52 return (N <= 0) ? false
54 std::integer_sequence<int, Ts...>());
55}
constexpr bool IsValidParameterDimensionSequence(std::integer_sequence< int >)

References IsValidParameterDimensionSequence().

◆ Take0thOrderPart()

template<typename JetT , typename T >
void g2o::ceres::internal::Take0thOrderPart ( int  M,
const JetT *  src,
dst 
)
inline

Definition at line 236 of file autodiff.h.

236 {
237 for (int i = 0; i < M; ++i) {
238 dst[i] = src[i].a;
239 }
240}

Referenced by AutoDifferentiate().

◆ Take1stOrderPart()

template<int N0, int N, typename JetT , typename T >
void g2o::ceres::internal::Take1stOrderPart ( const int  M,
const JetT *  src,
T *  dst 
)
inline

Definition at line 245 of file autodiff.h.

245 {
246 for (int i = 0; i < M; ++i) {
247 Eigen::Map<Eigen::Matrix<T, N, 1>>(dst + N * i, N) =
248 src[i].v.template segment<N>(N0);
249 }
250}

◆ VariadicEvaluate()

template<typename ParameterDims , typename Functor , typename T >
bool g2o::ceres::internal::VariadicEvaluate ( const Functor &  functor,
T const *const *  input,
T *  output 
)
inline

Definition at line 99 of file variadic_evaluate.h.

100 {
101 return VariadicEvaluateImpl<ParameterDims>(functor, input, output, &functor);
102}

◆ VariadicEvaluateImpl() [1/3]

template<typename ParameterDims , typename Functor , typename T >
bool g2o::ceres::internal::VariadicEvaluateImpl ( const Functor &  functor,
T const *const *  input,
T *  output,
const void *   
)
inline

Definition at line 68 of file variadic_evaluate.h.

69 {
70 using ParameterBlockIndices =
71 std::make_integer_sequence<int, ParameterDims::kNumParameterBlocks>;
72 using IsDynamic = std::integral_constant<bool, ParameterDims::kIsDynamic>;
73 return VariadicEvaluateImpl(functor, input, output, IsDynamic(),
74 ParameterBlockIndices());
75}
bool VariadicEvaluateImpl(const Functor &functor, T const *const *input, T *output, std::false_type, std::integer_sequence< int, Indices... >)

References VariadicEvaluateImpl().

◆ VariadicEvaluateImpl() [2/3]

template<typename Functor , typename T , int... Indices>
bool g2o::ceres::internal::VariadicEvaluateImpl ( const Functor &  functor,
T const *const *  input,
T *  output,
std::false_type  ,
std::integer_sequence< int, Indices... >   
)
inline

Definition at line 49 of file variadic_evaluate.h.

51 {
52 static_assert(sizeof...(Indices),
53 "Invalid number of parameter blocks. At least one parameter "
54 "block must be specified.");
55 return functor(input[Indices]..., output);
56}

Referenced by VariadicEvaluateImpl().

◆ VariadicEvaluateImpl() [3/3]

template<typename Functor , typename T >
bool g2o::ceres::internal::VariadicEvaluateImpl ( const Functor &  functor,
T const *const *  input,
T *  output,
std::true_type  ,
std::integer_sequence< int >   
)
inline

Definition at line 60 of file variadic_evaluate.h.

62 {
63 return functor(input, output);
64}

Variable Documentation

◆ kFixedArrayUseDefault

constexpr auto g2o::ceres::internal::kFixedArrayUseDefault = static_cast<size_t>(-1)
staticconstexpr

Definition at line 47 of file fixed_array.h.