Commit 820aca66 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

SWZ: replace free with swzFree

parent 12993a81
......@@ -119,7 +119,7 @@ int forecast_percentile(FILE *f_out, TVector percentiles, int draws, FILE *poste
ERROR_EXIT:
FreeMatrixHistogram(histogram);
FreeMatrix(forecast);
free(S);
swzFree(S);
FreeVector(initial);
FreeVector(prob);
FreeVector(init_prob);
......@@ -229,7 +229,7 @@ int forecast_percentile_regime(FILE *f_out, TVector percentiles, int draws,
ERROR_EXIT:
FreeMatrixHistogram(histogram);
FreeMatrix(forecast);
free(S);
swzFree(S);
FreeVector(initial);
FreeVector(prob);
FreeVector(init_prob);
......@@ -362,9 +362,9 @@ int main(int nargs, char **args)
Read_VAR_Parameters((FILE*)NULL,parm,head,model);
p=(T_VAR_Parameters*)(model->theta);
free(spec);
free(head);
free(parm);
swzFree(spec);
swzFree(head);
swzFree(parm);
//============================= Compute forecasts =============================
......@@ -374,7 +374,7 @@ int main(int nargs, char **args)
/* fmt="forecasts_mean_%s.prn"; */
/* sprintf(out_filename=(char*)swzMalloc(strlen(fmt) + strlen(tag) - 1),fmt,tag); */
/* f_out=fopen(out_filename,"wt"); */
/* free(out_filename); */
/* swzFree(out_filename); */
/* printf("Constructing mean forecast\n"); */
/* if (F=dw_state_space_mean_unconditional_forecast((TVector*)NULL,h,statespace->nobs,model)) */
/* for (i=0; i < h; i++) */
......@@ -452,7 +452,7 @@ int main(int nargs, char **args)
fmt="forecasts_percentiles_regime_%d_%s.prn";
sprintf(out_filename=(char*)swzMalloc(strlen(fmt) + strlen(tag) - 3),fmt,s,tag);
f_out=fopen(out_filename,"wt");
free(out_filename);
swzFree(out_filename);
printf("Constructing percentiles for forecasts - regime %d\n",s);
forecast_percentile_regime(f_out,percentiles,draws,posterior_file,s,p->nobs,horizon,model);
fclose(f_out);
......@@ -463,7 +463,7 @@ int main(int nargs, char **args)
fmt="forecasts_percentiles_regime_%d_%s.prn";
sprintf(out_filename=(char*)swzMalloc(strlen(fmt) + strlen(tag) - 3),fmt,s,tag);
f_out=fopen(out_filename,"wt");
free(out_filename);
swzFree(out_filename);
printf("Constructing percentiles for forecasts - regime %d\n",s);
forecast_percentile_regime(f_out,percentiles,draws,posterior_file,s,p->nobs,horizon,model);
fclose(f_out);
......@@ -473,7 +473,7 @@ int main(int nargs, char **args)
fmt="forecasts_percentiles_%s.prn";
sprintf(out_filename=(char*)swzMalloc(strlen(fmt) + strlen(tag) - 1),fmt,tag);
f_out=fopen(out_filename,"wt");
free(out_filename);
swzFree(out_filename);
printf("Constructing percentiles for forecasts - %d draws of shocks/regimes per posterior value\n",draws);
forecast_percentile(f_out,percentiles,draws,posterior_file,p->nobs,horizon,model);
fclose(f_out);
......
......@@ -81,17 +81,17 @@ void FreeMatrixHistogram(TMatrixHistogram *h)
int i, j;
for (i=h->rows-1; i >= 0; i--)
{
for (j=h->cols-1; j >= 0; j--) free(h->freq[i][j]);
free(h->freq[i]);
for (j=h->cols-1; j >= 0; j--) swzFree(h->freq[i][j]);
swzFree(h->freq[i]);
}
free(h->freq);
for (i=h->rows-1; i >= 0; i--) free(h->low[i]);
free(h->low);
for (i=h->rows-1; i >= 0; i--) free(h->high[i]);
free(h->high);
swzFree(h->freq);
for (i=h->rows-1; i >= 0; i--) swzFree(h->low[i]);
swzFree(h->low);
for (i=h->rows-1; i >= 0; i--) swzFree(h->high[i]);
swzFree(h->high);
FreeMatrix(h->Min);
FreeMatrix(h->Max);
free(h);
swzFree(h);
}
void AddMatrixObservation(TMatrix X, TMatrixHistogram *h)
......@@ -226,13 +226,13 @@ void SetMaxMinVectorHistogram(TVector Min, TVector Max, TVectorHistogram *h)
void FreeVectorHistogram(TVectorHistogram *h)
{
int i;
for (i=h->dim-1; i >= 0; i--) free(h->freq[i]);
free(h->freq);
free(h->low);
free(h->high);
for (i=h->dim-1; i >= 0; i--) swzFree(h->freq[i]);
swzFree(h->freq);
swzFree(h->low);
swzFree(h->high);
FreeVector(h->Min);
FreeVector(h->Max);
free(h);
swzFree(h);
}
void AddVectorObservation(TVector x, TVectorHistogram *h)
......@@ -355,8 +355,8 @@ void SetMaxMinScalarHistogram(PRECISION Min, PRECISION Max, TScalarHistogram *h)
void FreeScalarHistogram(TScalarHistogram *h)
{
free(h->freq);
free(h);
swzFree(h->freq);
swzFree(h);
}
void AddScalarObservation(PRECISION x, TScalarHistogram *h)
......
Supports Markdown
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