SWZ: replace exit with swzExit

time-shift
Houtan Bastani 2010-07-06 12:19:17 +02:00
parent 7aeb61b0f8
commit 1868cd7943
24 changed files with 87 additions and 89 deletions

View File

@ -75,7 +75,7 @@ swz_fprintf_err(char *str, ...)
}
void
swz_exit(int status)
swzExit(int status)
{
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
mexErrMsgTxt("Error in mexfile.\n");

View File

@ -18,10 +18,8 @@ extern int constant_seed;
/*#define fflush(stdout) mexEvalString("drawnow;");*/
#undef printf
#undef exit
#define printf mexPrintf
#define exit swz_exit
#define swz_fprintf_stdout mexPrintf

View File

@ -123,13 +123,13 @@ TMarkovStateVariable* CreateMarkovStateVariable_Single(int nstates, int nobs, TM
if (!CheckRestrictions(FreeDim,NonZeroIndex,MQ,nstates))
{
swz_fprintf_err("CreateMarkovStateVariable_Single(): Error in restrictions\n");
exit(0);
swzExit(0);
}
if (!CheckPrior(Prior,nstates) || !CheckPriorOnFreeParameters(Prior,NonZeroIndex,nstates))
{
swz_fprintf_err("CreateMarkovStateVariable_Single(): Error in priors\n");
exit(0);
swzExit(0);
}
/* //=== Compute total number of free transition matrix parameters ansi-c*/
@ -138,13 +138,13 @@ TMarkovStateVariable* CreateMarkovStateVariable_Single(int nstates, int nobs, TM
if ((nstates <= 0) || (nobs <= 0))
{
swz_fprintf_err("CreateMarkovStateVariable(): improper argument values\n");
exit(0);
swzExit(0);
}
if (!(sv=(TMarkovStateVariable*)swzMalloc(sizeof(TMarkovStateVariable))))
{
swz_fprintf_err("CreateMarkovStateVariable(): out of memory\n");
exit(0);
swzExit(0);
}
/* //=== Set flags === ansi-c*/
@ -263,13 +263,13 @@ TMarkovStateVariable* CreateMarkovStateVariable_Multiple(int nobs, int n_state_v
if ((n_state_variables <= 1) || (nobs <= 0) || !state_variable || (dw_DimA(state_variable) != n_state_variables))
{
printf("CreateMarkovStateVariable_Multiple(): invalid arguments\n");
exit(0);
swzExit(0);
}
if (!(sv=(TMarkovStateVariable*)swzMalloc(sizeof(TMarkovStateVariable))))
{
printf("CreateMarkovStateVariable_Multiple(): out of memory\n");
exit(0);
swzExit(0);
}
/* //=== Set to terminate on memory error === ansi-c*/
@ -697,7 +697,7 @@ TMarkovStateVariable* CreateMarkovStateVariable_Lags(int nlags, TMarkovStateVari
if (base->n_state_variables > 1)
{
swz_fprintf_err("CreateMarkovStateVariable_Lags(): multiple state variable for base.");
exit(0);
swzExit(0);
}
if (nlags > 0)
@ -802,13 +802,13 @@ void Swap_SV(TMarkovStateVariable *sv, int i, int j)
if (sv->n_state_variables > 1)
{
swz_fprintf_err("Swap(): Can only swap indices for terminal state variables.\n");
exit(0);
swzExit(0);
}
if ((i < 0) || (j < 0) || (i >= sv->nbasestates) || (j >= sv->nbasestates))
{
swz_fprintf_err("Swap(): Indicies out of range.\n");
exit(0);
swzExit(0);
}
X=TranspositionPermutation((TPermutation)NULL,i,j,sv->nbasestates);
@ -830,7 +830,7 @@ void Swap_SV(TMarkovStateVariable *sv, int i, int j)
if (!Update_B_from_Q_SV(sv))
{
swz_fprintf_err("Swap(): Restrictions violated.\n");
exit(0);
swzExit(0);
}
PropagateSwap_SV(sv);
}
@ -908,7 +908,7 @@ void DrawTransitionMatrix_SV(TMarkovStateVariable *sv)
if (!DrawDirichletVector(sv->b[k],sv->b[k]))
{
swz_fprintf_err("Error drawing Dirichlet vector\n");
exit(0);
swzExit(0);
}
/* // Compute Q ansi-c*/
@ -951,7 +951,7 @@ void DrawTransitionMatrixFromPrior_SV(TMarkovStateVariable *sv)
if (!DrawDirichletVector(sv->b[j],sv->b[j]))
{
swz_fprintf_err("Error drawing Dirichlet vector\n");
exit(0);
swzExit(0);
}
/* // Compute P ansi-c*/
@ -1010,7 +1010,7 @@ void DrawStatesFromTransitionMatrix_SV(TMarkovStateVariable *sv)
if (!sv->valid_transition_matrix)
{
printf("DrawStatesFromTransitionMatrix_SV(): Invalid transition matrix.\n");
exit(0);
swzExit(0);
}
/* //=== Draw initial state from ergodic or uniform distribution === ansi-c*/
@ -1020,7 +1020,7 @@ void DrawStatesFromTransitionMatrix_SV(TMarkovStateVariable *sv)
if (!(v=Ergodic((TVector)NULL,sv->Q)))
{
printf("DrawStatesFromTransitionMatrix_SV(): Ergodic distribution does not exists.\n");
exit(0);
swzExit(0);
}
if ((u=dw_uniform_rnd()) >= (s=ElementV(v,i=sv->nstates-1)))
while (--i > 0)
@ -1287,7 +1287,7 @@ int* CreateStateIndex(TMarkovStateVariable* sv, TMarkovStateVariable** list, int
if (!(index=dw_CreateArray_int(sv->nstates)))
{
printf("CreateStateIndex(): Out of memory.\n");
exit(0);
swzExit(0);
}
for (i=sv->nstates-1; i >= 0; i--)
{
@ -1295,7 +1295,7 @@ int* CreateStateIndex(TMarkovStateVariable* sv, TMarkovStateVariable** list, int
if ((k=IncrementIndex(k,i,sv,list[j])) == -1)
{
printf("CreateStateIndex(): Unable to find required state variable.\n");
exit(0);
swzExit(0);
}
index[i]=k;
}
@ -1418,7 +1418,7 @@ TStateModel* CreateStateModel_new(TMarkovStateVariable *sv, ThetaRoutines *routi
if (!(model=(TStateModel*)swzMalloc(sizeof(TStateModel))))
{
swz_fprintf_err("CreateStateModel(): Out of memory\n");
exit(0);
swzExit(0);
}
model->sv=sv;
@ -1509,7 +1509,7 @@ void ForwardRecursion(TStateModel *model)
if (!Ergodic(model->V[0],sv->Q))
{
printf("ForwardRecursion(): Ergodic distribution does not exist.\n");
exit(0);
swzExit(0);
}
/* //====== forward recursion ====== ansi-c*/
@ -2137,7 +2137,7 @@ void ConvertQToFreeParameters(TStateModel *model, PRECISION *f)
if (!(model->sv->valid_transition_matrix))
{
swz_fprintf_err("ConvertQToFreeParameters(): Transition matrices not valid.\n");
exit(0);
swzExit(0);
}
for (i=0; i < dw_DimA(ba); f+=k, i++)
memcpy(f,pElementV(ba[i]),(k=DimV(ba[i])-1)*sizeof(PRECISION));
@ -2211,7 +2211,7 @@ void ConvertQToLogFreeParameters(TStateModel *model, PRECISION *f)
if (!(model->sv->valid_transition_matrix))
{
swz_fprintf_err("ConvertQToFreeParameters(): Transition matrices not valid.\n");
exit(0);
swzExit(0);
}
for (i=0; i < dw_DimA(ba); f+=k, i++)

View File

@ -64,7 +64,7 @@ PRECISION PosteriorObjectiveFunction(PRECISION *x, int n)
/* // fprintf(f_out,"LogLikelihood_StatesIntegratedOut(): %le\n",li); ansi-c*/
/* // fprintf(f_out,"Posterior: %le\n\n",lp_Q+lp_Theta+li); ansi-c*/
/* // fclose(f_out); ansi-c*/
/* // exit(0); ansi-c*/
/* // swzExit(0); ansi-c*/
/* // } ansi-c*/
/* //return -(lp_Q+lp_Theta+li); ansi-c*/
}

View File

@ -1031,13 +1031,13 @@ TMarkovStateVariable* CreateMarkovStateVariable_File(FILE *f, char *filename, in
if (!dw_SetFilePosition(f_in,id))
{
swz_fprintf_err("Line identifier ""%s"" not found.\n",id);
exit(0);
swzExit(0);
}
fscanf(f_in," %d ",&nobs);
if (nobs <= 0)
{
swz_fprintf_err("Number Observations must be positive\n");
exit(0);
swzExit(0);
}
}
@ -1045,13 +1045,13 @@ TMarkovStateVariable* CreateMarkovStateVariable_File(FILE *f, char *filename, in
if (!dw_SetFilePosition(f_in,id))
{
swz_fprintf_err("Line identifier ""%s"" not found.\n",id);
exit(0);
swzExit(0);
}
fscanf(f_in," %d ",&n_state_variables);
if (n_state_variables <= 0)
{
swz_fprintf_err("Number Independent State Variables must be positive\n");
exit(0);
swzExit(0);
}
sv=(TMarkovStateVariable**)dw_CreateArray_pointer(n_state_variables,(void (*)(void*))FreeMarkovStateVariable);
@ -1061,20 +1061,20 @@ TMarkovStateVariable* CreateMarkovStateVariable_File(FILE *f, char *filename, in
if (!dw_SetFilePosition(f_in,id_buffer))
{
swz_fprintf_err("Line identifier ""%s"" not found.\n",id_buffer);
exit(0);
swzExit(0);
}
fscanf(f_in," %d ",&nstates);
if (nstates <= 0)
{
swz_fprintf_err("Number of states for state_variable[%d] must be positive\n",i+1);
exit(0);
swzExit(0);
}
sprintf(id_buffer,"//== Transition matrix prior for state_variable[%d]. (n_states x n_states) ==//",i+1);
if (!dw_SetFilePosition(f_in,id_buffer))
{
swz_fprintf_err("Line identifier ""%s"" not found.\n",id_buffer);
exit(0);
swzExit(0);
}
dw_ReadMatrix(f_in,prior=CreateMatrix(nstates,nstates));
@ -1089,7 +1089,7 @@ TMarkovStateVariable* CreateMarkovStateVariable_File(FILE *f, char *filename, in
if (!dw_SetFilePosition(f_in,id_buffer))
{
swz_fprintf_err("Line identifier ""%s"" not found.\n",id_buffer);
exit(0);
swzExit(0);
}
restrictions=dw_CreateArray_matrix(nstates);
for (j=0; j < nstates; j++)
@ -1098,7 +1098,7 @@ TMarkovStateVariable* CreateMarkovStateVariable_File(FILE *f, char *filename, in
else
{
swz_fprintf_err("Free Dirichet dimensions for column %d of state_variable[%d] must be positive\n",j+1,i+1);
exit(0);
swzExit(0);
}
sv[i]=CreateMarkovStateVariable_SimpleRestrictions(nstates,nobs,prior,restrictions);

View File

@ -71,7 +71,7 @@ int main(int nargs, char **args)
if (!(model=CreateTStateModelFromEstimateFinal(nargs,args,&cmd)))
{
swz_fprintf_err("Unable to read model or parameters\n");
exit(1);
swzExit(1);
}
p=(T_VAR_Parameters*)(model->theta);

View File

@ -187,14 +187,14 @@ T_VAR_Parameters* CreateTheta_VAR(int flag, int nvars, int nlags, int nexg, int
if ((nvars <= 0) || (nlags < 0) || (nexg < 0))
{
swz_fprintf_err("CreateTheta_VAR(): Invalid arguments passed.\n");
exit(0);
swzExit(0);
}
/* //=== Allocate memory for T_VAR_Parameters === ansi-c*/
if (!(p=(T_VAR_Parameters*)swzMalloc(sizeof(T_VAR_Parameters))))
{
swz_fprintf_err("Out of memory\n");
exit(0);
swzExit(0);
}
/* //=== Model Specification === ansi-c*/
@ -525,7 +525,7 @@ void SetPriors_VAR_SimsZha(T_VAR_Parameters *theta, TMatrix* A0_prior, TMatrix*
else
{
printf("Error SetPriors_VAR_SimsZha(): specification flag not set to SPEC_SIM_ZHA\n");
exit(0);
swzExit(0);
}
}
@ -1494,7 +1494,7 @@ static void GetProposedJump_A0(TVector b, int j, int k, T_VAR_Parameters *p)
dw_PrintMatrix(stdout,p->inverse_b0_prior[j],"%lg ");
printf("S =\n");
dw_PrintMatrix(stdout,S,"%lg ");
exit(1);
swzExit(1);
}
dw_SetTerminalErrors(terminal_errors);
/* else */
@ -2260,7 +2260,7 @@ void Update_bplus_from_lambda_psi(T_VAR_Parameters *p)
if (!(p->Specification & SPEC_SIMS_ZHA))
{
swz_fprintf_err("Update_bplus_from_lambda_psi() called without Sims-Zha specification\n");
exit(0);
swzExit(0);
}
for (j=p->nvars-1; j >= 0; j--)
{
@ -2731,7 +2731,7 @@ void SetLogPriorConstant_VAR(T_VAR_Parameters *p)
break;
default:
printf("Unknown normalization type\n");
exit(1);
swzExit(1);
}
}
#undef LN_TWO_PI
@ -3038,7 +3038,7 @@ int Normalize_VAR(T_VAR_Parameters *p)
case VAR_NORMALIZATION_NONE: return 0;
default:
printf("Unknown normalization type\n");
exit(1);
swzExit(1);
}
}
@ -3221,7 +3221,7 @@ int WZ_Normalize(T_VAR_Parameters *p)
/* if (!InverseProductMM(A,A,Ref)) */
/* { */
/* printf("\nNormalize_WZ(): A0 not invertible\n"); */
/* exit(0); */
/* swzExit(0); */
/* } */
/* for (j=p->nvars-1; j >= 0; j--) */

View File

@ -188,7 +188,7 @@ TStateModel* Read_VAR_Specification(FILE *f, char *filename)
case 0: spec=0; break;
case 1: spec=SPEC_SIMS_ZHA | SPEC_RANDOM_WALK; break;
case 2: spec=SPEC_RANDOM_WALK; break;
default: ReadError_VARio("//== Specification (0=default 1=Sims-Zha 2=Random Walk) ==//"); exit(0);
default: ReadError_VARio("//== Specification (0=default 1=Sims-Zha 2=Random Walk) ==//"); swzExit(0);
}
if (spec & SPEC_SIMS_ZHA)
lambda_prior=ReadScalar_VARio(f_in,"//== Variance of Gaussian prior on lambda ==//");

View File

@ -219,7 +219,7 @@ void ReadConstantParameters(char *filename, TStateModel *model)
if (!(f_in=fopen(filename,"rt")))
{
printf("Unable to read the input data file: %s\n", filename);
exit(0);
swzExit(0);
}
/* // A0 ansi-c*/
@ -281,7 +281,7 @@ TStateModel* CreateStateModel_VAR_matlab(char *filename)
if (!(f_in=fopen(filename,"rt")))
{
printf("Unable to read the input data file: %s\n", filename);
exit(0);
swzExit(0);
}
/* //=== Read sizes ===// ansi-c*/
@ -312,7 +312,7 @@ TStateModel* CreateStateModel_VAR_matlab(char *filename)
if (IV[j] != npre)
{
swz_fprintf_err("V[%d] not %d x %d\n",j,npre,npre);
exit(0);
swzExit(0);
}
V=dw_CreateArray_matrix(nvars);
for (j=nvars-1; j >= 0; j--)
@ -363,10 +363,10 @@ TStateModel* CreateStateModel_VAR_matlab(char *filename)
break;
case 4:
swz_fprintf_err("Case %d not implimented.\n",4);
exit(0);
swzExit(0);
default:
swz_fprintf_err("Unknown type.\n");
exit(0);
swzExit(0);
}
dw_FreeArray(IM);
@ -442,7 +442,7 @@ TStateModel* CreateStateModel_VAR_matlab(char *filename)
/* FreeMatrix(YY); */
/* getc(stdin); */
/* } */
/* //exit(0); */
/* //swzExit(0); */
/* id="//== nps: nvar-by-1 ==//"; */
/* if (!dw_SetFilePosition(f_in,id) || !dw_ReadArray(f_in,n0s=dw_CreateArray_int(nvars))) ReadError_VARio_matlab(id); */
@ -482,7 +482,7 @@ TStateModel* CreateStateModel_VAR_matlab(char *filename)
/* FreeMatrix(YY); */
/* getc(stdin); */
/* } */
/* exit(0); */
/* swzExit(0); */
/* //=========================== Checks */
/* // Initialize Y ansi-c*/

View File

@ -27,7 +27,7 @@ int main(int nargs, char **args)
if (nargs != 4)
{
swz_fprintf_err("Syntax:\n create_init_file <matlab filename> <specs filename> <file tag>\n");
exit(0);
swzExit(0);
}
model=Combine_matlab_standard(args[1],args[2]);

View File

@ -309,13 +309,13 @@ T_MHM* CreateMHM_CommandLine(int nargs, char **args)
{
swz_fprintf_err("CreateMHM_CommandLine(): No specification file given.\n");
if (mhm) FreeMHM(mhm);
exit(0);
swzExit(0);
}
if (!mhm)
{
swz_fprintf_err("CreateMHM_CommandLine: No mhm input data file specified.\n");
exit(0);
swzExit(0);
}
/* // Output filenames ansi-c*/

View File

@ -1596,7 +1596,7 @@ void ComputeMarginal_TruncatedGaussianProposal(int ndraws_proposal, TMatrix X, T
/* return SetupSphericalFromPosterior_Table(X,n); */
/* default: */
/* swz_fprintf_err("Unknown proposal type\n"); */
/* exit(0); */
/* swzExit(0); */
/* } */
/* } */
@ -1622,7 +1622,7 @@ void ComputeMarginal_TruncatedGaussianProposal(int ndraws_proposal, TMatrix X, T
/* break; */
/* default: */
/* swz_fprintf_err("Unknown proposal type\n"); */
/* exit(0); */
/* swzExit(0); */
/* } */
/* f_out=dw_CreateTextFile(filename); */
@ -1936,14 +1936,14 @@ int main(int nargs, char **args)
"\n -u <upper tail truncation>"
"\n -l <center region truncation>"
"\n\n");
exit(0);
swzExit(0);
}
/* // setup filenames ansi-c*/
if (!(tag=dw_ParseString_String(nargs,args,"ft",(char*)NULL)))
{
printf("Tag not specified. Usage: -ft <file tag name>\n\n");
exit(0);
swzExit(0);
}
fmt="mhm_draws_%s.dat";
@ -1990,7 +1990,7 @@ int main(int nargs, char **args)
if (!line)
{
printf("Not enough lines - %d\n",i+1);
exit(0);
swzExit(0);
}
if (dw_DimA(line) != n_fields)
{
@ -2001,7 +2001,7 @@ int main(int nargs, char **args)
dw_FreeArray(line);
}
}
exit(0);
swzExit(0);
}
fclose(f_in);

View File

@ -96,7 +96,7 @@ int main(int nargs, char **args)
" -fp : parameters filename (specification filename)\n"
" -fh : parameter header (Posterior mode: )\n"
);
exit(1);
swzExit(1);
}
if (!parm)

View File

@ -19,7 +19,7 @@ FILE *dw_OpenTextFile(char *filename)
if (!f)
{
printf("Unable to open %s\n",filename);
exit(0);
swzExit(0);
}
return (f);
}
@ -35,7 +35,7 @@ FILE *dw_CreateTextFile(char *filename)
if (!f)
{
printf("Unable to open %s\n",filename);
exit(0);
swzExit(0);
}
return (f);
}
@ -52,7 +52,7 @@ FILE *dw_AppendTextFile(char *filename)
if (!f)
{
printf("Unable to open %s\n",filename);
exit(0);
swzExit(0);
}
return (f);
}

View File

@ -129,7 +129,7 @@ int dw_SetError(int err, char *msg)
break;
}
if (VerboseErrors & ERROR) fprintf(f_err ? f_err : stderr,"%s\n",ERROR_MESSAGE);
if (TerminalErrors & ERROR) exit(ERROR);
if (TerminalErrors & ERROR) swzExit(ERROR);
return rtrn;
}

View File

@ -127,14 +127,14 @@ void SetupSpherical_Table(int n, PRECISION *table, int m)
if (SPHERICAL_TABLE_VALUES[0] != 0.0)
{
printf("First entry of inverse cumulative spherical table must be zero\n");
exit(0);
swzExit(0);
}
for (i=1; i < SPHERICAL_TABLE_LENGTH; i++)
if (SPHERICAL_TABLE_VALUES[i-1] >= SPHERICAL_TABLE_VALUES[i])
{
printf("Inverse cumulative spherical table must be strictly increasing\n");
for (i=0; i <= m; i++) printf("%lf\n",table[i]);
exit(0);
swzExit(0);
}
}
@ -164,7 +164,7 @@ PRECISION DrawSpherical(TVector x)
return r;
default:
swz_fprintf_err("Unknown spherical type\n");
exit(0);
swzExit(0);
}
}
@ -187,7 +187,7 @@ PRECISION LogSphericalDensity(PRECISION r)
return ((r < SPHERICAL_LOWER_TRUNCATE) || (r > SPHERICAL_UPPER_TRUNCATE)) ? MINUS_INFINITY : -0.5*r*r + SPHERICAL_CONSTANT;
default:
swz_fprintf_err("Unknown spherical type\n");
exit(0);
swzExit(0);
}
}

View File

@ -98,7 +98,7 @@ void frprmn(double p[], int n, int *iter, double *fret,
if ( !(fptr_interesults = fopen(filename_sp3vecs,"w")) ) {
printf("\n\nUnable to create the starting point data file %s in congradmin.c!\n", filename_sp3vecs);
getchar();
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
/* // rewind(fptr_interesults); //Must put the pointer at the beginning of the file. ansi-c*/
/* //=== Prints out the line search direction. ansi-c*/

View File

@ -365,7 +365,7 @@ void csminwel(double (*fcn)(double *x, int n, double **args, int *dims),
if ( !(fptr_interesults = fopen(filename_sp2vecs,"w")) ) {
printf("\n\nUnable to create the starting point data file %s in csminwel.c!\n", filename_sp2vecs);
getchar();
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
fprintf(fptr_interesults, "========= Only one block at a time if more-than-one blocks are used. ========== \n");
fprintf(fptr_interesults, "--------Numerical gradient---------\n");
@ -435,7 +435,7 @@ void csminwel(double (*fcn)(double *x, int n, double **args, int *dims),
if ( !(fptr_interesults = fopen(filename_sp2vecs,"w")) ) {
printf("\n\nUnable to create the starting point data file %s in csminwel.c!\n", filename_sp2vecs);
getchar();
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
fprintf(fptr_interesults, "========= Only a block at a time if more-than-one blocks are used. ========== \n");
fprintf(fptr_interesults, "--------Numerical gradient---------\n");

View File

@ -1468,7 +1468,7 @@ void fn_wznormalization(TSdvector *wznmlz_dv, TSdmatrix *A0draw_dm, TSdmatrix *A
if ( errflag=BdivA_rgens(X_dm, A0peak_dm, '\\', A0draw_dm) ) {
printf(".../cstz.c/fn_wznormalization(): errors when calling BdivA_rgens() with error flag %d", errflag);
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
if (wznmlz_dv) {
@ -2117,11 +2117,11 @@ void fn_ctfals_policyonly(TSdmatrix *ctfalstran_dm, TSdvector *xprimeminus1_dv,
if ( errflag=BdivA_rgens(tf_Bs_dc->C[si], tf_Aps_dc->C[si], '/', tf_A0sinv_dc->C[si]) ) {
//tf_A0sinv_dc is at this moment tf_A0s_dc.
printf(".../cstz.c/fn_ctfals_policyonly(): tf_Bs_dc->C[si] -- errors when calling BdivA_rgens() with error flag %d", errflag);
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
if ( errflag=invrgen(tf_A0sinv_dc->C[si], tf_A0sinv_dc->C[si]) ) {
printf(".../cstz.c/fn_ctfals_policyonly(): tf_A0sinv_dc->C -- errors when calling invrgen() with error flag %d", errflag);
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
}

View File

@ -1468,7 +1468,7 @@ void fn_wznormalization(TSdvector *wznmlz_dv, TSdmatrix *A0draw_dm, TSdmatrix *A
if ( errflag=BdivA_rgens(X_dm, A0peak_dm, '\\', A0draw_dm) ) {
printf(".../cstz.c/fn_wznormalization(): errors when calling BdivA_rgens() with error flag %d", errflag);
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
if (wznmlz_dv) {
@ -2117,11 +2117,11 @@ void fn_ctfals_policyonly(TSdmatrix *ctfalstran_dm, TSdvector *xprimeminus1_dv,
if ( errflag=BdivA_rgens(tf_Bs_dc->C[si], tf_Aps_dc->C[si], '/', tf_A0sinv_dc->C[si]) ) {
/* //tf_A0sinv_dc is at this moment tf_A0s_dc. ansi-c*/
printf(".../cstz.c/fn_ctfals_policyonly(): tf_Bs_dc->C[si] -- errors when calling BdivA_rgens() with error flag %d", errflag);
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
if ( errflag=invrgen(tf_A0sinv_dc->C[si], tf_A0sinv_dc->C[si]) ) {
printf(".../cstz.c/fn_ctfals_policyonly(): tf_A0sinv_dc->C -- errors when calling invrgen() with error flag %d", errflag);
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
}

View File

@ -186,7 +186,7 @@ void kalcvf_urw(TSkalcvfurw *kalcvfurw_ps, void *dummy_ps)
workdenominv = 1.0/(sigmasq_fix*square(kalcvfurw_ps->z10_dv->v[0]) + VectorDotVector(&xt_sdv, workkxby1_dv)); //1/[sigma^2 + x_t' P_{t|t-1} x_t];
else {
printf(".../kalman.c/kalcvf_urw(): Have not got time to deal with kalcvfurw_ps->indx_tvsigmasq defined in kalman.h other than 0 or 1");
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
@ -218,7 +218,7 @@ void kalcvf_urw(TSkalcvfurw *kalcvfurw_ps, void *dummy_ps)
workdenominv = 1.0/(sigmasq_fix*square(zbefore_sdv.v[0]) + VectorDotVector(&xt_sdv, workkxby1_dv)); //1/[sigma^2 + x_t' P_{t|t-1} x_t]
else {
printf(".../kalman.c/kalcvf_urw(): Have not got time to deal with kalcvfurw_ps->indx_tvsigmasq defined in kalman.h other than 0 or 1");
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
//--- Updating z_{t+1|t}.
CopyVector0(&zafter_sdv, &zbefore_sdv);
@ -780,7 +780,7 @@ double tz_kalfiltv(struct TSkalfiltv_tag *kalfiltv_ps)
printf("Fatal error: tz_kalfiltv() in kalman.c: the system is non-stationary solutions\n"
" and the initial conditions must be supplied by, say, input arguments");
fflush(stdout);
exit( EXIT_FAILURE );
swzExit( EXIT_FAILURE );
}
}
CopySubvector2matrix(zt_tm1_dm, 0, 0, z0_dv, 0, z0_dv->n);
@ -1026,7 +1026,7 @@ double tz_logTimetCondLH_kalfiltv(int st, int inpt, struct TSkalfiltv_tag *kalfi
fprintf(FPTR_DEBUG, "Fatal error: tz_logTimetCondLH_kalfiltv() in kalman.c: the system is non-stationary solutions\n"
" and thus the initial conditions must be supplied by, say, input arguments");
fflush(FPTR_DEBUG);
exit( EXIT_FAILURE );
swzExit( EXIT_FAILURE );
}
}
CopySubvector2matrix(zt_tm1_dm, 0, 0, z0_dv, 0, z0_dv->n);

View File

@ -1048,7 +1048,7 @@ double detspd(TSdmatrix *S_dm)
if (errflag) {
/* //printf("\nFatal Error in .../mathlib.c/detspd() when calling chol() with error flag %d\n", errflag); ansi-c*/
/* //exit(EXIT_FAILURE); ansi-c*/
/* //swzExit(EXIT_FAILURE); ansi-c*/
DestroyMatrix_lf(Work_dm);
return (-1.0);
}
@ -1089,7 +1089,7 @@ double logdetspd(TSdmatrix *S_dm)
if (errflag) {
/* //printf("\nFatal Error in .../mathlib.c/logdetspd() when calling chol() with error flag %d\n", errflag); ansi-c*/
/* //exit(EXIT_FAILURE); ansi-c*/
/* //swzExit(EXIT_FAILURE); ansi-c*/
DestroyMatrix_lf(Work_dm);
printf("----- errflag for chol() when calling logdetspd() in mathlib.c = %d -----", errflag);
return (log(-1.0));

View File

@ -378,7 +378,7 @@ void InitializeForMinproblem(struct TSminpack_tag *minpack_ps, char *filename_sp
if (fscanf(fptr_sp, " %lf ", x_dv->v+_i) != 1)
{
printf("Error: optpackage.c/InitializeForMinproblem() -- cannot read the number from the file %s. Check the data file", filename_sp);
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
x_dv->flag = V_DEF;
@ -399,7 +399,7 @@ void InitializeForMinproblem(struct TSminpack_tag *minpack_ps, char *filename_sp
// printf(" optpackage.c/InitializeForMinproblem(): Bad initialization. All parameters must be in the reasonable range.\n"
// " Most likely, the parameters get stuck in the following line in swz2_confuns.c:\n"
// " if ((tmpd1mPhi=1.0-fn_normalcdf(xid * (log(mt-boundthetamt_1) - logdbar))) <= 0.0) logvalue = -NEARINFINITY;\n");
// exit(EXIT_FAILURE);
// swzExit(EXIT_FAILURE);
}
}
/**/
@ -572,7 +572,7 @@ void minfinder_blockcsminwel(struct TSminpack_tag *minpack_ps, int indx_findMLE)
if ( !(fptr_interesults = fopen(filename_printout,"w")) ) {
printf("\n\nUnable to open the starting point data file %s in minfinder_blockcsminwel() in optpackage.c!\n", filename_printout);
getchar();
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
fprintf(fptr_interesults, "========= All blocks are reported here. ========== \n");
fprintf(fptr_interesults, "--------Numerical gradient---------\n");
@ -651,7 +651,7 @@ void InitializeForMinproblem_const(struct TSminpack_tag *minpack_ps, char *filen
if (fscanf(fptr_sp, " %lf ", x_dv->v+_i) != 1)
{
printf("Error: optpackage.c/InitializeForMinproblem_const() -- cannot read the number from the file %s. Check the data file", filename_sp);
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
x_dv->flag = V_DEF;

View File

@ -57,7 +57,7 @@ void fn_DisplayError(char *msg_s)
mexErrMsgTxt(".");
#else
/* //getchar(); ansi-c*/
exit( EXIT_FAILURE ); /* This exits the entire C program. ansi-c*/
swzExit( EXIT_FAILURE ); /* This exits the entire C program. ansi-c*/
#endif
}
@ -823,7 +823,7 @@ FILE *tzFopen(char *filename, char *mode) {
if ( !(fptr_dummy = fopen(filename,mode)) ) {
printf("\n\n...tzmatlab.c/tzFopen(): Fatal Error -- unable to write, read, or append the file %s!\n", filename);
/* //getchar(); ansi-c*/
exit(EXIT_FAILURE);
swzExit(EXIT_FAILURE);
}
}
else fn_DisplayError(".../tzmatlab.c/tzFopen(): the input filename must exit");