24 return A + (B - A)/eT(2);
37 const uword n_elem = X.size();
38 const uword half = n_elem/2;
61 std::vector<eT> tmp(X, X+n_elem);
77 std::vector<eT> tmp(X_n_elem);
79 for(
uword i=0; i<X_n_elem; ++i)
98 std::vector<eT> tmp(X_n_elem);
100 for(
uword i=0; i<X_n_elem; ++i)
114 template<
typename T1>
121 typedef typename T1::elem_type eT;
130 arma_debug_check( (dim > 1),
"median(): incorrect usage. dim must be 0 or 1");
136 arma_debug_check( (X_n_rows == 0),
"median(): given object has zero rows" );
140 std::vector<eT> tmp_vec(X_n_rows);
142 for(
uword col=0; col<X_n_cols; ++col)
144 const eT* colmem = X.
colptr(col);
146 for(
uword row=0; row<X_n_rows; ++row)
148 tmp_vec[row] = colmem[row];
159 arma_debug_check( (X_n_cols == 0),
"median(): given object has zero columns" );
163 std::vector<eT> tmp_vec(X_n_cols);
165 for(
uword row=0; row<X_n_rows; ++row)
167 for(
uword col=0; col<X_n_cols; ++col)
169 tmp_vec[col] = X.
at(row,col);
184 return A + (B - A)/T(2);
201 const uword n_elem = X.size();
202 const uword half = n_elem/2;
206 if((n_elem % 2) == 0)
208 out_index1 = X[half-1].index;
209 out_index2 = X[half ].index;
213 out_index1 = X[half].index;
214 out_index2 = out_index1;
227 const std::complex<T>* X,
233 std::vector< arma_cx_median_packet<T> > tmp(n_elem);
235 for(
uword i=0; i<n_elem; ++i)
253 const subview< std::complex<T> >&X
258 const uword n_elem = X.n_elem;
260 std::vector< arma_cx_median_packet<T> > tmp(n_elem);
262 for(
uword i=0; i<n_elem; ++i)
285 const uword n_elem = X.n_elem;
287 std::vector< arma_cx_median_packet<T> > tmp(n_elem);
289 for(
uword i=0; i<n_elem; ++i)
301 template<
typename T,
typename T1>
308 typedef typename std::complex<T> eT;
319 arma_debug_check( (dim > 1),
"median(): incorrect usage. dim must be 0 or 1");
325 arma_debug_check( (X_n_rows == 0),
"median(): given object has zero rows" );
327 out.set_size(1, X_n_cols);
329 std::vector< arma_cx_median_packet<T> > tmp_vec(X_n_rows);
331 for(
uword col=0; col<X_n_cols; ++col)
333 const eT* colmem = X.
colptr(col);
335 for(
uword row=0; row<X_n_rows; ++row)
337 tmp_vec[row].val =
std::abs(colmem[row]);
338 tmp_vec[row].index = row;
353 arma_debug_check( (X_n_cols == 0),
"median(): given object has zero columns" );
355 out.set_size(X_n_rows, 1);
357 std::vector< arma_cx_median_packet<T> > tmp_vec(X_n_cols);
359 for(
uword row=0; row<X_n_rows; ++row)
361 for(
uword col=0; col<X_n_cols; ++col)
364 tmp_vec[row].index = col;
void set_size(const uword in_elem)
change the matrix to have user specified dimensions (data is not preserved)
const uword n_cols
number of columns in the matrix (read-only)
const uword n_rows
number of rows in the matrix (read-only)
#define arma_extra_debug_print
arma_aligned const T1 & m
storage of reference to the operand (eg. a matrix)
arma_inline arma_warn_unused eT * colptr(const uword in_col)
returns a pointer to array of eTs for a specified column; no bounds check
#define arma_type_check(condition)
arma_inline arma_warn_unused eT & at(const uword i)
linear element accessor (treats the matrix as a vector); no bounds check.
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 Op< T1, op_sort > sort(const Base< typename T1::elem_type, T1 > &X, const uword sort_type=0, const uword dim=0)
Class for storing data required to extract and set the diagonals of a matrix.
arma_aligned uword aux_uword_a
storage of auxiliary data, uword format