Cleaned up some application-specific functions in GaussianFactor and VectorValues.
parent
6fec4aa73e
commit
17513a07d5
|
|
@ -151,10 +151,6 @@ namespace gtsam {
|
|||
|
||||
ABlock getA(iterator variable) { return Ab_(variable - keys_.begin()); }
|
||||
|
||||
// direct indexing
|
||||
constABlock getA(size_t idx) const { return Ab_(idx); }
|
||||
ABlock getA(size_t idx) { return Ab_(idx); }
|
||||
|
||||
/** Return the dimension of the variable pointed to by the given key iterator
|
||||
* todo: Remove this in favor of keeping track of dimensions with variables?
|
||||
*/
|
||||
|
|
@ -172,6 +168,13 @@ namespace gtsam {
|
|||
*/
|
||||
static shared_ptr Combine(const FactorGraph<GaussianFactor>& factors, const VariableSlots& variableSlots);
|
||||
|
||||
/**
|
||||
* Combine and eliminate several factors.
|
||||
*/
|
||||
// static std::pair<GaussianBayesNet::shared_ptr, shared_ptr> CombineAndEliminate(
|
||||
// const FactorGraph<GaussianFactor>& factors, const VariableSlots& variableSlots,
|
||||
// size_t nrFrontals=1, SolveMethod solveMethod = SOLVE_QR);
|
||||
|
||||
protected:
|
||||
|
||||
/** Internal debug check to make sure variables are sorted */
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ public:
|
|||
/* dot product */
|
||||
double dot(const VectorValues& V) const { return gtsam::dot(this->values_, V.values_) ; }
|
||||
|
||||
|
||||
/** Total dimensions capacity allocated */
|
||||
size_t dimCapacity() const { return values_.size(); }
|
||||
|
||||
|
|
@ -99,26 +98,11 @@ public:
|
|||
iterator end() { return _impl_iterator<VectorValues>(*this, varStarts_.size()-1); }
|
||||
const_iterator end() const { return _impl_iterator<const VectorValues>(*this, varStarts_.size()-1); }
|
||||
|
||||
double *ptr(Index idx = 0) { return values_.data().begin() + varStarts_[idx] ; }
|
||||
const double *ptr(Index idx = 0) const { return values_.data().begin() + varStarts_[idx] ; }
|
||||
const Vector& values() const { return values_ ; }
|
||||
Vector& values() { return values_ ; }
|
||||
/** Reference the entire solution vector (const version). */
|
||||
const Vector& vector() const { return values_; }
|
||||
|
||||
/* return the dimension spec of this vector, i.e. the dimension of each variable */
|
||||
template <typename T>
|
||||
std::vector<T> getDimSpec() const {
|
||||
const Index n = this->size() ;
|
||||
std::vector<T> spec(n) ;
|
||||
for ( Index i = 0 ; i < n ; ++i ) {
|
||||
spec[i] = varStarts_[i+1] - varStarts_[i] ;
|
||||
}
|
||||
return spec;
|
||||
}
|
||||
|
||||
/* get varStart */
|
||||
std::vector<size_t> getVarStart() const {
|
||||
return varStarts_ ;
|
||||
}
|
||||
/** Reference the entire solution vector. */
|
||||
Vector& vector() { return values_; }
|
||||
|
||||
/** Reserve space for a total number of variables and dimensionality */
|
||||
void reserve(Index nVars, size_t totalDims) { values_.resize(std::max(totalDims, values_.size())); varStarts_.reserve(nVars+1); }
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ TEST(VectorValues, constructor) {
|
|||
|
||||
VectorValues actual(dims, v);
|
||||
LONGS_EQUAL(3, actual.size());
|
||||
DOUBLES_EQUAL(1., *actual.ptr(0), 1e-15);
|
||||
DOUBLES_EQUAL(2., *actual.ptr(1), 1e-15);
|
||||
DOUBLES_EQUAL(4., *actual.ptr(2), 1e-15);
|
||||
DOUBLES_EQUAL(1., actual[0][0], 1e-15);
|
||||
DOUBLES_EQUAL(2., actual[1][0], 1e-15);
|
||||
DOUBLES_EQUAL(4., actual[2][0], 1e-15);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
|
|||
Loading…
Reference in New Issue