27 typedef typename T1::pod_type T;
35 const uword N = A.get_n_elem();
39 for(i=0, j=1; j<N; i+=2, j+=2)
52 const uword n_rows = A.get_n_rows();
53 const uword n_cols = A.get_n_cols();
55 for(
uword col=0; col<n_cols; ++col)
59 for(i=0, j=1; j<n_rows; i+=2, j+=2)
86 typedef typename T1::pod_type T;
94 const uword N = A.get_n_elem();
98 for(i=0, j=1; j<N; i+=2, j+=2)
100 const T tmp_i = P[i];
101 const T tmp_j = P[j];
103 acc += tmp_i * tmp_i;
104 acc += tmp_j * tmp_j;
109 const T tmp_i = P[i];
111 acc += tmp_i * tmp_i;
116 const uword n_rows = A.get_n_rows();
117 const uword n_cols = A.get_n_cols();
119 for(
uword col=0; col<n_cols; ++col)
123 for(i=0, j=1; j<n_rows; i+=2, j+=2)
125 const T tmp_i = A.at(i,col);
126 const T tmp_j = A.at(j,col);
128 acc += tmp_i * tmp_i;
129 acc += tmp_j * tmp_j;
134 const T tmp_i = A.at(i,col);
136 acc += tmp_i * tmp_i;
146 template<
typename T1>
149 typename T1::pod_type
155 typedef typename T1::pod_type T;
163 const uword N = A.get_n_elem();
165 for(
uword i=0; i<N; ++i)
173 const uword n_rows = A.get_n_rows();
174 const uword n_cols = A.get_n_cols();
176 for(
uword col=0; col<n_cols; ++col)
177 for(
uword row=0; row<n_rows; ++row)
179 const T tmp =
std::abs(A.at(row,col));
189 template<
typename T1>
192 typename T1::pod_type
197 typedef typename T1::pod_type T;
205 const uword N = A.get_n_elem();
209 for(i=0, j=1; j<N; i+=2, j+=2)
222 const uword n_rows = A.get_n_rows();
223 const uword n_cols = A.get_n_cols();
225 for(
uword col=0; col<n_cols; ++col)
226 for(
uword row=0; row<n_rows; ++row)
237 template<
typename T1>
240 typename T1::pod_type
245 typedef typename T1::pod_type T;
248 ea_type P = A.get_ea();
249 const uword N = A.get_n_elem();
251 T max_val = (N != 1) ? priv::most_neg<T>() :
std::abs(P[0]);
255 for(i=0, j=1; j<N; i+=2, j+=2)
260 if(max_val < tmp_i) { max_val = tmp_i; }
261 if(max_val < tmp_j) { max_val = tmp_j; }
268 if(max_val < tmp_i) { max_val = tmp_i; }
276 template<
typename T1>
279 typename T1::pod_type
284 typedef typename T1::pod_type T;
287 ea_type P = A.get_ea();
288 const uword N = A.get_n_elem();
290 T min_val = (N != 1) ? priv::most_pos<T>() :
std::abs(P[0]);
294 for(i=0, j=1; j<N; i+=2, j+=2)
299 if(min_val > tmp_i) { min_val = tmp_i; }
300 if(min_val > tmp_j) { min_val = tmp_j; }
307 if(min_val > tmp_i) { min_val = tmp_i; }
315 template<
typename T1>
317 typename T1::pod_type
322 typedef typename T1::elem_type eT;
323 typedef typename T1::pod_type T;
334 template<
typename T1>
336 typename T1::pod_type
341 typedef typename T1::elem_type eT;
342 typedef typename T1::pod_type T;
355 template<
typename T1>
357 typename T1::pod_type
362 typedef typename T1::elem_type eT;
363 typedef typename T1::pod_type T;
374 template<
typename T1>
377 typename T1::pod_type
388 typedef typename T1::elem_type eT;
389 typedef typename T1::pod_type T;
393 if(A.get_n_elem() == 0)
398 const bool is_vec = (A.get_n_rows() == 1) || (A.get_n_cols() == 1);
432 arma_stop(
"norm(): unsupported matrix norm type");
440 template<
typename T1>
443 typename T1::pod_type
454 typedef typename T1::elem_type eT;
455 typedef typename T1::pod_type T;
459 if(A.get_n_elem() == 0)
464 const char sig = method[0];
465 const bool is_vec = (A.get_n_rows() == 1) || (A.get_n_cols() == 1);
469 if( (sig ==
'i') || (sig ==
'I') || (sig ==
'+') )
479 if( (sig ==
'f') || (sig ==
'F') )
485 arma_stop(
"norm(): unsupported vector norm type");
491 if( (sig ==
'i') || (sig ==
'I') || (sig ==
'+') )
496 if( (sig ==
'f') || (sig ==
'F') )
502 arma_stop(
"norm(): unsupported matrix norm type");
arma_inline const Op< T1, op_sum > sum(const Base< typename T1::elem_type, T1 > &X, const uword dim=0)
Delayed sum 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. For dim = 1, find the sum of each row. The default is dim = 0. NOTE: this function works differently than in Matlab/Octave.
arma_hot T1::pod_type arma_vec_norm_1(const Proxy< T1 > &A)
T1::pod_type arma_mat_norm_inf(const Proxy< T1 > &A)
arma_inline const derived & get_ref() const
arma_inline const eOp< T1, eop_sqrt > sqrt(const Base< typename T1::elem_type, T1 > &A)
arma_hot T1::pod_type arma_vec_norm_k(const Proxy< T1 > &A, const int k)
const uword n_elem
number of elements in the matrix (read-only)
arma_inline const Op< T1, op_max > max(const Base< typename T1::elem_type, T1 > &X, const uword dim=0)
Delayed 'maximum values' operation. The dimension, along which the maxima are found, is set via 'dim'. For dim = 0, the maximum value of each column is found (i.e. searches by traversing across rows). For dim = 1, the maximum value of each row is found (i.e. searches by traversing across columns). The default is dim = 0.
arma_hot T1::pod_type arma_vec_norm_min(const Proxy< T1 > &A)
arma_warn_unused T1::pod_type norm(const Base< typename T1::elem_type, T1 > &X, const uword k, const typename arma_float_or_cx_only< typename T1::elem_type >::result *junk=0)
T1::pod_type arma_mat_norm_1(const Proxy< T1 > &A)
Class for column vectors (matrices with only one column)
arma_hot T1::pod_type arma_vec_norm_max(const Proxy< T1 > &A)
#define arma_ignore(variable)
arma_inline arma_warn_unused T1::elem_type as_scalar(const Glue< T1, T2, glue_times > &X, const typename arma_not_cx< typename T1::elem_type >::result *junk=0)
void arma_cold arma_stop(const T1 &x)
print a message to get_stream_err1() and/or throw a logic_error exception
arma_inline const eOp< T1, eop_abs > abs(const Base< typename T1::elem_type, T1 > &X, const typename arma_not_cx< typename T1::elem_type >::result *junk=0)
#define arma_extra_debug_sigprint
arma_inline const eOp< T1, eop_pow > pow(const Base< typename T1::elem_type, T1 > &A, const typename T1::elem_type exponent)
bool svd(Col< typename T1::pod_type > &S, const Base< typename T1::elem_type, T1 > &X, const typename arma_blas_type_only< typename T1::elem_type >::result *junk=0)
arma_hot T1::pod_type arma_vec_norm_2(const Proxy< T1 > &A, const typename arma_not_cx< typename T1::elem_type >::result *junk=0)
T1::pod_type arma_mat_norm_2(const Proxy< T1 > &A)