spdiagview_bones.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 spdiagview
  16. //! @{
  17. //! Class for storing data required to extract and set the diagonals of a sparse matrix
  18. template<typename eT>
  19. class spdiagview : public SpBase<eT, spdiagview<eT> >
  20. {
  21. public:
  22. typedef eT elem_type;
  23. typedef typename get_pod_type<eT>::result pod_type;
  24. arma_aligned const SpMat<eT>& m;
  25. static const bool is_row = false;
  26. static const bool is_col = true;
  27. static const bool is_xvec = false;
  28. const uword row_offset;
  29. const uword col_offset;
  30. const uword n_rows; // equal to n_elem
  31. const uword n_elem;
  32. static const uword n_cols = 1;
  33. protected:
  34. arma_inline spdiagview(const SpMat<eT>& in_m, const uword in_row_offset, const uword in_col_offset, const uword len);
  35. public:
  36. inline ~spdiagview();
  37. inline void operator=(const spdiagview& x);
  38. inline void operator+=(const eT val);
  39. inline void operator-=(const eT val);
  40. inline void operator*=(const eT val);
  41. inline void operator/=(const eT val);
  42. template<typename T1> inline void operator= (const Base<eT,T1>& x);
  43. template<typename T1> inline void operator+=(const Base<eT,T1>& x);
  44. template<typename T1> inline void operator-=(const Base<eT,T1>& x);
  45. template<typename T1> inline void operator%=(const Base<eT,T1>& x);
  46. template<typename T1> inline void operator/=(const Base<eT,T1>& x);
  47. template<typename T1> inline void operator= (const SpBase<eT,T1>& x);
  48. template<typename T1> inline void operator+=(const SpBase<eT,T1>& x);
  49. template<typename T1> inline void operator-=(const SpBase<eT,T1>& x);
  50. template<typename T1> inline void operator%=(const SpBase<eT,T1>& x);
  51. template<typename T1> inline void operator/=(const SpBase<eT,T1>& x);
  52. inline SpMat_MapMat_val<eT> operator[](const uword ii);
  53. inline eT operator[](const uword ii) const;
  54. inline SpMat_MapMat_val<eT> at(const uword ii);
  55. inline eT at(const uword ii) const;
  56. inline SpMat_MapMat_val<eT> operator()(const uword ii);
  57. inline eT operator()(const uword ii) const;
  58. inline SpMat_MapMat_val<eT> at(const uword in_n_row, const uword);
  59. inline eT at(const uword in_n_row, const uword) const;
  60. inline SpMat_MapMat_val<eT> operator()(const uword in_n_row, const uword in_n_col);
  61. inline eT operator()(const uword in_n_row, const uword in_n_col) const;
  62. inline void fill(const eT val);
  63. inline void zeros();
  64. inline void ones();
  65. inline void randu();
  66. inline void randn();
  67. inline static void extract(SpMat<eT>& out, const spdiagview& in);
  68. inline static void extract( Mat<eT>& out, const spdiagview& in);
  69. private:
  70. friend class SpMat<eT>;
  71. spdiagview();
  72. };
  73. //! @}