1 // SPDX-License-Identifier: Apache-2.0
2 //
3 // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
4 // Copyright 2008-2016 National ICT Australia (NICTA)
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 // ------------------------------------------------------------------------
17
18
19 //! \addtogroup fn_var
20 //! @{
21
22
23
24 template<typename T1>
25 arma_warn_unused
26 inline
27 typename
28 enable_if2
29 <
30 is_arma_type<T1>::value && resolves_to_vector<T1>::yes,
31 typename T1::pod_type
32 >::result
var(const T1 & X,const uword norm_type=0)33 var(const T1& X, const uword norm_type = 0)
34 {
35 arma_extra_debug_sigprint();
36
37 return op_var::var_vec(X, norm_type);
38 }
39
40
41
42 template<typename T1>
43 arma_warn_unused
44 inline
45 typename
46 enable_if2
47 <
48 is_arma_type<T1>::value && resolves_to_vector<T1>::no,
49 const mtOp<typename T1::pod_type, T1, op_var>
50 >::result
var(const T1 & X,const uword norm_type=0)51 var(const T1& X, const uword norm_type = 0)
52 {
53 arma_extra_debug_sigprint();
54
55 return mtOp<typename T1::pod_type, T1, op_var>(X, norm_type, 0);
56 }
57
58
59
60 template<typename T1>
61 arma_warn_unused
62 inline
63 typename
64 enable_if2
65 <
66 is_arma_type<T1>::value,
67 const mtOp<typename T1::pod_type, T1, op_var>
68 >::result
var(const T1 & X,const uword norm_type,const uword dim)69 var(const T1& X, const uword norm_type, const uword dim)
70 {
71 arma_extra_debug_sigprint();
72
73 return mtOp<typename T1::pod_type, T1, op_var>(X, norm_type, dim);
74 }
75
76
77
78 template<typename T>
79 arma_warn_unused
80 arma_inline
81 typename arma_scalar_only<T>::result
var(const T &)82 var(const T&)
83 {
84 return T(0);
85 }
86
87
88
89 template<typename T1>
90 arma_warn_unused
91 inline
92 typename
93 enable_if2
94 <
95 is_arma_sparse_type<T1>::value && resolves_to_sparse_vector<T1>::yes,
96 typename T1::pod_type
97 >::result
var(const T1 & X,const uword norm_type=0)98 var(const T1& X, const uword norm_type = 0)
99 {
100 arma_extra_debug_sigprint();
101
102 return spop_var::var_vec(X, norm_type);
103 }
104
105
106
107 template<typename T1>
108 arma_warn_unused
109 inline
110 typename
111 enable_if2
112 <
113 is_arma_sparse_type<T1>::value && resolves_to_sparse_vector<T1>::no,
114 const mtSpOp<typename T1::pod_type, T1, spop_var>
115 >::result
var(const T1 & X,const uword norm_type=0)116 var(const T1& X, const uword norm_type = 0)
117 {
118 arma_extra_debug_sigprint();
119
120 return mtSpOp<typename T1::pod_type, T1, spop_var>(X, norm_type, 0);
121 }
122
123
124
125 template<typename T1>
126 arma_warn_unused
127 inline
128 typename
129 enable_if2
130 <
131 is_arma_sparse_type<T1>::value,
132 const mtSpOp<typename T1::pod_type, T1, spop_var>
133 >::result
var(const T1 & X,const uword norm_type,const uword dim)134 var(const T1& X, const uword norm_type, const uword dim)
135 {
136 arma_extra_debug_sigprint();
137
138 return mtSpOp<typename T1::pod_type, T1, spop_var>(X, norm_type, dim);
139 }
140
141
142
143 //! @}
144