"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "include/armadillo_bits/op_logmat_meat.hpp" between
armadillo-10.8.2.tar.xz and armadillo-11.0.0.tar.xz

About: Armadillo is a C++ linear algebra library (matrix maths) aiming towards a good balance between speed and ease of use.

op_logmat_meat.hpp  (armadillo-10.8.2.tar.xz):op_logmat_meat.hpp  (armadillo-11.0.0.tar.xz)
skipping to change at line 130 skipping to change at line 130
} }
else else
{ {
out.at(i,i) = std::log( out_T(val) ); out.at(i,i) = std::log( out_T(val) );
} }
} }
return true; return true;
} }
#if defined(ARMA_OPTIMISE_SYMPD) const bool try_sympd = arma_config::optimise_sympd && sympd_helper::guess_symp
const bool try_sympd = sympd_helper::guess_sympd(A); d(A);
#else
const bool try_sympd = false;
#endif
if(try_sympd) if(try_sympd)
{ {
arma_extra_debug_print("op_logmat: attempting sympd optimisation"); arma_extra_debug_print("op_logmat: attempting sympd optimisation");
// if matrix A is sympd, all its eigenvalues are positive // if matrix A is sympd, all its eigenvalues are positive
Col<in_T> eigval; Col<in_T> eigval;
Mat<in_T> eigvec; Mat<in_T> eigvec;
skipping to change at line 170 skipping to change at line 166
eigval = log(eigval); eigval = log(eigval);
out = conv_to< Mat<out_T> >::from( eigvec * diagmat(eigval) * eigvec.t() ); out = conv_to< Mat<out_T> >::from( eigvec * diagmat(eigval) * eigvec.t() );
return true; return true;
} }
} }
arma_extra_debug_print("op_logmat: sympd optimisation failed"); arma_extra_debug_print("op_logmat: sympd optimisation failed");
// fallthrough if eigen decomposition failed or an eigenvalue is zero // fallthrough if eigen decomposition failed or an eigenvalue is <= 0
} }
Mat<out_T> S(A.n_rows, A.n_cols, arma_nozeros_indicator()); Mat<out_T> S(A.n_rows, A.n_cols, arma_nozeros_indicator());
const in_T* Amem = A.memptr(); const in_T* Amem = A.memptr();
out_T* Smem = S.memptr(); out_T* Smem = S.memptr();
const uword n_elem = A.n_elem; const uword n_elem = A.n_elem;
for(uword i=0; i<n_elem; ++i) for(uword i=0; i<n_elem; ++i)
skipping to change at line 294 skipping to change at line 290
const uword N = S.n_rows; const uword N = S.n_rows;
out.zeros(N,N); // aliasing can't happen as S is generated out.zeros(N,N); // aliasing can't happen as S is generated
for(uword i=0; i<N; ++i) { out.at(i,i) = std::log( S.at(i,i) ); } for(uword i=0; i<N; ++i) { out.at(i,i) = std::log( S.at(i,i) ); }
return true; return true;
} }
#if defined(ARMA_OPTIMISE_SYMPD) const bool try_sympd = arma_config::optimise_sympd && sympd_helper::guess_symp
const bool try_sympd = sympd_helper::guess_sympd(S); d(S);
#else
const bool try_sympd = false;
#endif
if(try_sympd) if(try_sympd)
{ {
arma_extra_debug_print("op_logmat_cx: attempting sympd optimisation"); arma_extra_debug_print("op_logmat_cx: attempting sympd optimisation");
// if matrix S is sympd, all its eigenvalues are positive // if matrix S is sympd, all its eigenvalues are positive
Col< T> eigval; Col< T> eigval;
Mat<eT> eigvec; Mat<eT> eigvec;
skipping to change at line 334 skipping to change at line 326
eigval = log(eigval); eigval = log(eigval);
out = eigvec * diagmat(eigval) * eigvec.t(); out = eigvec * diagmat(eigval) * eigvec.t();
return true; return true;
} }
} }
arma_extra_debug_print("op_logmat_cx: sympd optimisation failed"); arma_extra_debug_print("op_logmat_cx: sympd optimisation failed");
// fallthrough if eigen decomposition failed or an eigenvalue is zero // fallthrough if eigen decomposition failed or an eigenvalue is <= 0
} }
return op_logmat_cx::apply_common(out, S, n_iters); return op_logmat_cx::apply_common(out, S, n_iters);
} }
template<typename T> template<typename T>
inline inline
bool bool
op_logmat_cx::apply_common(Mat< std::complex<T> >& out, Mat< std::complex<T> >& S, const uword n_iters) op_logmat_cx::apply_common(Mat< std::complex<T> >& out, Mat< std::complex<T> >& S, const uword n_iters)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename std::complex<T> eT; typedef typename std::complex<T> eT;
Mat<eT> U; Mat<eT> U;
const bool schur_ok = auxlib::schur(U,S); const bool schur_ok = auxlib::schur(U,S);
if(schur_ok == false) { arma_extra_debug_print("logmat(): schur decomposition failed"); return false; } if(schur_ok == false) { arma_extra_debug_print("logmat(): schur decomposition failed"); return false; }
//double theta[] = { 1.10e-5, 1.82e-3, 1.62e-2, 5.39e-2, // NOTE: theta[0] and theta[1] not really used
1.14e-1, 1.87e-1, 2.64e-1 }; double theta[] = { 1.10e-5, 1.82e-3, 1.6206284795015624e-2, 5.3873532631381171
double theta[] = { 0.0, 0.0, 1.6206284795015624e-2, 5.3873532631381171 e-2, 1.1352802267628681e-1, 1.8662860613541288e-1, 2.642960831111435e-1 };
e-2, 1.1352802267628681e-1, 1.8662860613541288e-1, 2.642960831111435e-1 };
// theta[0] and theta[1] not really used
const uword N = S.n_rows; const uword N = S.n_rows;
uword p = 0; uword p = 0;
uword m = 6; uword m = 6;
uword iter = 0; uword iter = 0;
while(iter < n_iters) while(iter < n_iters)
{ {
skipping to change at line 493 skipping to change at line 484
#if defined(ARMA_USE_LAPACK) #if defined(ARMA_USE_LAPACK)
{ {
typedef typename T1::pod_type T; typedef typename T1::pod_type T;
typedef typename T1::elem_type eT; typedef typename T1::elem_type eT;
const unwrap<T1> U(expr.get_ref()); const unwrap<T1> U(expr.get_ref());
const Mat<eT>& X = U.M; const Mat<eT>& X = U.M;
arma_debug_check( (X.is_square() == false), "logmat_sympd(): given matrix mu st be square sized" ); arma_debug_check( (X.is_square() == false), "logmat_sympd(): given matrix mu st be square sized" );
if((arma_config::debug) && (arma_config::warn_level > 0) && (is_cx<eT>::yes)
&& (sympd_helper::check_diag_imag(X) == false))
{
arma_debug_warn_level(1, "logmat_sympd(): imaginary components on diagonal
are non-zero");
}
if(is_op_diagmat<T1>::value || X.is_diagmat())
{
arma_extra_debug_print("op_logmat_sympd: detected diagonal matrix");
out = X;
eT* colmem = out.memptr();
const uword N = X.n_rows;
for(uword i=0; i<N; ++i)
{
eT& out_ii = colmem[i];
T out_ii_real = access::tmp_real(out_ii);
if(out_ii_real <= T(0)) { return false; }
out_ii = std::log(out_ii);
colmem += N;
}
return true;
}
Col< T> eigval; Col< T> eigval;
Mat<eT> eigvec; Mat<eT> eigvec;
const bool status = eig_sym_helper(eigval, eigvec, X, 'd', "logmat_sympd()") ; const bool status = eig_sym_helper(eigval, eigvec, X, 'd', "logmat_sympd()") ;
if(status == false) { return false; } if(status == false) { return false; }
const uword N = eigval.n_elem; const uword N = eigval.n_elem;
const T* eigval_mem = eigval.memptr(); const T* eigval_mem = eigval.memptr();
 End of changes. 6 change blocks. 
17 lines changed or deleted 41 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)