max@0: // Copyright (C) 2009-2011 NICTA (www.nicta.com.au) max@0: // Copyright (C) 2009-2011 Conrad Sanderson max@0: // max@0: // This file is part of the Armadillo C++ library. max@0: // It is provided without any warranty of fitness max@0: // for any purpose. You can redistribute this file max@0: // and/or modify it under the terms of the GNU max@0: // Lesser General Public License (LGPL) as published max@0: // by the Free Software Foundation, either version 3 max@0: // of the License or (at your option) any later version. max@0: // (see http://www.opensource.org/licenses for more info) max@0: max@0: max@0: //! \addtogroup fn_stddev max@0: //! @{ max@0: max@0: max@0: max@0: template max@0: inline max@0: const mtOp max@0: stddev(const Base& X, const uword norm_type = 0, const uword dim = 0) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: return mtOp(X.get_ref(), norm_type, dim); max@0: } max@0: max@0: max@0: max@0: //! Immediate 'find the standard deviation of a row vector' operation max@0: template max@0: inline max@0: arma_warn_unused max@0: typename get_pod_type::result max@0: stddev(const Row& A, const uword norm_type = 0) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: const uword A_n_elem = A.n_elem; max@0: max@0: arma_debug_check( (A_n_elem == 0), "stddev(): given object has no elements" ); max@0: max@0: return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) ); max@0: } max@0: max@0: max@0: max@0: //! Immediate 'find the standard deviation of a column vector' operation max@0: template max@0: inline max@0: arma_warn_unused max@0: typename get_pod_type::result max@0: stddev(const Col& A, const uword norm_type = 0) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: const uword A_n_elem = A.n_elem; max@0: max@0: arma_debug_check( (A_n_elem == 0), "stddev(): given object has no elements" ); max@0: max@0: return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) ); max@0: } max@0: max@0: max@0: max@0: //! find the standard deviation of a subview_row max@0: template max@0: inline max@0: arma_warn_unused max@0: typename get_pod_type::result max@0: stddev(const subview_row& A, const uword norm_type = 0) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_debug_check( (A.n_elem == 0), "stddev(): given object has no elements" ); max@0: max@0: return std::sqrt( op_var::direct_var(A, norm_type) ); max@0: } max@0: max@0: max@0: max@0: //! find the standard deviation of a subview_col max@0: template max@0: inline max@0: arma_warn_unused max@0: typename get_pod_type::result max@0: stddev(const subview_col& A, const uword norm_type = 0) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_debug_check( (A.n_elem == 0), "stddev(): given object has no elements" ); max@0: max@0: return std::sqrt( op_var::direct_var(A.colptr(0), A.n_rows, norm_type) ); max@0: } max@0: max@0: max@0: max@0: //! find the standard deviation of a diagview max@0: template max@0: inline max@0: arma_warn_unused max@0: typename get_pod_type::result max@0: stddev(const diagview& A, const uword norm_type = 0) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_debug_check( (A.n_elem == 0), "stddev(): given object has no elements" ); max@0: max@0: return std::sqrt( op_var::direct_var(A, norm_type) ); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: arma_warn_unused max@0: typename get_pod_type::result max@0: stddev(const subview_elem1& A, const uword norm_type = 0) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: const Col X(A); max@0: max@0: return stddev(X, norm_type); max@0: } max@0: max@0: max@0: max@0: //! @}