From fe8097439b4eaa6c8dba4b64f18d372477ee855c Mon Sep 17 00:00:00 2001 From: conrad Date: Sun, 3 Jan 2021 12:59:20 +1000 Subject: [PATCH] optional debugging code --- include/armadillo_bits/sp_auxlib_bones.hpp | 6 +- include/armadillo_bits/sp_auxlib_meat.hpp | 64 ++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/include/armadillo_bits/sp_auxlib_bones.hpp b/include/armadillo_bits/sp_auxlib_bones.hpp index 91ee5772..52fcdac4 100644 --- a/include/armadillo_bits/sp_auxlib_bones.hpp +++ b/include/armadillo_bits/sp_auxlib_bones.hpp @@ -105,10 +105,14 @@ class sp_auxlib template inline static bool copy_to_supermatrix(superlu::SuperMatrix& out, const SpMat& A); - + template inline static bool copy_to_supermatrix_with_shift(superlu::SuperMatrix& out, const SpMat& A, const eT shift); + // // for debugging only + // template + // inline static void copy_to_spmat(SpMat& out, const superlu::SuperMatrix& A); + template inline static bool wrap_to_supermatrix(superlu::SuperMatrix& out, const Mat& A); diff --git a/include/armadillo_bits/sp_auxlib_meat.hpp b/include/armadillo_bits/sp_auxlib_meat.hpp index 9dfc90ad..f4fbf56f 100644 --- a/include/armadillo_bits/sp_auxlib_meat.hpp +++ b/include/armadillo_bits/sp_auxlib_meat.hpp @@ -1822,6 +1822,46 @@ sp_auxlib::spsolve_refine(Mat& X, typename T1::pod_type& +// // for debugging only +// template +// inline +// void +// sp_auxlib::copy_to_spmat(SpMat& out, const superlu::SuperMatrix& A) +// { +// arma_extra_debug_sigprint(); +// +// bool type_matched = false; +// +// if( is_float::value) { type_matched = (A.Dtype == superlu::SLU_S); } +// else if( is_double::value) { type_matched = (A.Dtype == superlu::SLU_D); } +// else if( is_cx_float::value) { type_matched = (A.Dtype == superlu::SLU_C); } +// else if(is_cx_double::value) { type_matched = (A.Dtype == superlu::SLU_Z); } +// +// arma_debug_check( (type_matched == false), "copy_to_spmat(): type mismatch" ); +// arma_debug_check( (A.Mtype != superlu::SLU_GE), "copy_to_spmat(): unknown layout" ); +// +// const superlu::NCformat* nc = (const superlu::NCformat*)(A.Store); +// +// if(nc == nullptr) { out.reset(); return; } +// +// if( (nc->nzval == nullptr) || (nc->colptr == nullptr) || (nc->rowind == nullptr) ) { out.reset(); return; } +// +// const uword A_n_rows = uword(A.nrow ); +// const uword A_n_cols = uword(A.ncol ); +// const uword A_n_nonzero = uword(nc->nnz); +// +// if(A_n_nonzero == 0) { out.zeros(A_n_rows, A_n_cols); return; } +// +// out.reserve(A_n_rows, A_n_cols, A_n_nonzero); +// +// arrayops::copy(access::rwp(out.values), (const eT*)(nc->nzval), A_n_nonzero); +// +// arrayops::convert(access::rwp(out.col_ptrs), nc->colptr, A_n_cols+1 ); +// arrayops::convert(access::rwp(out.row_indices), nc->rowind, A_n_nonzero); +// } + + + template inline bool @@ -2195,6 +2235,30 @@ sp_auxlib::run_aupd_shiftinvert return; } + // // for debugging only + // if(true) + // { + // cout << "*** testing output of copy_to_supermatrix_with_shift()" << endl; + // cout << "*** sigma: " << sigma << endl; + // + // SpMat Y(X); + // Y.diag() -= sigma; + // + // SpMat Z; + // + // sp_auxlib::copy_to_spmat(Z, x.get_ref()); + // + // cout << "*** size(Y): " << arma::size(Y) << endl; + // cout << "*** size(Z): " << arma::size(Z) << endl; + // cout << "*** accu(abs(Y)): " << accu(abs(Y)) << endl; + // cout << "*** accu(abs(Z)): " << accu(abs(Z)) << endl; + // + // if(arma::size(Y) == arma::size(Z)) + // { + // cout << "*** error: " << accu(abs(Y-Z)) << endl; + // } + // } + superlu_supermatrix_wrangler l; superlu_supermatrix_wrangler u;