spop_mean_bones.hpp 2.2 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 spop_mean
  16. //! @{
  17. //! Class for finding mean values of a sparse matrix
  18. class spop_mean
  19. : public traits_op_xvec
  20. {
  21. public:
  22. // Apply mean into an output sparse matrix (or vector).
  23. template<typename T1>
  24. inline static void apply(SpMat<typename T1::elem_type>& out, const SpOp<T1, spop_mean>& in);
  25. template<typename T1>
  26. inline static void apply_noalias_fast(SpMat<typename T1::elem_type>& out, const SpProxy<T1>& p, const uword dim);
  27. template<typename T1>
  28. inline static void apply_noalias_slow(SpMat<typename T1::elem_type>& out, const SpProxy<T1>& p, const uword dim);
  29. // Take direct mean of a set of values. Length of array and number of values can be different.
  30. template<typename eT>
  31. inline static eT direct_mean(const eT* const X, const uword length, const uword N);
  32. template<typename eT>
  33. inline static eT direct_mean_robust(const eT* const X, const uword length, const uword N);
  34. template<typename T1>
  35. inline static typename T1::elem_type mean_all(const SpBase<typename T1::elem_type, T1>& X);
  36. template<typename T1, typename spop_type>
  37. inline static typename T1::elem_type mean_all(const SpOp<T1, spop_type>& expr);
  38. // Take the mean using an iterator.
  39. template<typename T1, typename eT>
  40. inline static eT iterator_mean(T1& it, const T1& end, const uword n_zero, const eT junk);
  41. template<typename T1, typename eT>
  42. inline static eT iterator_mean_robust(T1& it, const T1& end, const uword n_zero, const eT junk);
  43. };
  44. //! @}