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 arma_isfinite(), exp(), and log().
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()) || (arma_isfinite(negdelta) == false) ) 00200 { 00201 return log_a; 00202 } 00203 else 00204 { 00205 #if defined(ARMA_HAVE_LOG1P) 00206 return (log_a + log1p(std::exp(negdelta))); 00207 #else 00208 return (log_a + std::log(1.0 + std::exp(negdelta))); 00209 #endif 00210 } 00211 }
eT trunc_log | ( | const eT | x | ) | [inline] |
Definition at line 218 of file fn_misc.hpp.
References log(), Math< eT >::log_max(), and Math< eT >::log_min().
Referenced by op_trunc_log::apply().
00219 { 00220 if(std::numeric_limits<eT>::is_iec559) 00221 { 00222 if(x == std::numeric_limits<eT>::infinity()) 00223 { 00224 return Math<eT>::log_max(); 00225 } 00226 if(x <= 0) 00227 { 00228 return Math<eT>::log_min(); 00229 } 00230 } 00231 else 00232 { 00233 return std::log(x); 00234 } 00235 }
eT trunc_exp | ( | const eT | x | ) | [inline] |
Definition at line 242 of file fn_misc.hpp.
Referenced by op_trunc_exp::apply().
00243 { 00244 if(std::numeric_limits<eT>::is_iec559 && (x >= Math<eT>::log_max() )) 00245 { 00246 return std::numeric_limits<eT>::max(); 00247 } 00248 else 00249 { 00250 return std::exp(x); 00251 } 00252 }
const Op<T1, op_log> log | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 262 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
Referenced by op_log::apply(), log_add(), Math< eT >::log_max(), Math< eT >::log_min(), and trunc_log().
00263 { 00264 arma_extra_debug_sigprint(); 00265 00266 return Op<T1, op_log>(A.get_ref()); 00267 }
const Op<T1, op_trunc_log> trunc_log | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 277 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
00278 { 00279 arma_extra_debug_sigprint(); 00280 00281 return Op<T1, op_trunc_log>(A.get_ref()); 00282 }
const Op<T1, op_log10> log10 | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 292 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
Referenced by op_log10::apply().
00293 { 00294 arma_extra_debug_sigprint(); 00295 00296 return Op<T1, op_log10>(A.get_ref()); 00297 }
const Op<T1, op_exp> exp | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 307 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
Referenced by op_exp::apply(), log_add(), and trunc_exp().
00308 { 00309 arma_extra_debug_sigprint(); 00310 00311 return Op<T1, op_exp>(A.get_ref()); 00312 }
const Op<T1, op_trunc_exp> trunc_exp | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 322 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
00323 { 00324 arma_extra_debug_sigprint(); 00325 00326 return Op<T1, op_trunc_exp>(A.get_ref()); 00327 }
Mat<typename T1::pod_type> abs | ( | const Base< typename T1::elem_type, T1 > & | X | ) | [inline] |
Definition at line 337 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().
00338 { 00339 arma_extra_debug_sigprint(); 00340 00341 const unwrap<T1> A_tmp(X.get_ref()); 00342 00343 // if T1 is a complex matrix, 00344 // pod_type is the underlying type used by std::complex; 00345 // otherwise pod_type is the same as elem_type 00346 00347 typedef typename T1::elem_type in_eT; 00348 typedef typename T1::pod_type out_eT; 00349 00350 const Mat<in_eT>& A = A_tmp.M; 00351 00352 Mat<out_eT> out(A.n_rows, A.n_cols); 00353 00354 const in_eT* A_mem = A.mem; 00355 out_eT* out_mem = out.memptr(); 00356 00357 for(u32 i=0; i<out.n_elem; ++i) 00358 { 00359 out_mem[i] = std::abs(A_mem[i]); 00360 } 00361 00362 return out; 00363 }
Mat<typename T1::pod_type> fabs | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 373 of file fn_misc.hpp.
References abs().
00374 { 00375 arma_extra_debug_sigprint(); 00376 00377 return abs(A); 00378 }
const Op<T1, op_square> square | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 388 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
00389 { 00390 arma_extra_debug_sigprint(); 00391 00392 return Op<T1, op_square>(A.get_ref()); 00393 }
const Op<T1, op_sqrt> sqrt | ( | const Base< typename T1::elem_type, T1 > & | A | ) | [inline] |
Definition at line 403 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().
00404 { 00405 arma_extra_debug_sigprint(); 00406 00407 return Op<T1, op_sqrt>(A.get_ref()); 00408 }
const Op<T1, op_pow> pow | ( | const Base< typename T1::elem_type, T1 > & | A, | |
const typename T1::elem_type | exponent | |||
) | [inline] |
Definition at line 417 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
Referenced by op_pow::apply(), op_pow_s32::internal_pow(), and norm().
00418 { 00419 arma_extra_debug_sigprint(); 00420 00421 return Op<T1, op_pow>(A.get_ref(), exponent); 00422 }
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 431 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
00432 { 00433 arma_extra_debug_sigprint(); 00434 00435 return Op<T1, op_pow>(A.get_ref(), eT(exponent)); 00436 }
const Op<T1, op_pow_s32> pow | ( | const Base< typename T1::elem_type, T1 > & | A, | |
const s32 | exponent | |||
) | [inline] |
Definition at line 445 of file fn_misc.hpp.
References Base< elem_type, derived >::get_ref().
00446 { 00447 arma_extra_debug_sigprint(); 00448 00449 if(exponent >= 0) 00450 { 00451 return Op<T1, op_pow_s32>(A.get_ref(), exponent, 0); 00452 } 00453 else 00454 { 00455 return Op<T1, op_pow_s32>(A.get_ref(), -exponent, 1); 00456 } 00457 }
const Op<T1, op_conj> conj | ( | const Base< std::complex< T >, T1 > & | A | ) | [inline] |
Definition at line 466 of file fn_misc.hpp.
Referenced by op_conj::apply(), op_htrans::apply(), op_htrans::apply_noalias(), and eig_gen().
00467 { 00468 arma_extra_debug_sigprint(); 00469 00470 return Op<T1, op_conj>(A.get_ref()); 00471 }
Definition at line 478 of file fn_misc.hpp.
References Op< T1, op_type >::m.
00479 { 00480 arma_extra_debug_sigprint(); 00481 00482 return A.m; 00483 }
the conjugate of the transpose of a complex matrix is the same as the hermitian transpose
Definition at line 491 of file fn_misc.hpp.
References Op< T1, op_type >::m.
00492 { 00493 arma_extra_debug_sigprint(); 00494 00495 arma_type_check< is_complex<typename T1::elem_type>::value == false >::apply(); 00496 00497 return Op<T1, op_htrans>(A.m); 00498 }