$search
00001 // Copyright (C) 2009-2011 NICTA (www.nicta.com.au) 00002 // Copyright (C) 2009-2011 Conrad Sanderson 00003 // 00004 // This file is part of the Armadillo C++ library. 00005 // It is provided without any warranty of fitness 00006 // for any purpose. You can redistribute this file 00007 // and/or modify it under the terms of the GNU 00008 // Lesser General Public License (LGPL) as published 00009 // by the Free Software Foundation, either version 3 00010 // of the License or (at your option) any later version. 00011 // (see http://www.opensource.org/licenses for more info) 00012 00013 00016 00017 00018 00019 template<typename T1> 00020 inline 00021 const mtOp<typename T1::pod_type, T1, op_stddev> 00022 stddev(const Base<typename T1::elem_type,T1>& X, const uword norm_type = 0, const uword dim = 0) 00023 { 00024 arma_extra_debug_sigprint(); 00025 00026 return mtOp<typename T1::pod_type, T1, op_stddev>(X.get_ref(), norm_type, dim); 00027 } 00028 00029 00030 00032 template<typename eT> 00033 inline 00034 arma_warn_unused 00035 typename get_pod_type<eT>::result 00036 stddev(const Row<eT>& A, const uword norm_type = 0) 00037 { 00038 arma_extra_debug_sigprint(); 00039 00040 const uword A_n_elem = A.n_elem; 00041 00042 arma_debug_check( (A_n_elem == 0), "stddev(): given object has no elements" ); 00043 00044 return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) ); 00045 } 00046 00047 00048 00050 template<typename eT> 00051 inline 00052 arma_warn_unused 00053 typename get_pod_type<eT>::result 00054 stddev(const Col<eT>& A, const uword norm_type = 0) 00055 { 00056 arma_extra_debug_sigprint(); 00057 00058 const uword A_n_elem = A.n_elem; 00059 00060 arma_debug_check( (A_n_elem == 0), "stddev(): given object has no elements" ); 00061 00062 return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) ); 00063 } 00064 00065 00066 00068 template<typename eT> 00069 inline 00070 arma_warn_unused 00071 typename get_pod_type<eT>::result 00072 stddev(const subview_row<eT>& A, const uword norm_type = 0) 00073 { 00074 arma_extra_debug_sigprint(); 00075 00076 arma_debug_check( (A.n_elem == 0), "stddev(): given object has no elements" ); 00077 00078 return std::sqrt( op_var::direct_var(A, norm_type) ); 00079 } 00080 00081 00082 00084 template<typename eT> 00085 inline 00086 arma_warn_unused 00087 typename get_pod_type<eT>::result 00088 stddev(const subview_col<eT>& A, const uword norm_type = 0) 00089 { 00090 arma_extra_debug_sigprint(); 00091 00092 arma_debug_check( (A.n_elem == 0), "stddev(): given object has no elements" ); 00093 00094 return std::sqrt( op_var::direct_var(A.colptr(0), A.n_rows, norm_type) ); 00095 } 00096 00097 00098 00100 template<typename eT> 00101 inline 00102 arma_warn_unused 00103 typename get_pod_type<eT>::result 00104 stddev(const diagview<eT>& A, const uword norm_type = 0) 00105 { 00106 arma_extra_debug_sigprint(); 00107 00108 arma_debug_check( (A.n_elem == 0), "stddev(): given object has no elements" ); 00109 00110 return std::sqrt( op_var::direct_var(A, norm_type) ); 00111 } 00112 00113 00114 00115 template<typename eT, typename T1> 00116 inline 00117 arma_warn_unused 00118 typename get_pod_type<eT>::result 00119 stddev(const subview_elem1<eT,T1>& A, const uword norm_type = 0) 00120 { 00121 arma_extra_debug_sigprint(); 00122 00123 const Col<eT> X(A); 00124 00125 return stddev(X, norm_type); 00126 } 00127 00128 00129