Added get and set

release/4.3a0
Frank Dellaert 2010-02-18 14:30:16 +00:00
parent ede0a8c874
commit cd5c281c76
5 changed files with 24 additions and 6 deletions

View File

@ -419,10 +419,10 @@
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="testVectorConfig.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<target name="testVectorMap.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments>-j2</buildArguments>
<buildTarget>testVectorConfig.run</buildTarget>
<buildTarget>testVectorMap.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
@ -469,7 +469,6 @@
</target>
<target name="testBayesTree.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testBayesTree.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -477,6 +476,7 @@
</target>
<target name="testSymbolicBayesNet.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testSymbolicBayesNet.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -484,7 +484,6 @@
</target>
<target name="testSymbolicFactorGraph.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testSymbolicFactorGraph.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -676,7 +675,6 @@
</target>
<target name="testGraph.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testGraph.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -732,6 +730,7 @@
</target>
<target name="testSimulated2D.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>testSimulated2D.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
@ -769,6 +768,14 @@
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="testVectorBTree.run" path="cpp" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments>-j2</buildArguments>
<buildTarget>testVectorBTree.run</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="install" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments>-j2</buildArguments>

View File

@ -102,6 +102,10 @@ public:
SubVector operator[](const Symbol& j);
ConstSubVector operator[](const Symbol& j) const;
/** [set] and [get] provided for access via MATLAB */
void set(const Symbol& j, const Vector& v) { (*this)[j] = v; }
inline const Vector get(const Symbol& j) const { return (*this)[j];}
/** max of the vectors */
double max() const;

View File

@ -60,6 +60,11 @@ namespace gtsam {
Vector& operator[](const Symbol& j);
const Vector& operator[](const Symbol& j) const;
/** [set] and [get] provided for access via MATLAB */
inline Vector& get(const Symbol& j) { return (*this)[j];}
void set(const Symbol& j, const Vector& v) { (*this)[j] = v; }
inline const Vector& get(const Symbol& j) const { return (*this)[j];}
bool contains(const Symbol& name) const {
const_iterator it = values.find(name);
return (it!=values.end());

View File

@ -48,6 +48,7 @@ TEST( VectorBTree, constructor_insert_get )
LONGS_EQUAL(1,actual.size())
CHECK(assert_equal(expected,actual))
CHECK(equal_with_abs_tol(v,actual[x1]))
CHECK(equal_with_abs_tol(v,actual.get(x1)))
}
/* ************************************************************************* */

View File

@ -44,6 +44,7 @@ TEST( VectorMap, equals1 )
VectorMap actual;
actual.insert("a",v);
CHECK(assert_equal(expected,actual));
CHECK(assert_equal(expected["a"],actual.get("a")))
}
/* ************************************************************************* */