From 918141f0f43963c10b271a56e925e13485ecd1a3 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Wed, 7 Sep 2011 01:16:35 +0000 Subject: [PATCH] Fixed doxygen warnings --- gtsam/geometry/Tensor1.h | 15 ++++--- gtsam/geometry/Tensor1Expression.h | 4 ++ gtsam/geometry/Tensor2.h | 6 ++- gtsam/geometry/Tensor2Expression.h | 68 +++++++++++++++++++----------- gtsam/geometry/Tensor3.h | 3 +- gtsam/geometry/Tensor3Expression.h | 5 +++ gtsam/geometry/Tensor4.h | 3 +- gtsam/geometry/Tensor5.h | 3 +- gtsam/geometry/Tensor5Expression.h | 18 +++++--- gtsam/geometry/tensors.h | 2 +- 10 files changed, 84 insertions(+), 43 deletions(-) diff --git a/gtsam/geometry/Tensor1.h b/gtsam/geometry/Tensor1.h index 6d2d8258e..7cd5c4b31 100644 --- a/gtsam/geometry/Tensor1.h +++ b/gtsam/geometry/Tensor1.h @@ -24,7 +24,7 @@ namespace tensors { /** A rank 1 tensor. Actually stores data. */ template class Tensor1 { - double T[N]; + double T[N]; ///< Storage public: @@ -60,12 +60,13 @@ namespace tensors { return T[i]; } - /* return an expression associated with an index */ - template Tensor1Expression > operator()(Index< - N, I> index) const { - return Tensor1Expression > (*this); + /// return an expression associated with an index + template Tensor1Expression > operator()( + Index index) const { + return Tensor1Expression >(*this); } - }; // Tensor1 + }; +// Tensor1 -} // namespace tensors +}// namespace tensors diff --git a/gtsam/geometry/Tensor1Expression.h b/gtsam/geometry/Tensor1Expression.h index c7de063a4..177234f82 100644 --- a/gtsam/geometry/Tensor1Expression.h +++ b/gtsam/geometry/Tensor1Expression.h @@ -43,9 +43,11 @@ namespace tensors { A iter; const double s; public: + /// Constructor TimesDouble_(const A &a, double s_) : iter(a), s(s_) { } + /// Element access inline double operator()(int i) const { return iter(i) * s; } @@ -67,6 +69,7 @@ namespace tensors { std::cout << "}" << std::endl; } + /// equality template bool equals(const Tensor1Expression & q, double tol) const { for (int i = 0; i < I::dim; i++) @@ -82,6 +85,7 @@ namespace tensors { return sqrt(sumsqr); } + /// test equivalence template bool equivalent(const Tensor1Expression & q, double tol = 1e-9) const { return ((*this) * (1.0 / norm())).equals(q * (1.0 / q.norm()), tol) diff --git a/gtsam/geometry/Tensor2.h b/gtsam/geometry/Tensor2.h index 75f07f2a3..93fcfd397 100644 --- a/gtsam/geometry/Tensor2.h +++ b/gtsam/geometry/Tensor2.h @@ -25,7 +25,7 @@ namespace tensors { template class Tensor2 { protected: - Tensor1 T[N2]; + Tensor1 T[N2]; ///< Storage public: @@ -33,7 +33,7 @@ public: Tensor2() { } - /* construct from data - expressed in row major form */ + /// construct from data - expressed in row major form Tensor2(const double data[N2][N1]) { for (int j = 0; j < N2; j++) T[j] = Tensor1 (data[j]); @@ -49,10 +49,12 @@ public: /** dimension - TODO: is this right for anything other than 3x3? */ size_t dim() const {return N1 * N2;} + /// const element access const double & operator()(int i, int j) const { return T[j](i); } + /// element access double & operator()(int i, int j) { return T[j](i); } diff --git a/gtsam/geometry/Tensor2Expression.h b/gtsam/geometry/Tensor2Expression.h index c73870ee0..6affdb087 100644 --- a/gtsam/geometry/Tensor2Expression.h +++ b/gtsam/geometry/Tensor2Expression.h @@ -39,7 +39,7 @@ namespace tensors { const A iter; public: FixJ_(int j_, const A &a) : - j(j_), iter(a) { + j(j_), iter(a) { } double operator()(int i) const { return iter(i, j); @@ -50,9 +50,11 @@ namespace tensors { class Swap_ { const A iter; public: + /// Constructor Swap_(const A &a) : - iter(a) { + iter(a) { } + /// Element access double operator()(int j, int i) const { return iter(i, j); } @@ -63,9 +65,11 @@ namespace tensors { A iter; const double s; public: + /// Constructor TimesDouble_(const A &a, double s_) : - iter(a), s(s_) { + iter(a), s(s_) { } + /// Element access inline double operator()(int i, int j) const { return iter(i, j) * s; } @@ -76,9 +80,11 @@ namespace tensors { const This a; const Tensor1Expression b; public: + /// Constructor ITimesRank1_(const This &a_, const Tensor1Expression &b_) : - a(a_), b(b_) { + a(a_), b(b_) { } + /// Element access double operator()(int j) const { double sum = 0.0; for (int i = 0; i < I::dim; i++) @@ -92,9 +98,11 @@ namespace tensors { const This a; const Tensor1Expression b; public: + /// Constructor JTimesRank1_(const This &a_, const Tensor1Expression &b_) : - a(a_), b(b_) { + a(a_), b(b_) { } + /// Element access double operator()(int i) const { double sum = 0.0; for (int j = 0; j < J::dim; j++) @@ -108,9 +116,11 @@ namespace tensors { const This a; const Tensor2Expression b; public: + /// Constructor ITimesRank2_(const This &a_, const Tensor2Expression &b_) : - a(a_), b(b_) { + a(a_), b(b_) { } + /// Element access double operator()(int j, int k) const { double sum = 0.0; for (int i = 0; i < I::dim; i++) @@ -123,7 +133,7 @@ namespace tensors { /** constructor */ Tensor2Expression(const A &a) : - iter(a) { + iter(a) { } /** Print */ @@ -137,10 +147,12 @@ namespace tensors { std::cout << "}" << std::endl; } + /// test equality template bool equals(const Tensor2Expression & q, double tol) const { for (int j = 0; j < J::dim; j++) - if (!(*this)(j).equals(q(j), tol)) return false; + if (!(*this)(j).equals(q(j), tol)) + return false; return true; } @@ -149,14 +161,15 @@ namespace tensors { double sumsqr = 0.0; for (int i = 0; i < I::dim; i++) for (int j = 0; j < J::dim; j++) - sumsqr += iter(i,j) * iter(i,j); + sumsqr += iter(i, j) * iter(i, j); return sqrt(sumsqr); } + /// test equivalence template bool equivalent(const Tensor2Expression & q, double tol) const { return ((*this) * (1.0 / norm())).equals(q * (1.0 / q.norm()), tol) - || ((*this) * (-1.0 / norm())).equals(q * (1.0 / q.norm()), tol); + || ((*this) * (-1.0 / norm())).equals(q * (1.0 / q.norm()), tol); } /** element access */ @@ -166,6 +179,7 @@ namespace tensors { /** swap indices */ typedef Tensor2Expression Swapped; + /// Return Swap_ helper class Swapped swap() { return Swap_(iter); } @@ -185,32 +199,34 @@ namespace tensors { bool operator==(const Tensor2Expression& T) const { for (int i = 0; i < I::dim; i++) for (int j = 0; j < J::dim; j++) - if (iter(i, j) != T(i, j)) return false; + if (iter(i, j) != T(i, j)) + return false; return true; } /** c(j) = a(i,j)*b(i) */ template - inline Tensor1Expression , J> operator*( + inline Tensor1Expression, J> operator*( const Tensor1Expression& p) { - return ITimesRank1_ (*this, p); + return ITimesRank1_(*this, p); } /** c(i) = a(i,j)*b(j) */ template - inline Tensor1Expression , I> operator*( + inline Tensor1Expression, I> operator*( const Tensor1Expression &p) { - return JTimesRank1_ (*this, p); + return JTimesRank1_(*this, p); } /** c(j,k) = a(i,j)*T(i,k) */ template inline Tensor2Expression , J, K> operator*( const Tensor2Expression& p) { - return ITimesRank2_ (*this, p); + return ITimesRank2_(*this, p); } - }; // Tensor2Expression + }; + // Tensor2Expression /** Print */ template @@ -224,10 +240,12 @@ namespace tensors { const Tensor1Expression iterA; const Tensor1Expression iterB; public: + /// Constructor Rank1Rank1_(const Tensor1Expression &a, - const Tensor1Expression &b) : - iterA(a), iterB(b) { + const Tensor1Expression &b) : + iterA(a), iterB(b) { } + /// element access double operator()(int i, int j) const { return iterA(i) * iterB(j); } @@ -237,7 +255,7 @@ namespace tensors { template inline Tensor2Expression , I, J> operator*( const Tensor1Expression &a, const Tensor1Expression &b) { - return Rank1Rank1_ (a, b); + return Rank1Rank1_(a, b); } /** @@ -245,8 +263,9 @@ namespace tensors { */ template bool assert_equality(const Tensor2Expression& expected, - const Tensor2Expression& actual, double tol = 1e-9) { - if (actual.equals(expected, tol)) return true; + const Tensor2Expression& actual, double tol = 1e-9) { + if (actual.equals(expected, tol)) + return true; std::cout << "Not equal:\n"; expected.print("expected:\n"); actual.print("actual:\n"); @@ -258,8 +277,9 @@ namespace tensors { */ template bool assert_equivalent(const Tensor2Expression& expected, - const Tensor2Expression& actual, double tol = 1e-9) { - if (actual.equivalent(expected, tol)) return true; + const Tensor2Expression& actual, double tol = 1e-9) { + if (actual.equivalent(expected, tol)) + return true; std::cout << "Not equal:\n"; expected.print("expected:\n"); actual.print("actual:\n"); diff --git a/gtsam/geometry/Tensor3.h b/gtsam/geometry/Tensor3.h index 03c9cb0d1..bd3873f40 100644 --- a/gtsam/geometry/Tensor3.h +++ b/gtsam/geometry/Tensor3.h @@ -24,7 +24,7 @@ namespace tensors { /** Rank 3 Tensor */ template class Tensor3 { - Tensor2 T[N3]; + Tensor2 T[N3]; ///< Storage public: @@ -46,6 +46,7 @@ namespace tensors { T[k] = a(k); } + /// element access double operator()(int i, int j, int k) const { return T[k](i, j); } diff --git a/gtsam/geometry/Tensor3Expression.h b/gtsam/geometry/Tensor3Expression.h index 0fd401e4c..68d880ff5 100644 --- a/gtsam/geometry/Tensor3Expression.h +++ b/gtsam/geometry/Tensor3Expression.h @@ -77,6 +77,7 @@ namespace tensors { std::cout << "}" << std::endl; } + /// test equality template bool equals(const Tensor3Expression & q, double tol) const { for (int k = 0; k < K::dim; k++) @@ -118,9 +119,11 @@ namespace tensors { const Rank2 iterA; const Rank1 iterB; public: + /// Constructor Rank2Rank1_(const Rank2 &a, const Rank1 &b) : iterA(a), iterB(b) { } + /// Element access double operator()(int i, int j, int k) const { return iterA(i, j) * iterB(k); } @@ -141,9 +144,11 @@ namespace tensors { const Rank1 iterA; const Rank2 iterB; public: + /// Constructor Rank1Rank2_(const Rank1 &a, const Rank2 &b) : iterA(a), iterB(b) { } + /// Element access double operator()(int i, int j, int k) const { return iterA(i) * iterB(j, k); } diff --git a/gtsam/geometry/Tensor4.h b/gtsam/geometry/Tensor4.h index 2565f5697..59577f1c2 100644 --- a/gtsam/geometry/Tensor4.h +++ b/gtsam/geometry/Tensor4.h @@ -27,7 +27,7 @@ namespace tensors { private: - Tensor3 T[N4]; + Tensor3 T[N4]; ///< Storage public: @@ -35,6 +35,7 @@ namespace tensors { Tensor4() { } + /// element access double operator()(int i, int j, int k, int l) const { return T[l](i, j, k); } diff --git a/gtsam/geometry/Tensor5.h b/gtsam/geometry/Tensor5.h index b2fecd72e..a33abc06d 100644 --- a/gtsam/geometry/Tensor5.h +++ b/gtsam/geometry/Tensor5.h @@ -27,7 +27,7 @@ namespace tensors { private: - Tensor4 T[N5]; + Tensor4 T[N5]; ///< Storage public: @@ -43,6 +43,7 @@ namespace tensors { T[m] = a(m); } + /// element access double operator()(int i, int j, int k, int l, int m) const { return T[m](i, j, k, l); } diff --git a/gtsam/geometry/Tensor5Expression.h b/gtsam/geometry/Tensor5Expression.h index a86b01b4d..7471901dd 100644 --- a/gtsam/geometry/Tensor5Expression.h +++ b/gtsam/geometry/Tensor5Expression.h @@ -33,9 +33,11 @@ namespace tensors { class Swap34_ { const A iter; public: + /// Constructor Swap34_(const A &a) : - iter(a) { + iter(a) { } + /// swapping element access double operator()(int i, int j, int k, int l, int m) const { return iter(i, j, l, k, m); } @@ -45,7 +47,7 @@ namespace tensors { /** constructor */ Tensor5Expression(const A &a) : - iter(a) { + iter(a) { } /** Print */ @@ -67,6 +69,7 @@ namespace tensors { /** swap indices */ typedef Tensor5Expression Swapped; + /// create Swap34_ helper class Swapped swap34() { return Swap34_(iter); } @@ -76,12 +79,13 @@ namespace tensors { return iter(i, j, k, l, m); } - }; // Tensor5Expression + }; + // Tensor5Expression /** Print */ template void print(const Tensor5Expression& T, - const std::string& s = "Tensor5:") { + const std::string& s = "Tensor5:") { T.print(s); } @@ -93,9 +97,11 @@ namespace tensors { const Rank3 iterA; const Rank2 iterB; public: + /// Constructor Rank3Rank2_(const Rank3 &a, const Rank2 &b) : - iterA(a), iterB(b) { + iterA(a), iterB(b) { } + /// Element access double operator()(int i, int j, int k, int l, int m) const { return iterA(i, j, k) * iterB(l, m); } @@ -106,7 +112,7 @@ namespace tensors { inline Tensor5Expression , I, J, K, L, M> operator*( const Tensor3Expression& a, const Tensor2Expression &b) { - return Rank3Rank2_ (a, b); + return Rank3Rank2_(a, b); } } // namespace tensors diff --git a/gtsam/geometry/tensors.h b/gtsam/geometry/tensors.h index 72168e86f..3d9363f20 100644 --- a/gtsam/geometry/tensors.h +++ b/gtsam/geometry/tensors.h @@ -22,7 +22,7 @@ namespace tensors { /** index */ template struct Index { - static const int dim = Dim; + static const int dim = Dim; ///< dimension }; } // namespace tensors