12 #define DbgLv(a) if(dbg_level>=a)qDebug()<<"SS-w:"<<thrnrank<<":"
25 bool signal_wanted ) : QObject(), data_sets( data_sets ),
26 thrnrank( thrnrank ), signal_wanted( signal_wanted )
34 if ( data_sets[ 0 ]->simparams.band_forming )
37 QFile bfcfile( bfcname );
38 if ( bfcfile.open( QIODevice::ReadOnly ) )
40 QTextStream tsi( &bfcfile );
42 while ( ! tsi.atEnd() )
44 QString fline = tsi.readLine();
45 int cmx = fline.indexOf(
"#" ) - 1;
47 ? fline.left( cmx ).simplified().toDouble() : 0.0;
50 else if ( fline.contains(
"zero threshold" ) )
52 else if ( fline.contains(
"linear threshold" ) )
54 else if ( fline.contains(
"maximum OD" ) )
56 else if ( fline.contains(
"minimum non-zero" ) )
58 else if ( fline.contains(
"sim multiply factor" ) )
60 else if ( fline.contains(
"exp multiply factor" ) )
67 if(thrnrank==1)
DbgLv(1) <<
"CR:zthr lthr mxod mnzc mfac mfex bthr"
90 double s_max, QString& smsg )
92 const long tstep_max = 10000L;
93 bool too_large =
false;
97 double bottom = sparams->
bottom;
98 int rpm_max = sparams->
speed_step[ 0 ].rotorspeed;
102 for (
int dd = 0; dd < data_sets.size(); dd++ )
104 sparams = &data_sets[ dd ]->simparams;
105 QVector< US_SimulationParameters::SpeedProfile > speed_step
108 for (
int ss = 0; ss < speed_step.size(); ss++ )
110 int duration = qRound( speed_step[ ss ].duration_hours * 3600.0
111 + speed_step[ ss ].duration_minutes * 60.0 );
112 time_max = qMax( time_max, duration );
113 rpm_max = qMax( rpm_max, speed_step[ ss ].rotorspeed );
117 double s_show = s_max * 1.0e13;
118 double omega_s =
sq( rpm_max * M_PI / 30.0 );
119 double lgbmrat = log( bottom / meniscus );
120 double somgfac = s_max * omega_s;
121 double dt = lgbmrat / ( somgfac * rsimpts );
122 long tsteps = (long)( time_max / dt ) + 1L;
126 if ( tsteps > tstep_max )
129 smsg = tr(
"The combination of rotor speed, the ratio of sedimentation\n"
130 "over diffusion coefficient, and length of experiment\n"
131 "caused the program to exceed available memory.\n"
132 "Please sufficiently reduce any of these to bring\n"
133 "the program into a feasible range.\n\n"
134 "Related data and simulation parameters include:\n"
135 " Maximum speed = %1 RPM ;\n"
136 " Maximum S value = %2 x 1e-13 ;\n"
137 " Computed grid time steps and radius points = %3 ;\n"
138 " Program-imposed grid time steps upper limit = %4 ." )
139 .arg( rpm_max ).arg( s_show ).arg( tsteps ).arg( tstep_max );
154 QVector< double >* ASave, QVector< double >* BSave )
156 QVector< double > sv_nnls_a;
157 QVector< double > sv_nnls_b;
161 int nsolutes = sim_vals.
solutes.size();
162 int nzsol = sim_vals.
zsolutes.size();
165 startCalc = QDateTime::currentDateTime();
169 double alphad = sim_vals.
alpha;
170 int lim_offs = offset + dataset_count;
172 bool use_zsol = ( nzsol > 0 );
173 nsolutes = use_zsol ? nzsol : nsolutes;
196 for (
int ee = offset; ee < lim_offs; ee++ )
201 ntotal += ( nscans * npoints );
206 bool tikreg = ( sim_vals.
alpha != 0.0 );
207 int narows = tikreg ? ( ntotal + nsolutes ) : ntotal;
210 int navals = narows * nsolutes;
214 QVector< double > nnls_a( navals, 0.0 );
217 QVector< double > nnls_a;
219 if ( navals > 20000000 )
221 iasize = narows * ( nsolutes / 2 );
223 nnls_a.reserve( iasize );
224 nnls_a.fill( 0.0, iasize );
226 QVector< double > nnls_b( narows, 0.0 );
227 QVector< double > nnls_x( nsolutes, 0.0 );
228 QVector< double > tinvec( ntinois, 0.0 );
229 QVector< double > rinvec( nrinois, 0.0 );
240 zcomponent.
f_f0 = 0.0;
257 for (
int ee = offset; ee < lim_offs; ee++ )
265 for (
int ss = 0; ss < nscans; ss++ )
267 for (
int rr = 0; rr < npoints; rr++ )
269 double evalue = edata->
value( ss, rr );
271 if ( evalue >= odlim )
280 s0max = qMax( s0max, evalue );
284 nnls_b[ kk++ ] = evalue;
288 DbgLv(1) <<
" CR:B fill kodl" << kodl;
294 alphad = ( s0max == 0.0 ) ? sim_vals.
alpha
295 : ( sim_vals.
alpha * sqrt( s0max ) );
301 QList< US_DataIO::RawData > simulations;
302 simulations.reserve( nsolutes * dataset_count );
305 int increp = nsolutes / 10;
306 increp = ( increp < 10 ) ? 10 : increp;
310 int stype =
data_sets[ offset ]->solute_type;
311 DbgLv(1) <<
" CR:BF STYPE" << stype;
323 int smask = ( attr_x << 6 ) | ( attr_y << 3 ) | attr_z;
327 <<
"vbar20" << dset->
vbar20;
329 for (
int cc = 0; cc < nsolutes; cc++ )
334 for (
int ee = offset; ee < lim_offs; ee++ )
398 DbgLv(1) <<
"CR: edat:"
402 DbgLv(1) <<
"CR: sdat:"
418 simulations << simdat;
422 DbgLv(1) <<
" CR: A fill kodl" << kodl <<
"bndthr ksol" <<
banddthr << ksols;
426 for (
int ss = 0; ss < nscans; ss++ )
427 for (
int rr = 0; rr < npoints; rr++ )
428 nnls_a[ kk++ ] = simdat.value( ss, rr );
431 DbgLv(1) <<
"CR: ks kk" << ks << kk
432 <<
"nnA s...k" << nnls_a[ks] << nnls_a[ks+1] << nnls_a[kk-2] << nnls_a[kk-1]
433 <<
"cc ee" << cc << ee;
437 for (
int ss = 0; ss < nscans; ss++ )
439 for (
int rr = 0; rr < npoints; rr++ )
441 if ( nnls_b[ bx++ ] != 0.0 )
442 nnls_a[ kk++ ] = simdat.value( ss, rr );
444 nnls_a[ kk++ ] = 0.0;
451 for (
int aa = 0; aa < nsolutes; aa++ )
453 nnls_a[ kk++ ] = ( aa == cc ) ? alphad : 0.0;
457 DbgLv(1) <<
"CR: NNLS A filled ee" << ee << lim_offs;
458 DbgLv(1) <<
"CR: NNLS &simdat" << &simdat;
459 DbgLv(1) <<
"CR: NNLS &model " << &model;
460 DbgLv(1) <<
"CR: NNLS &nnls_a" << &nnls_a;
461 DbgLv(1) <<
"CR: NNLS &simulations" << &simulations;
462 DbgLv(1) <<
"CR: NNLS astfem_rsa" << &astfem_rsa;
464 DbgLv(1) <<
"CR: NNLS A filled lo" << lim_offs;
471 DbgLv(1) <<
"CR: NNLS A filled EMIT complete";
474 if ( kk >= iasize && iasize < navals )
477 DbgLv(0) <<
" CR:na iasize navals" << iasize << navals <<
"kk narows npav" << kk << narows << npav;
478 iasize = qMin( navals, ( iasize + narows * 4 ) );
479 nnls_a.resize( iasize );
483 DbgLv(1) <<
"CR: NNLS A filled cc" << cc << nsolutes;
485 DbgLv(1) <<
"CR: NNLS A filled";
488 else if ( stype == 1 || stype > 9 )
493 int smask = ( attr_x << 6 ) | ( attr_y << 3 ) | attr_z;
497 attr_x = ( stype >> 6 ) & 7;
498 attr_y = ( stype >> 3 ) & 7;
502 DbgLv(1) <<
"CR: attr_ x,y,z" << attr_x << attr_y << attr_z << stype << smask
503 <<
"use_zsol" << use_zsol;
511 for (
int cc = 0; cc < nsolutes; cc++ )
516 for (
int ee = offset; ee < lim_offs; ee++ )
582 DbgLv(1) <<
"CR: edat:"
586 DbgLv(1) <<
"CR: sdat:"
601 simulations << simdat;
604 DbgLv(1) <<
" CR: A fill kodl" << kodl <<
"bndthr ksol" <<
banddthr << ksols;
608 for (
int ss = 0; ss < nscans; ss++ )
609 for (
int rr = 0; rr < npoints; rr++ )
610 nnls_a[ kk++ ] = simdat.value( ss, rr );
614 for (
int ss = 0; ss < nscans; ss++ )
616 for (
int rr = 0; rr < npoints; rr++ )
618 if ( nnls_b[ bx++ ] != 0.0 )
619 nnls_a[ kk++ ] = simdat.value( ss, rr );
621 nnls_a[ kk++ ] = 0.0;
631 for (
int aa = 0; aa < nsolutes; aa++ )
633 nnls_a[ kk++ ] = ( aa == cc ) ? alphad : 0.0;
652 int smask = ( attr_x << 6 ) | ( attr_y << 3 ) | attr_z;
654 for (
int cc = 0; cc < nsolutes; cc++ )
659 for (
int ee = offset; ee < lim_offs; ee++ )
721 simulations << simdat;
726 for (
int ss = 0; ss < nscans; ss++ )
727 for (
int rr = 0; rr < npoints; rr++ )
728 nnls_a[ kk++ ] = simdat.
value( ss, rr );
732 for (
int ss = 0; ss < nscans; ss++ )
734 for (
int rr = 0; rr < npoints; rr++ )
736 if ( nnls_b[ bx++ ] != 0.0 )
737 nnls_a[ kk++ ] = simdat.value( ss, rr );
739 nnls_a[ kk++ ] = 0.0;
746 for (
int aa = 0; aa < nsolutes; aa++ )
748 nnls_a[ kk++ ] = ( aa == cc ) ? alphad : 0.0;
761 nsolutes =
banddthr ? ksols : nsolutes;
768 int kstodo = nsolutes / 50;
769 kstodo =
max( kstodo, 2 );
777 QVector< double > a_tilde( nrinois, 0.0 );
783 QVector< double > a_bar( ntinois, 0.0 );
787 QVector< double > L_tildes( nrinois * nsolutes, 0.0 );
793 QVector< double > L_bars( ntinois * nsolutes, 0.0 );
795 L_bars, nnls_a, L_tildes );
798 DbgLv(1) <<
" set SMALL_A+B";
799 QVector< double > small_a(
sq( nsolutes ), 0.0 );
800 QVector< double > small_b( nsolutes, 0.0 );
803 small_a, small_b, a_bar, L_bars, nnls_a, nnls_b );
807 DbgLv(1) <<
" noise small NNLS";
809 small_b.data(), nnls_x.data() );
813 QVector< double > L( ntotal, 0.0 );
814 compute_L( ntotal, nsolutes, L, nnls_a, nnls_x );
818 QVector< double > L_tilde( nrinois, 0.0 );
824 QVector< double > L_bar( ntinois, 0.0 );
828 for (
int ii = 0; ii < ntinois; ii++ )
829 tinvec[ ii ] = a_bar[ ii ] - L_bar[ ii ];
833 for (
int ii = 0; ii < nrinois; ii++ )
834 rinvec[ ii ] = a_tilde[ ii ] - L_tilde[ ii ];
845 QVector< double > a_tilde( nrinois, 0.0 );
849 QVector< double > L_tildes( nrinois * nsolutes, 0.0 );
853 QVector< double > small_a(
sq( nsolutes ), 0.0 );
854 QVector< double > small_b( nsolutes, 0.0 );
858 small_a, small_b, a_tilde, L_tildes, nnls_a, nnls_b );
862 small_b.data(), nnls_x.data() );
866 QVector< double > L( ntotal, 0.0 );
867 compute_L( ntotal, nsolutes, L, nnls_a, nnls_x );
871 QVector< double > L_tilde( nrinois, 0.0 );
875 for (
int ii = 0; ii < nrinois; ii++ )
876 rinvec[ ii ] = a_tilde[ ii ] - L_tilde[ ii ];
887 if ( ASave != NULL && BSave != NULL )
891 DbgLv(1) <<
"CR: sv_nnls_a size" << sv_nnls_a.size() << nnls_a.size();
895 nnls_b.data(), nnls_x.data() );
897 if(lim_offs>1&&(thrnrank==1||thrnrank==11))
DbgLv(1) <<
"CR: narows nsolutes" << narows << nsolutes;
898 if(lim_offs>1&&(thrnrank==1||thrnrank==11))
DbgLv(1) <<
"CR: a0 a1 b0 b1"
899 << nnls_a[0] << nnls_a[1] << nnls_b[0] << nnls_b[1];
918 DbgLv(1) <<
"CR: kstodo" << kstodo;
925 for (
int ee = offset; ee < lim_offs; ee++ )
941 for (
int ss = 0; ss < nscans; ss++ )
943 DbgLv(1) <<
"CR: ss jscan" << ss << jscan <<
"ee kscans nscans" << ee << kscans << nscans;
950 DbgLv(1) <<
"CR: jscan kscans" << jscan << kscans;
959 for (
int cc = 0; cc < nsolutes; cc++ )
961 double soluval = nnls_x[ cc ];
962 if(
thrnrank==1)
DbgLv(1) <<
"CR: cc soluval" << cc << soluval;
968 DbgLv(1) <<
"CR: cc soluval" << cc << soluval;
971 for (
int ee = offset; ee < lim_offs; ee++ )
974 int sim_ix = cc * dataset_count + ee - offset;
980 DbgLv(1) <<
"CR: ee sim_ix np ns scnx" << ee << sim_ix << npoints << nscans << scnx;
982 for (
int ss = 0; ss < nscans; ss++, scnx++ )
984 for (
int rr = 0; rr < npoints; rr++ )
986 sdata->
scanData[ scnx ].rvalues[ rr ] +=
987 ( soluval * idata->
value( ss, rr ) );
995 DbgLv(1) <<
"CR: scnx ss rr" << scnx << ss << rr;
999 <<
"idat sdat" << idata->
value(ss,rr) << sdata->
value(ss,rr);
1000 if (soluval>100.0) {
1001 double drval=0.0;
double dmax=0.0;
double dsum=0.0;
1002 for (
int ss=0;ss<nscans;ss++ ) {
for (
int rr=0; rr<npoints; rr++ ) {
1003 drval=idata->
value(ss,rr); dmax=qMax(dmax,drval); dsum+=drval; }}
1005 << sim_vals.
zsolutes[cc].y <<
"sval" << soluval <<
"amax asum" << dmax << dsum; }
1007 DbgLv(1) <<
"CR: s k v" << sim_vals.
solutes[cc].s*1.0e+13
1008 << sim_vals.
solutes[cc].k << sim_vals.
solutes[cc].v <<
"sval" << soluval
1009 <<
"idat sdat" << idata->
value(ss,rr) << sdata->
value(ss,rr);
1010 if (soluval>100.0) {
1011 double drval=0.0;
double dmax=0.0;
double dsum=0.0;
1012 for (
int ss=0;ss<nscans;ss++ ) {
for (
int rr=0; rr<npoints; rr++ ) {
1013 drval=idata->
value(ss,rr); dmax=qMax(dmax,drval); dsum+=drval; }}
1014 DbgLv(1) <<
"CR:B s k" << sim_vals.
solutes[cc].s*1.0e+13
1015 << sim_vals.
solutes[cc].k <<
"sval" << soluval <<
"amax asum" << dmax << dsum; }
1023 double rmsds[ dataset_count ];
1024 int kntva[ dataset_count ];
1025 double variance = 0.0;
1037 for (
int ee = offset; ee < lim_offs; ee++, kdsx++ )
1045 double varidset = 0.0;
1047 for (
int ss = 0; ss < nscans; ss++, scnx++ )
1050 for (
int rr = 0; rr < npoints; rr++ )
1053 double resval = edata->
value( ss, rr )
1054 - sdata->
value( scnx, rr )
1055 - tinvec[ rr + tinoffs ]
1056 - rinvec[ ss + rinoffs ];
1057 resid->
setValue( scnx, rr, resval );
1059 double r2 =
sq( resval );
1066 rmsds[ kdsx ] = varidset;
1067 kntva[ kdsx ] = kntcs;
1071 DbgLv(1) <<
"CR: kdsx variance" << kdsx << varidset << variance;
1074 sim_vals.
variances.resize( dataset_count );
1075 variance /= (double)ktotal;
1079 for (
int ee = offset; ee < lim_offs; ee++ )
1081 sim_vals.
variances[ kk ] = rmsds[ kk ] / (double)( kntva[ kk ] );
1091 for (
int cc = 0; cc < nsolutes; cc++ )
1093 if ( nnls_x[ cc ] > 0.0 )
1095 sim_vals.
zsolutes[ cc ].c = nnls_x[ cc ];
1102 for (
int cc = 0; cc < nsolutes; cc++ )
1104 if ( nnls_x[ cc ] > 0.0 )
1106 sim_vals.
solutes[ cc ].c = nnls_x[ cc ];
1114 DbgLv(1) <<
"CR: out solutes size" << kk;
1117 sim_vals.
zsolutes.resize( qMax( kk, 1 ) );
1118 DbgLv(1) <<
"CR: jj solute-c" << 0 << sim_vals.
zsolutes[0].c;
1119 DbgLv(1) <<
"CR: jj solute-c" << 1 << (kk>1?sim_vals.
zsolutes[1].c:0.0);
1120 DbgLv(1) <<
"CR: jj solute-c" << kk-2 << (kk>1?sim_vals.
zsolutes[kk-2].c:0.0);
1121 DbgLv(1) <<
"CR: jj solute-c" << kk-1 << (kk>0?sim_vals.
zsolutes[kk-1].c:0.0);
1125 sim_vals.
solutes.resize( qMax( kk, 1 ) );
1126 DbgLv(1) <<
"CR: jj solute-c" << 0 << sim_vals.
solutes[0].c;
1127 DbgLv(1) <<
"CR: jj solute-c" << 1 << (kk>1?sim_vals.
solutes[1].c:0.0);
1128 DbgLv(1) <<
"CR: jj solute-c" << kk-2 << (kk>1?sim_vals.
solutes[kk-2].c:0.0);
1129 DbgLv(1) <<
"CR: jj solute-c" << kk-1 << (kk>0?sim_vals.
solutes[kk-1].c:0.0);
1131 if (
abort )
return;
1141 nsolutes = ( use_zsol ) ? sim_vals.
zsolutes.size()
1143 DbgLv(1) <<
"CR: nsolutes" << nsolutes;
1145 for (
int jj = 0; jj < nsolutes; jj++ )
1147 double cval = use_zsol ? sim_vals.
zsolutes[ jj ].c
1149 xnorm +=
sq( cval );
1154 DbgLv(1) <<
"CR: xnormsq" << xnorm;
1157 if ( ASave != NULL && BSave != NULL )
1163 (*ASave) = sv_nnls_a;
1164 (*BSave) = sv_nnls_b;
1173 for (
int cc = 0; cc < nsolutes; cc++ )
1175 for (
int jj = 0; jj < ntotal; jj++ )
1177 (*ASave) << sv_nnls_a[ kk++ ];
1180 for (
int jj = 0; jj < nsolutes; jj++ )
1186 for (
int jj = 0; jj < ntotal; jj++ )
1188 (*BSave) << sv_nnls_b[ jj ];
1191 for (
int cc = 0; cc < nsolutes; cc++ )
1202 int nscans =
data_sets[ 0 ]->run_data.scanCount();
1203 int npoints =
data_sets[ 0 ]->run_data.pointCount();
1206 for (
int ss = 0; ss < nscans; ss++ )
1208 double rinoi =
calc_ri ? rinvec[ ss ] : 0.0;
1210 for (
int rr = 0; rr < npoints; rr++ )
1212 double tinoi =
calc_ti ? tinvec[ rr ] : 0.0;
1213 (*BSave)[ kk++ ] += ( tinoi + rinoi );
1228 for (
int cc = 0; cc < nsolutes; cc++ )
1230 for (
int jj = 0; jj < ntotal; jj++ )
1232 (*ASave) << sv_nnls_a[ kk++ ];
1238 for (
int jj = 0; jj < ntotal; jj++ )
1240 (*BSave) << sv_nnls_b[ jj ];
1246 (*ASave) = sv_nnls_a;
1247 (*BSave) = sv_nnls_b;
1248 DbgLv(1) <<
"CR: ASv: sv_nnls_a size" << sv_nnls_a.size() << ASave->size();
1265 const QVector< double >& nnls_b )
1271 double avgscale = 1.0 / (double)npoints;
1273 for (
int ss = 0; ss < nscans; ss++ )
1275 for (
int rr = 0; rr < npoints; rr++ )
1276 a_tilde[ ss ] += nnls_b[ jb++ ];
1278 a_tilde[ ss ] *= avgscale;
1285 QVector< double >& L_tildes,
1286 const QVector< double >& nnls_a )
1291 double avgscale = 1.0 / (double)npoints;
1294 for (
int cc = 0; cc < nsolutes; cc++ )
1296 int t_index = cc * nrinois;
1298 for (
int ss = 0; ss < nscans; ss++ )
1300 for (
int rr = 0; rr < npoints; rr++ )
1301 L_tildes[ t_index ] += nnls_a[ a_index++ ];
1303 L_tildes[ t_index++ ] *= avgscale;
1310 const QVector< double >& L )
1315 double avgscale = 1.0 / (double)npoints;
1318 for (
int ss = 0; ss < nscans; ss++ )
1320 for (
int rr = 0; rr < npoints; rr++ )
1321 L_tilde[ ss ] += L[ index++ ];
1323 L_tilde[ ss ] *= avgscale;
1329 QVector< double >& L,
1330 const QVector< double >& nnls_a,
1331 const QVector< double >& nnls_x )
1337 for (
int cc = 0; cc < nsolutes; cc++ )
1339 double concentration = nnls_x[ cc ];
1341 if ( concentration > 0.0 )
1343 int r_index = cc * ntotal;
1346 for (
int ss = 0; ss < nscans; ss++ )
1348 for (
int rr = 0; rr < npoints; rr++ )
1350 L[ count++ ] += ( concentration * nnls_a[ r_index++ ] );
1360 QVector< double >& small_a,
1361 QVector< double >& small_b,
1362 const QVector< double >& a_tilde,
1363 const QVector< double >& L_tildes,
1364 const QVector< double >& nnls_a,
1365 const QVector< double >& nnls_b )
1371 int kstodo =
sq( nsolutes ) / 10;
1372 int incprg = nsolutes / 20;
1373 incprg =
max( incprg, 1 );
1374 incprg =
min( incprg, 10 );
1375 int jstprg = ( kstodo * incprg ) / nsolutes;
1378 for (
int cc = 0; cc < nsolutes; cc++ )
1380 int jsa2 = cc * ntotal;
1381 int jst2 = cc * nrinois;
1385 double sum_b = small_b[ cc ];
1387 for (
int ss = 0; ss < nscans; ss++ )
1395 double atil = a_tilde [ ss ];
1396 double Ltil = L_tildes[ jjlt++ ];
1398 for (
int rr = 0; rr < npoints; rr++ )
1400 sum_b += ( ( nnls_b[ jjnb++ ] - atil )
1401 * ( nnls_a[ jjna++ ] - Ltil ) );
1406 small_b[ cc ] = sum_b;
1408 for (
int kk = 0; kk < nsolutes; kk++ )
1419 int jjma = kk * nsolutes + cc;
1420 int jja1 = kk * ntotal;
1422 int jjt1 = kk * nrinois;
1424 double sum_a = small_a[ jjma ];
1426 for (
int ss = 0; ss < nscans; ss++ )
1428 double Ltil1 = L_tildes[ jjt1++ ];
1429 double Ltil2 = L_tildes[ jjt2++ ];
1431 for (
int rr = 0; rr < npoints; rr++ )
1433 sum_a += ( ( nnls_a[ jja1++ ] - Ltil1 )
1434 * ( nnls_a[ jja2++ ] - Ltil2 ) );
1438 small_a[ jjma ] = sum_a;
1448 if (
abort )
return;
1459 QVector< double >& small_a,
1460 QVector< double >& small_b,
1461 const QVector< double >& a_bar,
1462 const QVector< double >& L_bars,
1463 const QVector< double >& nnls_a,
1464 const QVector< double >& nnls_b )
1470 int kstodo =
sq( nsolutes ) / 10;
1471 int incprg = nsolutes / 20;
1472 incprg =
max( incprg, 1 );
1473 incprg =
min( incprg, 10 );
1474 int jstprg = ( kstodo * incprg ) / nsolutes;
1477 for (
int cc = 0; cc < nsolutes; cc++ )
1480 int jssa = cc * ntotal;
1481 int jssb = cc * ntinois;
1491 double sum_b = small_b[ cc ];
1493 for (
int ss = 0; ss < nscans; ss++ )
1497 for (
int rr = 0; rr < npoints; rr++ )
1499 sum_b += ( ( nnls_b[ jjnb++ ] - a_bar [ rr ] )
1500 * ( nnls_a[ jjna++ ] - L_bars[ jjlb++ ] ) );
1504 small_b[ cc ] = sum_b;
1514 for (
int kk = 0; kk < nsolutes; kk++ )
1516 int jjna1 = kk * ntotal;
1518 int jslb1 = kk * ntinois;
1520 double sum_a = small_a[ jjsa ];
1522 for (
int ss = 0; ss < nscans; ss++ )
1527 for (
int rr = 0; rr < npoints; rr++ )
1529 sum_a += ( ( nnls_a[ jjna1++ ] - L_bars[ jjlb1++ ] )
1530 * ( nnls_a[ jjna2++ ] - L_bars[ jjlb2++ ] ) );
1534 small_a[ jjsa ] = sum_a;
1545 if (
abort )
return;
1554 const QVector< double >& L,
1555 const QVector< double >& L_tilde )
1560 double avgscale = 1.0 / (double)nscans;
1562 for (
int rr = 0; rr < npoints; rr++)
1565 for (
int ss = 0; ss < nscans; ss++ )
1566 L_bar[ rr ] += ( L[ ss * npoints + rr ] - L_tilde[ ss ] );
1568 L_bar[ rr ] *= avgscale;
1574 const QVector< double >& a_tilde,
1575 const QVector< double >& nnls_b )
1580 double avgscale = 1.0 / (double)nscans;
1582 for (
int rr = 0; rr < npoints; rr++ )
1587 for (
int ss = 0; ss < nscans; ss++ )
1589 a_bar[ rr ] += ( nnls_b[ jb ] - a_tilde[ ss ] );
1593 a_bar[ rr ] *= avgscale;
1602 QVector< double >& L_bars,
1603 const QVector< double >& nnls_a,
1604 const QVector< double >& L_tildes )
1609 double avgscale = 1.0 / (double)nscans;
1611 for (
int cc = 0; cc < nsolutes; cc++ )
1613 int solute_offset = cc * ntotal;
1615 for (
int rr = 0; rr < npoints; rr++ )
1617 int r_index = cc * ntinois + rr;
1619 for (
int ss = 0; ss < nscans; ss++ )
1624 int n_index = solute_offset + ss * npoints + rr;
1625 int s_index = cc * nrinois + ss;
1627 L_bars[ r_index ] += ( nnls_a[ n_index ] - L_tildes[ s_index ] );
1630 L_bars[ r_index ] *= avgscale;
1640 qDebug() <<
"w" <<
thrnrank <<
"TM:" << mtext
1641 <<
startCalc.msecsTo( QDateTime::currentDateTime() ) / 1000.0;
1655 double clipout = mfactor *
maxod;
1656 double thrfact = mfactor / (double)( linethr - zerothr );
1660 for (
int ss = 0; ss < nscans; ss++ )
1662 for (
int rr = 0; rr < npoints; rr++ )
1664 double avalue = sdata->
value( ss, rr );
1665 maxsi=qMax(maxsi,avalue);
1667 if ( avalue < zerothr )
1673 else if ( avalue < linethr )
1675 avalue *= ( ( avalue -
zerothr ) * thrfact );
1679 else if ( avalue < maxod )
1690 if ( avalue != 0.0 )
1692 maxs=qMax(maxs,avalue);
1698 int lownnz = qRound(
minnzsc * (
double)( nscans * npoints ) );
1699 nnzro = ( nnzro < lownnz ) ? 0 : nnzro;
1700 DbgLv(1) <<
" CR:THR: nnzro zs nt cl" << nnzro << nzset << nntrp << nclip;
1704 return ( nnzro == 0 );
1714 double clipout = mfactor *
maxod;
1715 double thrfact = mfactor / (double)( linethr - zerothr );
1717 for (
int ss = 0; ss < nscans; ss++ )
1719 for (
int rr = 0; rr < npoints; rr++ )
1721 double avalue = edata->
value( ss, rr );
1723 if ( avalue < zerothr )
1728 else if ( avalue < linethr )
1730 avalue *= ( ( avalue -
zerothr ) * thrfact );
1733 else if ( avalue < maxod )
1743 if ( avalue != 0.0 )
1750 return ( nnzro == 0 );
1757 switch ( attr_type )
1761 component.
s = solute.
s;
1764 component.
f_f0 = solute.
k;
1767 component.
mw = solute.
d;
1773 component.
D = solute.
d;
1776 component.
f = solute.
d;