"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "include/armadillo_bits/glue_solve_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.

glue_solve_meat.hpp  (armadillo-10.8.2.tar.xz):glue_solve_meat.hpp  (armadillo-11.0.0.tar.xz)
skipping to change at line 22 skipping to change at line 22
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
//! \addtogroup glue_solve //! \addtogroup glue_solve
//! @{ //! @{
// //
// glue_solve_gen // glue_solve_gen_default
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_solve_gen::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_so lve_gen>& X) glue_solve_gen_default::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2 ,glue_solve_gen_default>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool status = glue_solve_gen::apply( out, X.A, X.B, X.aux_uword ); const bool status = glue_solve_gen_default::apply(out, X.A, X.B);
if(status == false) if(status == false)
{ {
out.soft_reset(); out.soft_reset();
arma_stop_runtime_error("solve(): solution not found"); arma_stop_runtime_error("solve(): solution not found");
} }
} }
template<typename eT, typename T1, typename T2> template<typename eT, typename T1, typename T2>
inline inline
bool bool
glue_solve_gen::apply(Mat<eT>& out, const Base<eT,T1>& A_expr, const Base<eT,T2> glue_solve_gen_default::apply(Mat<eT>& out, const Base<eT,T1>& A_expr, const Bas
& B_expr, const uword flags) e<eT,T2>& B_expr)
{
arma_extra_debug_sigprint();
return glue_solve_gen_full::apply<eT,T1,T2,false>( out, A_expr, B_expr, uword(
0));
}
//
// glue_solve_gen_full
template<typename T1, typename T2>
inline
void
glue_solve_gen_full::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,gl
ue_solve_gen_full>& X)
{
arma_extra_debug_sigprint();
const bool status = glue_solve_gen_full::apply( out, X.A, X.B, X.aux_uword );
if(status == false)
{
out.soft_reset();
arma_stop_runtime_error("solve(): solution not found");
}
}
template<typename eT, typename T1, typename T2, const bool has_user_flags>
inline
bool
glue_solve_gen_full::apply(Mat<eT>& out, const Base<eT,T1>& A_expr, const Base<e
T,T2>& B_expr, const uword flags)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const bool fast = bool(flags & solve_opts::flag_fast ); if(has_user_flags == true ) { arma_extra_debug_print("glue_solve_gen_full::ap
const bool equilibrate = bool(flags & solve_opts::flag_equilibrate ); ply(): has_user_flags = true" ); }
const bool no_approx = bool(flags & solve_opts::flag_no_approx ); if(has_user_flags == false) { arma_extra_debug_print("glue_solve_gen_full::ap
const bool no_band = bool(flags & solve_opts::flag_no_band ); ply(): has_user_flags = false"); }
const bool no_sympd = bool(flags & solve_opts::flag_no_sympd );
const bool allow_ugly = bool(flags & solve_opts::flag_allow_ugly );
const bool likely_sympd = bool(flags & solve_opts::flag_likely_sympd);
const bool refine = bool(flags & solve_opts::flag_refine );
const bool no_trimat = bool(flags & solve_opts::flag_no_trimat );
const bool force_approx = bool(flags & solve_opts::flag_force_approx);
arma_extra_debug_print("glue_solve_gen::apply(): enabled flags:"); const bool fast = has_user_flags && bool(flags & solve_opts::flag_fast
);
const bool equilibrate = has_user_flags && bool(flags & solve_opts::flag_equi
librate );
const bool no_approx = has_user_flags && bool(flags & solve_opts::flag_no_a
pprox );
const bool no_band = has_user_flags && bool(flags & solve_opts::flag_no_b
and );
const bool no_sympd = has_user_flags && bool(flags & solve_opts::flag_no_s
ympd );
const bool allow_ugly = has_user_flags && bool(flags & solve_opts::flag_allo
w_ugly );
const bool likely_sympd = has_user_flags && bool(flags & solve_opts::flag_like
ly_sympd);
const bool refine = has_user_flags && bool(flags & solve_opts::flag_refi
ne );
const bool no_trimat = has_user_flags && bool(flags & solve_opts::flag_no_t
rimat );
const bool force_approx = has_user_flags && bool(flags & solve_opts::flag_forc
e_approx);
arma_extra_debug_print("glue_solve_gen_full::apply(): enabled flags:");
if(fast ) { arma_extra_debug_print("fast"); } if(fast ) { arma_extra_debug_print("fast"); }
if(equilibrate ) { arma_extra_debug_print("equilibrate"); } if(equilibrate ) { arma_extra_debug_print("equilibrate"); }
if(no_approx ) { arma_extra_debug_print("no_approx"); } if(no_approx ) { arma_extra_debug_print("no_approx"); }
if(no_band ) { arma_extra_debug_print("no_band"); } if(no_band ) { arma_extra_debug_print("no_band"); }
if(no_sympd ) { arma_extra_debug_print("no_sympd"); } if(no_sympd ) { arma_extra_debug_print("no_sympd"); }
if(allow_ugly ) { arma_extra_debug_print("allow_ugly"); } if(allow_ugly ) { arma_extra_debug_print("allow_ugly"); }
if(likely_sympd) { arma_extra_debug_print("likely_sympd"); } if(likely_sympd) { arma_extra_debug_print("likely_sympd"); }
if(refine ) { arma_extra_debug_print("refine"); } if(refine ) { arma_extra_debug_print("refine"); }
if(no_trimat ) { arma_extra_debug_print("no_trimat"); } if(no_trimat ) { arma_extra_debug_print("no_trimat"); }
if(force_approx) { arma_extra_debug_print("force_approx"); } if(force_approx) { arma_extra_debug_print("force_approx"); }
arma_debug_check( (fast && equilibrate ), "solve(): options 'fast' and 'eq uilibrate' are mutually exclusive" ); arma_debug_check( (fast && equilibrate ), "solve(): options 'fast' and 'eq uilibrate' are mutually exclusive" );
arma_debug_check( (fast && refine ), "solve(): options 'fast' and 're fine' are mutually exclusive" ); arma_debug_check( (fast && refine ), "solve(): options 'fast' and 're fine' are mutually exclusive" );
arma_debug_check( (no_sympd && likely_sympd), "solve(): options 'no_sympd' and 'likely_sympd' are mutually exclusive" ); arma_debug_check( (no_sympd && likely_sympd), "solve(): options 'no_sympd' and 'likely_sympd' are mutually exclusive" );
Mat<eT> A = A_expr.get_ref(); Mat<eT> A = A_expr.get_ref();
if(force_approx) if(force_approx)
{ {
arma_extra_debug_print("glue_solve_gen::apply(): forced approximate solution "); arma_extra_debug_print("glue_solve_gen_full::apply(): forced approximate sol ution");
arma_debug_check( no_approx, "solve(): options 'no_approx' and 'force_approx ' are mutually exclusive" ); arma_debug_check( no_approx, "solve(): options 'no_approx' and 'force_approx ' are mutually exclusive" );
if(fast) { arma_debug_warn_level(2, "solve(): option 'fast' ignore d for forced approximate solution" ); } if(fast) { arma_debug_warn_level(2, "solve(): option 'fast' ignore d for forced approximate solution" ); }
if(equilibrate) { arma_debug_warn_level(2, "solve(): option 'equilibrate' ignored for forced approximate solution" ); } if(equilibrate) { arma_debug_warn_level(2, "solve(): option 'equilibrate' ignored for forced approximate solution" ); }
if(refine) { arma_debug_warn_level(2, "solve(): option 'refine' igno red for forced approximate solution" ); } if(refine) { arma_debug_warn_level(2, "solve(): option 'refine' igno red for forced approximate solution" ); }
if(likely_sympd) { arma_debug_warn_level(2, "solve(): option 'likely_sympd ' ignored for forced approximate solution" ); } if(likely_sympd) { arma_debug_warn_level(2, "solve(): option 'likely_sympd ' ignored for forced approximate solution" ); }
return auxlib::solve_approx_svd(out, A, B_expr.get_ref()); // A is overwrit ten return auxlib::solve_approx_svd(out, A, B_expr.get_ref()); // A is overwrit ten
} }
T rcond = T(0); T rcond = T(0);
bool status = false; bool status = false;
if(A.n_rows == A.n_cols) if(A.n_rows == A.n_cols)
{ {
arma_extra_debug_print("glue_solve_gen::apply(): detected square system"); arma_extra_debug_print("glue_solve_gen_full::apply(): detected square system ");
uword KL = 0; uword KL = 0;
uword KU = 0; uword KU = 0;
#if defined(ARMA_OPTIMISE_BAND) const bool is_band = arma_config::optimise_band && ((no_band || auxlib::cri
const bool is_band = (no_band || auxlib::crippled_lapack(A)) ? false : ba ppled_lapack(A)) ? false : band_helper::is_band(KL, KU, A, uword(32)));
nd_helper::is_band(KL, KU, A, uword(32));
#else
const bool is_band = false;
#endif
const bool is_triu = (no_trimat || refine || equilibrate || likely_sympd || is_band ) ? false : trimat_helper::is_triu(A); const bool is_triu = (no_trimat || refine || equilibrate || likely_sympd || is_band ) ? false : trimat_helper::is_triu(A);
const bool is_tril = (no_trimat || refine || equilibrate || likely_sympd || is_band || is_triu) ? false : trimat_helper::is_tril(A); const bool is_tril = (no_trimat || refine || equilibrate || likely_sympd || is_band || is_triu) ? false : trimat_helper::is_tril(A);
#if defined(ARMA_OPTIMISE_SYMPD) const bool try_sympd = arma_config::optimise_sympd && ((no_sympd || auxlib::
const bool try_sympd = (no_sympd || auxlib::crippled_lapack(A) || is_band crippled_lapack(A) || is_band || is_triu || is_tril) ? false : (likely_sympd ? t
|| is_triu || is_tril) ? false : (likely_sympd ? true : sympd_helper::guess_symp rue : sympd_helper::guess_sympd(A, uword(16))));
d(A, uword(16)));
#else
const bool try_sympd = false;
#endif
if(fast) if(fast)
{ {
// fast mode: solvers without refinement and without rcond estimate // fast mode: solvers without refinement and without rcond estimate
arma_extra_debug_print("glue_solve_gen::apply(): fast mode"); arma_extra_debug_print("glue_solve_gen_full::apply(): fast mode");
if(is_band) if(is_band)
{ {
if( (KL == 1) && (KU == 1) ) if( (KL == 1) && (KU == 1) )
{ {
arma_extra_debug_print("glue_solve_gen::apply(): fast + tridiagonal"); arma_extra_debug_print("glue_solve_gen_full::apply(): fast + tridiagon al");
status = auxlib::solve_tridiag_fast(out, A, B_expr.get_ref()); status = auxlib::solve_tridiag_fast(out, A, B_expr.get_ref());
} }
else else
{ {
arma_extra_debug_print("glue_solve_gen::apply(): fast + band"); arma_extra_debug_print("glue_solve_gen_full::apply(): fast + band");
status = auxlib::solve_band_fast(out, A, KL, KU, B_expr.get_ref()); status = auxlib::solve_band_fast(out, A, KL, KU, B_expr.get_ref());
} }
} }
else else
if(is_triu || is_tril) if(is_triu || is_tril)
{ {
if(is_triu) { arma_extra_debug_print("glue_solve_gen::apply(): fast + u if(is_triu) { arma_extra_debug_print("glue_solve_gen_full::apply(): fas
pper triangular matrix"); } t + upper triangular matrix"); }
if(is_tril) { arma_extra_debug_print("glue_solve_gen::apply(): fast + l if(is_tril) { arma_extra_debug_print("glue_solve_gen_full::apply(): fas
ower triangular matrix"); } t + lower triangular matrix"); }
const uword layout = (is_triu) ? uword(0) : uword(1); const uword layout = (is_triu) ? uword(0) : uword(1);
status = auxlib::solve_trimat_fast(out, A, B_expr.get_ref(), layout); status = auxlib::solve_trimat_fast(out, A, B_expr.get_ref(), layout);
} }
else else
if(try_sympd) if(try_sympd)
{ {
arma_extra_debug_print("glue_solve_gen::apply(): fast + try_sympd"); arma_extra_debug_print("glue_solve_gen_full::apply(): fast + try_sympd") ;
status = auxlib::solve_sympd_fast(out, A, B_expr.get_ref()); // A is ov erwritten status = auxlib::solve_sympd_fast(out, A, B_expr.get_ref()); // A is ov erwritten
if(status == false) if(status == false)
{ {
arma_extra_debug_print("glue_solve_gen::apply(): auxlib::solve_sympd_f
ast() failed; retrying");
// auxlib::solve_sympd_fast() may have failed because A isn't really s ympd // auxlib::solve_sympd_fast() may have failed because A isn't really s ympd
arma_extra_debug_print("glue_solve_gen_full::apply(): auxlib::solve_sy
mpd_fast() failed; retrying");
A = A_expr.get_ref(); A = A_expr.get_ref();
status = auxlib::solve_square_fast(out, A, B_expr.get_ref()); // A is overwritten status = auxlib::solve_square_fast(out, A, B_expr.get_ref()); // A is overwritten
} }
} }
else else
{ {
arma_extra_debug_print("glue_solve_gen::apply(): fast + dense"); arma_extra_debug_print("glue_solve_gen_full::apply(): fast + dense");
status = auxlib::solve_square_fast(out, A, B_expr.get_ref()); // A is o verwritten status = auxlib::solve_square_fast(out, A, B_expr.get_ref()); // A is o verwritten
} }
} }
else else
if(refine || equilibrate) if(refine || equilibrate)
{ {
// refine mode: solvers with refinement and with rcond estimate // refine mode: solvers with refinement and with rcond estimate
arma_extra_debug_print("glue_solve_gen::apply(): refine mode"); arma_extra_debug_print("glue_solve_gen_full::apply(): refine mode");
if(is_band) if(is_band)
{ {
arma_extra_debug_print("glue_solve_gen::apply(): refine + band"); arma_extra_debug_print("glue_solve_gen_full::apply(): refine + band");
status = auxlib::solve_band_refine(out, rcond, A, KL, KU, B_expr, equili brate, allow_ugly); status = auxlib::solve_band_refine(out, rcond, A, KL, KU, B_expr, equili brate, allow_ugly);
} }
else else
if(try_sympd) if(try_sympd)
{ {
arma_extra_debug_print("glue_solve_gen::apply(): refine + try_sympd"); arma_extra_debug_print("glue_solve_gen_full::apply(): refine + try_sympd ");
status = auxlib::solve_sympd_refine(out, rcond, A, B_expr.get_ref(), equ ilibrate, allow_ugly); // A is overwritten status = auxlib::solve_sympd_refine(out, rcond, A, B_expr.get_ref(), equ ilibrate, allow_ugly); // A is overwritten
if(status == false) if( (status == false) && (rcond == T(0)) )
{ {
arma_extra_debug_print("glue_solve_gen::apply(): auxlib::solve_sympd_r // auxlib::solve_sympd_refine() may have failed because A isn't really
efine() failed; retrying"); sympd;
// in that case rcond is set to zero
arma_extra_debug_print("glue_solve_gen_full::apply(): auxlib::solve_sy
mpd_refine() failed; retrying");
// auxlib::solve_sympd_refine() may have failed because A isn't really sympd
A = A_expr.get_ref(); A = A_expr.get_ref();
status = auxlib::solve_square_refine(out, rcond, A, B_expr.get_ref(), equilibrate, allow_ugly); // A is overwritten status = auxlib::solve_square_refine(out, rcond, A, B_expr.get_ref(), equilibrate, allow_ugly); // A is overwritten
} }
} }
else else
{ {
arma_extra_debug_print("glue_solve_gen::apply(): refine + dense"); arma_extra_debug_print("glue_solve_gen_full::apply(): refine + dense");
status = auxlib::solve_square_refine(out, rcond, A, B_expr, equilibrate, allow_ugly); // A is overwritten status = auxlib::solve_square_refine(out, rcond, A, B_expr, equilibrate, allow_ugly); // A is overwritten
} }
} }
else else
{ {
// default mode: solvers without refinement but with rcond estimate // default mode: solvers without refinement but with rcond estimate
arma_extra_debug_print("glue_solve_gen::apply(): default mode"); arma_extra_debug_print("glue_solve_gen_full::apply(): default mode");
if(is_band) if(is_band)
{ {
arma_extra_debug_print("glue_solve_gen::apply(): rcond + band"); arma_extra_debug_print("glue_solve_gen_full::apply(): rcond + band");
status = auxlib::solve_band_rcond(out, rcond, A, KL, KU, B_expr.get_ref( ), allow_ugly); status = auxlib::solve_band_rcond(out, rcond, A, KL, KU, B_expr.get_ref( ), allow_ugly);
} }
else else
if(is_triu || is_tril) if(is_triu || is_tril)
{ {
if(is_triu) { arma_extra_debug_print("glue_solve_gen::apply(): rcond + if(is_triu) { arma_extra_debug_print("glue_solve_gen_full::apply(): rco
upper triangular matrix"); } nd + upper triangular matrix"); }
if(is_tril) { arma_extra_debug_print("glue_solve_gen::apply(): rcond + if(is_tril) { arma_extra_debug_print("glue_solve_gen_full::apply(): rco
lower triangular matrix"); } nd + lower triangular matrix"); }
const uword layout = (is_triu) ? uword(0) : uword(1); const uword layout = (is_triu) ? uword(0) : uword(1);
status = auxlib::solve_trimat_rcond(out, rcond, A, B_expr.get_ref(), lay out, allow_ugly); status = auxlib::solve_trimat_rcond(out, rcond, A, B_expr.get_ref(), lay out, allow_ugly);
} }
else else
if(try_sympd) if(try_sympd)
{ {
status = auxlib::solve_sympd_rcond(out, rcond, A, B_expr.get_ref(), allo w_ugly); // A is overwritten bool sympd_state = false;
if(status == false) status = auxlib::solve_sympd_rcond(out, sympd_state, rcond, A, B_expr.ge
t_ref(), allow_ugly); // A is overwritten
if( (status == false) && (sympd_state == false) )
{ {
arma_extra_debug_print("glue_solve_gen::apply(): auxlib::solve_sympd_r cond() failed; retrying"); arma_extra_debug_print("glue_solve_gen_full::apply(): auxlib::solve_sy mpd_rcond() failed; retrying");
// auxlib::solve_sympd_rcond() may have failed because A isn't really sympd
A = A_expr.get_ref(); A = A_expr.get_ref();
status = auxlib::solve_square_rcond(out, rcond, A, B_expr.get_ref(), a llow_ugly); // A is overwritten status = auxlib::solve_square_rcond(out, rcond, A, B_expr.get_ref(), a llow_ugly); // A is overwritten
} }
} }
else else
{ {
status = auxlib::solve_square_rcond(out, rcond, A, B_expr.get_ref(), all ow_ugly); // A is overwritten status = auxlib::solve_square_rcond(out, rcond, A, B_expr.get_ref(), all ow_ugly); // A is overwritten
} }
} }
if( (status == true) && (rcond > T(0)) && (rcond < auxlib::epsilon_lapack(A) ) ) if( (status == true) && (rcond > T(0)) && (rcond < auxlib::epsilon_lapack(A) ) )
{ {
arma_debug_warn_level(2, "solve(): solution computed, but system is singul ar to working precision (rcond: ", rcond, ")"); arma_debug_warn_level(2, "solve(): solution computed, but system is singul ar to working precision (rcond: ", rcond, ")");
} }
if( (status == false) && (no_approx == false) ) if( (status == false) && (no_approx == false) )
{ {
arma_extra_debug_print("glue_solve_gen::apply(): solving rank deficient sy stem"); arma_extra_debug_print("glue_solve_gen_full::apply(): solving rank deficie nt system");
if(rcond > T(0)) if(rcond > T(0))
{ {
arma_debug_warn_level(2, "solve(): system is singular (rcond: ", rcond, "); attempting approx solution"); arma_debug_warn_level(2, "solve(): system is singular (rcond: ", rcond, "); attempting approx solution");
} }
else else
{ {
arma_debug_warn_level(2, "solve(): system is singular; attempting approx solution"); arma_debug_warn_level(2, "solve(): system is singular; attempting approx solution");
} }
// TODO: conditionally recreate A: have a separate state flag which indica tes whether A was previously overwritten // TODO: conditionally recreate A: have a separate state flag which indica tes whether A was previously overwritten
A = A_expr.get_ref(); // as A may have been overwritten A = A_expr.get_ref(); // as A may have been overwritten
status = auxlib::solve_approx_svd(out, A, B_expr.get_ref()); // A is over written status = auxlib::solve_approx_svd(out, A, B_expr.get_ref()); // A is over written
} }
} }
else else
{ {
arma_extra_debug_print("glue_solve_gen::apply(): detected non-square system" ); arma_extra_debug_print("glue_solve_gen_full::apply(): detected non-square sy stem");
if(equilibrate) { arma_debug_warn_level(2, "solve(): option 'equilibrate' ignored for non-square matrix" ); } if(equilibrate) { arma_debug_warn_level(2, "solve(): option 'equilibrate' ignored for non-square matrix" ); }
if(refine) { arma_debug_warn_level(2, "solve(): option 'refine' igno red for non-square matrix" ); } if(refine) { arma_debug_warn_level(2, "solve(): option 'refine' igno red for non-square matrix" ); }
if(likely_sympd) { arma_debug_warn_level(2, "solve(): option 'likely_sympd ' ignored for non-square matrix" ); } if(likely_sympd) { arma_debug_warn_level(2, "solve(): option 'likely_sympd ' ignored for non-square matrix" ); }
if(fast) if(fast)
{ {
status = auxlib::solve_rect_fast(out, A, B_expr.get_ref()); // A is overw ritten status = auxlib::solve_rect_fast(out, A, B_expr.get_ref()); // A is overw ritten
} }
else else
skipping to change at line 299 skipping to change at line 327
status = auxlib::solve_rect_rcond(out, rcond, A, B_expr.get_ref(), allow_u gly); // A is overwritten status = auxlib::solve_rect_rcond(out, rcond, A, B_expr.get_ref(), allow_u gly); // A is overwritten
} }
if( (status == true) && (rcond > T(0)) && (rcond < auxlib::epsilon_lapack(A) ) ) if( (status == true) && (rcond > T(0)) && (rcond < auxlib::epsilon_lapack(A) ) )
{ {
arma_debug_warn_level(2, "solve(): solution computed, but system is singul ar to working precision (rcond: ", rcond, ")"); arma_debug_warn_level(2, "solve(): solution computed, but system is singul ar to working precision (rcond: ", rcond, ")");
} }
if( (status == false) && (no_approx == false) ) if( (status == false) && (no_approx == false) )
{ {
arma_extra_debug_print("glue_solve_gen::apply(): solving rank deficient sy stem"); arma_extra_debug_print("glue_solve_gen_full::apply(): solving rank deficie nt system");
if(rcond > T(0)) if(rcond > T(0))
{ {
arma_debug_warn_level(2, "solve(): system is singular (rcond: ", rcond, "); attempting approx solution"); arma_debug_warn_level(2, "solve(): system is singular (rcond: ", rcond, "); attempting approx solution");
} }
else else
{ {
arma_debug_warn_level(2, "solve(): system is singular; attempting approx solution"); arma_debug_warn_level(2, "solve(): system is singular; attempting approx solution");
} }
A = A_expr.get_ref(); // as A was overwritten A = A_expr.get_ref(); // as A was overwritten
status = auxlib::solve_approx_svd(out, A, B_expr.get_ref()); // A is over written status = auxlib::solve_approx_svd(out, A, B_expr.get_ref()); // A is over written
} }
} }
return status; return status;
} }
// //
// glue_solve_tri // glue_solve_tri_default
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_solve_tri_default::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2 ,glue_solve_tri_default>& X) glue_solve_tri_default::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2 ,glue_solve_tri_default>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool status = glue_solve_tri_default::apply( out, X.A, X.B, X.aux_uword ); const bool status = glue_solve_tri_default::apply( out, X.A, X.B, X.aux_uword );
skipping to change at line 379 skipping to change at line 407
status = auxlib::solve_trimat_rcond(out, rcond, A, B_expr.get_ref(), layout, a llow_ugly); // A is not modified status = auxlib::solve_trimat_rcond(out, rcond, A, B_expr.get_ref(), layout, a llow_ugly); // A is not modified
if( (status == true) && (rcond > T(0)) && (rcond < auxlib::epsilon_lapack(A)) ) if( (status == true) && (rcond > T(0)) && (rcond < auxlib::epsilon_lapack(A)) )
{ {
arma_debug_warn_level(2, "solve(): solution computed, but system is singular to working precision (rcond: ", rcond, ")"); arma_debug_warn_level(2, "solve(): solution computed, but system is singular to working precision (rcond: ", rcond, ")");
} }
if(status == false) if(status == false)
{ {
arma_extra_debug_print("glue_solve_tri::apply(): solving rank deficient syst em"); arma_extra_debug_print("glue_solve_tri_default::apply(): solving rank defici ent system");
if(rcond > T(0)) if(rcond > T(0))
{ {
arma_debug_warn_level(2, "solve(): system is singular (rcond: ", rcond, ") ; attempting approx solution"); arma_debug_warn_level(2, "solve(): system is singular (rcond: ", rcond, ") ; attempting approx solution");
} }
else else
{ {
arma_debug_warn_level(2, "solve(): system is singular; attempting approx s olution"); arma_debug_warn_level(2, "solve(): system is singular; attempting approx s olution");
} }
Mat<eT> triA = (triu) ? trimatu(A) : trimatl(A); // trimatu() and trimatl() return the same type Mat<eT> triA = (triu) ? trimatu(A) : trimatl(A); // trimatu() and trimatl() return the same type
status = auxlib::solve_approx_svd(out, triA, B_expr.get_ref()); // triA is overwritten status = auxlib::solve_approx_svd(out, triA, B_expr.get_ref()); // triA is overwritten
} }
if(is_alias) { actual_out.steal_mem(out); } if(is_alias) { actual_out.steal_mem(out); }
return status; return status;
} }
//
// glue_solve_tri_full
template<typename T1, typename T2> template<typename T1, typename T2>
inline inline
void void
glue_solve_tri::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_so lve_tri>& X) glue_solve_tri_full::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,gl ue_solve_tri_full>& X)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
const bool status = glue_solve_tri::apply( out, X.A, X.B, X.aux_uword ); const bool status = glue_solve_tri_full::apply( out, X.A, X.B, X.aux_uword );
if(status == false) if(status == false)
{ {
out.soft_reset(); out.soft_reset();
arma_stop_runtime_error("solve(): solution not found"); arma_stop_runtime_error("solve(): solution not found");
} }
} }
template<typename eT, typename T1, typename T2> template<typename eT, typename T1, typename T2>
inline inline
bool bool
glue_solve_tri::apply(Mat<eT>& actual_out, const Base<eT,T1>& A_expr, const Base <eT,T2>& B_expr, const uword flags) glue_solve_tri_full::apply(Mat<eT>& actual_out, const Base<eT,T1>& A_expr, const Base<eT,T2>& B_expr, const uword flags)
{ {
arma_extra_debug_sigprint(); arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T; typedef typename get_pod_type<eT>::result T;
const bool fast = bool(flags & solve_opts::flag_fast ); const bool fast = bool(flags & solve_opts::flag_fast );
const bool equilibrate = bool(flags & solve_opts::flag_equilibrate ); const bool equilibrate = bool(flags & solve_opts::flag_equilibrate );
const bool no_approx = bool(flags & solve_opts::flag_no_approx ); const bool no_approx = bool(flags & solve_opts::flag_no_approx );
const bool triu = bool(flags & solve_opts::flag_triu ); const bool triu = bool(flags & solve_opts::flag_triu );
const bool tril = bool(flags & solve_opts::flag_tril ); const bool tril = bool(flags & solve_opts::flag_tril );
const bool allow_ugly = bool(flags & solve_opts::flag_allow_ugly ); const bool allow_ugly = bool(flags & solve_opts::flag_allow_ugly );
const bool likely_sympd = bool(flags & solve_opts::flag_likely_sympd); const bool likely_sympd = bool(flags & solve_opts::flag_likely_sympd);
const bool refine = bool(flags & solve_opts::flag_refine ); const bool refine = bool(flags & solve_opts::flag_refine );
const bool no_trimat = bool(flags & solve_opts::flag_no_trimat ); const bool no_trimat = bool(flags & solve_opts::flag_no_trimat );
const bool force_approx = bool(flags & solve_opts::flag_force_approx); const bool force_approx = bool(flags & solve_opts::flag_force_approx);
arma_extra_debug_print("glue_solve_tri::apply(): enabled flags:"); arma_extra_debug_print("glue_solve_tri_full::apply(): enabled flags:");
if(fast ) { arma_extra_debug_print("fast"); } if(fast ) { arma_extra_debug_print("fast"); }
if(equilibrate ) { arma_extra_debug_print("equilibrate"); } if(equilibrate ) { arma_extra_debug_print("equilibrate"); }
if(no_approx ) { arma_extra_debug_print("no_approx"); } if(no_approx ) { arma_extra_debug_print("no_approx"); }
if(triu ) { arma_extra_debug_print("triu"); } if(triu ) { arma_extra_debug_print("triu"); }
if(tril ) { arma_extra_debug_print("tril"); } if(tril ) { arma_extra_debug_print("tril"); }
if(allow_ugly ) { arma_extra_debug_print("allow_ugly"); } if(allow_ugly ) { arma_extra_debug_print("allow_ugly"); }
if(likely_sympd) { arma_extra_debug_print("likely_sympd"); } if(likely_sympd) { arma_extra_debug_print("likely_sympd"); }
if(refine ) { arma_extra_debug_print("refine"); } if(refine ) { arma_extra_debug_print("refine"); }
if(no_trimat ) { arma_extra_debug_print("no_trimat"); } if(no_trimat ) { arma_extra_debug_print("no_trimat"); }
if(force_approx) { arma_extra_debug_print("force_approx"); } if(force_approx) { arma_extra_debug_print("force_approx"); }
if(no_trimat || equilibrate || refine || force_approx) if(no_trimat || equilibrate || refine || force_approx)
{ {
const uword mask = ~(solve_opts::flag_triu | solve_opts::flag_tril); const uword mask = ~(solve_opts::flag_triu | solve_opts::flag_tril);
return glue_solve_gen::apply(actual_out, ((triu) ? trimatu(A_expr.get_ref()) : trimatl(A_expr.get_ref())), B_expr, (flags & mask)); return glue_solve_gen_full::apply(actual_out, ((triu) ? trimatu(A_expr.get_r ef()) : trimatl(A_expr.get_ref())), B_expr, (flags & mask));
} }
if(likely_sympd) { arma_debug_warn_level(2, "solve(): option 'likely_sympd' i gnored for triangular matrix"); } if(likely_sympd) { arma_debug_warn_level(2, "solve(): option 'likely_sympd' i gnored for triangular matrix"); }
const quasi_unwrap<T1> U(A_expr.get_ref()); const quasi_unwrap<T1> U(A_expr.get_ref());
const Mat<eT>& A = U.M; const Mat<eT>& A = U.M;
arma_debug_check( (A.is_square() == false), "solve(): matrix marked as triangu lar must be square sized" ); arma_debug_check( (A.is_square() == false), "solve(): matrix marked as triangu lar must be square sized" );
const uword layout = (triu) ? uword(0) : uword(1); const uword layout = (triu) ? uword(0) : uword(1);
skipping to change at line 488 skipping to change at line 519
status = auxlib::solve_trimat_rcond(out, rcond, A, B_expr.get_ref(), layout, allow_ugly); // A is not modified status = auxlib::solve_trimat_rcond(out, rcond, A, B_expr.get_ref(), layout, allow_ugly); // A is not modified
} }
if( (status == true) && (rcond > T(0)) && (rcond < auxlib::epsilon_lapack(A)) ) if( (status == true) && (rcond > T(0)) && (rcond < auxlib::epsilon_lapack(A)) )
{ {
arma_debug_warn_level(2, "solve(): solution computed, but system is singular to working precision (rcond: ", rcond, ")"); arma_debug_warn_level(2, "solve(): solution computed, but system is singular to working precision (rcond: ", rcond, ")");
} }
if( (status == false) && (no_approx == false) ) if( (status == false) && (no_approx == false) )
{ {
arma_extra_debug_print("glue_solve_tri::apply(): solving rank deficient syst em"); arma_extra_debug_print("glue_solve_tri_full::apply(): solving rank deficient system");
if(rcond > T(0)) if(rcond > T(0))
{ {
arma_debug_warn_level(2, "solve(): system is singular (rcond: ", rcond, ") ; attempting approx solution"); arma_debug_warn_level(2, "solve(): system is singular (rcond: ", rcond, ") ; attempting approx solution");
} }
else else
{ {
arma_debug_warn_level(2, "solve(): system is singular; attempting approx s olution"); arma_debug_warn_level(2, "solve(): system is singular; attempting approx s olution");
} }
 End of changes. 44 change blocks. 
72 lines changed or deleted 120 lines changed or added

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