Functions | |
template<typename eT > | |
Mat< eT > | linspace (const eT start, const eT end, const u32 num, const u32 dim=0) |
Generate a vector with 'num' elements. The values of the elements linearly increase from 'start' upto (and including) 'end'. | |
mat | linspace (const double start, const double end, const u32 num, const u32 dim=0) |
template<typename T1 > | |
Mat< typename T1::elem_type > | reshape (const Base< typename T1::elem_type, T1 > &X, const u32 in_n_rows, const u32 in_n_cols, const u32 dim=0) |
template<typename T , typename T1 > | |
Mat< T > | real (const Base< std::complex< T >, T1 > &X) |
template<typename T , typename T1 > | |
Mat< T > | imag (const Base< std::complex< T >, T1 > &X) |
template<typename eT > | |
eT | log_add (eT log_a, eT log_b) |
template<typename eT > | |
eT | trunc_log (const eT x) |
template<typename eT > | |
eT | trunc_exp (const eT x) |
template<typename T1 > | |
const Op< T1, op_log > | log (const Base< typename T1::elem_type, T1 > &A) |
template<typename T1 > | |
const Op< T1, op_trunc_log > | trunc_log (const Base< typename T1::elem_type, T1 > &A) |
template<typename T1 > | |
const Op< T1, op_log10 > | log10 (const Base< typename T1::elem_type, T1 > &A) |
template<typename T1 > | |
const Op< T1, op_exp > | exp (const Base< typename T1::elem_type, T1 > &A) |
template<typename T1 > | |
const Op< T1, op_trunc_exp > | trunc_exp (const Base< typename T1::elem_type, T1 > &A) |
template<typename T1 > | |
Mat< typename T1::pod_type > | abs (const Base< typename T1::elem_type, T1 > &X) |
template<typename T1 > | |
Mat< typename T1::pod_type > | fabs (const Base< typename T1::elem_type, T1 > &A) |
template<typename T1 > | |
const Op< T1, op_square > | square (const Base< typename T1::elem_type, T1 > &A) |
template<typename T1 > | |
const Op< T1, op_sqrt > | sqrt (const Base< typename T1::elem_type, T1 > &A) |
template<typename T1 > | |
const Op< T1, op_pow > | pow (const Base< typename T1::elem_type, T1 > &A, const typename T1::elem_type exponent) |
template<typename T1 > | |
const Op< T1, op_pow > | pow (const Base< typename T1::elem_type, T1 > &A, const typename T1::elem_type::value_type exponent) |
template<typename T1 > | |
const Op< T1, op_pow_s32 > | pow (const Base< typename T1::elem_type, T1 > &A, const s32 exponent) |
template<typename T , typename T1 > | |
const Op< T1, op_conj > | conj (const Base< std::complex< T >, T1 > &A) |
template<typename T1 > | |
const T1 & | conj (const Op< T1, op_conj > &A) |
template<typename T1 > | |
const Op< T1, op_htrans > | conj (const Op< T1, op_trans > &A) |
the conjugate of the transpose of a complex matrix is the same as the hermitian transpose |
Mat<eT> linspace | ( | const eT | start, | |
const eT | end, | |||
const u32 | num, | |||
const u32 | dim = 0 | |||
) | [inline] |
Generate a vector with 'num' elements. The values of the elements linearly increase from 'start' upto (and including) 'end'.
Definition at line 26 of file fn_misc.hpp.
References Mat< eT >::set_size().
00027 { 00028 arma_extra_debug_sigprint(); 00029 00030 arma_debug_check( (num < 2), "linspace(): num must be >= 2"); 00031 00032 Mat<eT> x; 00033 00034 if(dim == 0) 00035 { 00036 x.set_size(num,1); // column vector 00037 } 00038 else 00039 { 00040 x.set_size(1,num); // row vector 00041 } 00042 00043 00044 const eT delta = (end-start)/(num-1); 00045 00046 x[0] = start; 00047 00048 for(u32 i=1; i<num; ++i) 00049 { 00050 x[i] = x[i-1] + delta; 00051 } 00052 00053 return x; 00054 }
Definition at line 60 of file fn_misc.hpp.
00061 { 00062 arma_extra_debug_sigprint(); 00063 return linspace<double>(start, end, num, dim); 00064 }
Mat<typename T1::elem_type> reshape | ( | const Base< typename T1::elem_type, T1 > & | X, | |
const u32 | in_n_rows, | |||
const u32 | in_n_cols, | |||
const u32 | dim = 0 | |||
) | [inline] |
Definition at line 77 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref(), Mat< eT >::memptr(), Mat< eT >::n_cols, Mat< eT >::n_rows, access::rw(), and Mat< eT >::set_size().
00078 { 00079 arma_extra_debug_sigprint(); 00080 00081 typedef typename T1::elem_type eT; 00082 00083 Mat<eT> out; 00084 00085 const unwrap<T1> A_tmp(X.get_ref()); 00086 const Mat<eT>& A = A_tmp.M; 00087 00088 const u32 in_n_elem = in_n_rows * in_n_cols; 00089 00090 arma_debug_check( (A.n_elem != in_n_elem), "reshape(): incompatible dimensions"); 00091 arma_debug_check( (dim > 1), "reshape(): dim must be 0 or 1"); 00092 00093 if(dim == 0) 00094 { 00095 out = A; 00096 00097 access::rw(out.n_rows) = in_n_rows; 00098 access::rw(out.n_cols) = in_n_cols; 00099 00100 return out; 00101 } 00102 else 00103 { 00104 out.set_size(in_n_rows, in_n_cols); 00105 00106 eT* out_mem = out.memptr(); 00107 u32 i = 0; 00108 00109 for(u32 row=0; row<A.n_rows; ++row) 00110 { 00111 for(u32 col=0; col<A.n_cols; ++col) 00112 { 00113 out_mem[i] = A.at(row,col); 00114 ++i; 00115 } 00116 } 00117 00118 return out; 00119 } 00120 }
Mat<T> real | ( | const Base< std::complex< T >, T1 > & | X | ) | [inline] |
Definition at line 130 of file fn_misc.hpp.
References Mat< eT >::memptr(), and Mat< eT >::n_elem.
Referenced by auxlib::svd().
00131 { 00132 arma_extra_debug_sigprint(); 00133 00134 typedef std::complex<T> eT; 00135 00136 const unwrap<T1> A_tmp(X.get_ref()); 00137 const Mat<eT>& A = A_tmp.M; 00138 00139 Mat<T> out(A.n_rows, A.n_cols); 00140 00141 const eT* A_mem = A.mem; 00142 T* out_mem = out.memptr(); 00143 00144 for(u32 i=0; i<out.n_elem; ++i) 00145 { 00146 out_mem[i] = std::real(A_mem[i]); 00147 } 00148 00149 return out; 00150 }
Mat<T> imag | ( | const Base< std::complex< T >, T1 > & | X | ) | [inline] |
Definition at line 160 of file fn_misc.hpp.
References Mat< eT >::memptr(), and Mat< eT >::n_elem.
00161 { 00162 arma_extra_debug_sigprint(); 00163 00164 typedef std::complex<T> eT; 00165 00166 const unwrap<T1> A_tmp(X.get_ref()); 00167 const Mat<eT>& A = A_tmp.M; 00168 00169 Mat<T> out(A.n_rows, A.n_cols); 00170 00171 const eT* A_mem = A.mem; 00172 T* out_mem = out.memptr(); 00173 00174 for(u32 i=0; i<out.n_elem; ++i) 00175 { 00176 out_mem[i] = std::imag(A_mem[i]); 00177 } 00178 00179 return out; 00180 }
eT log_add | ( | eT | log_a, | |
eT | log_b | |||
) | [inline] |
Definition at line 190 of file fn_misc.hpp.
References exp().
00191 { 00192 if(log_a < log_b) 00193 { 00194 std::swap(log_a, log_b); 00195 } 00196 00197 const eT negdelta = log_b - log_a; 00198 00199 if( (negdelta < Math<eT>::log_min()) || std::isnan(negdelta) ) 00200 { 00201 return log_a; 00202 } 00203 else 00204 { 00205 return (log_a + log1p(std::exp(negdelta))); 00206 } 00207 }
eT trunc_log | ( | const eT | x | ) | [inline] |
Definition at line 214 of file fn_misc.hpp.
References log(), Math< eT >::log_max(), and Math< eT >::log_min().
Referenced by op_trunc_log::apply().
00215 { 00216 if(std::numeric_limits<eT>::is_iec559) 00217 { 00218 if(x == std::numeric_limits<eT>::infinity()) 00219 { 00220 return Math<eT>::log_max(); 00221 } 00222 if(x <= 0) 00223 { 00224 return Math<eT>::log_min(); 00225 } 00226 } 00227 else 00228 { 00229 return std::log(x); 00230 } 00231 }
eT trunc_exp | ( | const eT | x | ) | [inline] |
Definition at line 238 of file fn_misc.hpp.
Referenced by op_trunc_exp::apply().
00239 { 00240 if(std::numeric_limits<eT>::is_iec559 && (x >= Math<eT>::log_max() )) 00241 { 00242 return std::numeric_limits<eT>::max(); 00243 } 00244 else 00245 { 00246 return std::exp(x); 00247 } 00248 }
const Op<T1, op_log> log | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 258 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
Referenced by op_log::apply(), Math< eT >::log_max(), Math< eT >::log_min(), and trunc_log().
00259 { 00260 arma_extra_debug_sigprint(); 00261 00262 return Op<T1, op_log>(A.get_ref()); 00263 }
const Op<T1, op_trunc_log> trunc_log | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 273 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
00274 { 00275 arma_extra_debug_sigprint(); 00276 00277 return Op<T1, op_trunc_log>(A.get_ref()); 00278 }
const Op<T1, op_log10> log10 | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 288 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
Referenced by op_log10::apply().
00289 { 00290 arma_extra_debug_sigprint(); 00291 00292 return Op<T1, op_log10>(A.get_ref()); 00293 }
const Op<T1, op_exp> exp | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 303 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
Referenced by op_exp::apply(), log_add(), and trunc_exp().
00304 { 00305 arma_extra_debug_sigprint(); 00306 00307 return Op<T1, op_exp>(A.get_ref()); 00308 }
const Op<T1, op_trunc_exp> trunc_exp | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 318 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
00319 { 00320 arma_extra_debug_sigprint(); 00321 00322 return Op<T1, op_trunc_exp>(A.get_ref()); 00323 }
Mat<typename T1::pod_type> abs | ( | const Base< typename T1::elem_type, T1 > & | X | ) | [inline] |
Definition at line 333 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref(), Mat< eT >::mem, Mat< eT >::memptr(), Mat< eT >::n_cols, Mat< eT >::n_elem, and Mat< eT >::n_rows.
Referenced by op_min::apply(), op_median::apply(), op_max::apply(), arma_qsort_helper< std::complex< T > >::ascend_compare(), arma_qsort_helper< std::complex< T > >::descend_compare(), op_median::direct_cx_median_index(), op_max::direct_max(), op_min::direct_min(), fabs(), and norm().
00334 { 00335 arma_extra_debug_sigprint(); 00336 00337 const unwrap<T1> A_tmp(X.get_ref()); 00338 00339 // if T1 is a complex matrix, 00340 // pod_type is the underlying type used by std::complex; 00341 // otherwise pod_type is the same as elem_type 00342 00343 typedef typename T1::elem_type in_eT; 00344 typedef typename T1::pod_type out_eT; 00345 00346 const Mat<in_eT>& A = A_tmp.M; 00347 00348 Mat<out_eT> out(A.n_rows, A.n_cols); 00349 00350 const in_eT* A_mem = A.mem; 00351 out_eT* out_mem = out.memptr(); 00352 00353 for(u32 i=0; i<out.n_elem; ++i) 00354 { 00355 out_mem[i] = std::abs(A_mem[i]); 00356 } 00357 00358 return out; 00359 }
Mat<typename T1::pod_type> fabs | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 369 of file fn_misc.hpp.
References abs().
00370 { 00371 arma_extra_debug_sigprint(); 00372 00373 return abs(A); 00374 }
const Op<T1, op_square> square | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 384 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
00385 { 00386 arma_extra_debug_sigprint(); 00387 00388 return Op<T1, op_square>(A.get_ref()); 00389 }
const Op<T1, op_sqrt> sqrt | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 399 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
Referenced by accu(), op_stddev::apply(), op_sqrt::apply(), op_norm_dot::apply(), norm(), running_stat< eT >::stddev(), and stddev().
00400 { 00401 arma_extra_debug_sigprint(); 00402 00403 return Op<T1, op_sqrt>(A.get_ref()); 00404 }
const Op<T1, op_pow> pow | ( | const Base< typename T1::elem_type, T1 > & | A, | |
const typename T1::elem_type | exponent | |||
) | [inline] |
Definition at line 413 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
Referenced by op_pow::apply(), op_pow_s32::internal_pow(), and norm().
00414 { 00415 arma_extra_debug_sigprint(); 00416 00417 return Op<T1, op_pow>(A.get_ref(), exponent); 00418 }
const Op<T1, op_pow> pow | ( | const Base< typename T1::elem_type, T1 > & | A, | |
const typename T1::elem_type::value_type | exponent | |||
) | [inline] |
Definition at line 427 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
00428 { 00429 arma_extra_debug_sigprint(); 00430 00431 return Op<T1, op_pow>(A.get_ref(), eT(exponent)); 00432 }
const Op<T1, op_pow_s32> pow | ( | const Base< typename T1::elem_type, T1 > & | A, | |
const s32 | exponent | |||
) | [inline] |
Definition at line 441 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
00442 { 00443 arma_extra_debug_sigprint(); 00444 00445 if(exponent >= 0) 00446 { 00447 return Op<T1, op_pow_s32>(A.get_ref(), exponent, 0); 00448 } 00449 else 00450 { 00451 return Op<T1, op_pow_s32>(A.get_ref(), -exponent, 1); 00452 } 00453 }
const Op<T1, op_conj> conj | ( | const Base< std::complex< T >, T1 > & | A | ) | [inline] |
Definition at line 462 of file fn_misc.hpp.
Referenced by op_conj::apply(), op_htrans::apply(), op_htrans::apply_noalias(), and eig_gen().
00463 { 00464 arma_extra_debug_sigprint(); 00465 00466 return Op<T1, op_conj>(A.get_ref()); 00467 }
Definition at line 474 of file fn_misc.hpp.
References Op< T1, op_type >::m.
00475 { 00476 arma_extra_debug_sigprint(); 00477 00478 return A.m; 00479 }
the conjugate of the transpose of a complex matrix is the same as the hermitian transpose
Definition at line 487 of file fn_misc.hpp.
References Op< T1, op_type >::m.
00488 { 00489 arma_extra_debug_sigprint(); 00490 00491 arma_type_check< is_complex<typename T1::elem_type>::value == false >::apply(); 00492 00493 return Op<T1, op_htrans>(A.m); 00494 }