Commit c11fd409 authored by Tyson Littenberg's avatar Tyson Littenberg
Browse files

Merge branch 'bayesline-speedup' into 'master'

replace straight copies with memcpy

See merge request !216
parents 73addbad c0233b85
Pipeline #278496 passed with stages
in 17 minutes and 9 seconds
......@@ -355,7 +355,7 @@ void full_spectrum_add_or_subtract(double *Snew, double *Sold, double *Sbase, do
double flow = data->flow;
// copy over current model
for(i=0; i< ncut; i++) Snew[i] = Sold[i];
memcpy(Snew, Sold, ncut*sizeof(double));
// here we figure out how many frequency bins are needed for the line profile
imid = (int)((f-flow)*Tobs);
......@@ -433,7 +433,7 @@ void full_spectrum_spline(double *Sline, double *Sbase, double *sfreq, dataParam
for(k=0; k<lines->n; k++)
{
j = lines->larray[k];
for(i=0; i<data->ncut; i++) Stemp[i]=Sline[i];
memcpy(Stemp,Sline,data->ncut*sizeof(double));
full_spectrum_add_or_subtract(Sline, Stemp, Sbase, sfreq, data, lines, j, &istart, &istop, 1);
}
......
......@@ -345,30 +345,23 @@ double EvaluateMarkovianLogLikelihood(int typ, int ii, int det, struct Model *mx
// copy over current multi-template
for(ifo=0; ifo<NI; ifo++)
{
if(ifo==0)
{
for(i=0; i<N; i++)
{
if(ifo==0)
{
if(det==-1)
{
for(n=0; n<mx->Npol; n++)
{
my->signal[n]->templates[i] = mx->signal[n]->templates[i];
}
for(n=0; n<mx->Npol; n++)
{
memcpy(my->signal[n]->templates, mx->signal[n]->templates, N*sizeof(double));
}
}
else wave_y->templates[i] = wave_x->templates[i];
else memcpy(wave_y->templates,wave_x->templates,N*sizeof(double));
memcpy(r[ifo],s[ifo],N*sizeof(double));
//while we're at it, copy data->s (the data) into data->r (workspace for forming the residual)
r[ifo][i] = s[ifo][i];
}
}
else
{
for(i=0; i<N; i++)
{
r[ifo][i] = s[ifo][i];
}
}
}
else
{
memcpy(r[ifo],s[ifo],N*sizeof(double));
}
if(mx->glitch[ifo]->size>0)
{
//subtract current glitch model from residual
......
......@@ -1158,8 +1158,6 @@ void RJMCMC(struct Data *data, struct Model **model, struct BayesLineParams ***b
copy_int_model(model[chain->index[0]], model_MAP, N, NI,-1);
for(ifo=0; ifo<NI; ifo++) copy_int_model(model[chain->index[0]], model_MAP, N, NI,ifo);
FILE *logLscript = NULL;
if(data->gnuplotFlag)
{
......@@ -1169,7 +1167,7 @@ void RJMCMC(struct Data *data, struct Model **model, struct BayesLineParams ***b
/* */
/******************************************************************************/
sprintf(filename,"waveforms/%s_avgLogL_animate.gpi",modelname);
logLscript=fopen(filename,"w");
FILE *logLscript=fopen(filename,"w");
fprintf(logLscript,"set terminal gif small size 800,600 animate optimize delay 0.5 enhanced font\n");
fprintf(logLscript,"set output \"%s_avgLogL.gif\" \n",modelname);
fprintf(logLscript," \n");
......@@ -1177,8 +1175,8 @@ void RJMCMC(struct Data *data, struct Model **model, struct BayesLineParams ***b
fprintf(logLscript,"set xrange [1e-8:1] \n");
fprintf(logLscript,"set xlabel \"1/T\" \n");
fprintf(logLscript,"set ylabel \"<logL>\" \n");
fflush(logLscript);
fclose(logLscript);
}
/******************************************************************************/
......
......@@ -1007,8 +1007,8 @@ void copy_int_model(struct Model *origin, struct Model *copy, int N, int NI, int
if(det==-1)
{
for(ip=0; ip<origin->Npol; ip++) copy_wavelet(origin->signal[ip], copy->signal[ip], N);
for(ip=0; ip<=origin->Npol; ip++) for(i=0; i<N; i++) copy->h[ip][i] = origin->h[ip][i];
for(ifo=0; ifo<NI; ifo++) for(i=0; i<N; i++) copy->response[ifo][i] = origin->response[ifo][i];
for(ip=0; ip<=origin->Npol; ip++) memcpy(copy->h[ip],origin->h[ip],N*sizeof(double));
for(ifo=0; ifo<NI; ifo++) memcpy(copy->response[ifo],origin->response[ifo],N*sizeof(double));
}
else
{
......@@ -1025,21 +1025,15 @@ void copy_int_model(struct Model *origin, struct Model *copy, int N, int NI, int
void copy_psd_model(struct Model *origin, struct Model *copy, int N, int NI)
{
int n,ifo;
int halfN = N/2;
for(ifo=0; ifo<NI; ifo++)
{
for(n=0; n<halfN; n++)
int n,ifo;
int halfN = N/2;
for(ifo=0; ifo<NI; ifo++)
{
copy->SnS[ifo][n] = origin->SnS[ifo][n];
copy->Snf[ifo][n] = origin->Snf[ifo][n];
copy->invSnf[ifo][n] = origin->invSnf[ifo][n];
memcpy(copy->SnS[ifo],origin->SnS[ifo],halfN*sizeof(double));
memcpy(copy->Snf[ifo],origin->Snf[ifo],halfN*sizeof(double));
memcpy(copy->invSnf[ifo],origin->invSnf[ifo],halfN*sizeof(double));
}
}
for(n=0; n<halfN; n++)
{
copy->SnGeo[n] = origin->SnGeo[n];
}
memcpy(copy->SnGeo,origin->SnGeo,halfN*sizeof(double));
}
void copy_ext_model(struct Model *origin, struct Model *copy, int N, int NI)
......@@ -1149,7 +1143,7 @@ void copy_wavelet(struct Wavelet *origin, struct Wavelet *copy, int N)
copy->index[i] = origin->index[i];
for(j=0; j<origin->dimension; j++) copy->intParams[i][j] = origin->intParams[i][j];
}
for(j=0; j<N; j++) copy->templates[j] = origin->templates[j];
memcpy(copy->templates,origin->templates,N*sizeof(double));
copy->size = origin->size;
copy->dimension = origin->dimension;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment