9 #define DbgTime() qDebug() << "TM:" << (startTime.msecsTo(QDateTime::currentDateTime())/1000.0)
15 DbgLv(1) <<
"pcsa_mast: IN";
17 DbgLv(1) <<
"pcsa_mast: init complete";
19 DbgLv(1) <<
"pcsa_mast: fill_pcsa_queue complete";
43 DbgLv(1) <<
"pcsa_mast: submit_pcsa kc" << kcurve;
72 for(
int jm=0; jm<km; jm++ )
if(
mrecs[jm].rmsd<1.0) kg++;
73 DbgLv(1) <<
"final-mr0: ki kw kr" << ki << kw << kr <<
"km kg" << km << kg;
81 progress +=
"; Datasets: "
84 progress +=
"; Dataset: "
86 +
" (" + tripleID +
") of "
90 progress +=
"; MonteCarlo: "
94 progress +=
"; RMSD: "
95 + QString::number(
mrecs[ 0 ].rmsd );
106 qDebug() <<
" == Grid-Fit Iterations for Dataset"
111 qDebug() <<
" == Grid-Fit Iterations for Datasets 1 to"
116 <<
" Variance:" <<
mrecs[ 0 ].variance
117 <<
"RMSD:" <<
mrecs[ 0 ].rmsd;
126 DbgLv(1) <<
" master loop-BOT: dssize" <<
data_sets.size() <<
"ds_to_p"
133 DbgLv(1) <<
" master loop-BOT: ds" << current_dataset+1 <<
"data l m h"
143 DbgLv(1) <<
" master loop-BOT: GF job_queue empty" <<
job_queue.isEmpty();
166 QString tripleID = QString(
data_sets[ current_dataset ]->model
167 .description ).section(
".", -3, -3 );
173 <<
"(" << tripleID <<
")"
174 <<
" : model was output.";
179 <<
"(" << tripleID <<
")"
180 <<
" : model/noise(s) were output.";
220 switch( status.MPI_TAG )
223 worker = status.MPI_SOURCE;
224 DbgLv(1) <<
" master loop-BOTTOM: READY worker" << worker;
229 worker = status.MPI_SOURCE;
230 DbgLv(1) <<
" master loop-BOTTOM: RESULTS worker" << worker;
236 QString msg =
"Master PCSA: Received invalid status " +
237 QString::number( status.MPI_TAG );
249 DbgLv(1) <<
" init_pcsa_sols: IN";
260 double x_min =
parameters[
"x_min" ].toDouble();
261 double x_max =
parameters[
"x_max" ].toDouble();
262 double y_min =
parameters[
"y_min" ].toDouble();
263 double y_max =
parameters[
"y_max" ].toDouble();
264 double zval =
parameters[
"z_value" ].toDouble();
269 int nkpts =
parameters[
"vars_count" ].toInt();
270 int nkpto =
sq( nkpts );
271 int nlpts =
parameters[
"curves_points" ].toInt();
272 DbgLv(1) <<
" init_pcsa_sols: nkpts" << nkpts <<
"nkpto" << nkpto;
274 zval = ( zval == 0.0 ) ? vbar20 : zval;
276 double *parlims = (
double*)
pararry;
278 parlims[ 4 ] = stype;
281 DbgLv(1) <<
" init_pcsa_sols: s_ctyp" << s_ctyp <<
"ctype" << ctype;
285 mrecs.reserve( nkpto );
286 DbgLv(1) <<
" init_pcsa_sols: call compute_slines nkpts" << nkpts;
288 nkpts, nlpts, parlims,
mrecs );
289 DbgLv(1) <<
" init_pcsa_sols: compute_slines: mrecs sz" <<
mrecs.size();
294 mrecs.reserve( nkpto );
295 DbgLv(1) <<
" init_pcsa_sols: call compute_sigmoids nkpts" << nkpts;
297 nkpts, nlpts, parlims,
mrecs );
298 DbgLv(1) <<
" init_pcsa_sols: compute_sigmoids: mrecs sz" <<
mrecs.size();
304 mrecs.reserve( nkpto );
306 nkpts, nlpts, parlims,
mrecs );
314 double *parlims1 = parlims + 12;
315 double *parlims2 = parlims + 24;
316 parlims1[ 0 ] = parlims[ 0 ];
317 parlims1[ 4 ] = parlims[ 4 ];
318 parlims1[ 5 ] = parlims[ 5 ];
319 parlims2[ 0 ] = parlims[ 0 ];
320 parlims2[ 4 ] = parlims[ 4 ];
321 parlims2[ 5 ] = parlims[ 5 ];
322 mrecs.reserve( nkpto );
325 nkpts, nlpts, parlims,
mrecs );
327 nkpts, nlpts, parlims1,
mrecs );
329 nkpts, nlpts, parlims2,
mrecs );
335 DbgLv(1) <<
" init_pcsa_sols: nkpts" << nkpts <<
"nkpto" << nkpto;
336 mrecs.reserve( nkpto );
338 nkpts, nlpts, parlims,
mrecs );
341 for (
int ii = 0; ii <
mrecs.size(); ii++ )
357 if (dd==0) {
DbgLv(1) <<
"Mast: submit: worker" << worker <<
" sols"
359 else {
DbgLv(1) <<
"Mast: submit: worker" << worker <<
" sols"
361 DbgLv(1) <<
"Mast: submit: len sol offs cnt"
368 DbgLv(1) <<
" master loop-SEND PROCESS worker" << worker
376 DbgLv(1) <<
"Mast: submit: send #1";
385 DbgLv(1) <<
"Mast: submit: send #2";
442 DbgLv(1) <<
"Mast: process_results: worker" << worker
443 <<
" solsize" << sizes[0];
456 int jcurve = result.
depth;
457 jcurve = qMax( 0, qMin( (
mrecs.size() - 1 ), jcurve ) );
458 DbgLv(1) <<
"Mast: process_solutes: worker" << result.
worker
459 <<
"jcurve" << jcurve <<
" solsize" << result.
solutes.size();
463 cMr = &
mrecs[ jcurve ];
472 if ( ( noiflg & 1 ) > 0 )
475 if ( ( noiflg & 2 ) > 0 )
490 DbgLv(1) <<
"pcsa:wrmr: editGUID=" <<
mrecs[0].editGUID
491 <<
"modelGUID=" <<
mrecs[0].modelGUID;
493 .replace(
".model",
".mrecs" );
498 double x_min =
parameters[
"x_min" ].toDouble();
499 double x_max =
parameters[
"x_max" ].toDouble();
500 double y_min =
parameters[
"y_min" ].toDouble();
501 double y_max =
parameters[
"y_max" ].toDouble();
503 mrecs[ 0 ].ctype = ctype;
504 mrecs[ 0 ].xmin = x_min;
505 mrecs[ 0 ].xmax = x_max;
506 mrecs[ 0 ].ymin = y_min;
507 mrecs[ 0 ].ymax = y_max;
508 QString fnameo = s_desc +
".xml";
509 QFile fileo( fnameo );
511 if ( fileo.open( QIODevice::WriteOnly | QIODevice::Text ) )
513 QXmlStreamWriter xmlo( &fileo );
515 DbgLv(1) <<
"pcsa:wrmr: call wr_mr: s_desc" << s_desc;
517 x_min, x_max, y_min, y_max, stype );
518 DbgLv(1) <<
"pcsa:wrmr: rtn wr_mr";
524 QFile filea(
"analysis_files.txt" );
526 if ( ! filea.open( QIODevice::WriteOnly | QIODevice::Text
527 | QIODevice::Append ) )
529 abort(
"Could not open 'analysis_files.txt' for writing" );
533 QTextStream tsout( &filea );
536 int run = ( mc_iter > 1 ) ? mc_iter : 1;
541 QString runstring =
"Run: " + QString::number( run ) +
" " + tripleID;
545 <<
";MC_iteration=" << mc_iter
547 <<
";run=" << runstring
550 DbgLv(1) <<
"pcsa:wrmr: wr-to-atxt fnameo=" << fnameo;
556 static double rmsd_last = 0.0;
557 double rmsd_curr =
mrecs[ 0 ].rmsd;
558 double thr_dr_rat =
parameters[
"thr_deltr_ratio" ].toDouble();
566 double dr_rat = qAbs( ( rmsd_curr - rmsd_last ) / rmsd_last );
567 DbgLv(1) <<
"iter_p: rmsd_c rmsd_l" << rmsd_curr << rmsd_last
568 <<
"dr_rat thr_dr_rat" << dr_rat << thr_dr_rat;
571 if ( dr_rat < thr_dr_rat )
573 qDebug() <<
"Virtually identical RMSDs of"
574 << rmsd_last << rmsd_curr
582 double x_min =
parameters[
"x_min" ].toDouble();
583 double x_max =
parameters[
"x_max" ].toDouble();
584 double y_min =
parameters[
"y_min" ].toDouble();
585 double y_max =
parameters[
"y_max" ].toDouble();
586 double zval =
parameters[
"z_value" ].toDouble();
591 int nkpts =
parameters[
"vars_count" ].toInt();
592 int nlpts =
parameters[
"curves_points" ].toInt();
594 zval = ( zval == 0.0 ) ? vbar20 : zval;
595 double *parlims = (
double*)
pararry;
597 parlims[ 4 ] = stype;
599 DbgLv(1) <<
"iter_p: ctype" << ctype << s_ctyp;
607 nkpts, nlpts, parlims,
mrecs );
608 DbgLv(1) <<
"iter_p: parlims"
609 << parlims[0] << parlims[1] << parlims[2] << parlims[3] << parlims[4]
610 << parlims[5] << parlims[6] << parlims[7] << parlims[8] << parlims[9];
615 QVector< US_ModelRecord > mrecs_sl;
616 QVector< US_ModelRecord > mrecs_is;
617 QVector< US_ModelRecord > mrecs_ds;
618 double* plims_sl = parlims;
619 double* plims_is = plims_sl + 12;
620 double* plims_ds = plims_is + 24;
630 nkpts, nlpts, plims_sl, mrecs_sl );
634 nkpts, nlpts, plims_is, mrecs_is );
638 nkpts, nlpts, plims_ds, mrecs_ds );
642 int ncurve =
sq( nkpts );
643 DbgLv(1) <<
"iter_p: ncurve" << ncurve;
645 for (
int ii = 0; ii < ncurve; ii++, kk++ )
647 mrecs[ kk ] = mrecs_sl[ ii ];
648 mrecs[ kk ].taskx = kk;
651 for (
int ii = 0; ii < ncurve; ii++, kk++ )
653 mrecs[ kk ] = mrecs_is[ ii ];
654 mrecs[ kk ].taskx = kk;
657 for (
int ii = 0; ii < ncurve; ii++, kk++ )
659 mrecs[ kk ] = mrecs_ds[ ii ];
660 mrecs[ kk ].taskx = kk;
664 mrecs[0].v_ctype = ctype;
665 plims_is[ 5 ] = parlims[ 5 ];
666 plims_ds[ 5 ] = parlims[ 5 ];
667 DbgLv(1) <<
"iter_p: plims_sl"
668 << plims_sl[0] << plims_sl[1] << plims_sl[2] << plims_sl[3] << plims_sl[4];
669 DbgLv(1) <<
"iter_p: plims_is"
670 << plims_is[0] << plims_is[1] << plims_is[2] << plims_is[3] << plims_is[4];
671 DbgLv(1) <<
"iter_p: plims_ds"
672 << plims_ds[0] << plims_ds[1] << plims_ds[2] << plims_ds[3] << plims_ds[4];
679 for (
int ii = 0; ii <
mrecs.size(); ii++ )
689 rmsd_last = rmsd_curr;
696 int tikreg =
parameters[
"tikreg_option" ].toInt();
697 DbgLv(1) <<
"tikr: tikreg" << tikreg;
702 alpha = ( tikreg == 1 )
726 qDebug() <<
"Tikhonov Regularization RMSD" <<
mrec.
rmsd;
731 QString progress =
"Regularization: "
735 progress +=
"; Datasets: "
739 +
" (" + tripleID +
") of "
742 progress +=
"; RMSD: " + QString::number(
mrec.
rmsd );
787 int mcd_incr = nscan * npoint;
788 int mcd_size = mcd_incr * 2;
793 for (
int ii = 0; ii < nscan; ii++ )
795 int ks = ii * npoint;
796 int kr = ks + mcd_incr;
798 for (
int jj = 0; jj < npoint; jj++, ks++, kr++ )
807 for ( worker = 1; worker <=
my_workers; worker++ )
856 DbgLv(1) <<
" masterMC loop-ready_worker" << worker;
864 DbgLv(1) <<
" masterMC loop-SEND PROCESS_MC worker" << worker
865 <<
"iter" << kci_send;
898 worker = status.MPI_SOURCE;
899 DbgLv(1) <<
" masterMC loop-BOTTOM: status TAG" << status.MPI_TAG
900 <<
" source" << status.MPI_SOURCE
901 <<
"sizes" << sizes[0] << sizes[1] << sizes[2] << sizes[3];
902 switch( status.MPI_TAG )
905 DbgLv(1) <<
" masterMC loop-RECV READY worker" << worker;
911 DbgLv(1) <<
" masterMC loop-RECV RESULTS_MC worker" << worker <<
"kci_recv" << kci_recv;
952 DbgLv(1) <<
" masterMC loop-RECV RESULTS_MC mc_iter" << mc_iter <<
"of" <<
mc_iterations;
956 progress =
"Datasets: "
959 progress =
"Dataset: "
961 +
" (" + tripleID +
") of "
964 progress +=
"; MonteCarlo: "
965 + QString::number( mc_iter );
971 DbgLv(1) <<
" masterMC loop-RECV RESULTS worker" << worker <<
"wstat" <<
worker_status[worker];
973 QVector< double > dwork;
974 int mxsiz = qMax( sizes[ 0 ], sizes[ 1 ] );
975 mxsiz = qMax( mxsiz, sizes[ 2 ] );
977 dwork.resize( mxsiz );
978 double* wbuf = dwork.data();
982 sizes[ 0 ] * solute_doubles,
1020 DbgLv(1) <<
" masterMC loop-RECV invalid worker" << worker <<
"tag" << status.MPI_TAG;
1021 progress =
"Master PCSA: Received invalid status "
1022 + QString::number( status.MPI_TAG );
1036 int mrx = (
mrecs[ 2 ].taskx ==
mrecs[ 0 ].taskx ) ? 2 : 1;
1038 QString mfilt =
"*" + tripleID +
"*.mcN*model.xml";
1039 QStringList mfltl( mfilt );
1040 QStringList mlist = QDir(
"." ).entryList( mfltl, QDir::Files );
1042 int nmfile = mlist.size();
1048 else if ( nmfile > 1 )
1051 qDebug() <<
"*WARNING* More than 1" << mfilt <<
"file exists!";
1052 QDateTime mtime = QFileInfo( mfile ).lastModified();
1054 for (
int jj = 1; jj < mlist.size(); jj++ )
1056 QDateTime ftime = QFileInfo( mlist[ 0 ] ).lastModified();
1057 if ( ftime > mtime )
1066 qDebug() <<
"*ERROR* No" << mfilt <<
"file exists!";
1087 QVector< US_ModelRecord >& mrecs_a, QVector< US_ModelRecord >& mrecs_t )
1089 int namrec = mrecs_a.size();
1090 int ntmrec = namrec / 3;
1092 mrecs_t.reserve( ntmrec );
1094 for (
int ii = 0; ii < namrec; ii++ )
1095 if ( mrecs_a[ ii ].ctype == ctype )
1096 mrecs_t << mrecs_a[ ii ];
1103 int nmrec = mrecs.size();
1104 int lmrec = nmrec - 1;
1107 for (
int ii = lmrec; ii > 1; ii-- )
1109 if ( mrecs[ ii ].csolutes.size() != 0 )
1117 if ( goodx == lmrec )
1120 DbgLv(1) <<
" master:clean_mrecs: goodx lmrec" << goodx << lmrec;
1123 for (
int ii = goodx + 1; ii < nmrec; ii++ )
1125 mrecs[ ii ].csolutes = mrecs[ goodx ].csolutes;
1126 mrecs[ ii ].rmsd = mrecs[ goodx ].rmsd;
1138 for (
int ii = goodx; ii > 1; ii-- )
1140 if ( mrecs[ ii ].ctype ==
CTYPE_SL )
1142 if ( gx_sl > 0 )
continue;
1146 else if ( mrecs[ ii ].ctype ==
CTYPE_IS )
1148 if ( gx_is > 0 )
continue;
1152 else if ( mrecs[ ii ].ctype ==
CTYPE_DS )
1154 if ( gx_ds > 0 )
continue;
1159 if ( ktype >= 3 )
break;
1163 for (
int ii = goodx + 1; ii < nmrec; ii++ )
1165 if ( mrecs[ ii ].ctype ==
CTYPE_SL )
1167 mrecs[ ii ].csolutes = mrecs[ gx_sl ].csolutes;
1168 mrecs[ ii ].rmsd = mrecs[ gx_sl ].rmsd;
1170 else if ( mrecs[ ii ].ctype ==
CTYPE_IS )
1172 mrecs[ ii ].csolutes = mrecs[ gx_is ].csolutes;
1173 mrecs[ ii ].rmsd = mrecs[ gx_is ].rmsd;
1175 else if ( mrecs[ ii ].ctype ==
CTYPE_DS )
1177 mrecs[ ii ].csolutes = mrecs[ gx_ds ].csolutes;
1178 mrecs[ ii ].rmsd = mrecs[ gx_ds ].rmsd;
1208 int tikreg =
parameters[
"tikreg_option" ].toInt();
1215 int nadd = ( mc_iterations > 1 ) ? 2 : 1;
1218 mrecs[ 1 ].model = mdummy;
1219 mrecs[ 1 ].csolutes .clear();
1220 mrecs[ 1 ].ti_noise .clear();
1221 mrecs[ 1 ].ri_noise .clear();
1222 mrecs[ 1 ].mrecGUID .clear();
1223 mrecs[ 1 ].mrecGUID .clear();
1224 mrecs[ 1 ].modelGUID.clear();
1228 mrecs[ 2 ].model = mdummy;
1229 mrecs[ 2 ].csolutes .clear();
1230 mrecs[ 2 ].ti_noise .clear();
1231 mrecs[ 2 ].ri_noise .clear();
1232 mrecs[ 2 ].mrecGUID .clear();
1233 mrecs[ 2 ].mrecGUID .clear();
1234 mrecs[ 2 ].modelGUID.clear();
1238 else if ( mc_iterations > 1 )
1241 mrecs[ 1 ].model = mdummy;
1242 mrecs[ 1 ].csolutes .clear();
1243 mrecs[ 1 ].ti_noise .clear();
1244 mrecs[ 1 ].ri_noise .clear();
1245 mrecs[ 1 ].mrecGUID .clear();
1246 mrecs[ 1 ].mrecGUID .clear();
1247 mrecs[ 1 ].modelGUID.clear();
1250 if ( ( tikreg != 0 || mc_iterations > 1 ) &&
1254 double vnoise = 0.0;
1259 DbgLv(1) <<
"bestm: noise apply ns np sc rc" << nscan << npoint << scount << rcount;
1260 npoint = ( noiflg & 1 ) > 0 ? npoint : rcount;
1261 nscan = ( noiflg & 2 ) > 0 ? nscan : scount;
1263 if ( rcount != npoint || scount != nscan )
1265 qDebug() <<
"*ERROR* noise count(s) do not match data dimensions!";
1269 if ( ( noiflg & 1 ) > 0 )
1271 DbgLv(1) <<
"bestm: noise flag" << noiflg <<
"TI_NOISE apply";
1272 for (
int jj = 0; jj < rcount; jj++ )
1275 for (
int ii = 0; ii < scount; ii++ )
1277 edata->
scanData[ ii ].rvalues[ jj ] += vnoise;
1282 if ( ( noiflg & 2 ) > 0 )
1284 DbgLv(1) <<
"bestm: noise flag" << noiflg <<
"RI_NOISE apply";
1285 for (
int ii = 0; ii < scount; ii++ )
1288 for (
int jj = 0; jj < rcount; jj++ )
1290 edata->
scanData[ ii ].rvalues[ jj ] += vnoise;
1304 QString runID = QString( mdesc ).section(
".", 0, -4 );
1305 QString tripID = QString( mdesc ).section(
".", -3, -3 );
1306 QString asysID = QString( mdesc ).section(
".", -2, -2 );
1307 QString typeExt = QString(
".model" );
1308 QString dates = QString( asysID ).section(
"_", 0, 1 );
1309 QString atype = QString( asysID ).section(
"_", 2, 2 );
1310 QString reqID = QString( asysID ).section(
"_", 3, 3 );
1311 QString iterID =
"i01" ;
1322 iterID = QString().sprintf(
"mc%04d", iter );
1323 int jj = (
mrecs[ 2 ].taskx ==
mrecs[ 0 ].taskx ) ? 2 : 1;
1326 asysID = dates +
"_" + atype +
"_" + reqID +
"_" + iterID;
1327 mdesc = runID +
"." + tripID +
"." + asysID + typeExt;
1330 DbgLv(1) <<
"wraux: mdesc" << mdesc;
1331 QString s_styp =
parameters[
"solute_type" ];
1334 for (
int ii = 0; ii <
wksim_vals.zsolutes.size(); ii++ )
1339 component.
name = QString().sprintf(
"SC%04d", ii + 1 );
1347 QString fext = ( iter == 0 ) ?
".model.xml" :
".mdl.tmp";
1348 QString fileid =
"." + atype +
"." + tripID +
"." + iterID + fext;
1349 QString fn = runID + fileid;
1350 int lenfn = fn.length();
1354 int lenri = runID.length() + 99 - lenfn;
1355 fn = QString( runID ).left( lenri ) + fileid;
1362 QFile fileo(
"analysis_files.txt" );
1364 if ( ! fileo.open( QIODevice::WriteOnly | QIODevice::Text
1365 | QIODevice::Append ) )
1367 abort(
"Could not open 'analysis_files.txt' for writing" );
1371 QTextStream tsout( &fileo );
1375 <<
";MC_iteration=" << iter
1377 <<
";run=Run: 1 " << tripID <<
"\n";
1392 const double salpha = 0.10;
1393 const double ealpha = 0.90;
1394 const double dalpha = 0.01;
1395 const double roundv = dalpha * 0.05;
1396 const double alphadef = salpha + ( ealpha - salpha ) * 0.25;
1397 int nalpha = qRound( ( ealpha - salpha ) / dalpha ) + 1;
1398 QVector< double > alphas;
1399 QVector< double > varias;
1400 QVector< double > xnorms;
1401 QVector< double > sv_nnls_a;
1402 QVector< double > sv_nnls_b;
1406 alphas.reserve( nalpha );
1407 varias.reserve( nalpha );
1408 xnorms.reserve( nalpha );
1412 double v_vari = 0.0;
1413 double v_xnsq = 0.0;
1414 double calpha = salpha;
1416 for (
int ja = 0; ja < nalpha; ja++ )
1425 QVector< double > csolutes;
1433 for (
int ja = 0; ja < nalpha; ja++ )
1435 calpha = alphas[ ja ];
1440 sim_vals.
alpha = calpha;
1446 &sv_nnls_a, &sv_nnls_b );
1455 nscans, npoints, nisols, v_vari, v_xnsq );
1458 varias[ ja ] = v_vari;
1459 xnorms[ ja ] = v_xnsq;
1460 varmx = qMax( varmx, v_vari );
1461 xnomx = qMax( xnomx, v_xnsq );
1462 DbgLv(1) <<
"a v x" << calpha << v_vari << v_xnsq;
1468 int lgv = 0 - (int)qFloor( log10( varmx ) );
1469 int lgx = -1 - (int)qFloor( log10( xnomx ) );
1470 double vscl = qPow( 10.0, lgv );
1471 double xscl = qPow( 10.0, lgx );
1472 DbgLv(1) <<
"Log-varia Log-xnorm" << lgv << lgx <<
"vscl xscl" << vscl << xscl;
1474 for (
int ja = 0; ja < nalpha; ja++ )
1476 varias[ ja ] *= vscl;
1477 xnorms[ ja ] *= xscl;
1481 double* xx = varias.data();
1482 double* yy = xnorms.data();
1485 double* xe = (
double*)xa;
1486 double* ye = (
double*)ya;
1487 double slope;
double slop2;
1488 double intcp;
double intc2;
1489 double sigma;
double corre;
1490 double xlipt;
double ylipt;
double xcipt;
double ycipt;
1494 while ( nlp < nalpha )
1497 &sigma, &corre, nlp );
1498 DbgLv(1) <<
"ASCN:H1: avg" << avg <<
"nlp" << nlp;
1499 DbgLv(1) <<
"ASCN:H1: sl" << slope <<
"in" << intcp <<
"sg" << sigma
1501 if ( slope < 1e99 && slope > (-1e99) )
1508 int je = nalpha - 1;
1509 for (
int jj = 0; jj < 5; jj++, je-- )
1511 xe[ jj ] = xx[ je ];
1512 ye[ jj ] = yy[ je ];
1523 &xcipt, &ycipt, alphas.data(), &calpha );
1528 double xcvp1 = xx[ 0 ];
1529 double ycvp1 = yy[ 0 ];
1530 double xcvp2 = xx[ je ];
1531 double ycvp2 = yy[ je ];
1532 bool good_fit = ( xlipt >= xcvp1 && ylipt <= ycvp1 &&
1533 xlipt <= xcvp2 && ylipt >= ycvp2 );
1534 DbgLv(1) <<
"ASCN:T4: cv: x1,y1" << xcvp1 << ycvp1
1535 <<
"x2,y2" << xcvp2 << ycvp2 <<
" good_fit" << good_fit;
1537 calpha = (double)qRound( calpha / roundv ) * roundv;
1538 calpha = good_fit ? calpha : alphadef;
1544 QVector< double >* psv_nnls_b,
const int nscans,
const int npoints,
1545 const int nisols,
double& variance,
double& xnormsq )
1547 int ntotal = nscans * npoints;
1548 int narows = ntotal + nisols;
1552 QVector< double > nnls_a = *psv_nnls_a;
1553 QVector< double > nnls_b = *psv_nnls_b;
1554 QVector< double > nnls_x;
1555 QVector< double > simdat;
1556 nnls_x.fill( 0.0, nisols );
1557 simdat.fill( 0.0, ntotal );
1561 int dinc = ntotal + nisols + 1;
1563 for (
int cc = 0; cc < nisols; cc++ )
1565 nnls_a[ dx ] =
alpha;
1571 nnls_b.data(), nnls_x.data() );
1574 for (
int cc = 0; cc < nisols; cc++ )
1576 double soluval = nnls_x[ cc ];
1578 if ( soluval > 0.0 )
1580 xnormsq +=
sq( soluval );
1582 int aa = cc * narows;
1584 for (
int kk = 0; kk < ntotal; kk++ )
1586 simdat[ kk ] += ( soluval * (*psv_nnls_a)[ aa++ ] );
1592 for (
int kk = 0; kk < ntotal; kk++ )
1594 variance +=
sq( ( (*psv_nnls_b)[ kk ] - simdat[ kk ] ) );
1598 variance /= (double)ntotal;