From f5cd87129d0f63585d557dae4f60f1d58b2a3aac Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Thu, 21 Jun 2012 17:53:45 +0000 Subject: [PATCH] Added at(Index) synonym for the operator[]. This allows easier matlab wrapping. --- gtsam/inference/Permutation.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/gtsam/inference/Permutation.h b/gtsam/inference/Permutation.h index 5454dafec..0aa322e87 100644 --- a/gtsam/inference/Permutation.h +++ b/gtsam/inference/Permutation.h @@ -86,11 +86,25 @@ public: /// @{ /** - * Permute the given variable, i.e. determine it's new index after the - * permutation. + * Return the new index of the supplied variable after the permutation */ Index operator[](Index variable) const { check(variable); return rangeIndices_[variable]; } + /** + * Return the new index of the supplied variable after the permutation. This version allows modification. + */ + Index& operator[](Index variable) { check(variable); return rangeIndices_[variable]; } + + /** + * Return the new index of the supplied variable after the permutation. Synonym for operator[](Index). + */ + Index at(Index variable) const { return operator[](variable); } + + /** + * Return the new index of the supplied variable after the permutation. This version allows modification. Synonym for operator[](Index). + */ + Index& at(Index variable) { return operator[](variable); } + /** * The number of variables in the range of this permutation, i.e. the output * space. @@ -145,10 +159,6 @@ public: /// @name Advanced Interface /// @{ - /** - * TODO: comment - */ - Index& operator[](Index variable) { check(variable); return rangeIndices_[variable]; } /** * A partial permutation, reorders the variables selected by selector through