Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-2.4.4/include/armadillo_bits/fn_stddev.hpp @ 0:8b6102e2a9b0
Armadillo Library
author | maxzanoni76 <max.zanoni@eecs.qmul.ac.uk> |
---|---|
date | Wed, 11 Apr 2012 09:27:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8b6102e2a9b0 |
---|---|
1 // Copyright (C) 2009-2011 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2009-2011 Conrad Sanderson | |
3 // | |
4 // This file is part of the Armadillo C++ library. | |
5 // It is provided without any warranty of fitness | |
6 // for any purpose. You can redistribute this file | |
7 // and/or modify it under the terms of the GNU | |
8 // Lesser General Public License (LGPL) as published | |
9 // by the Free Software Foundation, either version 3 | |
10 // of the License or (at your option) any later version. | |
11 // (see http://www.opensource.org/licenses for more info) | |
12 | |
13 | |
14 //! \addtogroup fn_stddev | |
15 //! @{ | |
16 | |
17 | |
18 | |
19 template<typename T1> | |
20 inline | |
21 const mtOp<typename T1::pod_type, T1, op_stddev> | |
22 stddev(const Base<typename T1::elem_type,T1>& X, const uword norm_type = 0, const uword dim = 0) | |
23 { | |
24 arma_extra_debug_sigprint(); | |
25 | |
26 return mtOp<typename T1::pod_type, T1, op_stddev>(X.get_ref(), norm_type, dim); | |
27 } | |
28 | |
29 | |
30 | |
31 //! Immediate 'find the standard deviation of a row vector' operation | |
32 template<typename eT> | |
33 inline | |
34 arma_warn_unused | |
35 typename get_pod_type<eT>::result | |
36 stddev(const Row<eT>& A, const uword norm_type = 0) | |
37 { | |
38 arma_extra_debug_sigprint(); | |
39 | |
40 const uword A_n_elem = A.n_elem; | |
41 | |
42 arma_debug_check( (A_n_elem == 0), "stddev(): given object has no elements" ); | |
43 | |
44 return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) ); | |
45 } | |
46 | |
47 | |
48 | |
49 //! Immediate 'find the standard deviation of a column vector' operation | |
50 template<typename eT> | |
51 inline | |
52 arma_warn_unused | |
53 typename get_pod_type<eT>::result | |
54 stddev(const Col<eT>& A, const uword norm_type = 0) | |
55 { | |
56 arma_extra_debug_sigprint(); | |
57 | |
58 const uword A_n_elem = A.n_elem; | |
59 | |
60 arma_debug_check( (A_n_elem == 0), "stddev(): given object has no elements" ); | |
61 | |
62 return std::sqrt( op_var::direct_var(A.mem, A_n_elem, norm_type) ); | |
63 } | |
64 | |
65 | |
66 | |
67 //! find the standard deviation of a subview_row | |
68 template<typename eT> | |
69 inline | |
70 arma_warn_unused | |
71 typename get_pod_type<eT>::result | |
72 stddev(const subview_row<eT>& A, const uword norm_type = 0) | |
73 { | |
74 arma_extra_debug_sigprint(); | |
75 | |
76 arma_debug_check( (A.n_elem == 0), "stddev(): given object has no elements" ); | |
77 | |
78 return std::sqrt( op_var::direct_var(A, norm_type) ); | |
79 } | |
80 | |
81 | |
82 | |
83 //! find the standard deviation of a subview_col | |
84 template<typename eT> | |
85 inline | |
86 arma_warn_unused | |
87 typename get_pod_type<eT>::result | |
88 stddev(const subview_col<eT>& A, const uword norm_type = 0) | |
89 { | |
90 arma_extra_debug_sigprint(); | |
91 | |
92 arma_debug_check( (A.n_elem == 0), "stddev(): given object has no elements" ); | |
93 | |
94 return std::sqrt( op_var::direct_var(A.colptr(0), A.n_rows, norm_type) ); | |
95 } | |
96 | |
97 | |
98 | |
99 //! find the standard deviation of a diagview | |
100 template<typename eT> | |
101 inline | |
102 arma_warn_unused | |
103 typename get_pod_type<eT>::result | |
104 stddev(const diagview<eT>& A, const uword norm_type = 0) | |
105 { | |
106 arma_extra_debug_sigprint(); | |
107 | |
108 arma_debug_check( (A.n_elem == 0), "stddev(): given object has no elements" ); | |
109 | |
110 return std::sqrt( op_var::direct_var(A, norm_type) ); | |
111 } | |
112 | |
113 | |
114 | |
115 template<typename eT, typename T1> | |
116 inline | |
117 arma_warn_unused | |
118 typename get_pod_type<eT>::result | |
119 stddev(const subview_elem1<eT,T1>& A, const uword norm_type = 0) | |
120 { | |
121 arma_extra_debug_sigprint(); | |
122 | |
123 const Col<eT> X(A); | |
124 | |
125 return stddev(X, norm_type); | |
126 } | |
127 | |
128 | |
129 | |
130 //! @} |