Small changes, mainly const correctness
parent
c957672656
commit
92c58e50a1
|
@ -62,7 +62,7 @@ namespace gtsam {
|
|||
|
||||
/** Call print on the object */
|
||||
template<class T>
|
||||
inline void print_(const T& object, const char *s = "") {
|
||||
inline void print_(const T& object, const std::string& s = "") {
|
||||
object.print(s);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,20 +16,20 @@ using namespace std;
|
|||
namespace gtsam {
|
||||
|
||||
template<class T>
|
||||
void LieConfig<T>::print(const std::string &s) const {
|
||||
std::cout << "LieConfig " << s << ", size " << values_.size() << "\n";
|
||||
std::pair<std::string, T> v;
|
||||
void LieConfig<T>::print(const string &s) const {
|
||||
cout << "LieConfig " << s << ", size " << values_.size() << "\n";
|
||||
pair<string, T> v;
|
||||
BOOST_FOREACH(v, values_)
|
||||
::gtsam::print(v.second, v.first + ": ");
|
||||
gtsam::print(v.second, v.first + ": ");
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool LieConfig<T>::equals(const LieConfig<T>& expected, double tol) const {
|
||||
if (values_.size() != expected.values_.size()) return false;
|
||||
std::pair<std::string, T> v;
|
||||
pair<string, T> v;
|
||||
BOOST_FOREACH(v, values_) {
|
||||
boost::optional<const T&> expval = expected.gettry(v.first);
|
||||
if(!expval || !::gtsam::equal(v.second, *expval, tol))
|
||||
if(!expval || !gtsam::equal(v.second, *expval, tol))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -38,7 +38,7 @@ namespace gtsam {
|
|||
template<class T>
|
||||
LieConfig<T> expmap(const LieConfig<T>& c, const VectorConfig& delta) {
|
||||
LieConfig<T> newConfig;
|
||||
std::string j; T pj;
|
||||
string j; T pj;
|
||||
FOREACH_PAIR(j, pj, c.values_) {
|
||||
if (delta.contains(j)) {
|
||||
const Vector& dj = delta[j];
|
||||
|
@ -53,7 +53,7 @@ namespace gtsam {
|
|||
template<class T>
|
||||
LieConfig<T> expmap(const LieConfig<T>& c, const Vector& delta) {
|
||||
LieConfig<T> newConfig;
|
||||
std::pair<std::string, Vector> value;
|
||||
pair<string, Vector> value;
|
||||
int delta_offset = 0;
|
||||
BOOST_FOREACH(value, c) {
|
||||
int cur_dim = dim(value.second);
|
||||
|
|
|
@ -57,14 +57,14 @@ namespace gtsam {
|
|||
virtual ~LieConfig() {}
|
||||
|
||||
/** Retrieve a variable by key, throws std::invalid_argument if not found */
|
||||
const T& get(std::string& key) const {
|
||||
const T& get(const std::string& key) const {
|
||||
iterator it = values_.find(key);
|
||||
if (it == values_.end()) throw std::invalid_argument("invalid key");
|
||||
else return it->second;
|
||||
}
|
||||
|
||||
/** Retrieve a variable by key, returns nothing if not found */
|
||||
boost::optional<const T&> gettry(std::string& key) const {
|
||||
boost::optional<const T&> gettry(const std::string& key) const {
|
||||
const_iterator it = values_.find(key);
|
||||
if (it == values_.end()) return boost::optional<const T&>();
|
||||
else return it->second;
|
||||
|
|
Loading…
Reference in New Issue