fn_var.hpp
Go to the documentation of this file.
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 
16 
17 
18 
19 template<typename T1>
20 inline
22 var(const Base<typename T1::elem_type,T1>& X, const uword norm_type = 0, const uword dim = 0)
23  {
25 
26  return mtOp<typename T1::pod_type, T1, op_var>(X.get_ref(), norm_type, dim);
27  }
28 
29 
30 
32 template<typename eT>
33 inline
36 var(const Row<eT>& A, const uword norm_type = 0)
37  {
39 
40  const uword A_n_elem = A.n_elem;
41 
42  arma_debug_check( (A_n_elem == 0), "var(): given object has no elements" );
43 
44  return op_var::direct_var(A.mem, A_n_elem, norm_type);
45  }
46 
47 
48 
50 template<typename eT>
51 inline
54 var(const Col<eT>& A, const uword norm_type = 0)
55  {
57 
58  const uword A_n_elem = A.n_elem;
59 
60  arma_debug_check( (A_n_elem == 0), "var(): given object has no elements" );
61 
62  return op_var::direct_var(A.mem, A_n_elem, norm_type);
63  }
64 
65 
66 
67 template<typename eT>
68 inline
71 var(const subview_row<eT>& A, const uword norm_type = 0)
72  {
74 
75  arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" );
76 
77  return op_var::direct_var(A, norm_type);
78  }
79 
80 
81 
82 template<typename eT>
83 inline
86 var(const subview_col<eT>& A, const uword norm_type = 0)
87  {
89 
90  arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" );
91 
92  return op_var::direct_var(A.colptr(0), A.n_rows, norm_type);
93  }
94 
95 
96 
97 template<typename eT>
98 inline
101 var(const diagview<eT>& A, const uword norm_type = 0)
102  {
104 
105  arma_debug_check( (A.n_elem == 0), "var(): given object has no elements" );
106 
107  return op_var::direct_var(A, norm_type);
108  }
109 
110 
111 
112 template<typename eT, typename T1>
113 inline
116 var(const subview_elem1<eT,T1>& A, const uword norm_type = 0)
117  {
119 
120  const Col<eT> X(A);
121 
122  return var(X, norm_type);
123  }
124 
125 
126 
arma_inline const derived & get_ref() const
Definition: Base_meat.hpp:22
const uword n_rows
const uword n_elem
number of elements in the matrix (read-only)
Definition: Mat_bones.hpp:31
const uword n_elem
u32 uword
Definition: typedef.hpp:85
Class for column vectors (matrices with only one column)
Definition: Col_bones.hpp:20
#define arma_debug_check
Definition: debug.hpp:1084
static eT direct_var(const eT *const X, const uword N, const uword norm_type=0)
find the variance of an array
Definition: op_var_meat.hpp:22
arma_inline eT * colptr(const uword in_col)
Class for row vectors (matrices with only one row)
#define arma_extra_debug_sigprint
Definition: debug.hpp:1116
#define arma_warn_unused
const uword n_elem
const mtOp< typename T1::pod_type, T1, op_var > var(const Base< typename T1::elem_type, T1 > &X, const uword norm_type=0, const uword dim=0)
Definition: fn_var.hpp:22
arma_aligned const eT *const mem
pointer to the memory used by the matrix (memory is read-only)
Definition: Mat_bones.hpp:40
Class for storing data required to extract and set the diagonals of a matrix.


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:57