diff --git a/matlab/MakeAllFigures.m b/matlab/MakeAllFigures.m index a8902192135d48dd50aa88557f7e26b03a16f054..89f35dac6095ee8c9240381815fbc4138b76f696 100644 --- a/matlab/MakeAllFigures.m +++ b/matlab/MakeAllFigures.m @@ -153,14 +153,14 @@ if Info.SaveFormat.Eps eval(['print -depsc2 ' M_.fname Info.SaveFormat.GenericName Info.SaveFormat.Name '.eps']); end end -if Info.SaveFormat.Pdf && ~exist('OCTAVE_VERSION') +if Info.SaveFormat.Pdf && ~isoctave if isempty(Info.SaveFormat.Name) eval(['print -dpdf ' M_.fname Info.SaveFormat.GenericName int2str(Info.SaveFormat.Number)]); else eval(['print -dpdf ' M_.fname Info.SaveFormat.GenericName Info.SaveFormat.Name]); end end -if Info.SaveFormat.Fig && ~exist('OCTAVE_VERSION') +if Info.SaveFormat.Fig && ~isoctave if isempty(Info.SaveFormat.Name) saveas(FigHandle,[M_.fname Info.SaveFormat.GenericName int2str(Info.SaveFormat.Number) '.fig']); else diff --git a/matlab/McMCDiagnostics_core.m b/matlab/McMCDiagnostics_core.m index 540c322e6f0cf7ac8673dd519b4261542428daef..bf014e7522b501bb0944e0f70078ddf8195b52a0 100644 --- a/matlab/McMCDiagnostics_core.m +++ b/matlab/McMCDiagnostics_core.m @@ -73,7 +73,7 @@ if whoiam fMessageStatus(0,whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab)); end for j=fpar:npar, - if exist('OCTAVE_VERSION'), + if isoctave if (whoiam==0), printf(' Parameter %d... ',j); end @@ -122,7 +122,7 @@ for j=fpar:npar, UDIAG(ligne,6,j-fpar+1) = UDIAG(ligne,6,j-fpar+1) + sum(abs(pmet(:,1)-moyenne).^3)/(n-1); end end - if exist('OCTAVE_VERSION'), + if isoctave if (whoiam==0), printf('Done! \n'); end diff --git a/matlab/PosteriorIRF.m b/matlab/PosteriorIRF.m index 42e11640a77629c7babb924603c3b6cd044b3dfd..d7ce72c299a5081f41ead446db1dd308022d9418 100644 --- a/matlab/PosteriorIRF.m +++ b/matlab/PosteriorIRF.m @@ -444,7 +444,7 @@ end % Comment for testing! -if ~exist('OCTAVE_VERSION') +if ~isoctave if isnumeric(options_.parallel) || (M_.exo_nbr*ceil(size(varlist,1)/MaxNumberOfPlotPerFigure))<8, [fout] = PosteriorIRF_core2(localVars,1,M_.exo_nbr,0); else diff --git a/matlab/PosteriorIRF_core1.m b/matlab/PosteriorIRF_core1.m index 20294afa2ffe93251f9fd42ce317cd07143986ca..00b33847822a2b318a6e00a481879e4a7fc63701 100644 --- a/matlab/PosteriorIRF_core1.m +++ b/matlab/PosteriorIRF_core1.m @@ -278,7 +278,7 @@ while fpar<B ifil2 = ifil2 + 1; irun2 = 0; end -% if exist('OCTAVE_VERSION'), +% if isoctave % if (whoiam==0), % printf(['Posterior IRF %3.f%% done\r'],(fpar/B*100)); % end @@ -286,7 +286,7 @@ while fpar<B % waitbar(fpar/B,h); % end % if whoiam, -% if ~exist('OCTAVE_VERSION') +% if ~isoctave % fprintf('Done! \n'); % end % waitbarString = [ 'Subdraw ' int2str(fpar) '/' int2str(B) ' done.']; diff --git a/matlab/UnivariateSpectralDensity.m b/matlab/UnivariateSpectralDensity.m index f9760ef794f2ae0054bfcc293c1da52853160c5b..0303cd3064383ee359dc6bf85fc7a87476db1209 100644 --- a/matlab/UnivariateSpectralDensity.m +++ b/matlab/UnivariateSpectralDensity.m @@ -39,7 +39,7 @@ sdl = options_.SpectralDensity.sdl; omega = (0:sdl:pi)'; GridSize = length(omega); exo_names_orig_ord = M_.exo_names_orig_ord; -if exist('OCTAVE_VERSION') +if isoctave warning('off', 'Octave:divide-by-zero') else warning off MATLAB:dividebyzero @@ -160,7 +160,7 @@ for i=1:nvar f(i,:) = Gamma(i,1)/(2*pi) + Gamma(i,H+1)*cos(H'*omega')/pi; end -if exist('OCTAVE_VERSION') +if isoctave warning('on', 'Octave:divide-by-zero') else warning on MATLAB:dividebyzero diff --git a/matlab/draw_prior_density.m b/matlab/draw_prior_density.m index ec0fa3c7626dd1a7acd19ac7f6c9c7316d4b02d2..1d364eecfd4261dfd012926b7ddeefe26a7e6eba 100644 --- a/matlab/draw_prior_density.m +++ b/matlab/draw_prior_density.m @@ -54,7 +54,7 @@ switch pshape(indx) supbound = gaminv(1-truncprior,p6(indx),p7(indx))+p3(indx); catch % Workaround for ticket #161 - if exist('OCTAVE_VERSION') + if isoctave error(['Due to a bug in Octave, you must choose other values for mean and/or variance of your prior on ' bayestopt_.name{indx} ', or use another shape']) else rethrow(lasterror) @@ -73,7 +73,7 @@ switch pshape(indx) supbound = 1/sqrt(gaminv(10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx); catch % Workaround for ticket #161 - if exist('OCTAVE_VERSION') + if isoctave error(['Due to a bug in Octave, you must choose other values for mean and/or variance of your prior on ' bayestopt_.name{indx} ', or use another shape']) else rethrow(lasterror) @@ -92,7 +92,7 @@ switch pshape(indx) supbound = 1/(gaminv(10*truncprior, p7(indx)/2, 2/p6(indx)))+p3(indx); catch % Workaround for ticket #161 - if exist('OCTAVE_VERSION') + if isoctave error(['Due to a bug in Octave, you must choose other values for mean and/or variance of your prior on ' bayestopt_.name{indx} ', or use another shape']) else rethrow(lasterror) diff --git a/matlab/dyn_saveas.m b/matlab/dyn_saveas.m index 533f8a755872c86bddf78707593eb43487eba72c..2bd513cc8d9087718a3e4403f6b439d782fbf082 100644 --- a/matlab/dyn_saveas.m +++ b/matlab/dyn_saveas.m @@ -31,7 +31,7 @@ function dyn_saveas(h,fname,DynareOptions) % along with Dynare. If not, see <http://www.gnu.org/licenses/>. if any(strcmp('eps',cellstr(DynareOptions.graph_format))) - if exist('OCTAVE_VERSION') + if isoctave fname = strrep(fname,'/',filesep); fname = strrep(fname,'\',filesep); if DynareOptions.nodisplay && ispc, @@ -41,14 +41,14 @@ if any(strcmp('eps',cellstr(DynareOptions.graph_format))) print(h,'-depsc2',[fname,'.eps']) end if any(strcmp('pdf',cellstr(DynareOptions.graph_format))) - if exist('OCTAVE_VERSION') + if isoctave error('Octave cannot create pdf files!') else print(h,'-dpdf',[fname,'.pdf']) end end if any(strcmp('fig',cellstr(DynareOptions.graph_format))) - if exist('OCTAVE_VERSION') + if isoctave error('Octave cannot create fig files!') else if DynareOptions.nodisplay diff --git a/matlab/dyn_waitbar.m b/matlab/dyn_waitbar.m index 73577c798c1cf4f101824900a97faf6476e633d2..f9665c950982b6cc879fc9af6c4489c5120be9b7 100644 --- a/matlab/dyn_waitbar.m +++ b/matlab/dyn_waitbar.m @@ -44,7 +44,7 @@ end if ~whoiam - if exist('OCTAVE_VERSION') || options_.console_mode, + if isoctave || options_.console_mode if init, diary off; @@ -55,7 +55,7 @@ if ~whoiam running_text = varargin{2}; end - if exist('OCTAVE_VERSION'), + if isoctave printf([running_text,' %3.f%% done\r'], prctdone*100); else s0=repmat('\b',1,length(newString)); diff --git a/matlab/dyn_waitbar_close.m b/matlab/dyn_waitbar_close.m index 4dbb628e51af7eb8e895876e9ead62eaad9ab7ca..894e4c6fad6663652c0d2ec339e3d1dacfe49c18 100644 --- a/matlab/dyn_waitbar_close.m +++ b/matlab/dyn_waitbar_close.m @@ -22,7 +22,7 @@ function dyn_waitbar_close(h) % along with Dynare. If not, see <http://www.gnu.org/licenses/>. global options_ -if exist('OCTAVE_VERSION') || options_.console_mode, +if isoctave || options_.console_mode, clear dyn_waitbar; diary on, fprintf('\n'); diff --git a/matlab/dynare.m b/matlab/dynare.m index 793a33886afef91d2f8e411affa5e01197519ec3..0d533accc6ce9c98d5a897bb5d46bf28794c2354 100644 --- a/matlab/dynare.m +++ b/matlab/dynare.m @@ -46,7 +46,7 @@ end warning_config() -if exist('OCTAVE_VERSION') +if isoctave if octave_ver_less_than('3.6.0') warning('This version of Dynare has only been tested on Octave 3.6.0 and above. Since your Octave version is older than that, Dynare may fail to run, or give unexpected results. Consider upgrading your Octave installation.'); end @@ -60,7 +60,7 @@ end more off % sets default format for save() command -if exist('OCTAVE_VERSION') +if isoctave default_save_options('-mat') end diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m index 3180a81a6cb741e9da526144e5a0c677463e890c..d52edad9ff5fb9d86d9bbebcf930402b2287aa1c 100644 --- a/matlab/dynare_config.m +++ b/matlab/dynare_config.m @@ -67,7 +67,7 @@ addpath([dynareroot '/reports/']) % For functions that exist only under some Octave versions % or some MATLAB versions, and for which we provide some replacement functions -if ~exist('OCTAVE_VERSION') +if ~isoctave % Replacements for rows(), columns() and issquare() (inexistent under MATLAB) addpath([dynareroot '/missing/rows_columns']) addpath([dynareroot '/missing/issquare']) @@ -80,34 +80,34 @@ if ~exist('OCTAVE_VERSION') end % ordeig() doesn't exist in Octave -if exist('OCTAVE_VERSION') +if isoctave addpath([dynareroot '/missing/ordeig']) end % bsxfun is missing in old versions of MATLAB (and exists in Octave) -if ~exist('OCTAVE_VERSION') && matlab_ver_less_than('7.4') +if ~isoctave && matlab_ver_less_than('7.4') addpath([dynareroot '/missing/bsxfun']) end % ilu is missing in old versions of MATLAB and in Octave -if exist('OCTAVE_VERSION') || matlab_ver_less_than('7.4') +if isoctave || matlab_ver_less_than('7.4') addpath([dynareroot '/missing/ilu']) end % strjoin is missing in older versions of MATLAB and in Octave -if exist('OCTAVE_VERSION') || matlab_ver_less_than('8.1') +if isoctave || matlab_ver_less_than('8.1') addpath([dynareroot '/missing/strjoin']) end % nanmean is in Octave Forge Statistics package and in MATLAB Statistics % toolbox -if (exist('OCTAVE_VERSION') && ~user_has_octave_forge_package('statistics')) ... - || (~exist('OCTAVE_VERSION') && ~user_has_matlab_license('statistics_toolbox')) +if (isoctave && ~user_has_octave_forge_package('statistics')) ... + || (~isoctave && ~user_has_matlab_license('statistics_toolbox')) addpath([dynareroot '/missing/nanmean']) end % Add path to MEX files -if exist('OCTAVE_VERSION') +if isoctave addpath([dynareroot '../mex/octave/']); else % Add win32 specific paths for Dynare Windows package diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m index 2c8783bfd2674bbceda38087da391909c004496e..aa92fdc1b2686fd63f22b0aa1a192928aaa05ca2 100644 --- a/matlab/dynare_estimation_1.m +++ b/matlab/dynare_estimation_1.m @@ -218,7 +218,7 @@ end if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation switch options_.mode_compute case 1 - if exist('OCTAVE_VERSION') + if isoctave error('Option mode_compute=1 is not available under Octave') elseif ~user_has_matlab_license('optimization_toolbox') error('Option mode_compute=1 requires the Optimization Toolbox') @@ -236,9 +236,9 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation case 2 error('ESTIMATION: mode_compute=2 option (Lester Ingber''s Adaptive Simulated Annealing) is no longer available') case 3 - if exist('OCTAVE_VERSION') && ~user_has_octave_forge_package('optim') + if isoctave && ~user_has_octave_forge_package('optim') error('Option mode_compute=3 requires the optim package') - elseif ~exist('OCTAVE_VERSION') && ~user_has_matlab_license('optimization_toolbox') + elseif ~isoctave && ~user_has_matlab_license('optimization_toolbox') error('Option mode_compute=3 requires the Optimization Toolbox') end % Set default optimization options for fminunc. @@ -249,7 +249,7 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation if options_.analytic_derivation, optim_options = optimset(optim_options,'GradObj','on'); end - if ~exist('OCTAVE_VERSION') + if ~isoctave [xparam1,fval,exitflag] = fminunc(objective_function,xparam1,optim_options,dataset_,options_,M_,estim_params_,bayestopt_,oo_); else % Under Octave, use a wrapper, since fminunc() does not have a 4th arg @@ -456,9 +456,9 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation save([M_.fname '_mode.mat'],'xparam1','hh','parameter_names'); case 7 % Matlab's simplex (Optimization toolbox needed). - if exist('OCTAVE_VERSION') && ~user_has_octave_forge_package('optim') + if isoctave && ~user_has_octave_forge_package('optim') error('Option mode_compute=7 requires the optim package') - elseif ~exist('OCTAVE_VERSION') && ~user_has_matlab_license('optimization_toolbox') + elseif ~isoctave && ~user_has_matlab_license('optimization_toolbox') error('Option mode_compute=7 requires the Optimization Toolbox') end optim_options = optimset('display','iter','MaxFunEvals',1000000,'MaxIter',6000,'TolFun',1e-8,'TolX',1e-6); diff --git a/matlab/dynare_identification.m b/matlab/dynare_identification.m index c9c10072165da87f2a058ff3c3f352d7bb133d12..1e96f8b72c2539d044c2ceb6637453f2d09ea011 100644 --- a/matlab/dynare_identification.m +++ b/matlab/dynare_identification.m @@ -38,7 +38,7 @@ function [pdraws, TAU, GAM, LRE, gp, H, JJ] = dynare_identification(options_iden global M_ options_ oo_ bayestopt_ estim_params_ -if exist('OCTAVE_VERSION') +if isoctave warning('off'), else warning off, @@ -442,7 +442,7 @@ if iload <=0, end if SampleSize > 1, -% if exist('OCTAVE_VERSION') || options_.console_mode, +% if isoctave || options_.console_mode, % console_waitbar(0,iteration/SampleSize); % else dyn_waitbar(iteration/SampleSize,h,['MC identification checks ',int2str(iteration),'/',int2str(SampleSize)]) @@ -454,7 +454,7 @@ if iload <=0, if SampleSize > 1, - if exist('OCTAVE_VERSION') || options_.console_mode, + if isoctave || options_.console_mode, fprintf('\n'); diary on; else @@ -581,7 +581,7 @@ if SampleSize > 1, end end -if exist('OCTAVE_VERSION') +if isoctave warning('on'), else warning on, diff --git a/matlab/dynare_sensitivity.m b/matlab/dynare_sensitivity.m index 07ffc50d0342d225c30ed83b06c8f677e41ca224..79820d7af854a85fff194f2d61f6811c795fad60 100644 --- a/matlab/dynare_sensitivity.m +++ b/matlab/dynare_sensitivity.m @@ -300,7 +300,7 @@ if options_gsa.rmse, else a=whos('-file',[OutputDirectoryName,'/',fname_,'_mc'],'logpo2'); end - if exist('OCTAVE_VERSION'), + if isoctave aflag=0; for ja=1:length(a), aflag=aflag+strcmp('logpo2',a(ja).name); diff --git a/matlab/dynare_solve.m b/matlab/dynare_solve.m index f8eb4af9e647cc7a75535e641f99dd9dd4091fc0..61fda72444fb697952bc7e58a8037d03799d5cdf 100644 --- a/matlab/dynare_solve.m +++ b/matlab/dynare_solve.m @@ -84,7 +84,7 @@ if max(abs(fvec)) < tolf end if options_.solve_algo == 0 - if ~exist('OCTAVE_VERSION') + if ~isoctave if ~user_has_matlab_license('optimization_toolbox') error('You can''t use solve_algo=0 since you don''t have MATLAB''s Optimization Toolbox') end @@ -99,7 +99,7 @@ if options_.solve_algo == 0 else options.Jacobian = 'off'; end - if ~exist('OCTAVE_VERSION') + if ~isoctave [x,fval,exitval,output] = fsolve(func,x,options,varargin{:}); else % Under Octave, use a wrapper, since fsolve() does not have a 4th arg diff --git a/matlab/gensylv/sylvester3.m b/matlab/gensylv/sylvester3.m index 38465d6c4cb39c491ad36ddfaf8edcf66925bc93..aabdc6650c447c4a18422d03435b336d48000006 100644 --- a/matlab/gensylv/sylvester3.m +++ b/matlab/gensylv/sylvester3.m @@ -35,7 +35,7 @@ if m == 1 return; end [u,t]=schur(c); -if exist('OCTAVE_VERSION') +if isoctave [aa,bb,qq,zz]=qz(full(a),full(b)); for j=1:p, if octave_ver_less_than('3.4.0') diff --git a/matlab/get_dynare_random_generator_state.m b/matlab/get_dynare_random_generator_state.m index 42cf80a38ae196dbb35de62f3a049b6c102f4c86..513919c220ff7de3f5a3d364cefd6637381d08e0 100644 --- a/matlab/get_dynare_random_generator_state.m +++ b/matlab/get_dynare_random_generator_state.m @@ -23,7 +23,7 @@ function [state_u,state_n] = get_dynare_random_generator_state() % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. - matlab_random_streams = ~(exist('OCTAVE_VERSION') || matlab_ver_less_than('7.7')); + matlab_random_streams = ~(isoctave || matlab_ver_less_than('7.7')); if matlab_random_streams% Use new matlab interface. if matlab_ver_less_than('7.12') diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m index 0c57eef4d302c56470ca92bebceed118c3c53a24..abd1b3a1364a03b672aafe47cd1fa92cba32893d 100644 --- a/matlab/global_initialization.m +++ b/matlab/global_initialization.m @@ -124,7 +124,7 @@ options_.nograph = 0; options_.XTick = []; options_.XTickLabel = []; options_.console_mode = 0; -if exist('OCTAVE_VERSION') +if isoctave if sum(get(0,'screensize'))==4 options_.console_mode = 1; options_.nodisplay = 1; diff --git a/matlab/gsa/filt_mc_.m b/matlab/gsa/filt_mc_.m index 5e09b0b72eaefce820c6d9859b6e4fad5e16017a..b4bc83af513b462a86f7b8a67a7687c3733d49d3 100644 --- a/matlab/gsa/filt_mc_.m +++ b/matlab/gsa/filt_mc_.m @@ -565,7 +565,7 @@ else title([pnam{nsnam(j)}],'interpreter','none') end %subplot(3,2,6) - if exist('OCTAVE_VERSION'), + if isoctave legend(char('base',vvarvecm),'location','eastoutside'); else h0=legend(char('base',vvarvecm),0); diff --git a/matlab/independent_metropolis_hastings_core.m b/matlab/independent_metropolis_hastings_core.m index 3162bd402ea6d2fa057fc32ad80a3cdbe0a8677f..f30a700843ea63ba0c8d934f1a4ceb6c83ea7ce3 100644 --- a/matlab/independent_metropolis_hastings_core.m +++ b/matlab/independent_metropolis_hastings_core.m @@ -128,7 +128,7 @@ for b = fblck:nblck, x2 = zeros(InitSizeArray(b),npar); logpo2 = zeros(InitSizeArray(b),1); end - if exist('OCTAVE_VERSION') || options_.console_mode + if isoctave || options_.console_mode diary off skipline() elseif whoiam @@ -176,9 +176,9 @@ for b = fblck:nblck, logpo2(irun) = ilogpo2(b); end prtfrc = j/nruns(b); - if exist('OCTAVE_VERSION') || options_.console_mode + if isoctave || options_.console_mode if mod(j, 10) == 0 - if exist('OCTAVE_VERSION') + if isoctave if (whoiam==0), printf('MH: Computing Metropolis-Hastings (chain %d/%d): %3.f%% done, acception rate: %3.f%%\r', b, nblck, 100 * prtfrc, 100 * isux / j); end @@ -245,7 +245,7 @@ for b = fblck:nblck, irun = irun + 1; end% End of the simulations for one mh-block. record.AcceptationRates(b) = isux/j; - if exist('OCTAVE_VERSION') || options_.console_mode + if isoctave || options_.console_mode printf('\n'); diary on elseif ~whoiam diff --git a/matlab/load_csv_file_data.m b/matlab/load_csv_file_data.m index ed370cf784fa668e625b4fcd1d5002ebd1a550c1..3af3e34941e293ffec6d4cc76c668ec04f7edd45 100644 --- a/matlab/load_csv_file_data.m +++ b/matlab/load_csv_file_data.m @@ -62,7 +62,7 @@ end freq = 1; % Default frequency is annual. init = dates(1,1); % Default initial date is year one. varlist = []; -if ~exist('OCTAVE_VERSION') +if ~isoctave % Under Matlab, save time by using importdata assert(exist(file, 'file') == 2, ['load_csv_file_data: I can''t find file ' file '!']); A = importdata(file, ',', withnames); diff --git a/matlab/lyapunov_symm.m b/matlab/lyapunov_symm.m index e23323f77b7634fce692e3004a5e5520d668520f..3d3d0c7682f9ca3ff887cf4d6fb0aa4d0f338d46 100644 --- a/matlab/lyapunov_symm.m +++ b/matlab/lyapunov_symm.m @@ -85,7 +85,7 @@ if method == 3 end; elseif method == 4 % works only with Matlab System Control toolbox or octave the control package, - if exist('OCTAVE_VERSION') + if isoctave if ~user_has_octave_forge_package('control') error('lyapunov=square_root_solver not available; you must install the control package from Octave Forge') end diff --git a/matlab/mode_check.m b/matlab/mode_check.m index a8e06a32d67c3da03a072f370794f6ed3a79bd9e..786acb7daba832115ce983ca09c089b1b40cf92f 100644 --- a/matlab/mode_check.m +++ b/matlab/mode_check.m @@ -168,7 +168,7 @@ for plt = 1:nbplt, drawnow end if DynareOptions.mode_check.nolik==0, - if exist('OCTAVE_VERSION'), + if isoctave axes('outerposition',[0.3 0.93 0.42 0.07],'box','on'), else axes('position',[0.3 0.01 0.42 0.05],'box','on'), diff --git a/matlab/ms-sbvar/dyn_save_graph.m b/matlab/ms-sbvar/dyn_save_graph.m index 355b7f13e7f48dc5a008c7a51417bb2d92cf8aea..612be4960c9b583721c0439922ebfd72b6eafd82 100644 --- a/matlab/ms-sbvar/dyn_save_graph.m +++ b/matlab/ms-sbvar/dyn_save_graph.m @@ -44,10 +44,10 @@ function dyn_save_graph(dirname,graph_name,graph_formats,TeX,names,texnames,capt if graph_formats.eps || TeX print([ graph_name '.eps' ],'-depsc2'); end - if graph_formats.pdf && ~exist(OCTAVE_VERSION) + if graph_formats.pdf && ~isoctave print(graph_name,'-dpdf'); end - if graph_formats.fig && ~exist(OCTAVE_VERSION) + if graph_formats.fig && ~isoctave print(graph_name,'-dfig'); end diff --git a/matlab/ms-sbvar/plot_ms_variance_decomposition.m b/matlab/ms-sbvar/plot_ms_variance_decomposition.m index 0188af2ccdbe63cb5236c69b21141ca9b5557f55..7cd30dca84cd97a42f0057343ff9bd7e1b42b955 100644 --- a/matlab/ms-sbvar/plot_ms_variance_decomposition.m +++ b/matlab/ms-sbvar/plot_ms_variance_decomposition.m @@ -150,7 +150,7 @@ end plot(x(2:end)',steady(:,k), '--k','LineWidth',2.25); end if k==K - if exist('OCTAVE_VERSION') + if isoctave legend(shock_names,'Location','SouthOutside'); else legend(shock_names,'Location','BestOutside','Orientation','horizontal'); diff --git a/matlab/parallel/AnalyseComputationalEnvironment.m b/matlab/parallel/AnalyseComputationalEnvironment.m index f6dd9e970a436fffac5c5ca5241b6c0310a98bea..8ca50428854359e85df397c0d4e455b52ee84158 100644 --- a/matlab/parallel/AnalyseComputationalEnvironment.m +++ b/matlab/parallel/AnalyseComputationalEnvironment.m @@ -366,7 +366,7 @@ for Node=1:length(DataInput) % To obtain a recoursive function remove the 'for' StrCommand=([s1,s2,s3,s4,s41,s42,s5,s51,s52,send]); % Mettere controllo su NbW ... - % if exist('OCTAVE_VERSION') + % if isoctave % NbW = fprintf(fid,StrCommand, '%s'); % else NbW = fprintf(fid,StrCommand, '%s'); diff --git a/matlab/parallel/InitializeComputationalEnvironment.m b/matlab/parallel/InitializeComputationalEnvironment.m index 22cc49c8303fc0972c72aa74a99fd2029ed68559..02df7aad432c08f154ef490c287b1fcf35cb4f61 100644 --- a/matlab/parallel/InitializeComputationalEnvironment.m +++ b/matlab/parallel/InitializeComputationalEnvironment.m @@ -37,7 +37,7 @@ function InitializeComputationalEnvironment() % Comment the line 'warning('off');' in order to view the warning message % in Octave! -if exist('OCTAVE_VERSION'), +if isoctave warning('off'); end @@ -48,7 +48,7 @@ global options_ isHybridMatlabOctave = false; for j=1:length(options_.parallel), if isempty(options_.parallel(j).MatlabOctavePath), - if exist('OCTAVE_VERSION') + if isoctave options_.parallel(j).MatlabOctavePath = 'octave'; else options_.parallel(j).MatlabOctavePath = 'matlab'; @@ -60,7 +60,7 @@ for j=1:length(options_.parallel), end isHybridMatlabOctave = isHybridMatlabOctave || any(regexpi([options_.parallel(j).MatlabOctavePath], 'octave')); end -isHybridMatlabOctave = isHybridMatlabOctave && ~exist('OCTAVE_VERSION'); +isHybridMatlabOctave = isHybridMatlabOctave && ~isoctave; options_.parallel_info.isHybridMatlabOctave = isHybridMatlabOctave; if isHybridMatlabOctave, % Reset dynare random generator and seed. diff --git a/matlab/parallel/dynareParallelDir.m b/matlab/parallel/dynareParallelDir.m index ba31dafe0aeacd3ec9e6367ec8662fcac6fe46dd..d257e8090e51c20846e0c16aad33cb59b34500b5 100644 --- a/matlab/parallel/dynareParallelDir.m +++ b/matlab/parallel/dynareParallelDir.m @@ -36,7 +36,7 @@ for indPC=1:length(Parallel), else ssh_token = ''; end - if exist('OCTAVE_VERSION') % Patch for peculiar behaviour of ssh-ls under Linux. + if isoctave % Patch for peculiar behaviour of ssh-ls under Linux. % It is necessary to capture the ls warning message. % To do it under the ssh protocol it is necessary to redirect the ls message in a text file. % The file is 'OctaveStandardOutputMessage.txt' and it is @@ -56,7 +56,7 @@ for indPC=1:length(Parallel), end else - if exist('OCTAVE_VERSION') % Patch for peculiar behaviour of ls under Linux. + if isoctave % Patch for peculiar behaviour of ls under Linux. % It is necessary to capture the ls warning message and properly manage the jolly char '*'! [check ax]=system(['ls ' ,filename, ' 2> OctaveStandardOutputMessage.txt']); @@ -74,7 +74,7 @@ for indPC=1:length(Parallel), end else - if exist('OCTAVE_VERSION'), % Patch for peculiar behaviour of ls under Windows. + if isoctave % Patch for peculiar behaviour of ls under Windows. if Parallel(indPC).Local==0, ax0=dir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir,'\',filename]); else diff --git a/matlab/parallel/dynareParallelGetFiles.m b/matlab/parallel/dynareParallelGetFiles.m index bfffaf97286fb8eec2c03a50efa00a8d09de32ce..dbd13d683149cfc04c84d75f8f0cbdd87368a9ed 100644 --- a/matlab/parallel/dynareParallelGetFiles.m +++ b/matlab/parallel/dynareParallelGetFiles.m @@ -54,7 +54,7 @@ for indPC=1:length(Parallel), end for jfil=1:size(NamFileInput,1), - if exist('OCTAVE_VERSION') % Patch for peculiar behaviour of ls under Linux. + if isoctave % Patch for peculiar behaviour of ls under Linux. % It is necessary to manage the jolly char '*'! FindAst=strfind(NamFileInput{jfil,2},'comp_status_random_walk_metropolis_hastings_core*'); diff --git a/matlab/parallel/dynareParallelRmDir.m b/matlab/parallel/dynareParallelRmDir.m index 6322f9b8adce038679128562a1288d0c50d79eb6..de08a55992da97a16f6a2e9f1c08d503f95e7f67 100644 --- a/matlab/parallel/dynareParallelRmDir.m +++ b/matlab/parallel/dynareParallelRmDir.m @@ -64,7 +64,7 @@ for indPC=1:length(Parallel), [stat NonServe] = system(['ssh ',ssh_token,' ',Parallel(indPC).UserName,'@',Parallel(indPC).ComputerName,' rm -fr ',Parallel(indPC).RemoteDirectory,'/',PRCDir,]); break; else - if exist('OCTAVE_VERSION'), % Patch for peculiar behaviour of rmdir under Windows. + if isoctave % Patch for peculiar behaviour of rmdir under Windows. % It is necessary because the command rmdir always ask at the user to confirm your decision before % deleting a directory: this stops the computation! The Octave native function 'confirm_recursive_rmdir' % disable this mechanism. diff --git a/matlab/parallel/dynareParallelSendFiles.m b/matlab/parallel/dynareParallelSendFiles.m index b1dc9cc2896113d95d5aa80e4391e5957d3e953a..d76f8a7bd575ef1ec322970d210bb0f70da6e35f 100644 --- a/matlab/parallel/dynareParallelSendFiles.m +++ b/matlab/parallel/dynareParallelSendFiles.m @@ -63,7 +63,7 @@ for indPC=1:length(Parallel), if ~isempty(NamFileInput{jfil,1}) if isempty(dynareParallelDir(NamFileInput{jfil,1},PRCDir,Parallel(indPC))) - if exist('OCTAVE_VERSION') % Patch for peculiar behaviour of mkdir under Windows. + if isoctave % Patch for peculiar behaviour of mkdir under Windows. % It is Necessary because Octave is not able to % create two nested directory at the same time. @@ -89,7 +89,7 @@ for indPC=1:length(Parallel), end end - if exist('OCTAVE_VERSION') % Patch for peculiar behaviour copyfile ls under Windows. + if isoctave % Patch for peculiar behaviour copyfile ls under Windows. % It is Necessary because Octave is not able to % use the jolly char '*' with copyfile. diff --git a/matlab/parallel/masterParallel.m b/matlab/parallel/masterParallel.m index 1b64b5ba1ec33a02b767cc24fc41054860584298..a0657176ffe549baaf25ab2b7f9856e3bcefe098 100644 --- a/matlab/parallel/masterParallel.m +++ b/matlab/parallel/masterParallel.m @@ -110,13 +110,13 @@ end % Comment the line 'warning('off');' in order to view the warning messages % in Octave! -if exist('OCTAVE_VERSION'), +if isoctave warning('off'); end % check if there are function_handles in the input or global vars when % octave is used -if isHybridMatlabOctave || exist('OCTAVE_VERSION'), +if isHybridMatlabOctave || isoctave fInputNames = fieldnames(fInputVar); for j=1:length(fInputNames), TargetVar = fInputVar.(fInputNames{j}); @@ -504,7 +504,7 @@ if Strategy==0 || newInstance, % See above. pause(1) else - if exist('OCTAVE_VERSION') + if isoctave % Redirect the standard output to the file 'OctaveStandardOutputMessage.txt'! % This file is saved in the Model directory. system('ConcurrentCommand1.bat > OctaveStandardOutputMessage.txt'); @@ -523,9 +523,9 @@ global options_ % Create a parallel (local/remote) specialized computational status bars! -if exist('OCTAVE_VERSION') || (options_.console_mode == 1), +if isoctave || options_.console_mode diary off; - if exist('OCTAVE_VERSION') + if isoctave printf('\n'); else fprintf('\n'); @@ -575,9 +575,9 @@ idCPU = NaN(1,totCPU); % Caption for console mode computing ... -if (options_.console_mode == 1) || exist('OCTAVE_VERSION') +if options_.console_mode || isoctave - if ~exist('OCTAVE_VERSION') + if ~isoctave if strcmpi([Parallel(indPC).MatlabOctavePath], 'octave') RjInformation='Hybrid Computing Is Active: Remote jobs are computed by Octave!'; fprintf([RjInformation,'\n\n']); @@ -607,7 +607,7 @@ if (options_.console_mode == 1) || exist('OCTAVE_VERSION') fnameTemp(L)=''; Information=['Parallel ' fnameTemp ' Computing ...']; - if exist('OCTAVE_VERSION') + if isoctave if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)) && (Strategy==0) printf('\n'); pause(2); @@ -660,7 +660,7 @@ while (ForEver) end pcerdone(j) = prtfrc; idCPU(j) = njob; - if exist('OCTAVE_VERSION') || (options_.console_mode == 1), + if isoctave || options_.console_mode if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)) statusString = [statusString, int2str(j), ' %3.f%% done! ']; else @@ -672,7 +672,7 @@ while (ForEver) end catch % ME % To define! - if exist('OCTAVE_VERSION') || (options_.console_mode == 1), + if isoctave || options_.console_mode if (~ispc || strcmpi('unix',Parallel(indPC).OperatingSystem)) statusString = [statusString, int2str(j), ' %3.f%% done! ']; else @@ -681,15 +681,14 @@ while (ForEver) end end end - if exist('OCTAVE_VERSION') || (options_.console_mode == 1), - if exist('OCTAVE_VERSION') + if isoctave || options_.console_mode + if isoctave printf([statusString,'\r'], 100 .* pcerdone); else if ~isempty(statusString) fprintf([statusString0,statusString], 100 .* pcerdone); end end - else for j=1:totCPU, try @@ -705,7 +704,7 @@ while (ForEver) % 1. The files .log and .txt are not copied. % 2. The comp_status_*.mat files are managed separately. - if exist('OCTAVE_VERSION'), % to avoid synchronism problems + if isoctave % to avoid synchronism problems try PRCDirSnapshot=dynareParallelGetNewFiles(PRCDir,Parallel(1:totSlaves),PRCDirSnapshot); catch @@ -729,8 +728,8 @@ while (ForEver) if HoTuttiGliOutput==totCPU, mydelete(['comp_status_',fname,'*.mat']); - if exist('OCTAVE_VERSION')|| (options_.console_mode == 1), - if exist('OCTAVE_VERSION') + if isoctave || options_.console_mode + if isoctave printf('\n'); printf(['End Parallel Session ....','\n\n']); else diff --git a/matlab/partial_information/PI_gensys.m b/matlab/partial_information/PI_gensys.m index de63ba9a0e59fa4825b2ff9a9103091811b6f081..c46d45d0729af627efd2ffbc1ffac8728cd6c480 100644 --- a/matlab/partial_information/PI_gensys.m +++ b/matlab/partial_information/PI_gensys.m @@ -180,7 +180,7 @@ try % In Octave: [aa bb q z v w] = qz(a,b) s.t. q'az = aa, q'bz=bb % % and qzcomplex() extension based on lapack zgges produces same % qz output for Octave as Matlab qz() does for Matlab thus: - if exist('OCTAVE_VERSION') + if isoctave [a b q z]=qzcomplex(G0pi,G1pi); q=q'; else diff --git a/matlab/plot_icforecast.m b/matlab/plot_icforecast.m index 6284769fa684a13c5b7c52d2c28c407c5970b2fe..84db7297b1e21c7f243cf7ebc956b81fb97c953c 100644 --- a/matlab/plot_icforecast.m +++ b/matlab/plot_icforecast.m @@ -27,7 +27,7 @@ function plot_icforecast(Variables,periods,options_) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -if exist('OCTAVE_VERSION') && octave_ver_less_than('3.4.0') +if isoctave && octave_ver_less_than('3.4.0') % The set() command on the handle returned by area() crashes in Octave 3.2 error('plot_conditional_forecast: you need Octave >= 3.4 (because of a bug in older versions)') end diff --git a/matlab/pm3.m b/matlab/pm3.m index 09488aa5e31afe74c49b3a599f7793d4a9ea6dd7..5974fca2728141cc786408298f4c5d4e70ec6c73 100644 --- a/matlab/pm3.m +++ b/matlab/pm3.m @@ -118,7 +118,7 @@ localVars.Mean=Mean; % Like sequential execution! nvar0=nvar; -if ~exist('OCTAVE_VERSION') +if ~isoctave % Commenting for testing! if isnumeric(options_.parallel) || ceil(size(varlist,1)/MaxNumberOfPlotsPerFigure)<4, fout = pm3_core(localVars,1,nvar,0); diff --git a/matlab/prior_bounds.m b/matlab/prior_bounds.m index 2d187c9a5f9632bd1ba17554b9664c5cd1d66018..4eb290e57ddcd9597d34f2360542eef6f22d5970 100644 --- a/matlab/prior_bounds.m +++ b/matlab/prior_bounds.m @@ -95,7 +95,7 @@ for i=1:length(p6) bounds(i,2) = gaminv(1-prior_trunc,p6(i),p7(i))+p3(i); catch % Workaround for ticket #161 - if exist('OCTAVE_VERSION') + if isoctave error(['Due to a bug in Octave, you must choose other values for mean and/or variance of your prior on ' bayestopt.name{i} ', or use another shape']) else rethrow(lasterror) @@ -121,7 +121,7 @@ for i=1:length(p6) 2/p6(i)))+p3(i); catch % Workaround for ticket #161 - if exist('OCTAVE_VERSION') + if isoctave error(['Due to a bug in Octave, you must choose other values for mean and/or variance of your prior on ' bayestopt.name{i} ', or use another shape']) else rethrow(lasterror) @@ -146,7 +146,7 @@ for i=1:length(p6) bounds(i,2) = 1/gaminv(prior_trunc, p7(i)/2, 2/p6(i))+ p3(i); catch % Workaround for ticket #161 - if exist('OCTAVE_VERSION') + if isoctave error(['Due to a bug in Octave, you must choose other values for mean and/or variance of your prior on ' bayestopt.name{i} ', or use another shape']) else rethrow(lasterror) diff --git a/matlab/qz/mjdgges.m b/matlab/qz/mjdgges.m index fea90931fd504f7dae1b79e9f39876b7efc3c524..2225e257b0cea14bb272d1382e40535f80c376af 100644 --- a/matlab/qz/mjdgges.m +++ b/matlab/qz/mjdgges.m @@ -63,7 +63,7 @@ info = 0; % as an option % - under Octave, only real decomposition available, but grouping of % eigenvalues <= 1 is implemented as an option (criterium can't be changed) -if exist('OCTAVE_VERSION') +if isoctave [ss,tt,w,eigval] = qz(e,d,'S'); sdim = sum(abs(eigval) <= 1.0); if any(abs(eigval) > 1.0 & abs(eigval) <= qz_criterium) diff --git a/matlab/random_walk_metropolis_hastings_core.m b/matlab/random_walk_metropolis_hastings_core.m index fa1b771d212c0d7623c346dc5321aa340ee60f45..6cdb46b918b0941d7f042c7071d72382d30415c6 100644 --- a/matlab/random_walk_metropolis_hastings_core.m +++ b/matlab/random_walk_metropolis_hastings_core.m @@ -152,7 +152,7 @@ for b = fblck:nblck, logpo2 = zeros(InitSizeArray(b),1); end if whoiam - prc0=(b-fblck)/(nblck-fblck+1)*(exist('OCTAVE_VERSION') || options_.console_mode); + prc0=(b-fblck)/(nblck-fblck+1)*(isoctave || options_.console_mode); hh = dyn_waitbar({prc0,whoiam,options_.parallel(ThisMatlab)},['MH (' int2str(b) '/' int2str(options_.mh_nblck) ')...']); else hh = dyn_waitbar(0,['Metropolis-Hastings (' int2str(b) '/' int2str(options_.mh_nblck) ')...']); @@ -185,9 +185,9 @@ for b = fblck:nblck, logpo2(irun) = ilogpo2(b); end prtfrc = j/nruns(b); -% if exist('OCTAVE_VERSION') || options_.console_mode +% if isoctave || options_.console_mode % if mod(j, 10) == 0 -% if exist('OCTAVE_VERSION') +% if isoctave % if (whoiam==0) % printf('MH: Computing Metropolis-Hastings (chain %d/%d): %3.f%% done, acception rate: %3.f%%\r', b, nblck, 100 * prtfrc, 100 * isux / j); % end @@ -263,8 +263,8 @@ for b = fblck:nblck, irun = irun + 1; end% End of the simulations for one mh-block. record.AcceptationRates(b) = isux/j; -% if exist('OCTAVE_VERSION') || options_.console_mode || whoiam -% if exist('OCTAVE_VERSION') +% if isoctave || options_.console_mode || whoiam +% if isoctave % printf('\n'); % else % fprintf('\n'); diff --git a/matlab/reports/@graph/createGraph.m b/matlab/reports/@graph/createGraph.m index 48f1c3771260b87d84b30f8d2d4454f3a2443f72..22eaafae3868a1a6051e0d96fbb81fe91cff91f6 100755 --- a/matlab/reports/@graph/createGraph.m +++ b/matlab/reports/@graph/createGraph.m @@ -142,7 +142,7 @@ if isempty(o.figname) o.figname = [tn '.tex']; end disp(' converting to tex....'); -if exist('OCTAVE_VERSION') && isempty(regexpi(computer, '.*apple.*', 'once')) +if isoctave && isempty(regexpi(computer, '.*apple.*', 'once')) print(o.figname, '-dtikz'); else matlab2tikz('filename', o.figname, ... diff --git a/matlab/reports/@report/compile.m b/matlab/reports/@report/compile.m index 06b48db8f9dfc4f279df080e42ea4d79fac0e4b9..6388ba7dd3173f3c3aff984d994dd3d00a114058 100755 --- a/matlab/reports/@report/compile.m +++ b/matlab/reports/@report/compile.m @@ -47,7 +47,7 @@ if ~exist(o.filename, 'file') end middle = ' ./'; -if exist('OCTAVE_VERSION') +if isoctave echo = 1; else echo = '-echo'; @@ -82,7 +82,7 @@ fprintf(1, '\n\nDone.\n') disp('Your compiled report is located here:'); disp([' ' pwd filesep rfn '.pdf']); -if ~exist('OCTAVE_VERSION') +if ~isoctave open([pwd filesep rfn '.pdf']); end end \ No newline at end of file diff --git a/matlab/reports/@report/write.m b/matlab/reports/@report/write.m index 0b34bdadb9d0145101fc4f7e5ae23e5b5d591103..91ca0c523155b287a6462805553878c413b241fd 100644 --- a/matlab/reports/@report/write.m +++ b/matlab/reports/@report/write.m @@ -46,7 +46,7 @@ fprintf(fid, ['\\makeatletter\n' ... '\\def\\blfootnote{\\gdef\\@thefnmark{}\\@footnotetext}\n' ... '\\makeatother\n']); -if exist('OCTAVE_VERSION') && isempty(regexpi(computer, '.*apple.*', 'once')) +if isoctave && isempty(regexpi(computer, '.*apple.*', 'once')) fprintf(fid, '\\usepackage[T1]{fontenc}\n'); fprintf(fid, '\\usepackage[utf8x]{inputenc}\n'); fprintf(fid, '\\usepackage{gnuplot-lua-tikz}\n'); diff --git a/matlab/rplot.m b/matlab/rplot.m index 50cda1bca13d4531094aff634313686f4512c4c1..df7712535fed2406d8bc3dee9b0ca2ccbf3c77c8 100644 --- a/matlab/rplot.m +++ b/matlab/rplot.m @@ -63,7 +63,7 @@ if rplottype == 0 title (t,'Interpreter','none') ; xlabel('Periods') ; if size(s1,1) > 1 - if exist('OCTAVE_VERSION') + if isoctave legend(s1, 0); else h = legend(s1,0); diff --git a/matlab/set_dynare_random_generator_state.m b/matlab/set_dynare_random_generator_state.m index dccc6d16f8413d9c911665093590d7972d577f07..f16ce13aed7eb52402aa00a635add310bca09326 100644 --- a/matlab/set_dynare_random_generator_state.m +++ b/matlab/set_dynare_random_generator_state.m @@ -23,7 +23,7 @@ function [state_u,state_n] = set_dynare_random_generator_state(state_u,state_n) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. - matlab_random_streams = ~(exist('OCTAVE_VERSION') || matlab_ver_less_than('7.7')); + matlab_random_streams = ~(isoctave || matlab_ver_less_than('7.7')); if matlab_random_streams% Use new matlab interface. if matlab_ver_less_than('7.12') diff --git a/matlab/set_dynare_seed.m b/matlab/set_dynare_seed.m index 991b8ed57bb19408b0684108d3bc9940e972bae6..fbde1abc305ee0671ef3e8761c7ebb4a1cacebd8 100644 --- a/matlab/set_dynare_seed.m +++ b/matlab/set_dynare_seed.m @@ -24,7 +24,7 @@ if ~nargin error('set_dynare_seed:: I need at least one input argument!') end -matlab_random_streams = ~(exist('OCTAVE_VERSION') || matlab_ver_less_than('7.7') || options_.parallel_info.isHybridMatlabOctave); +matlab_random_streams = ~(isoctave || matlab_ver_less_than('7.7') || options_.parallel_info.isHybridMatlabOctave); if matlab_random_streams% Use new matlab interface. if nargin==1 @@ -93,7 +93,7 @@ if matlab_random_streams% Use new matlab interface. else% Use old matlab interface. if nargin==1 if ischar(a) && strcmpi(a,'default') - if exist('OCTAVE_VERSION') || matlab_ver_less_than('7.4') + if isoctave || matlab_ver_less_than('7.4') options_.DynareRandomStreams.algo = 'state'; else % Twister was introduced in MATLAB 7.4 diff --git a/matlab/simul.m b/matlab/simul.m index c9fb8f8966cc00604fe7527ac09250ab60ecdec2..953bb67d71f8da324166000ae749b21fbc3f5b08 100644 --- a/matlab/simul.m +++ b/matlab/simul.m @@ -50,7 +50,7 @@ if (options_.block || options_.bytecode) && options_.stack_solve_algo == 6 error('SIMUL: you can''t use stack_solve_algo = 6 with block or bytecode option') end -if exist('OCTAVE_VERSION') && options_.stack_solve_algo == 2 +if isoctave && options_.stack_solve_algo == 2 error('SIMUL: you can''t use stack_solve_algo = 2 under Octave') end diff --git a/matlab/solve_one_boundary.m b/matlab/solve_one_boundary.m index 21227076a73c9e98b115813bc4da7e98e05372e7..304b81892851dbbbcbbd1fc3d0733b2e076762ce 100644 --- a/matlab/solve_one_boundary.m +++ b/matlab/solve_one_boundary.m @@ -224,7 +224,7 @@ for it_=start:incr:finish if (verbose == 1) disp('steady: fsolve'); end - if ~exist('OCTAVE_VERSION') + if ~isoctave if ~user_has_matlab_license('optimization_toolbox') error('SOLVE_ONE_BOUNDARY: you can''t use solve_algo=0 since you don''t have MATLAB''s Optimization Toolbox') end @@ -235,7 +235,7 @@ for it_=start:incr:finish options.TolFun=1e-8; options.Display = 'iter'; options.Jacobian = 'on'; - if ~exist('OCTAVE_VERSION') + if ~isoctave [yn,fval,exitval,output] = fsolve(@local_fname, y(y_index_eq), ... options, x, params, steady_state, y, y_index_eq, fname, 0); else @@ -309,7 +309,7 @@ for it_=start:incr:finish end; elseif((stack_solve_algo==2 && is_dynamic) || (options.solve_algo==7 && ~is_dynamic)), flag1=1; - if exist('OCTAVE_VERSION') + 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) diff --git a/matlab/steady_.m b/matlab/steady_.m index 822d4fbf4654465f0f833fbc0af9837e653de963..df1772a72d0e7a2fd43599f80724c27cd85a00f0 100644 --- a/matlab/steady_.m +++ b/matlab/steady_.m @@ -47,7 +47,7 @@ if ~options_.bytecode && options_.block && options_.solve_algo == 5 error('STEADY: you can''t use solve_algo = 5 without bytecode option') end -if exist('OCTAVE_VERSION') && options_.solve_algo == 7 +if isoctave && options_.solve_algo == 7 error('SIMUL: you can''t use solve_algo = 7 under Octave') end diff --git a/matlab/th_autocovariances.m b/matlab/th_autocovariances.m index eff41b89d4c34341cfe2a02c7e2a4c721870b1dc..889f7d9f40af8fdf88c4e791cb87b4509f9d6644 100644 --- a/matlab/th_autocovariances.m +++ b/matlab/th_autocovariances.m @@ -51,7 +51,7 @@ end endo_nbr = M_.endo_nbr; exo_names_orig_ord = M_.exo_names_orig_ord; -if exist('OCTAVE_VERSION') +if isoctave warning('off', 'Octave:divide-by-zero') else warning off MATLAB:dividebyzero @@ -260,7 +260,7 @@ else% ==> Theoretical HP filter. end end end -if exist('OCTAVE_VERSION') +if isoctave warning('on', 'Octave:divide-by-zero') else warning on MATLAB:dividebyzero diff --git a/matlab/utilities/general/isoctave.m b/matlab/utilities/general/isoctave.m new file mode 100644 index 0000000000000000000000000000000000000000..15c6fb38d1ef3df32cee857f08261ebc9b3ab262 --- /dev/null +++ b/matlab/utilities/general/isoctave.m @@ -0,0 +1,20 @@ +function A = isoctave() + +% Copyright (C) 2013 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +A = exist('OCTAVE_VERSION'); \ No newline at end of file diff --git a/matlab/varlist_indices.m b/matlab/varlist_indices.m index 20ece2830fc59be34978dc57a6153367d0a77f1c..d267adca1117c209b09239c18626d70140e386dd 100644 --- a/matlab/varlist_indices.m +++ b/matlab/varlist_indices.m @@ -31,7 +31,7 @@ function [i_var,nvar] = varlist_indices(sublist,list) % along with Dynare. If not, see <http://www.gnu.org/licenses/>. % In Octave, ismember() doesn't operate on character arrays -if ~exist('OCTAVE_VERSION') +if ~isoctave if isempty(sublist) check = []; i_var = []; diff --git a/matlab/warning_config.m b/matlab/warning_config.m index 3e377140930a83571f090a20275180790fd98773..6b6f533063e40fa970e678ac4a430a5e63bc5d8c 100644 --- a/matlab/warning_config.m +++ b/matlab/warning_config.m @@ -32,7 +32,7 @@ warning on; % Display a calling stack trace when a warning is issued warning('on', 'backtrace'); -if exist('OCTAVE_VERSION') +if isoctave warning('off', 'Octave:separator-insert'); warning('off', 'Octave:matlab-incompatible'); warning('off', 'Octave:single-quote-string'); diff --git a/matlab/writedata.m b/matlab/writedata.m index 93bd99c56395ec92562972dc0378b6b71c1c496a..815563008db886159c31b718ba08a639989a4886 100644 --- a/matlab/writedata.m +++ b/matlab/writedata.m @@ -30,7 +30,7 @@ function writedata(fname) global M_ oo_ % xlswrite doesn't exist on Octave, and appeared in MATLAB 7.0 -if exist('OCTAVE_VERSION') || matlab_ver_less_than('7.0') +if isoctave || matlab_ver_less_than('7.0') error('Function not supported on your version of MATLAB or Octave') end