From 8f8cc458201cab8136addfecb420b4d8bfb09145 Mon Sep 17 00:00:00 2001 From: rajiv2605 Date: Thu, 6 Jul 2017 23:23:39 +0530 Subject: [PATCH] Removed unnecessary code for backporting in src/mlpack/core/arma_extend/ --- .../core/arma_extend/Mat_extra_bones.hpp | 134 +---- .../core/arma_extend/Mat_extra_meat.hpp | 480 +----------------- .../core/arma_extend/SpMat_extra_bones.hpp | 15 +- .../core/arma_extend/SpMat_extra_meat.hpp | 39 +- src/mlpack/core/arma_extend/fn_ind2sub.hpp | 72 +-- .../core/arma_extend/operator_minus.hpp | 25 +- 6 files changed, 6 insertions(+), 759 deletions(-) diff --git a/src/mlpack/core/arma_extend/Mat_extra_bones.hpp b/src/mlpack/core/arma_extend/Mat_extra_bones.hpp index f4f25d610a..7cd678ab3b 100644 --- a/src/mlpack/core/arma_extend/Mat_extra_bones.hpp +++ b/src/mlpack/core/arma_extend/Mat_extra_bones.hpp @@ -29,136 +29,4 @@ typedef Row row_type; * row_col_iterator for Mat. This iterator can return row and column index * of the entry its pointing too. The functionality of this iterator is similar * to sparse matrix iterators. - */ - -#if ARMA_VERSION_MAJOR < 4 || \ - (ARMA_VERSION_MAJOR == 4 && ARMA_VERSION_MINOR < 349) -class row_col_iterator; - -class const_row_col_iterator - { - public: - - // empty constructor - inline const_row_col_iterator(); - // constructs const iterator from other iterators - inline const_row_col_iterator(const row_col_iterator& it); - inline const_row_col_iterator(const const_row_iterator& it); - inline const_row_col_iterator(const row_iterator& it); - // constructs iterator with given row and col index - inline const_row_col_iterator(const Mat& in_M, const uword row = 0, const uword col = 0); - - /* - * Returns the value of the current position. - */ - inline arma_hot const eT& operator*() const { return *current_pos; } - - /* - * Increment and decrement operators for this iterator. - */ - inline arma_hot const_row_col_iterator& operator++(); - inline arma_hot const_row_col_iterator operator++(int); - inline arma_hot const_row_col_iterator& operator--(); - inline arma_hot const_row_col_iterator operator--(int); - - /* - * Comparison operator with itself and other relevant iterators. - */ - inline arma_hot bool operator==(const const_row_col_iterator& rhs) const; - inline arma_hot bool operator!=(const const_row_col_iterator& rhs) const; - inline arma_hot bool operator==(const row_col_iterator& rhs) const; - inline arma_hot bool operator!=(const row_col_iterator& rhs) const; - inline arma_hot bool operator==(const const_iterator& rhs) const; - inline arma_hot bool operator!=(const const_iterator& rhs) const; - inline arma_hot bool operator==(const iterator& rhs) const; - inline arma_hot bool operator!=(const iterator& rhs) const; - inline arma_hot bool operator==(const const_row_iterator& rhs) const; - inline arma_hot bool operator!=(const const_row_iterator& rhs) const; - inline arma_hot bool operator==(const row_iterator& rhs) const; - inline arma_hot bool operator!=(const row_iterator& rhs) const; - - arma_inline uword row() const { return internal_row; } - arma_inline uword col() const { return internal_col; } - - // So that we satisfy the STL iterator types. - typedef std::bidirectional_iterator_tag iterator_category; - typedef eT value_type; - typedef uword difference_type; // not certain on this one - typedef const eT* pointer; - typedef const eT& reference; - - arma_aligned const Mat* M; - - arma_aligned const eT* current_pos; - arma_aligned uword internal_col; - arma_aligned uword internal_row; - }; - -class row_col_iterator - { - public: - - // empty constructor - inline row_col_iterator(); - // constructs const iterator from other iterators - inline row_col_iterator(const row_iterator& it); - // constructs iterator with given row and col index - inline row_col_iterator(Mat& in_M, const uword row = 0, const uword col = 0); - - /* - * Returns the value of the current position. - */ - inline arma_hot eT& operator*() const { return *current_pos; } - - /* - * Increment and decrement operators for this iterator. - */ - inline arma_hot row_col_iterator& operator++(); - inline arma_hot row_col_iterator operator++(int); - inline arma_hot row_col_iterator& operator--(); - inline arma_hot row_col_iterator operator--(int); - - /* - * Comparison operator with itself and other relevant iterators. - */ - inline arma_hot bool operator==(const const_row_col_iterator& rhs) const; - inline arma_hot bool operator!=(const const_row_col_iterator& rhs) const; - inline arma_hot bool operator==(const row_col_iterator& rhs) const; - inline arma_hot bool operator!=(const row_col_iterator& rhs) const; - inline arma_hot bool operator==(const const_iterator& rhs) const; - inline arma_hot bool operator!=(const const_iterator& rhs) const; - inline arma_hot bool operator==(const iterator& rhs) const; - inline arma_hot bool operator!=(const iterator& rhs) const; - inline arma_hot bool operator==(const const_row_iterator& rhs) const; - inline arma_hot bool operator!=(const const_row_iterator& rhs) const; - inline arma_hot bool operator==(const row_iterator& rhs) const; - inline arma_hot bool operator!=(const row_iterator& rhs) const; - - arma_inline uword row() const { return internal_row; } - arma_inline uword col() const { return internal_col; } - - // So that we satisfy the STL iterator types. - typedef std::bidirectional_iterator_tag iterator_category; - typedef eT value_type; - typedef uword difference_type; // not certain on this one - typedef const eT* pointer; - typedef const eT& reference; - - arma_aligned const Mat* M; - - arma_aligned eT* current_pos; - arma_aligned uword internal_col; - arma_aligned uword internal_row; - }; - -/* - * Extra functions for Mat - */ -// begin for iterator row_col_iterator -inline const_row_col_iterator begin_row_col() const; -inline row_col_iterator begin_row_col(); - -// end for iterator row_col_iterator -inline const_row_col_iterator end_row_col() const; -inline row_col_iterator end_row_col(); -#endif + */ \ No newline at end of file diff --git a/src/mlpack/core/arma_extend/Mat_extra_meat.hpp b/src/mlpack/core/arma_extend/Mat_extra_meat.hpp index 0a6851e9fd..4771716078 100644 --- a/src/mlpack/core/arma_extend/Mat_extra_meat.hpp +++ b/src/mlpack/core/arma_extend/Mat_extra_meat.hpp @@ -41,482 +41,4 @@ void Mat::serialize(Archive& ar, const unsigned int /* version */) } ar & make_array(access::rwp(mem), n_elem); -} - -#if ARMA_VERSION_MAJOR < 4 || \ - (ARMA_VERSION_MAJOR == 4 && ARMA_VERSION_MINOR < 349) -/////////////////////////////////////////////////////////////////////////////// -// Mat::const_row_col_iterator implementation // -/////////////////////////////////////////////////////////////////////////////// - -template -inline -Mat::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 -inline -Mat::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 -inline -Mat::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 -inline -Mat::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 -inline -Mat::const_row_col_iterator::const_row_col_iterator(const Mat& 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 -inline typename Mat::const_row_col_iterator& -Mat::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 -inline typename Mat::const_row_col_iterator -Mat::const_row_col_iterator::operator++(int) - { - typename Mat::const_row_col_iterator temp(*this); - - ++(*this); - - return temp; - } - - - -template -inline typename Mat::const_row_col_iterator& -Mat::const_row_col_iterator::operator--() - { - if(internal_row > 0) - { - current_pos--; - internal_row--; - } - else if(internal_col > 0) - { - current_pos--; - internal_col--; - internal_row = M->n_rows - 1; - } - - return *this; - } - - - -template -inline typename Mat::const_row_col_iterator -Mat::const_row_col_iterator::operator--(int) - { - typename Mat::const_row_col_iterator temp(*this); - - --(*this); - - return temp; - } - - - -template -inline bool -Mat::const_row_col_iterator::operator==(const const_row_col_iterator& rhs) const - { - return (rhs.current_pos == current_pos); - } - - - -template -inline bool -Mat::const_row_col_iterator::operator!=(const const_row_col_iterator& rhs) const - { - return (rhs.current_pos != current_pos); - } - - - -template -inline bool -Mat::const_row_col_iterator::operator==(const row_col_iterator& rhs) const - { - return (rhs.current_pos == current_pos); - } - - - -template -inline bool -Mat::const_row_col_iterator::operator!=(const row_col_iterator& rhs) const - { - return (rhs.current_pos != current_pos); - } - - - -template -inline bool -Mat::const_row_col_iterator::operator==(const const_iterator& rhs) const - { - return (rhs == current_pos); - } - - - -template -inline bool -Mat::const_row_col_iterator::operator!=(const const_iterator& rhs) const - { - return (rhs != current_pos); - } - - - -template -inline bool -Mat::const_row_col_iterator::operator==(const iterator& rhs) const - { - return (rhs == current_pos); - } - - - -template -inline bool -Mat::const_row_col_iterator::operator!=(const iterator& rhs) const - { - return (rhs != current_pos); - } - - - -template -inline bool -Mat::const_row_col_iterator::operator==(const const_row_iterator& rhs) const - { - return (&rhs.M(rhs.row, rhs.col) == current_pos); - } - - - -template -inline bool -Mat::const_row_col_iterator::operator!=(const const_row_iterator& rhs) const - { - return (&rhs.M(rhs.row, rhs.col) != current_pos); - } - - - -template -inline bool -Mat::const_row_col_iterator::operator==(const row_iterator& rhs) const - { - return (&rhs.M(rhs.row, rhs.col) == current_pos); - } - - - -template -inline bool -Mat::const_row_col_iterator::operator!=(const row_iterator& rhs) const - { - return (&rhs.M(rhs.row, rhs.col) != current_pos); - } - - - -/////////////////////////////////////////////////////////////////////////////// -// Mat::row_col_iterator implementation // -/////////////////////////////////////////////////////////////////////////////// - -template -inline -Mat::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 -inline -Mat::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 -inline -Mat::row_col_iterator::row_col_iterator(Mat& 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 -inline typename Mat::row_col_iterator& -Mat::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 -inline typename Mat::row_col_iterator -Mat::row_col_iterator::operator++(int) - { - typename Mat::row_col_iterator temp(*this); - - ++(*this); - - return temp; - } - - - -template -inline typename Mat::row_col_iterator& -Mat::row_col_iterator::operator--() - { - if(internal_row != 0) - { - current_pos--; - internal_row--; - } - else if(internal_col != 0) - { - current_pos--; - internal_col--; - internal_row = M->n_rows - 1; - } - - return *this; - } - - - -template -inline typename Mat::row_col_iterator -Mat::row_col_iterator::operator--(int) - { - typename Mat::row_col_iterator temp(*this); - - --(*this); - - return temp; - } - - - -template -inline bool -Mat::row_col_iterator::operator==(const const_row_col_iterator& rhs) const - { - return (rhs.current_pos == current_pos); - } - - - -template -inline bool -Mat::row_col_iterator::operator!=(const const_row_col_iterator& rhs) const - { - return (rhs.current_pos != current_pos); - } - - - -template -inline bool -Mat::row_col_iterator::operator==(const row_col_iterator& rhs) const - { - return (rhs.current_pos == current_pos); - } - - - -template -inline bool -Mat::row_col_iterator::operator!=(const row_col_iterator& rhs) const - { - return (rhs.current_pos != current_pos); - } - - - -template -inline bool -Mat::row_col_iterator::operator==(const const_iterator& rhs) const - { - return (rhs == current_pos); - } - - - -template -inline bool -Mat::row_col_iterator::operator!=(const const_iterator& rhs) const - { - return (rhs != current_pos); - } - - - -template -inline bool -Mat::row_col_iterator::operator==(const iterator& rhs) const - { - return (rhs == current_pos); - } - - - -template -inline bool -Mat::row_col_iterator::operator!=(const iterator& rhs) const - { - return (rhs != current_pos); - } - - - -template -inline bool -Mat::row_col_iterator::operator==(const const_row_iterator& rhs) const - { - return (&rhs.M(rhs.row, rhs.col) == current_pos); - } - - - -template -inline bool -Mat::row_col_iterator::operator!=(const const_row_iterator& rhs) const - { - return (&rhs.M(rhs.row, rhs.col) != current_pos); - } - - - -template -inline bool -Mat::row_col_iterator::operator==(const row_iterator& rhs) const - { - return (&rhs.M(rhs.row, rhs.col) == current_pos); - } - - - -template -inline bool -Mat::row_col_iterator::operator!=(const row_iterator& rhs) const - { - return (&rhs.M(rhs.row, rhs.col) != current_pos); - } - - - -/////////////////////////////////////////////////////////////////////////////// -// extended Mat functionality implementation // -/////////////////////////////////////////////////////////////////////////////// - -template -inline typename Mat::const_row_col_iterator -Mat::begin_row_col() const - { - return const_row_col_iterator(*this); - } - - - -template -inline typename Mat::row_col_iterator -Mat::begin_row_col() - { - return row_col_iterator(*this); - } - - - -template -inline typename Mat::const_row_col_iterator -Mat::end_row_col() const - { - return ++const_row_col_iterator(*this, n_rows - 1, n_cols - 1); - } - - - -template -inline typename Mat::row_col_iterator -Mat::end_row_col() - { - return ++row_col_iterator(*this, n_rows - 1, n_cols - 1); - } - -#endif +} \ No newline at end of file diff --git a/src/mlpack/core/arma_extend/SpMat_extra_bones.hpp b/src/mlpack/core/arma_extend/SpMat_extra_bones.hpp index a5d274c4b9..a05a8f3708 100644 --- a/src/mlpack/core/arma_extend/SpMat_extra_bones.hpp +++ b/src/mlpack/core/arma_extend/SpMat_extra_bones.hpp @@ -27,17 +27,4 @@ typedef SpRow row_type; /* * Extra functions for SpMat * Adding definition of row_col_iterator to generalize with Mat::row_col_iterator - */ -#if ARMA_VERSION_MAJOR < 4 || \ - (ARMA_VERSION_MAJOR == 4 && ARMA_VERSION_MINOR < 349) -typedef iterator row_col_iterator; -typedef const_iterator const_row_col_iterator; - -// begin for iterator row_col_iterator -inline const_row_col_iterator begin_row_col() const; -inline row_col_iterator begin_row_col(); - -// end for iterator row_col_iterator -inline const_row_col_iterator end_row_col() const; -inline row_col_iterator end_row_col(); -#endif + */ \ No newline at end of file diff --git a/src/mlpack/core/arma_extend/SpMat_extra_meat.hpp b/src/mlpack/core/arma_extend/SpMat_extra_meat.hpp index 6035b09938..f21a4f6728 100644 --- a/src/mlpack/core/arma_extend/SpMat_extra_meat.hpp +++ b/src/mlpack/core/arma_extend/SpMat_extra_meat.hpp @@ -41,41 +41,4 @@ void SpMat::serialize(Archive& ar, const unsigned int /* version */) ar & make_array(access::rwp(values), n_nonzero); ar & make_array(access::rwp(row_indices), n_nonzero); ar & make_array(access::rwp(col_ptrs), n_cols + 1); -} - -#if ARMA_VERSION_MAJOR < 4 || \ - (ARMA_VERSION_MAJOR == 4 && ARMA_VERSION_MINOR < 349) -template -inline typename SpMat::const_row_col_iterator -SpMat::begin_row_col() const - { - return begin(); - } - - - -template -inline typename SpMat::row_col_iterator -SpMat::begin_row_col() - { - return begin(); - } - - - -template -inline typename SpMat::const_row_col_iterator -SpMat::end_row_col() const - { - return end(); - } - - - -template -inline typename SpMat::row_col_iterator -SpMat::end_row_col() - { - return end(); - } -#endif +} \ No newline at end of file diff --git a/src/mlpack/core/arma_extend/fn_ind2sub.hpp b/src/mlpack/core/arma_extend/fn_ind2sub.hpp index a3bff68195..e134ef2227 100644 --- a/src/mlpack/core/arma_extend/fn_ind2sub.hpp +++ b/src/mlpack/core/arma_extend/fn_ind2sub.hpp @@ -5,74 +5,4 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. // ------------------------------------------------------------------- // -// Written by Conrad Sanderson - http://conradsanderson.id.au - - #if (ARMA_VERSION_MAJOR < 6 || \ - (ARMA_VERSION_MAJOR == 6 && ARMA_VERSION_MINOR < 399)) - inline - uvec - ind2sub(const SizeMat& s, const uword i) - { - arma_extra_debug_sigprint(); - - arma_debug_check( (i >= (s.n_rows * s.n_cols) ), "ind2sub(): index out of range" ); - - uvec out(2); - - out[0] = i % s.n_rows; - out[1] = i / s.n_rows; - - return out; - } - - - inline - uvec - ind2sub(const SizeCube& s, const uword i) - { - arma_extra_debug_sigprint(); - - arma_debug_check( (i >= (s.n_rows * s.n_cols * s.n_slices) ), "ind2sub(): index out of range" ); - - const uword n_elem_slice = s.n_rows * s.n_cols; - - const uword slice = i / n_elem_slice; - const uword j = i - (slice * n_elem_slice); - const uword row = j % s.n_rows; - const uword col = j / s.n_rows; - - uvec out(3); - - out[0] = row; - out[1] = col; - out[2] = slice; - - return out; - } - - - arma_inline - uword - sub2ind(const SizeMat& s, const uword row, const uword col) - { - arma_extra_debug_sigprint(); - - arma_debug_check( ((row >= s.n_rows) || (col >= s.n_cols)), "sub2ind(): subscript out of range" ); - - return uword(row + col*s.n_rows); - } - - - arma_inline - uword - sub2ind(const SizeCube& s, const uword row, const uword col, const uword slice) - { - arma_extra_debug_sigprint(); - - arma_debug_check( ((row >= s.n_rows) || (col >= s.n_cols) || (slice >= s.n_slices)), "sub2ind(): subscript out of range" ); - - return uword( (slice * s.n_rows * s.n_cols) + (col * s.n_rows) + row ); - } -#endif - - +// Written by Conrad Sanderson - http://conradsanderson.id.au \ No newline at end of file diff --git a/src/mlpack/core/arma_extend/operator_minus.hpp b/src/mlpack/core/arma_extend/operator_minus.hpp index 0e56c6218a..0d46b8bfb0 100644 --- a/src/mlpack/core/arma_extend/operator_minus.hpp +++ b/src/mlpack/core/arma_extend/operator_minus.hpp @@ -9,27 +9,4 @@ // Written by Ryan Curtin // Backport unary minus operator for sparse matrices to Armadillo 4.000 and -// older. - -#if (ARMA_VERSION_MAJOR < 4) || \ - (ARMA_VERSION_MAJOR == 4 && ARMA_VERSION_MINOR <= 0) - -template -inline -typename -enable_if2 - < - is_arma_sparse_type::value && is_signed::value, - SpOp - >::result -operator- -(const T1& X) - { - arma_extra_debug_sigprint(); - - typedef typename T1::elem_type eT; - - return SpOp(X, eT(-1)); - } - -#endif +// older. \ No newline at end of file