Define and use move constructor
parent
d3cd876cf9
commit
85b457f1e3
|
@ -33,4 +33,10 @@ namespace gtsam {
|
||||||
const KEYS& keys, size_t nrFrontals, const VerticalBlockMatrix& augmentedMatrix, const SharedDiagonal& sigmas) :
|
const KEYS& keys, size_t nrFrontals, const VerticalBlockMatrix& augmentedMatrix, const SharedDiagonal& sigmas) :
|
||||||
BaseFactor(keys, augmentedMatrix, sigmas), BaseConditional(nrFrontals) {}
|
BaseFactor(keys, augmentedMatrix, sigmas), BaseConditional(nrFrontals) {}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
template<typename KEYS>
|
||||||
|
GaussianConditional::GaussianConditional(
|
||||||
|
const KEYS& keys, size_t nrFrontals, VerticalBlockMatrix&& augmentedMatrix, const SharedDiagonal& sigmas) :
|
||||||
|
BaseFactor(keys, std::move(augmentedMatrix), sigmas), BaseConditional(nrFrontals) {}
|
||||||
|
|
||||||
} // gtsam
|
} // gtsam
|
||||||
|
|
|
@ -75,13 +75,34 @@ namespace gtsam {
|
||||||
size_t nrFrontals, const Vector& d,
|
size_t nrFrontals, const Vector& d,
|
||||||
const SharedDiagonal& sigmas = SharedDiagonal());
|
const SharedDiagonal& sigmas = SharedDiagonal());
|
||||||
|
|
||||||
/** Constructor with arbitrary number keys, and where the augmented matrix is given all together
|
/**
|
||||||
* instead of in block terms. Note that only the active view of the provided augmented matrix
|
* @brief Constructor with an arbitrary number of keys, where the augmented matrix
|
||||||
* is used, and that the matrix data is copied into a newly-allocated matrix in the constructed
|
* is given all together instead of in block terms.
|
||||||
* factor. */
|
*
|
||||||
|
* @tparam KEYS Type of the keys container.
|
||||||
|
* @param keys Container of keys.
|
||||||
|
* @param nrFrontals Number of frontal variables.
|
||||||
|
* @param augmentedMatrix The augmented matrix containing the coefficients.
|
||||||
|
* @param sigmas Optional noise model (default is an empty SharedDiagonal).
|
||||||
|
*/
|
||||||
template <typename KEYS>
|
template <typename KEYS>
|
||||||
GaussianConditional(
|
GaussianConditional(const KEYS& keys, size_t nrFrontals,
|
||||||
const KEYS& keys, size_t nrFrontals, const VerticalBlockMatrix& augmentedMatrix,
|
const VerticalBlockMatrix& augmentedMatrix,
|
||||||
|
const SharedDiagonal& sigmas = SharedDiagonal());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Constructor with an arbitrary number of keys, where the augmented matrix
|
||||||
|
* is given all together instead of in block terms, using move semantics for efficiency.
|
||||||
|
*
|
||||||
|
* @tparam KEYS Type of the keys container.
|
||||||
|
* @param keys Container of keys.
|
||||||
|
* @param nrFrontals Number of frontal variables.
|
||||||
|
* @param augmentedMatrix The augmented matrix containing the coefficients (moved).
|
||||||
|
* @param sigmas Optional noise model (default is an empty SharedDiagonal).
|
||||||
|
*/
|
||||||
|
template <typename KEYS>
|
||||||
|
GaussianConditional(const KEYS& keys, size_t nrFrontals,
|
||||||
|
VerticalBlockMatrix&& augmentedMatrix,
|
||||||
const SharedDiagonal& sigmas = SharedDiagonal());
|
const SharedDiagonal& sigmas = SharedDiagonal());
|
||||||
|
|
||||||
/// Construct from mean `mu` and standard deviation `sigma`.
|
/// Construct from mean `mu` and standard deviation `sigma`.
|
||||||
|
|
|
@ -470,7 +470,7 @@ std::shared_ptr<GaussianConditional> HessianFactor::eliminateCholesky(const Orde
|
||||||
|
|
||||||
// TODO(frank): pre-allocate GaussianConditional and write into it
|
// TODO(frank): pre-allocate GaussianConditional and write into it
|
||||||
const VerticalBlockMatrix Ab = info_.split(nFrontals);
|
const VerticalBlockMatrix Ab = info_.split(nFrontals);
|
||||||
conditional = std::make_shared<GaussianConditional>(keys_, nFrontals, Ab);
|
conditional = std::make_shared<GaussianConditional>(keys_, nFrontals, std::move(Ab));
|
||||||
|
|
||||||
// Erase the eliminated keys in this factor
|
// Erase the eliminated keys in this factor
|
||||||
keys_.erase(begin(), begin() + nFrontals);
|
keys_.erase(begin(), begin() + nFrontals);
|
||||||
|
|
Loading…
Reference in New Issue