g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
core
solver.cpp
Go to the documentation of this file.
1
// g2o - General Graph Optimization
2
// Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are
7
// met:
8
//
9
// * Redistributions of source code must retain the above copyright notice,
10
// this list of conditions and the following disclaimer.
11
// * Redistributions in binary form must reproduce the above copyright
12
// notice, this list of conditions and the following disclaimer in the
13
// documentation and/or other materials provided with the distribution.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27
#include "
solver.h
"
28
29
#include <algorithm>
30
#include <cstring>
31
32
#include "
dynamic_aligned_buffer.hpp
"
33
34
namespace
g2o
{
35
36
Solver::Solver
()
37
:
_optimizer
(0),
38
_x
(0),
39
_b
(0),
40
_xSize
(0),
41
_maxXSize
(0),
42
_isLevenberg
(false),
43
_additionalVectorSpace
(0) {}
44
45
Solver::~Solver
() {
46
free_aligned
(
_x
);
47
free_aligned
(
_b
);
48
}
49
50
void
Solver::resizeVector
(
size_t
sx) {
51
size_t
oldSize =
_xSize
;
52
_xSize
= sx;
53
sx +=
_additionalVectorSpace
;
// allocate some additional space if requested
54
if
(
_maxXSize
< sx) {
55
_maxXSize
= 2 * sx;
56
free_aligned
(
_x
);
57
_x
=
allocate_aligned<double>
(
_maxXSize
);
58
#ifndef NDEBUG
59
memset(
_x
, 0,
_maxXSize
*
sizeof
(
double
));
60
#endif
61
if
(
_b
) {
// backup the former b, might still be needed for online
62
// processing
63
memcpy(
_x
,
_b
, oldSize *
sizeof
(
double
));
64
free_aligned
(
_b
);
65
_b
=
allocate_aligned<double>
(
_maxXSize
);
66
std::swap(
_b
,
_x
);
67
}
else
{
68
_b
=
allocate_aligned<double>
(
_maxXSize
);
69
#ifndef NDEBUG
70
memset(
_b
, 0,
_maxXSize
*
sizeof
(
double
));
71
#endif
72
}
73
}
74
}
75
76
void
Solver::setOptimizer
(
SparseOptimizer
*
optimizer
) {
77
_optimizer
=
optimizer
;
78
}
79
80
void
Solver::setLevenberg
(
bool
levenberg
) {
_isLevenberg
=
levenberg
; }
81
82
void
Solver::setAdditionalVectorSpace
(
size_t
s) {
_additionalVectorSpace
= s; }
83
84
}
// namespace g2o
g2o::Solver::setLevenberg
void setLevenberg(bool levenberg)
Definition
solver.cpp:80
g2o::Solver::_maxXSize
size_t _maxXSize
Definition
solver.h:142
g2o::Solver::~Solver
virtual ~Solver()
Definition
solver.cpp:45
g2o::Solver::_b
double * _b
Definition
solver.h:141
g2o::Solver::_additionalVectorSpace
size_t _additionalVectorSpace
Definition
solver.h:145
g2o::Solver::_isLevenberg
bool _isLevenberg
Definition
solver.h:143
g2o::Solver::_x
double * _x
Definition
solver.h:140
g2o::Solver::levenberg
bool levenberg() const
the system is Levenberg-Marquardt
Definition
solver.h:112
g2o::Solver::_xSize
size_t _xSize
Definition
solver.h:142
g2o::Solver::resizeVector
void resizeVector(size_t sx)
Definition
solver.cpp:50
g2o::Solver::setAdditionalVectorSpace
void setAdditionalVectorSpace(size_t s)
Definition
solver.cpp:82
g2o::Solver::Solver
Solver()
Definition
solver.cpp:36
g2o::Solver::setOptimizer
void setOptimizer(SparseOptimizer *optimizer)
Definition
solver.cpp:76
g2o::Solver::optimizer
SparseOptimizer * optimizer() const
the optimizer (graph) on which the solver works
Definition
solver.h:108
g2o::Solver::_optimizer
SparseOptimizer * _optimizer
Definition
solver.h:139
g2o::SparseOptimizer
Definition
sparse_optimizer.h:42
dynamic_aligned_buffer.hpp
g2o
Definition
dl_wrapper.cpp:55
g2o::allocate_aligned
Type * allocate_aligned(size_t n)
Definition
dynamic_aligned_buffer.hpp:10
g2o::free_aligned
void free_aligned(Type *block)
Definition
dynamic_aligned_buffer.hpp:21
solver.h
Generated on
for g2o by
1.17.0