From d03cc56587f793d853db007dbecb236a11932d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Thu, 2 Aug 2018 15:20:39 +0200 Subject: [PATCH] solve_algo=7 and stack_solve_algo=2 are now allowed under Octave The gmres() function has been implemented (actually since Octave 3.4.1!). --- doc/dynare.texi | 4 ++-- .../private/check_input_arguments.m | 4 ---- matlab/solve_one_boundary.m | 3 --- matlab/steady_.m | 2 +- mex/sources/bytecode/SparseMatrix.cc | 8 -------- tests/run_block_byte_tests_octave.m | 10 ++++------ 6 files changed, 7 insertions(+), 24 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index a1142ac78..a8a05bff0 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -3352,7 +3352,7 @@ Newton algorithm with a sparse LU solver at each iteration (requires @item 7 Newton algorithm with a Generalized Minimal Residual (GMRES) solver at each iteration (requires @code{bytecode} and/or @code{block} option, -@pxref{Model declaration}; not available under Octave) +@pxref{Model declaration}) @item 8 Newton algorithm with a Stabilized Bi-Conjugate Gradient (BICGSTAB) @@ -3984,7 +3984,7 @@ declaration}). @item 2 Use a Newton algorithm with a Generalized Minimal Residual (GMRES) solver at each iteration (requires @code{bytecode} and/or @code{block} -option, @pxref{Model declaration}; not available under Octave) +option, @pxref{Model declaration}) @item 3 Use a Newton algorithm with a Stabilized Bi-Conjugate Gradient diff --git a/matlab/perfect-foresight-models/private/check_input_arguments.m b/matlab/perfect-foresight-models/private/check_input_arguments.m index fc50114d0..42b1b697e 100644 --- a/matlab/perfect-foresight-models/private/check_input_arguments.m +++ b/matlab/perfect-foresight-models/private/check_input_arguments.m @@ -37,10 +37,6 @@ if (DynareOptions.block || DynareOptions.bytecode) && DynareOptions.stack_solve_ error('perfect_foresight_solver:ArgCheck','PERFECT_FORESIGHT_SOLVER: you can''t use stack_solve_algo = 6 with block or bytecode option') end -if isoctave && DynareOptions.stack_solve_algo == 2 - error('perfect_foresight_solver:ArgCheck','PERFECT_FORESIGHT_SOLVER: you can''t use stack_solve_algo = 2 under Octave') -end - if isempty(DynareResults.endo_simul) || any(size(DynareResults.endo_simul) ~= [ DynareModel.endo_nbr, DynareModel.maximum_lag+DynareOptions.periods+DynareModel.maximum_lead ]) diff --git a/matlab/solve_one_boundary.m b/matlab/solve_one_boundary.m index e121fbf2b..f36f0e348 100644 --- a/matlab/solve_one_boundary.m +++ b/matlab/solve_one_boundary.m @@ -280,9 +280,6 @@ for it_=start:incr:finish end elseif (stack_solve_algo==2 && is_dynamic) || (options.solve_algo==7 && ~is_dynamic) flag1=1; - if isoctave - error('SOLVE_ONE_BOUNDARY: you can''t use solve_algo=7 since GMRES is not implemented in Octave') - end if verbose == 1 && ~is_dynamic disp('steady: GMRES ') end diff --git a/matlab/steady_.m b/matlab/steady_.m index 46c0e3411..a689d46db 100644 --- a/matlab/steady_.m +++ b/matlab/steady_.m @@ -48,7 +48,7 @@ if ~options_.bytecode && options_.block && options_.solve_algo == 5 error('STEADY: you can''t use solve_algo = 5 without bytecode option') end -if isoctave && ismember(options_.solve_algo,[7,11]) +if isoctave && options_.solve_algo == 11 error(['SIMUL: you can''t use solve_algo = %u under Octave'],options_.solve_algo) end diff --git a/mex/sources/bytecode/SparseMatrix.cc b/mex/sources/bytecode/SparseMatrix.cc index 2e4feb90c..1fd7c7d76 100644 --- a/mex/sources/bytecode/SparseMatrix.cc +++ b/mex/sources/bytecode/SparseMatrix.cc @@ -4833,14 +4833,6 @@ dynSparseMatrix::Solve_CUDA_BiCGStab(int *Ap, int *Ai, double *Ax, int *Ap_tild, void dynSparseMatrix::Solve_Matlab_GMRES(mxArray *A_m, mxArray *b_m, int Size, double slowc, int block, bool is_two_boundaries, int it_, mxArray *x0_m) { -#ifdef OCTAVE_MEX_FILE - ostringstream tmp; - if (steady_state) - tmp << " GMRES method is not implemented in Octave. You cannot use solve_algo=7, change solve_algo.\n"; - else - tmp << " GMRES method is not implemented in Octave. You cannot use stack_solve_algo=2, change stack_solve_algo.\n"; - throw FatalExceptionHandling(tmp.str()); -#endif size_t n = mxGetM(A_m); const char *field_names[] = {"droptol", "type"}; mwSize dims[1] = { 1 }; diff --git a/tests/run_block_byte_tests_octave.m b/tests/run_block_byte_tests_octave.m index be1acf564..31f8c66b7 100644 --- a/tests/run_block_byte_tests_octave.m +++ b/tests/run_block_byte_tests_octave.m @@ -43,19 +43,17 @@ cd([top_test_dir filesep 'block_bytecode']); tic; for blockFlag = 0:1 for bytecodeFlag = 0:1 - ## Recall that solve_algo=7 and stack_solve_algo=2 are not supported - ## under Octave default_solve_algo = 2; default_stack_solve_algo = 0; if !blockFlag && !bytecodeFlag solve_algos = 0:4; stack_solve_algos = [0 6]; elseif blockFlag && !bytecodeFlag - solve_algos = [0:4 6 8]; - stack_solve_algos = [0 1 3 4]; + solve_algos = [0:4 6:8]; + stack_solve_algos = 0:4; else - solve_algos = [0:6 8]; - stack_solve_algos = [0 1 3:5]; + solve_algos = 0:8; + stack_solve_algos = 0:5; endif sleep(1) # Workaround for strange race condition related to the _static.m file