Bump minimal required Octave version to 4.4

parent fd99f4fe
......@@ -187,12 +187,6 @@ Copyright: 2013-2019 Ben Abbott
2019 Dynare Team
License: GPL-3+
Files: matlab/missing/corrcoef/corrcoef.m matlab/missing/corrcoef/sumskipnan.m
matlab/missing/corrcoef/flag_implicit_skip_nan.m matlab/missing/corrcoef/tcdf.m
Copyright: 2000-2005,2008,2009,2011 by Alois Schloegl <alois.schloegl@gmail.com>
2014 Dynare Team
License: GPL-3+
Files: matlab/lmmcp/catstruct.m
Copyright: 2005 Jos van der Geest <jos@jasen.nl>
2013 Christophe Gouel
......
......@@ -78,14 +78,14 @@ if isoctave
'of precompiled mex files and some\nfeatures, like solution ' ...
'of models approximated at third order, will not be available.'], supported_octave_version())
skipline()
elseif octave_ver_less_than('4.2') % Should match the test in mex/build/octave/configure.ac
% and in m4/ax_mexopts.m4
elseif octave_ver_less_than('4.4') % Should match the test in mex/build/octave/configure.ac
skipline()
warning(['This version of Dynare has only been tested on Octave 4.2 and above. Dynare may fail to run or give unexpected result. Consider upgrading your version of Octave.'])
warning(['This version of Dynare has only been tested on Octave 4.4 and above. Dynare may fail to run or give unexpected result. Consider upgrading your version of Octave.'])
skipline()
end
else
if matlab_ver_less_than('7.9') % Should match the test in mex/build/matlab/configure.ac
% and in m4/ax_mexopts.m4
skipline()
warning('This version of Dynare has only been tested on MATLAB 7.9 (R2009b) and above. Since your MATLAB version is older than that, Dynare may fail to run, or give unexpected results. Consider upgrading your MATLAB installation, or switch to Octave.');
skipline()
......
......@@ -86,11 +86,6 @@ if isoctave && octave_ver_less_than('5')
p{end+1} = '/missing/ordeig';
end
% corrcoef with two outputs is missing in Octave < 4.4 (ticket #796)
if isoctave && octave_ver_less_than('4.4') && ~user_has_octave_forge_package('nan')
p{end+1} = '/missing/corrcoef';
end
%% intersect(…, 'stable') doesn't exist in Octave and in MATLAB < R2013a
if isoctave || matlab_ver_less_than('8.1')
p{end+1} = '/missing/intersect_stable';
......@@ -98,10 +93,10 @@ end
% Replacements for functions of the MATLAB statistics toolbox
if isoctave
% These functions were part of Octave < 4.4, they are now in the statistics Forge package
if ~octave_ver_less_than('4.4') && ~user_has_octave_forge_package('statistics')
% Our replacement functions don't work under Octave (because of gamrnd, see
% #1638), hence the statistics toolbox is now a hard requirement
% Under Octave, these functions are in the statistics Forge package.
% Our replacement functions don't work under Octave (because of gamrnd, see
% #1638), hence the statistics toolbox is now a hard requirement
if ~user_has_octave_forge_package('statistics')
error('You must install the "statistics" package from Octave Forge, either with your distribution package manager or with "pkg install -forge statistics"')
end
else
......
This diff is collapsed.
function FLAG = flag_implicit_skip_nan(i)
% FLAG_IMPLICIT_SKIP_NAN sets and gets default mode for handling NaNs
% 1 skips NaN's (the default mode if no mode is set)
% 0 NaNs are propagated; input NaN's give NaN's at the output
%
% FLAG = flag_implicit_skip_nan()
% gets current mode
%
% flag_implicit_skip_nan(FLAG) % sets mode
%
% prevFLAG = flag_implicit_skip_nan(nextFLAG)
% gets previous set FLAG and sets FLAG for the future
% flag_implicit_skip_nan(prevFLAG)
% resets FLAG to previous mode
%
% It is used in:
% SUMSKIPNAN, MEDIAN, QUANTILES, TRIMEAN
% and affects many other functions like:
% CENTER, KURTOSIS, MAD, MEAN, MOMENT, RMS, SEM, SKEWNESS,
% STATISTIC, STD, VAR, ZSCORE etc.
%
% The mode is stored in the global variable FLAG_implicit_skip_nan
% It is recommended to use flag_implicit_skip_nan(1) as default and
% flag_implicit_skip_nan(0) should be used for exceptional cases only.
% This feature might disappear without further notice, so you should really not
% rely on it.
% This program 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.
%
% This program 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 this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
% $Id: flag_implicit_skip_nan.m 8351 2011-06-24 17:35:07Z carandraug $
% Copyright (C) 2001-2003,2009 by Alois Schloegl <alois.schloegl@gmail.com>
% Copyright (C) 2014-2017 Dynare Team
%
% This function is part of the NaN-toolbox
% http://pub.ist.ac.at/~schloegl/matlab/NaN/
persistent FLAG_implicit_skip_nan;
%% if strcmp(version,'3.6'), FLAG_implicit_skip_nan=(1==1); end; %% hack for the use with Freemat3.6
%%% set DEFAULT value of FLAG
if isempty(FLAG_implicit_skip_nan)
FLAG_implicit_skip_nan = (1==1); %logical(1); % logical.m not available on 2.0.16
end
FLAG = FLAG_implicit_skip_nan;
if nargin>0
FLAG_implicit_skip_nan = (i~=0); %logical(i); %logical.m not available in 2.0.16
if (~i)
warning('flag_implicit_skipnan(0): You are warned!!! You have turned off skipping NaN in sumskipnan. This is not recommended. Make sure you really know what you do.')
end
end
function [o,count,SSQ] = sumskipnan(x, DIM, W)
% SUMSKIPNAN adds all non-NaN values.
%
% All NaN's are skipped; NaN's are considered as missing values.
% SUMSKIPNAN of NaN's only gives O; and the number of valid elements is return.
% SUMSKIPNAN is also the elementary function for calculating
% various statistics (e.g. MEAN, STD, VAR, RMS, MEANSQ, SKEWNESS,
% KURTOSIS, MOMENT, STATISTIC etc.) from data with missing values.
% SUMSKIPNAN implements the DIMENSION-argument for data with missing values.
% Also the second output argument return the number of valid elements (not NaNs)
%
% Y = sumskipnan(x [,DIM])
% [Y,N,SSQ] = sumskipnan(x [,DIM])
% [...] = sumskipnan(x, DIM, W)
%
% x input data
% DIM dimension (default: [])
% empty DIM sets DIM to first non singleton dimension
% W weight vector for weighted sum, numel(W) must fit size(x,DIM)
% Y resulting sum
% N number of valid (not missing) elements
% SSQ sum of squares
%
% the function FLAG_NANS_OCCURED() returns whether any value in x
% is a not-a-number (NaN)
%
% features:
% - can deal with NaN's (missing values)
% - implements dimension argument.
% - computes weighted sum
% - compatible with Matlab and Octave
%
% see also: FLAG_NANS_OCCURED, SUM, NANSUM, MEAN, STD, VAR, RMS, MEANSQ,
% SSQ, MOMENT, SKEWNESS, KURTOSIS, SEM
% This program 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.
%
% This program 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 this program; If not, see <http://www.gnu.org/licenses/>.
% $Id: sumskipnan.m 9033 2011-11-08 20:58:07Z schloegl $
%
% Copyright (C) 2000-2005,2009,2011 by Alois Schloegl <alois.schloegl@gmail.com>
% Copyright (C) 2014-2017 Dynare Team
% This function is part of the NaN-toolbox
% http://pub.ist.ac.at/~schloegl/matlab/NaN/
global FLAG_NANS_OCCURED;
if nargin<2
DIM = [];
end
if nargin<3
W = [];
end
% an efficient implementation in C of the following lines
% could significantly increase performance
% only one loop and only one check for isnan is needed
% An MEX-Implementation is available in sumskipnan.cpp
%
% Outline of the algorithm:
% for { k=1,o=0,count=0; k++; k<N}
% if ~isnan(i(k))
% { o += x(k);
% count += 1;
% tmp = x(k)*x(k)
% o2 += tmp;
% o3 += tmp.*tmp;
% };
if isempty(DIM)
DIM = find(size(x)>1,1);
if isempty(DIM), DIM = 1; end
end
if (DIM<1), DIM = 1; end %% Hack, because min([])=0 for FreeMat v3.5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% non-float data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (isempty(W) && (~(isa(x,'float') || isa(x,'double')))) || ~flag_implicit_skip_nan() %%% skip always NaN's
if ~isempty(W)
error('SUMSKIPNAN: weighted sum of integers not supported, yet');
end
x = double(x);
o = sum(x,DIM);
if nargout>1
sz = size(x);
N = sz(DIM);
sz(DIM) = 1;
count = repmat(N,sz);
if nargout>2
x = x.*x;
SSQ = sum(x,DIM);
end
end
return
end
if (length(size(x))<DIM)
error('SUMSKIPNAN: DIM argument larger than number of dimensions of x');
elseif ~isempty(W) && (size(x,DIM)~=numel(W))
error('SUMSKIPNAN: size of weight vector does not match size(x,DIM)');
end
%% mex and oct files expect double
x = double(x);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% use Matlab-MEX function when available
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%if 1,
try
%% using sumskipnan_mex.mex
%% !!! hack: FLAG_NANS_OCCURED is an output argument, reserve memory !!!
if isempty(FLAG_NANS_OCCURED)
FLAG_NANS_OCCURED = logical(0); % default value
end
if (nargout<2)
o = sumskipnan_mex(real(x),DIM,FLAG_NANS_OCCURED,W);
if (~isreal(x))
io = sumskipnan_mex(imag(x),DIM,FLAG_NANS_OCCURED,W);
o = o + i*io;
end
return
elseif (nargout==2)
[o,count] = sumskipnan_mex(real(x),DIM,FLAG_NANS_OCCURED,W);
if (~isreal(x))
[io,icount] = sumskipnan_mex(imag(x),DIM,FLAG_NANS_OCCURED,W);
if any(count(:)-icount(:))
error('Number of NaNs differ for REAL and IMAG part');
else
o = o+i*io;
end
end
return
elseif (nargout>=3)
[o,count,SSQ] = sumskipnan_mex(real(x),DIM,FLAG_NANS_OCCURED,W);
if (~isreal(x))
[io,icount,iSSQ] = sumskipnan_mex(imag(x),DIM,FLAG_NANS_OCCURED,W);
if any(count(:)-icount(:))
error('Number of NaNs differ for REAL and IMAG part');
else
o = o+i*io;
SSQ = SSQ+iSSQ;
end
end
return
end
end
if ~isempty(W)
error('weighted sumskipnan requires sumskipnan_mex');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% count non-NaN's
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargout>1
count = sum(x==x,DIM);
FLAG_NANS_OCCURED = any(count(:)<size(x,DIM));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% replace NaN's with zero
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x(x~=x) = 0;
o = sum(x,DIM);
if nargout>2
x = real(x).^2 + imag(x).^2;
SSQ = sum(x,DIM);
end
%!assert(sumskipnan([1,2],1),[1,2])
%!assert(sumskipnan([1,NaN],2),1)
%!assert(sumskipnan([1,NaN],2),1)
%!assert(sumskipnan([nan,1,4,5]),10)
%!assert(sumskipnan([nan,1,4,5]',1,[3;2;1;0]),6)
function p = tcdf(x,n)
% TCDF returns student cumulative distribtion function
%
% cdf = tcdf(x,DF);
%
% Computes the CDF of the students distribution
% with DF degrees of freedom
% x,DF must be matrices of same size, or any one can be a scalar.
%
% see also: NORMCDF, TPDF, TINV
% Reference(s):
% $Id: tcdf.m 9033 2011-11-08 20:58:07Z schloegl $
% Copyright (C) 2000-2003,2009 by Alois Schloegl <alois.schloegl@gmail.com>
% Copyright (C) 2014-2017 Dynare Team
%
% This is part of the NaN-toolbox. For more details see
% http://pub.ist.ac.at/~schloegl/matlab/NaN/
% This program 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.
%
% This program 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 this program; If not, see <http://www.gnu.org/licenses/>.
% check size of arguments
if all(size(x)==1)
x = repmat(x,size(n));
elseif all(size(n)==1)
n = repmat(n,size(x));
elseif all(size(x)==size(n))
% OK, do nothing
else
error('size of input arguments must be equal or scalar')
end
% allocate memory
p = zeros(size(x));
p((x==Inf) & (n>0)) = 1;
% workaround for invalid arguments in BETAINC
ix = isnan(x) | ~(n>0);
p(ix)= NaN;
ix = (x > -Inf) & (x < Inf) & (n > 0);
p(ix) = betainc (n(ix) ./ (n(ix) + x(ix).^2), n(ix)/2, 1/2) / 2;
ix = find(x>0);
p(ix) = 1 - p(ix);
% shape output
p = reshape(p,size(x));
%!assert(tcdf(NaN,4),NaN)
......@@ -41,7 +41,7 @@ case ${host_os} in
esac
OCTAVE_VERSION=$($MKOCTFILE -v 2>&1 | sed 's/mkoctfile, version //')
AX_COMPARE_VERSION([$OCTAVE_VERSION], [lt], [4.2], [AC_MSG_ERROR([Your Octave is too old, please upgrade to version 4.2 at least (or disable Octave support with --disable-octave).])])
AX_COMPARE_VERSION([$OCTAVE_VERSION], [lt], [4.4], [AC_MSG_ERROR([Your Octave is too old, please upgrade to version 4.4 at least (or disable Octave support with --disable-octave).])])
AC_PROG_F77([gfortran g77 f77])
AC_PROG_CC
......
Markdown is supported
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