[mlpack-git] master: Minor formatting changes for row_col_iterators, mostly to adhere to the Whitesmiths style. (becd757)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:56:47 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40
>---------------------------------------------------------------
commit becd7575d0caddb6e801c536cd3513c379a60864
Author: Ryan Curtin <ryan at ratml.org>
Date: Tue Aug 5 14:58:57 2014 +0000
Minor formatting changes for row_col_iterators, mostly to adhere to the
Whitesmiths style.
>---------------------------------------------------------------
becd7575d0caddb6e801c536cd3513c379a60864
src/mlpack/core/arma_extend/Mat_extra_bones.hpp | 14 +-
src/mlpack/core/arma_extend/Mat_extra_meat.hpp | 275 +++++++++++++++--------
src/mlpack/core/arma_extend/SpMat_extra_meat.hpp | 6 +
3 files changed, 193 insertions(+), 102 deletions(-)
diff --git a/src/mlpack/core/arma_extend/Mat_extra_bones.hpp b/src/mlpack/core/arma_extend/Mat_extra_bones.hpp
index fb307fc..7823663 100644
--- a/src/mlpack/core/arma_extend/Mat_extra_bones.hpp
+++ b/src/mlpack/core/arma_extend/Mat_extra_bones.hpp
@@ -11,8 +11,9 @@
class row_col_iterator;
class const_row_col_iterator
-{
-public:
+ {
+ public:
+
// empty constructor
inline const_row_col_iterator();
// constructs const iterator from other iterators
@@ -66,11 +67,12 @@ public:
arma_aligned const eT* current_pos;
arma_aligned uword internal_col;
arma_aligned uword internal_row;
-};
+ };
class row_col_iterator
-{
-public:
+ {
+ public:
+
// empty constructor
inline row_col_iterator();
// constructs const iterator from other iterators
@@ -122,7 +124,7 @@ public:
arma_aligned eT* current_pos;
arma_aligned uword internal_col;
arma_aligned uword internal_row;
-};
+ };
/*
* Extra functions for Mat<eT>
diff --git a/src/mlpack/core/arma_extend/Mat_extra_meat.hpp b/src/mlpack/core/arma_extend/Mat_extra_meat.hpp
index 0161d05..6a9b2fa 100644
--- a/src/mlpack/core/arma_extend/Mat_extra_meat.hpp
+++ b/src/mlpack/core/arma_extend/Mat_extra_meat.hpp
@@ -6,182 +6,223 @@ template<typename eT>
inline
Mat<eT>::const_row_col_iterator::const_row_col_iterator()
: M(NULL), current_pos(NULL), internal_col(0), internal_row(0)
-{
+ {
// Technically this iterator is invalid (it may not point to a real element)
-}
+ }
+
+
template<typename eT>
inline
Mat<eT>::const_row_col_iterator::const_row_col_iterator(const row_col_iterator& it)
: M(it.M), current_pos(it.current_pos), internal_col(it.col()), internal_row(it.row())
-{
+ {
// Nothing to do.
-}
+ }
+
+
template<typename eT>
inline
Mat<eT>::const_row_col_iterator::const_row_col_iterator(const const_row_iterator& it)
: M(&it.M), current_pos(&it.M(it.row, it.col)), internal_col(it.col), internal_row(it.row)
-{
+ {
// Nothing to do.
-}
+ }
+
+
template<typename eT>
inline
Mat<eT>::const_row_col_iterator::const_row_col_iterator(const row_iterator& it)
: M(&it.M), current_pos(&it.M(it.row, it.col)), internal_col(it.col), internal_row(it.row)
-{
+ {
// Nothing to do.
-}
+ }
+
template<typename eT>
inline
Mat<eT>::const_row_col_iterator::const_row_col_iterator(const Mat<eT>& in_M, const uword row, const uword col)
: M(&in_M), current_pos(&in_M(row,col)), internal_col(col), internal_row(row)
-{
+ {
// Nothing to do.
-}
+ }
+
+
template<typename eT>
inline typename Mat<eT>::const_row_col_iterator&
Mat<eT>::const_row_col_iterator::operator++()
-{
+ {
current_pos++;
internal_row++;
// Check to see if we moved a column.
if(internal_row == M->n_rows)
- {
+ {
internal_col++;
internal_row = 0;
- }
+ }
return *this;
-}
+ }
+
+
template<typename eT>
inline typename Mat<eT>::const_row_col_iterator
Mat<eT>::const_row_col_iterator::operator++(int)
-{
+ {
typename Mat<eT>::const_row_col_iterator temp(*this);
++(*this);
return temp;
-}
+ }
+
+
template<typename eT>
inline typename Mat<eT>::const_row_col_iterator&
Mat<eT>::const_row_col_iterator::operator--()
-{
+ {
current_pos--;
internal_row--;
// Check to see if we moved a column.
if(internal_row == -1)
- {
+ {
internal_col--;
internal_row = M->n_rows - 1;
- }
+ }
return *this;
-}
+ }
+
+
template<typename eT>
inline typename Mat<eT>::const_row_col_iterator
Mat<eT>::const_row_col_iterator::operator--(int)
-{
+ {
typename Mat<eT>::const_row_col_iterator temp(*this);
--(*this);
return temp;
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::const_row_col_iterator::operator==(const const_row_col_iterator& rhs) const
-{
+ {
return (rhs.current_pos == current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::const_row_col_iterator::operator!=(const const_row_col_iterator& rhs) const
-{
+ {
return (rhs.current_pos != current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::const_row_col_iterator::operator==(const row_col_iterator& rhs) const
-{
+ {
return (rhs.current_pos == current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::const_row_col_iterator::operator!=(const row_col_iterator& rhs) const
-{
+ {
return (rhs.current_pos != current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::const_row_col_iterator::operator==(const const_iterator& rhs) const
-{
+ {
return (rhs == current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::const_row_col_iterator::operator!=(const const_iterator& rhs) const
-{
+ {
return (rhs != current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::const_row_col_iterator::operator==(const iterator& rhs) const
-{
+ {
return (rhs == current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::const_row_col_iterator::operator!=(const iterator& rhs) const
-{
+ {
return (rhs != current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::const_row_col_iterator::operator==(const const_row_iterator& rhs) const
-{
+ {
return (&rhs.M(rhs.row, rhs.col) == current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::const_row_col_iterator::operator!=(const const_row_iterator& rhs) const
-{
+ {
return (&rhs.M(rhs.row, rhs.col) != current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::const_row_col_iterator::operator==(const row_iterator& rhs) const
-{
+ {
return (&rhs.M(rhs.row, rhs.col) == current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::const_row_col_iterator::operator!=(const row_iterator& rhs) const
-{
+ {
return (&rhs.M(rhs.row, rhs.col) != current_pos);
-}
+ }
+
+
///////////////////////////////////////////////////////////////////////////////
// Mat::row_col_iterator implementation //
@@ -191,166 +232,202 @@ template<typename eT>
inline
Mat<eT>::row_col_iterator::row_col_iterator()
: M(NULL), current_pos(NULL), internal_col(0), internal_row(0)
-{
+ {
// Technically this iterator is invalid (it may not point to a real element)
-}
+ }
+
+
template<typename eT>
inline
Mat<eT>::row_col_iterator::row_col_iterator(const row_iterator& it)
: M(&it.M), current_pos(&it.M(it.row, it.col)), internal_col(it.col), internal_row(it.row)
-{
+ {
// Nothing to do.
-}
+ }
+
template<typename eT>
inline
Mat<eT>::row_col_iterator::row_col_iterator(Mat<eT>& in_M, const uword row, const uword col)
: M(&in_M), current_pos(&in_M(row,col)), internal_col(col), internal_row(row)
-{
+ {
// Nothing to do.
-}
+ }
+
+
template<typename eT>
inline typename Mat<eT>::row_col_iterator&
Mat<eT>::row_col_iterator::operator++()
-{
+ {
current_pos++;
internal_row++;
// Check to see if we moved a column.
if(internal_row == M->n_rows)
- {
+ {
internal_col++;
internal_row = 0;
- }
+ }
return *this;
-}
+ }
+
+
template<typename eT>
inline typename Mat<eT>::row_col_iterator
Mat<eT>::row_col_iterator::operator++(int)
-{
+ {
typename Mat<eT>::row_col_iterator temp(*this);
++(*this);
return temp;
-}
+ }
+
+
template<typename eT>
inline typename Mat<eT>::row_col_iterator&
Mat<eT>::row_col_iterator::operator--()
-{
+ {
current_pos--;
internal_row--;
// Check to see if we moved a column.
if(internal_row == -1)
- {
+ {
internal_col--;
internal_row = M->n_rows - 1;
- }
+ }
return *this;
-}
+ }
+
+
template<typename eT>
inline typename Mat<eT>::row_col_iterator
Mat<eT>::row_col_iterator::operator--(int)
-{
+ {
typename Mat<eT>::row_col_iterator temp(*this);
--(*this);
return temp;
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::row_col_iterator::operator==(const const_row_col_iterator& rhs) const
-{
+ {
return (rhs.current_pos == current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::row_col_iterator::operator!=(const const_row_col_iterator& rhs) const
-{
+ {
return (rhs.current_pos != current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::row_col_iterator::operator==(const row_col_iterator& rhs) const
-{
+ {
return (rhs.current_pos == current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::row_col_iterator::operator!=(const row_col_iterator& rhs) const
-{
+ {
return (rhs.current_pos != current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::row_col_iterator::operator==(const const_iterator& rhs) const
-{
+ {
return (rhs == current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::row_col_iterator::operator!=(const const_iterator& rhs) const
-{
+ {
return (rhs != current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::row_col_iterator::operator==(const iterator& rhs) const
-{
+ {
return (rhs == current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::row_col_iterator::operator!=(const iterator& rhs) const
-{
+ {
return (rhs != current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::row_col_iterator::operator==(const const_row_iterator& rhs) const
-{
+ {
return (&rhs.M(rhs.row, rhs.col) == current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::row_col_iterator::operator!=(const const_row_iterator& rhs) const
-{
+ {
return (&rhs.M(rhs.row, rhs.col) != current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::row_col_iterator::operator==(const row_iterator& rhs) const
-{
+ {
return (&rhs.M(rhs.row, rhs.col) == current_pos);
-}
+ }
+
+
template<typename eT>
inline bool
Mat<eT>::row_col_iterator::operator!=(const row_iterator& rhs) const
-{
+ {
return (&rhs.M(rhs.row, rhs.col) != current_pos);
-}
+ }
+
///////////////////////////////////////////////////////////////////////////////
@@ -360,27 +437,33 @@ Mat<eT>::row_col_iterator::operator!=(const row_iterator& rhs) const
template<typename eT>
inline typename Mat<eT>::const_row_col_iterator
Mat<eT>::begin_row_col() const
-{
+ {
return const_row_col_iterator(*this);
-}
+ }
+
+
template<typename eT>
inline typename Mat<eT>::row_col_iterator
Mat<eT>::begin_row_col()
-{
+ {
return row_col_iterator(*this);
-}
+ }
+
+
template<typename eT>
inline typename Mat<eT>::const_row_col_iterator
Mat<eT>::end_row_col() const
-{
+ {
return ++const_row_col_iterator(*this, n_rows - 1, n_cols - 1);
-}
+ }
+
+
template<typename eT>
inline typename Mat<eT>::row_col_iterator
Mat<eT>::end_row_col()
-{
+ {
return ++row_col_iterator(*this, n_rows - 1, n_cols - 1);
-}
+ }
diff --git a/src/mlpack/core/arma_extend/SpMat_extra_meat.hpp b/src/mlpack/core/arma_extend/SpMat_extra_meat.hpp
index 7c5558e..e8b0413 100644
--- a/src/mlpack/core/arma_extend/SpMat_extra_meat.hpp
+++ b/src/mlpack/core/arma_extend/SpMat_extra_meat.hpp
@@ -257,6 +257,8 @@ SpMat<eT>::begin_row_col() const
return begin();
}
+
+
template<typename eT>
inline typename SpMat<eT>::row_col_iterator
SpMat<eT>::begin_row_col()
@@ -264,6 +266,8 @@ SpMat<eT>::begin_row_col()
return begin();
}
+
+
template<typename eT>
inline typename SpMat<eT>::const_row_col_iterator
SpMat<eT>::end_row_col() const
@@ -271,6 +275,8 @@ SpMat<eT>::end_row_col() const
return end();
}
+
+
template<typename eT>
inline typename SpMat<eT>::row_col_iterator
SpMat<eT>::end_row_col()
More information about the mlpack-git
mailing list