(in branch) added VectorValues::setZero() function
parent
a56fe9572e
commit
2ef911b7e9
|
@ -39,7 +39,7 @@ VectorValues& VectorValues::operator=(const VectorValues& rhs) {
|
|||
/* ************************************************************************* */
|
||||
VectorValues VectorValues::Zero(const VectorValues& x) {
|
||||
VectorValues cloned(SameStructure(x));
|
||||
cloned.vector() = Vector::Zero(x.dim());
|
||||
cloned.setZero();
|
||||
return cloned;
|
||||
}
|
||||
|
||||
|
@ -124,10 +124,15 @@ VectorValues VectorValues::SameStructure(const VectorValues& other) {
|
|||
/* ************************************************************************* */
|
||||
VectorValues VectorValues::Zero(Index nVars, size_t varDim) {
|
||||
VectorValues ret(nVars, varDim);
|
||||
ret.vector() = Vector::Zero(ret.dim());
|
||||
ret.setZero();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
void VectorValues::setZero() {
|
||||
values_.setZero();
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
bool VectorValues::hasSameStructure(const VectorValues& other) const {
|
||||
if(this->size() != other.size())
|
||||
|
|
|
@ -238,6 +238,9 @@ namespace gtsam {
|
|||
template<class CONTAINER>
|
||||
void append(const CONTAINER& dimensions);
|
||||
|
||||
/** Set all entries to zero, does not modify the size. */
|
||||
void setZero();
|
||||
|
||||
/** Reference the entire solution vector (const version). */
|
||||
const Vector& vector() const { chk(); return values_; }
|
||||
|
||||
|
@ -383,7 +386,7 @@ namespace gtsam {
|
|||
template<class CONTAINER>
|
||||
VectorValues VectorValues::Zero(const CONTAINER& dimensions) {
|
||||
VectorValues ret(dimensions);
|
||||
ret.vector() = Vector::Zero(ret.dim());
|
||||
ret.setZero();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue