SWZ: make comments conform to ansi C standard
parent
60a3c2cad4
commit
137c4cf6b1
|
@ -733,7 +733,7 @@ int ReadBaseTransitionMatricesFlat_SV(FILE *f_in, TMarkovStateVariable *sv)
|
|||
}
|
||||
else
|
||||
{
|
||||
// Read transition matrix
|
||||
/* // Read transition matrix ansi-c*/
|
||||
Q=CreateMatrix(sv->nbasestates,sv->nbasestates);
|
||||
for (j=0; j < ColM(Q); j++)
|
||||
for (i=0; i < RowM(Q); i++)
|
||||
|
@ -743,7 +743,7 @@ int ReadBaseTransitionMatricesFlat_SV(FILE *f_in, TMarkovStateVariable *sv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Scale the columns of Q - loose requirement on sumation to one
|
||||
/* // Scale the columns of Q - loose requirement on sumation to one ansi-c*/
|
||||
for (j=sv->nbasestates-1; j >= 0; j--)
|
||||
{
|
||||
for (sum=0.0, i=sv->nbasestates-1; i >= 0; i--)
|
||||
|
@ -765,13 +765,13 @@ int ReadBaseTransitionMatricesFlat_SV(FILE *f_in, TMarkovStateVariable *sv)
|
|||
ElementM(Q,i,j)*=sum;
|
||||
}
|
||||
|
||||
// Convert base transition matrix to full transition matrix.
|
||||
/* // Convert base transition matrix to full transition matrix. ansi-c*/
|
||||
ConvertBaseTransitionMatrix(sv->Q,Q,sv->nlags_encoded);
|
||||
|
||||
// Free Q
|
||||
/* // Free Q ansi-c*/
|
||||
FreeMatrix(Q);
|
||||
|
||||
// Update
|
||||
/* // Update ansi-c*/
|
||||
if (!Update_B_from_Q_SV(sv))
|
||||
{
|
||||
dw_UserError("Transition matrices do not satisfy restrictions");
|
||||
|
|
|
@ -2418,17 +2418,17 @@ TMatrix forecast_base(TMatrix forecast, int horizon, TVector initial, TVector *s
|
|||
TVector x, y;
|
||||
int i, t;
|
||||
|
||||
// allocate forecast if necessary
|
||||
/* // allocate forecast if necessary ansi-c*/
|
||||
if (!forecast && !(forecast=CreateMatrix(horizon,p->nvars)))
|
||||
return (TMatrix)NULL;
|
||||
|
||||
// allocate memory
|
||||
/* // allocate memory ansi-c*/
|
||||
y=CreateVector(p->nvars);
|
||||
x=EquateVector((TVector)NULL,initial);
|
||||
A0=MakeA0_All((TMatrix*)NULL,p);
|
||||
Aplus=MakeAplus_All((TMatrix*)NULL,p);
|
||||
|
||||
// forecast
|
||||
/* // forecast ansi-c*/
|
||||
for (t=0; t < horizon; t++)
|
||||
{
|
||||
ProductVM(y,x,Aplus[S[t]]);
|
||||
|
@ -2445,7 +2445,7 @@ TMatrix forecast_base(TMatrix forecast, int horizon, TVector initial, TVector *s
|
|||
memcpy(pElementV(x),pElementV(y),p->nvars*sizeof(PRECISION));
|
||||
}
|
||||
|
||||
// free memory
|
||||
/* // free memory ansi-c*/
|
||||
dw_FreeArray(Aplus);
|
||||
dw_FreeArray(A0);
|
||||
FreeVector(x);
|
||||
|
|
|
@ -201,8 +201,8 @@ void Draw_lambda(TStateModel *model);
|
|||
/* Forecasts */
|
||||
TMatrix forecast_base(TMatrix forecast, int horizon, TVector initial, TVector *shocks, int *S, TStateModel *model);
|
||||
|
||||
//TVector* mean_conditional_forecast(TVector *F, PRECISION ***y, int h, int t0, TStateModel *model);
|
||||
//TVector* mean_unconditional_forecast(TVector *F, int h, int t0, TStateModel *model);
|
||||
/* //TVector* mean_conditional_forecast(TVector *F, PRECISION ***y, int h, int t0, TStateModel *model); ansi-c*/
|
||||
/* //TVector* mean_unconditional_forecast(TVector *F, int h, int t0, TStateModel *model); ansi-c*/
|
||||
|
||||
/* Utilities */
|
||||
void ComputeDotProducts_All(T_VAR_Parameters *p);
|
||||
|
|
|
@ -570,12 +570,12 @@ int Read_VAR_ParametersFlat(FILE *f_in, TStateModel *model)
|
|||
int i, j, s, rtrn=0;
|
||||
T_VAR_Parameters *p=(T_VAR_Parameters*)(model->theta);
|
||||
|
||||
// Allocate memory
|
||||
/* // Allocate memory ansi-c*/
|
||||
A0=dw_CreateArray_matrix(p->nstates);
|
||||
Aplus=dw_CreateArray_matrix(p->nstates);
|
||||
Zeta=dw_CreateArray_vector(p->nstates);
|
||||
|
||||
// Read File
|
||||
/* // Read File ansi-c*/
|
||||
for (s=0; s < p->nstates; s++)
|
||||
{
|
||||
A0[s]=CreateMatrix(p->nvars,p->nvars);
|
||||
|
@ -599,7 +599,7 @@ int Read_VAR_ParametersFlat(FILE *f_in, TStateModel *model)
|
|||
goto ERROR;
|
||||
}
|
||||
|
||||
// Set A0, Aplus, and Zeta
|
||||
/* // Set A0, Aplus, and Zeta ansi-c*/
|
||||
for (j=0; j < p->nvars; j++)
|
||||
for (s=0; s < p->nstates; s++)
|
||||
{
|
||||
|
@ -612,18 +612,18 @@ int Read_VAR_ParametersFlat(FILE *f_in, TStateModel *model)
|
|||
p->Zeta[j][p->var_states[j][s]]=ElementV(Zeta[s],j);
|
||||
}
|
||||
|
||||
// Update b0, bplus, lambda, psi
|
||||
/* // Update b0, bplus, lambda, psi ansi-c*/
|
||||
Update_b0_bplus_from_A0_Aplus(p);
|
||||
if ((p->Specification & SPEC_SIMS_ZHA) == SPEC_SIMS_ZHA) Update_lambda_psi_from_bplus(p);
|
||||
|
||||
// Flags and notification that the VAR parameters have changed
|
||||
/* // Flags and notification that the VAR parameters have changed ansi-c*/
|
||||
p->valid_parameters=1;
|
||||
ThetaChanged(model);
|
||||
rtrn=1;
|
||||
|
||||
ERROR:
|
||||
|
||||
// Free memory
|
||||
/* // Free memory ansi-c*/
|
||||
dw_FreeArray(A0);
|
||||
dw_FreeArray(Aplus);
|
||||
dw_FreeArray(Zeta);
|
||||
|
|
|
@ -37,14 +37,14 @@ int forecast_percentile(FILE *f_out, TVector percentiles, int draws, FILE *poste
|
|||
TMatrix forecast;
|
||||
TMatrixHistogram *histogram;
|
||||
|
||||
// quick check of passed parameters
|
||||
/* // quick check of passed parameters ansi-c*/
|
||||
if (!f_out || !percentiles || (draws <= 0) || (T < 0) || (h < 0) || !model) return 0;
|
||||
|
||||
p=(T_VAR_Parameters*)(model->theta);
|
||||
|
||||
if (T > p->nobs) return 0;
|
||||
|
||||
// allocate memory
|
||||
/* // allocate memory ansi-c*/
|
||||
S=(int*)swzMalloc(h*sizeof(int));
|
||||
forecast=CreateMatrix(h,p->nvars);
|
||||
histogram=CreateMatrixHistogram(h,p->nvars,100,HISTOGRAM_VARIABLE);
|
||||
|
@ -54,13 +54,13 @@ int forecast_percentile(FILE *f_out, TVector percentiles, int draws, FILE *poste
|
|||
init_prob=CreateVector(p->nstates);
|
||||
prob=CreateVector(p->nstates);
|
||||
|
||||
// Initial value
|
||||
/* // Initial value ansi-c*/
|
||||
EquateVector(initial,p->X[T]);
|
||||
|
||||
i=0;
|
||||
while (!done)
|
||||
{
|
||||
// Read parameters and push them into model
|
||||
/* // Read parameters and push them into model ansi-c*/
|
||||
if (!posterior_file)
|
||||
done=1;
|
||||
else
|
||||
|
@ -78,30 +78,30 @@ int forecast_percentile(FILE *f_out, TVector percentiles, int draws, FILE *poste
|
|||
|
||||
if (done != 2)
|
||||
{
|
||||
// Get filtered probability at time T
|
||||
/* // Get filtered probability at time T ansi-c*/
|
||||
for (j=p->nstates-1; j >= 0; j--)
|
||||
ElementV(init_prob,j)=ProbabilityStateConditionalCurrent(j,T,model);
|
||||
|
||||
for (k=draws; k > 0; k--)
|
||||
{
|
||||
// Draw time T regime
|
||||
/* // Draw time T regime ansi-c*/
|
||||
m=DrawDiscrete(init_prob);
|
||||
|
||||
// Draw regimes from time T+1 through T+h inclusive
|
||||
/* // Draw regimes from time T+1 through T+h inclusive ansi-c*/
|
||||
for (j=0; j < h; j++)
|
||||
{
|
||||
ColumnVector(prob,model->sv->Q,m);
|
||||
S[j]=m=DrawDiscrete(prob);
|
||||
}
|
||||
|
||||
// Draw shocks
|
||||
for (j=h-1; j >= 0; j--) dw_NormalVector(shocks[j]); // InitializeVector(shocks[i],0.0);
|
||||
/* // Draw shocks ansi-c*/
|
||||
for (j=h-1; j >= 0; j--) dw_NormalVector(shocks[j]); /* InitializeVector(shocks[i],0.0); ansi-c*/
|
||||
|
||||
// Compute forecast
|
||||
/* // Compute forecast ansi-c*/
|
||||
if (!forecast_base(forecast,h,initial,shocks,S,model))
|
||||
goto ERROR_EXIT;
|
||||
|
||||
// Accumulate impulse response
|
||||
/* // Accumulate impulse response ansi-c*/
|
||||
AddMatrixObservation(forecast,histogram);
|
||||
}
|
||||
}
|
||||
|
@ -160,14 +160,14 @@ int forecast_percentile_regime(FILE *f_out, TVector percentiles, int draws,
|
|||
TMatrix forecast;
|
||||
TMatrixHistogram *histogram;
|
||||
|
||||
// quick check of passed parameters
|
||||
/* // quick check of passed parameters ansi-c*/
|
||||
if (!f_out || !percentiles || (draws <= 0) || (T < 0) || (h < 0) || !model) return 0;
|
||||
|
||||
p=(T_VAR_Parameters*)(model->theta);
|
||||
|
||||
if (T > p->nobs) return 0;
|
||||
|
||||
// allocate memory
|
||||
/* // allocate memory ansi-c*/
|
||||
S=(int*)swzMalloc(h*sizeof(int));
|
||||
for (i=0; i < h; i++) S[i]=s;
|
||||
forecast=CreateMatrix(h,p->nvars);
|
||||
|
@ -178,13 +178,13 @@ int forecast_percentile_regime(FILE *f_out, TVector percentiles, int draws,
|
|||
init_prob=CreateVector(p->nstates);
|
||||
prob=CreateVector(p->nstates);
|
||||
|
||||
// Initial value
|
||||
/* // Initial value ansi-c*/
|
||||
EquateVector(initial,p->X[T]);
|
||||
|
||||
i=0;
|
||||
while (!done)
|
||||
{
|
||||
// Read parameters and push them into model
|
||||
/* // Read parameters and push them into model ansi-c*/
|
||||
if (!posterior_file)
|
||||
done=1;
|
||||
else
|
||||
|
@ -204,14 +204,14 @@ int forecast_percentile_regime(FILE *f_out, TVector percentiles, int draws,
|
|||
{
|
||||
for (k=draws; k > 0; k--)
|
||||
{
|
||||
// Draw shocks
|
||||
for (j=h-1; j >= 0; j--) dw_NormalVector(shocks[j]); // InitializeVector(shocks[i],0.0);
|
||||
/* // Draw shocks ansi-c*/
|
||||
for (j=h-1; j >= 0; j--) dw_NormalVector(shocks[j]); /* InitializeVector(shocks[i],0.0); ansi-c*/
|
||||
|
||||
// Compute forecast
|
||||
/* // Compute forecast ansi-c*/
|
||||
if (!forecast_base(forecast,h,initial,shocks,S,model))
|
||||
goto ERROR_EXIT;
|
||||
|
||||
// Accumulate impulse response
|
||||
/* // Accumulate impulse response ansi-c*/
|
||||
AddMatrixObservation(forecast,histogram);
|
||||
}
|
||||
}
|
||||
|
@ -306,33 +306,33 @@ int main(int nargs, char **args)
|
|||
int s, horizon, thin, draws, i, j, n;
|
||||
FILE *f_out, *posterior_file;
|
||||
|
||||
// specification filename
|
||||
/* // specification filename ansi-c*/
|
||||
if (buffer=dw_ParseString_String(nargs,args,"fs",(char*)NULL))
|
||||
strcpy(spec=(char*)swzMalloc(strlen(buffer)+1),buffer);
|
||||
|
||||
// parameter filename
|
||||
/* // parameter filename ansi-c*/
|
||||
if (buffer=dw_ParseString_String(nargs,args,"fp",(char*)NULL))
|
||||
strcpy(parm=(char*)swzMalloc(strlen(buffer)+1),buffer);
|
||||
|
||||
// header
|
||||
/* // header ansi-c*/
|
||||
if (buffer=dw_ParseString_String(nargs,args,"ph",(char*)NULL))
|
||||
strcpy(head=(char*)swzMalloc(strlen(buffer)+1),buffer);
|
||||
|
||||
// file tag
|
||||
/* // file tag ansi-c*/
|
||||
if (tag=dw_ParseString_String(nargs,args,"ft",(char*)NULL))
|
||||
{
|
||||
fmt="est_final_%s.dat";
|
||||
|
||||
// specification filename
|
||||
/* // specification filename ansi-c*/
|
||||
if (!spec)
|
||||
sprintf(spec=(char*)swzMalloc(strlen(fmt) + strlen(tag) - 1),fmt,tag);
|
||||
|
||||
// parameter filename
|
||||
/* // parameter filename ansi-c*/
|
||||
if (!parm)
|
||||
sprintf(parm=(char*)swzMalloc(strlen(fmt) + strlen(tag) - 1),fmt,tag);
|
||||
}
|
||||
|
||||
// horizon
|
||||
/* // horizon ansi-c*/
|
||||
horizon=dw_ParseInteger_String(nargs,args,"horizon",12);
|
||||
|
||||
if (!spec)
|
||||
|
@ -366,9 +366,9 @@ int main(int nargs, char **args)
|
|||
swzFree(head);
|
||||
swzFree(parm);
|
||||
|
||||
//============================= Compute forecasts =============================
|
||||
/* //============================= Compute forecasts ============================= ansi-c*/
|
||||
|
||||
// Mean forecast
|
||||
/* // Mean forecast ansi-c*/
|
||||
/* if (dw_FindArgument_String(nargs,args,"mean") != -1) */
|
||||
/* { */
|
||||
/* fmt="forecasts_mean_%s.prn"; */
|
||||
|
@ -383,10 +383,10 @@ int main(int nargs, char **args)
|
|||
/* return; */
|
||||
/* } */
|
||||
|
||||
// Parameter uncertainty
|
||||
/* // Parameter uncertainty ansi-c*/
|
||||
if (dw_FindArgument_String(nargs,args,"parameter_uncertainity") != -1)
|
||||
{
|
||||
// Open posterior draws file
|
||||
/* // Open posterior draws file ansi-c*/
|
||||
fmt="draws_%s.dat";
|
||||
sprintf(post=(char*)swzMalloc(strlen(fmt) + strlen(tag) - 1),fmt,tag);
|
||||
if (!(posterior_file=fopen(post,"rt")))
|
||||
|
@ -395,25 +395,25 @@ int main(int nargs, char **args)
|
|||
swzExit(0);
|
||||
}
|
||||
|
||||
// Get thinning factor from command line
|
||||
/* // Get thinning factor from command line ansi-c*/
|
||||
thin=dw_ParseInteger_String(nargs,args,"thin",1);
|
||||
|
||||
// Get shocks_per_parameter from command line
|
||||
/* // Get shocks_per_parameter from command line ansi-c*/
|
||||
draws=dw_ParseInteger_String(nargs,args,"shocks_per_parameter",1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Using posterior estimate
|
||||
/* // Using posterior estimate ansi-c*/
|
||||
posterior_file=(FILE*)NULL;
|
||||
|
||||
// thinning factor not used
|
||||
/* // thinning factor not used ansi-c*/
|
||||
thin=1;
|
||||
|
||||
// Get shocks_per_parameter from command line
|
||||
/* // Get shocks_per_parameter from command line ansi-c*/
|
||||
draws=dw_ParseInteger_String(nargs,args,"shocks_per_parameter",10000);
|
||||
}
|
||||
|
||||
// Setup percentiles
|
||||
/* // Setup percentiles ansi-c*/
|
||||
if ((i=dw_FindArgument_String(nargs,args,"percentiles")) == -1)
|
||||
if (dw_FindArgument_String(nargs,args,"error_bands") == -1)
|
||||
{
|
||||
|
@ -481,7 +481,7 @@ int main(int nargs, char **args)
|
|||
|
||||
if (posterior_file) fclose(posterior_file);
|
||||
FreeVector(percentiles);
|
||||
//=============================================================================
|
||||
/* //============================================================================= ansi-c*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue