create VectorValues with all 1.0
parent
dd3c1fd073
commit
bbb76aab95
|
|
@ -66,6 +66,15 @@ namespace gtsam {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
VectorValues VectorValues::One(const VectorValues& other)
|
||||||
|
{
|
||||||
|
VectorValues result;
|
||||||
|
BOOST_FOREACH(const KeyValuePair& v, other)
|
||||||
|
result.values_.insert(make_pair(v.first, Vector::Ones(v.second.size())));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void VectorValues::update(const VectorValues& values)
|
void VectorValues::update(const VectorValues& values)
|
||||||
{
|
{
|
||||||
|
|
@ -307,6 +316,22 @@ namespace gtsam {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
VectorValues VectorValues::operator*(const VectorValues& c) const
|
||||||
|
{
|
||||||
|
if(this->size() != c.size())
|
||||||
|
throw invalid_argument("VectorValues::operator* called with different vector sizes");
|
||||||
|
assert_throw(hasSameStructure(c),
|
||||||
|
invalid_argument("VectorValues::operator* called with different vector sizes"));
|
||||||
|
|
||||||
|
VectorValues result;
|
||||||
|
// The result.end() hint here should result in constant-time inserts
|
||||||
|
for(const_iterator j1 = begin(), j2 = c.begin(); j1 != end(); ++j1, ++j2)
|
||||||
|
result.values_.insert(result.end(), make_pair(j1->first, j1->second * j2->second));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
VectorValues VectorValues::subtract(const VectorValues& c) const
|
VectorValues VectorValues::subtract(const VectorValues& c) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,9 @@ namespace gtsam {
|
||||||
/** Create a VectorValues with the same structure as \c other, but filled with zeros. */
|
/** Create a VectorValues with the same structure as \c other, but filled with zeros. */
|
||||||
static VectorValues Zero(const VectorValues& other);
|
static VectorValues Zero(const VectorValues& other);
|
||||||
|
|
||||||
|
/** Create a VectorValues with the same structure as \c other, but filled with a constant. */
|
||||||
|
static VectorValues One(const VectorValues& other);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Standard Interface
|
/// @name Standard Interface
|
||||||
/// @{
|
/// @{
|
||||||
|
|
@ -302,6 +305,10 @@ namespace gtsam {
|
||||||
* structure (checked when NDEBUG is not defined). */
|
* structure (checked when NDEBUG is not defined). */
|
||||||
VectorValues subtract(const VectorValues& c) const;
|
VectorValues subtract(const VectorValues& c) const;
|
||||||
|
|
||||||
|
/** Element-wise multiplication. Both VectorValues must have the same structure
|
||||||
|
* (checked when NDEBUG is not defined). */
|
||||||
|
VectorValues operator*(const VectorValues& c) const;
|
||||||
|
|
||||||
/** Element-wise scaling by a constant. */
|
/** Element-wise scaling by a constant. */
|
||||||
friend GTSAM_EXPORT VectorValues operator*(const double a, const VectorValues &v);
|
friend GTSAM_EXPORT VectorValues operator*(const double a, const VectorValues &v);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue