spop_var_bones.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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_var
  16. //! @{
  17. //! Class for finding variance values of a sparse matrix
  18. class spop_var
  19. : public traits_op_xvec
  20. {
  21. public:
  22. template<typename T1>
  23. inline static void apply(SpMat<typename T1::pod_type>& out, const mtSpOp<typename T1::pod_type, T1, spop_var>& in);
  24. template<typename T1>
  25. inline static void apply_noalias(SpMat<typename T1::pod_type>& out, const SpProxy<T1>& p, const uword norm_type, const uword dim);
  26. // Calculate variance of a sparse vector, where we can directly use the memory.
  27. template<typename T1>
  28. inline static typename T1::pod_type var_vec(const T1& X, const uword norm_type = 0);
  29. // Calculate the variance directly. Because this is for sparse matrices, we
  30. // specify both the number of elements in the array (the length of the array)
  31. // as well as the actual number of elements when zeros are included.
  32. template<typename eT>
  33. inline static eT direct_var(const eT* const X, const uword length, const uword N, const uword norm_type = 0);
  34. // For complex numbers.
  35. template<typename T>
  36. inline static T direct_var(const std::complex<T>* const X, const uword length, const uword N, const uword norm_type = 0);
  37. // Calculate the variance using iterators, for non-complex numbers.
  38. template<typename T1, typename eT>
  39. inline static eT iterator_var(T1& it, const T1& end, const uword n_zero, const uword norm_type, const eT junk1, const typename arma_not_cx<eT>::result* junk2 = 0);
  40. // Calculate the variance using iterators, for complex numbers.
  41. template<typename T1, typename eT>
  42. inline static typename get_pod_type<eT>::result iterator_var(T1& it, const T1& end, const uword n_zero, const uword norm_type, const eT junk1, const typename arma_cx_only<eT>::result* junk2 = 0);
  43. };
  44. //! @}