g2o
Loading...
Searching...
No Matches
g2o
autodiff
array_selector.h
Go to the documentation of this file.
1
// Ceres Solver - A fast non-linear least squares minimizer
2
// Copyright 2020 Google Inc. All rights reserved.
3
// http://ceres-solver.org/
4
//
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are met:
7
//
8
// * Redistributions of source code must retain the above copyright notice,
9
// this list of conditions and the following disclaimer.
10
// * Redistributions in binary form must reproduce the above copyright notice,
11
// this list of conditions and the following disclaimer in the documentation
12
// and/or other materials provided with the distribution.
13
// * Neither the name of Google Inc. nor the names of its contributors may be
14
// used to endorse or promote products derived from this software without
15
// specific prior written permission.
16
//
17
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
// POSSIBILITY OF SUCH DAMAGE.
28
//
29
// Author: darius.rueckert@fau.de (Darius Rueckert)
30
//
31
32
#ifndef G2O_CERES_PUBLIC_INTERNAL_ARRAY_SELECTOR_H_
33
#define G2O_CERES_PUBLIC_INTERNAL_ARRAY_SELECTOR_H_
34
35
#include <array>
36
#include <vector>
37
38
#include "
fixed_array.h
"
39
#include "
types.h
"
40
41
namespace
g2o
{
42
namespace
ceres {
43
namespace
internal
{
44
45
// StaticFixedArray selects the best array implementation based on template
46
// arguments. If the size is not known at compile-time, pass
47
// ceres::DYNAMIC as a size-template argument.
48
//
49
// Three different containers are selected in different scenarios:
50
//
51
// num_elements == DYNAMIC:
52
// -> ceres::internal::FixedArray<T, max_stack_size>(size)
53
54
// num_elements != DYNAMIC && num_elements <= max_stack_size
55
// -> std::array<T,num_elements>
56
57
// num_elements != DYNAMIC && num_elements > max_stack_size
58
// -> std::vector<T>(num_elements)
59
//
60
template
<
typename
T,
int
NumElements,
int
MaxNumElementsOnStack,
61
bool
Dynamic = (NumElements ==
kDynamic
),
62
bool
FitsOnStack = (NumElements <= MaxNumElementsOnStack)>
63
struct
ArraySelector
{};
64
65
template
<
typename
T,
int
NumElements,
int
MaxNumElementsOnStack,
66
bool
FitsOnStack>
67
struct
ArraySelector
<T, NumElements, MaxNumElementsOnStack, true, FitsOnStack>
68
:
ceres::internal::FixedArray
<T, MaxNumElementsOnStack> {
69
explicit
ArraySelector
(
int
s)
70
: ceres::
internal
::
FixedArray
<T, MaxNumElementsOnStack>(s) {}
71
};
72
73
template
<
typename
T,
int
NumElements,
int
MaxNumElementsOnStack>
74
struct
ArraySelector
<T, NumElements, MaxNumElementsOnStack, false, true>
75
: std::array<T, NumElements> {
76
explicit
ArraySelector
(
int
/*s*/
) {}
77
};
78
79
template
<
typename
T,
int
num_elements,
int
max_num_elements_on_stack>
80
struct
ArraySelector
<T, num_elements, max_num_elements_on_stack, false, false>
81
: std::vector<T> {
82
explicit
ArraySelector
(
int
s) :
std
::vector<T>(s) {}
83
};
84
85
}
// namespace internal
86
}
// namespace ceres
87
}
// namespace g2o
88
89
#endif
// G2O_CERES_PUBLIC_INTERNAL_ARRAY_SELECTOR_H_
g2o::ceres::internal::FixedArray
Definition
fixed_array.h:85
fixed_array.h
g2o::ceres::kDynamic
@ kDynamic
Definition
types.h:51
g2o
Definition
dl_wrapper.cpp:55
internal
Definition
base_variable_sized_edge.hpp:29
std
Definition
jet.h:876
g2o::ceres::internal::ArraySelector< T, NumElements, MaxNumElementsOnStack, true, FitsOnStack >::ArraySelector
ArraySelector(int s)
Definition
array_selector.h:69
g2o::ceres::internal::ArraySelector< T, NumElements, MaxNumElementsOnStack, false, true >::ArraySelector
ArraySelector(int)
Definition
array_selector.h:76
g2o::ceres::internal::ArraySelector< T, num_elements, max_num_elements_on_stack, false, false >::ArraySelector
ArraySelector(int s)
Definition
array_selector.h:82
g2o::ceres::internal::ArraySelector
Definition
array_selector.h:63
types.h
Generated on Tue Nov 11 2025 05:18:45 for g2o by
1.9.8