Functions | |
template<typename T1 > | |
arma_inline const Op< T1, op_prod > | prod (const Base< typename T1::elem_type, T1 > &X, const u32 dim=0) |
Delayed product of elements of a matrix along a specified dimension (either rows or columns). The result is stored in a dense matrix that has either one column or one row. For dim = 0, find the sum of each column (i.e. traverse across rows) For dim = 1, find the sum of each row (i.e. traverse across columns) The default is dim = 0. NOTE: this function works differently than in Matlab/Octave. | |
template<typename eT > | |
eT | prod (const Row< eT > &X) |
Immediate 'product of all values' operation for a row vector. | |
template<typename eT > | |
eT | prod (const Col< eT > &X) |
Immediate 'product of all values' operation for a column vector. | |
template<typename T1 > | |
T1::elem_type | prod (const Op< T1, op_prod > &in) |
Immediate 'product of all values' operation, invoked, for example, by: prod(prod(A)). | |
template<typename T1 > | |
const Op< Op< T1, op_prod > , op_prod > | prod (const Op< T1, op_prod > &in, const u32 dim) |
template<typename eT > | |
eT | prod (const subview_row< eT > &S) |
product of all values of a subview_row | |
template<typename eT > | |
eT | prod (const subview_col< eT > &S) |
product of all values of a subview_col | |
template<typename eT > | |
eT | prod (const diagview< eT > &X) |
product of all values of a diagview |
arma_inline const Op<T1, op_prod> prod | ( | const Base< typename T1::elem_type, T1 > & | X, | |
const u32 | dim = 0 | |||
) | [inline] |
Delayed product of elements of a matrix along a specified dimension (either rows or columns). The result is stored in a dense matrix that has either one column or one row. For dim = 0, find the sum of each column (i.e. traverse across rows) For dim = 1, find the sum of each row (i.e. traverse across columns) The default is dim = 0. NOTE: this function works differently than in Matlab/Octave.
Definition at line 32 of file fn_prod.hpp.
References Base< elem_type, derived >::get_ref().
00033 { 00034 arma_extra_debug_sigprint(); 00035 00036 return Op<T1, op_prod>(X.get_ref(), dim, 0); 00037 }
eT prod | ( | const Row< eT > & | X | ) | [inline] |
Immediate 'product of all values' operation for a row vector.
Definition at line 46 of file fn_prod.hpp.
References Mat< eT >::memptr(), and Mat< eT >::n_elem.
00047 { 00048 arma_extra_debug_sigprint(); 00049 00050 arma_debug_check( (X.n_elem < 1), "prod(): given object has no elements" ); 00051 00052 const u32 n_elem = X.n_elem; 00053 const eT* X_mem = X.memptr(); 00054 00055 eT val = X_mem[0]; 00056 00057 for(u32 i=1; i<n_elem; ++i) 00058 { 00059 val *= X_mem[i]; 00060 } 00061 00062 return val; 00063 }
eT prod | ( | const Col< eT > & | X | ) | [inline] |
Immediate 'product of all values' operation for a column vector.
Definition at line 72 of file fn_prod.hpp.
References Mat< eT >::memptr(), and Mat< eT >::n_elem.
00073 { 00074 arma_extra_debug_sigprint(); 00075 00076 arma_debug_check( (X.n_elem < 1), "prod(): given object has no elements" ); 00077 00078 const u32 n_elem = X.n_elem; 00079 const eT* X_mem = X.memptr(); 00080 00081 eT val = X_mem[0]; 00082 00083 for(u32 i=1; i<n_elem; ++i) 00084 { 00085 val *= X_mem[i]; 00086 } 00087 00088 return val; 00089 }
Immediate 'product of all values' operation, invoked, for example, by: prod(prod(A)).
Definition at line 100 of file fn_prod.hpp.
References unwrap< T1 >::M, Op< T1, op_type >::m, Mat< eT >::memptr(), and Mat< eT >::n_elem.
00101 { 00102 arma_extra_debug_sigprint(); 00103 arma_extra_debug_print("prod(): two consecutive prod() calls detected"); 00104 00105 typedef typename T1::elem_type eT; 00106 00107 const unwrap<T1> tmp(in.m); 00108 const Mat<eT>& X = tmp.M; 00109 00110 arma_debug_check( (X.n_elem < 1), "prod(): given object has no elements" ); 00111 00112 const u32 n_elem = X.n_elem; 00113 const eT* X_mem = X.memptr(); 00114 00115 eT val = X_mem[0]; 00116 00117 for(u32 i=1; i<n_elem; ++i) 00118 { 00119 val *= X_mem[i]; 00120 } 00121 00122 return val; 00123 }
const Op<Op<T1, op_prod>, op_prod> prod | ( | const Op< T1, op_prod > & | in, | |
const u32 | dim | |||
) | [inline] |
Definition at line 130 of file fn_prod.hpp.
00131 { 00132 arma_extra_debug_sigprint(); 00133 00134 return Op<Op<T1, op_prod>, op_prod>(in, dim, 0); 00135 }
eT prod | ( | const subview_row< eT > & | S | ) | [inline] |
product of all values of a subview_row
Definition at line 143 of file fn_prod.hpp.
References Mat< eT >::at(), subview< eT >::aux_col1, subview< eT >::aux_col2, subview< eT >::aux_row1, subview< eT >::m, and subview< eT >::n_elem.
00144 { 00145 arma_extra_debug_sigprint(); 00146 00147 arma_debug_check( (S.n_elem < 1), "prod(): given object has no elements" ); 00148 00149 const Mat<eT>& X = S.m; 00150 00151 const u32 row = S.aux_row1; 00152 const u32 start_col = S.aux_col1; 00153 const u32 end_col = S.aux_col2; 00154 00155 eT val = X.at(row,start_col); 00156 00157 for(u32 col=start_col+1; col<=end_col; ++col) 00158 { 00159 val *= X.at(row,col); 00160 } 00161 00162 return val; 00163 }
eT prod | ( | const subview_col< eT > & | S | ) | [inline] |
product of all values of a subview_col
Definition at line 171 of file fn_prod.hpp.
References subview< eT >::colptr(), subview< eT >::n_elem, and subview< eT >::n_rows.
00172 { 00173 arma_extra_debug_sigprint(); 00174 00175 arma_debug_check( (S.n_elem < 1), "prod(): given object has no elements" ); 00176 00177 const eT* S_colptr = S.colptr(0); 00178 const u32 n_rows = S.n_rows; 00179 00180 eT val = S_colptr[0]; 00181 00182 for(u32 row=1; row<n_rows; ++row) 00183 { 00184 val *= S_colptr[row]; 00185 } 00186 00187 return val; 00188 }
eT prod | ( | const diagview< eT > & | X | ) | [inline] |
product of all values of a diagview
Definition at line 196 of file fn_prod.hpp.
References diagview< eT >::n_elem.
00197 { 00198 arma_extra_debug_sigprint(); 00199 00200 arma_debug_check( (X.n_elem < 1), "prod(): given object has no elements" ); 00201 00202 const u32 n_elem = X.n_elem; 00203 00204 eT val = X[0]; 00205 00206 for(u32 i=1; i<n_elem; ++i) 00207 { 00208 val *= X[i]; 00209 } 00210 00211 return val; 00212 }