Gen_bones.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 Gen
  16. //! @{
  17. //! support class for generator functions (eg. zeros, randu, randn, ...)
  18. template<typename T1, typename gen_type>
  19. class Gen
  20. : public Base<typename T1::elem_type, Gen<T1, gen_type> >
  21. , public GenSpecialiser<typename T1::elem_type, is_same_type<gen_type, gen_zeros>::yes, is_same_type<gen_type, gen_ones>::yes, is_same_type<gen_type, gen_randu>::yes, is_same_type<gen_type, gen_randn>::yes>
  22. {
  23. public:
  24. typedef typename T1::elem_type elem_type;
  25. typedef typename get_pod_type<elem_type>::result pod_type;
  26. static const bool use_at = (is_same_type<gen_type, gen_eye>::value);
  27. static const bool is_simple = (is_same_type<gen_type, gen_ones>::value) || (is_same_type<gen_type, gen_zeros>::value);
  28. static const bool is_row = T1::is_row;
  29. static const bool is_col = T1::is_col;
  30. static const bool is_xvec = T1::is_xvec;
  31. arma_aligned const uword n_rows;
  32. arma_aligned const uword n_cols;
  33. arma_inline Gen(const uword in_n_rows, const uword in_n_cols);
  34. arma_inline ~Gen();
  35. arma_inline elem_type operator[] (const uword ii) const;
  36. arma_inline elem_type at (const uword row, const uword col) const;
  37. arma_inline elem_type at_alt (const uword ii) const;
  38. inline void apply (Mat<elem_type>& out) const;
  39. inline void apply_inplace_plus (Mat<elem_type>& out) const;
  40. inline void apply_inplace_minus(Mat<elem_type>& out) const;
  41. inline void apply_inplace_schur(Mat<elem_type>& out) const;
  42. inline void apply_inplace_div (Mat<elem_type>& out) const;
  43. inline void apply(subview<elem_type>& out) const;
  44. };
  45. //! @}