subview_field_bones.hpp 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
  2. // Copyright 2008-2016 National ICT Australia (NICTA)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // ------------------------------------------------------------------------
  15. //! \addtogroup subview_field
  16. //! @{
  17. //! Class for storing data required to construct or apply operations to a subfield
  18. //! (i.e. where the subfield starts and ends as well as a reference/pointer to the original field),
  19. template<typename oT>
  20. class subview_field
  21. {
  22. public:
  23. typedef oT object_type;
  24. const field<oT>& f;
  25. const uword aux_row1;
  26. const uword aux_col1;
  27. const uword aux_slice1;
  28. const uword n_rows;
  29. const uword n_cols;
  30. const uword n_slices;
  31. const uword n_elem;
  32. protected:
  33. arma_inline subview_field(const field<oT>& in_f, const uword in_row1, const uword in_col1, const uword in_n_rows, const uword in_n_cols);
  34. arma_inline subview_field(const field<oT>& in_f, const uword in_row1, const uword in_col1, const uword in_slice1, const uword in_n_rows, const uword in_n_cols, const uword in_n_slices);
  35. public:
  36. inline ~subview_field();
  37. inline void operator= (const field<oT>& x);
  38. inline void operator= (const subview_field& x);
  39. arma_inline oT& operator[](const uword i);
  40. arma_inline const oT& operator[](const uword i) const;
  41. arma_inline oT& operator()(const uword i);
  42. arma_inline const oT& operator()(const uword i) const;
  43. arma_inline oT& at(const uword row, const uword col);
  44. arma_inline const oT& at(const uword row, const uword col) const;
  45. arma_inline oT& at(const uword row, const uword col, const uword slice);
  46. arma_inline const oT& at(const uword row, const uword col, const uword slice) const;
  47. arma_inline oT& operator()(const uword row, const uword col);
  48. arma_inline const oT& operator()(const uword row, const uword col) const;
  49. arma_inline oT& operator()(const uword row, const uword col, const uword slice);
  50. arma_inline const oT& operator()(const uword row, const uword col, const uword slice) const;
  51. arma_inline bool is_empty() const;
  52. inline bool check_overlap(const subview_field& x) const;
  53. inline void print(const std::string extra_text = "") const;
  54. inline void print(std::ostream& user_stream, const std::string extra_text = "") const;
  55. template<typename functor> inline void for_each(functor F);
  56. template<typename functor> inline void for_each(functor F) const;
  57. inline void fill(const oT& x);
  58. inline static void extract(field<oT>& out, const subview_field& in);
  59. private:
  60. friend class field<oT>;
  61. subview_field();
  62. //subview_field(const subview_field&);
  63. };
  64. //! @}