Hello community, here is the log from the commit of package octave-forge-nan for openSUSE:Factory checked in at 2016-06-14 23:07:44 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/octave-forge-nan (Old) and /work/SRC/openSUSE:Factory/.octave-forge-nan.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "octave-forge-nan" Changes: -------- --- /work/SRC/openSUSE:Factory/octave-forge-nan/octave-forge-nan.changes 2016-04-28 16:56:56.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.octave-forge-nan.new/octave-forge-nan.changes 2016-06-14 23:07:45.000000000 +0200 @@ -1,0 +2,9 @@ +Fri Jun 10 17:51:45 UTC 2016 - [email protected] + +- Update to version 3.0.1 + * no changelog available +- Drop obsolete + * nan-openmp.patch + * nan-gcc.patch + +------------------------------------------------------------------- Old: ---- nan-2.8.1.tar.gz nan-gcc.patch nan-openmp.patch New: ---- nan-3.0.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ octave-forge-nan.spec ++++++ --- /var/tmp/diff_new_pack.lI64ev/_old 2016-06-14 23:07:46.000000000 +0200 +++ /var/tmp/diff_new_pack.lI64ev/_new 2016-06-14 23:07:46.000000000 +0200 @@ -18,18 +18,14 @@ %define octpkg nan Name: octave-forge-%{octpkg} -Version: 2.8.1 +Version: 3.0.1 Release: 0 Summary: A statistics and machine learning toolbox License: GPL-3.0+ Group: Productivity/Scientific/Math Url: http://octave.sourceforge.net Source0: http://downloads.sourceforge.net/octave/%{octpkg}-%{version}.tar.gz -# PATCH-FIX-UPSTREAM nan-openmp.patch -- Fix build with OpenMP support -Patch1: nan-openmp.patch -# PATCH-FIX-UPSTREAM nan-gcc.patch -- Fix GCC warnings -Patch2: nan-gcc.patch -Patch3: nan_xpt2d_add_return_for_BE.patch +Patch1: nan_xpt2d_add_return_for_BE.patch BuildRequires: blas-devel BuildRequires: gcc-c++ BuildRequires: octave-devel @@ -41,9 +37,7 @@ %prep %setup -q -c %{name}-%{version} -%patch1 -p0 -%patch2 -p1 -%patch3 -p1 +%patch1 -p1 %octave_pkg_src %build ++++++ nan-2.8.1.tar.gz -> nan-3.0.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/DESCRIPTION new/NaN/DESCRIPTION --- old/NaN/DESCRIPTION 2015-07-06 21:43:26.000000000 +0200 +++ new/NaN/DESCRIPTION 2016-02-26 16:09:14.000000000 +0100 @@ -1,7 +1,7 @@ Name: NaN -Version: 2.8.1 -Date: 2015-07-06 -Author: Alois Schloegl <[email protected]> +Version: 3.0.1 +Date: 2016-02-26 +Author: Alois Schloegl <[email protected]> Maintainer: Alois Schloegl Title: The NaN-toolbox Description: A statistics and machine learning toolbox for data with and w/o missing values @@ -9,4 +9,3 @@ License: GPLv3+ Url: http://pub.ist.ac.at/~schloegl/matlab/NaN Autoload: no -SVNRelease: $Rev: 12813 $ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/INDEX new/NaN/INDEX --- old/NaN/INDEX 2012-04-02 20:16:48.000000000 +0200 +++ new/NaN/INDEX 2016-02-26 16:09:14.000000000 +0100 @@ -9,5 +9,5 @@ var mean sem spearman trimean tpdf tcdf tinv zscore flag_implicit_significance xcovf train_sc test_sc xval classify train_lda_sparse decovm gscatter mahal - cdfplot hist2res fss cat2bin ttest ttest2 xptopen + cdfplot hist2res fss cat2bin ttest ttest2.m bland_altman cumsumskipnan range diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/NEWS new/NaN/NEWS --- old/NaN/NEWS 2015-07-06 21:42:45.000000000 +0200 +++ new/NaN/NEWS 2016-02-26 16:07:46.000000000 +0100 @@ -1,3 +1,18 @@ +2015-02-26: Release of NaN-tb v3.0.1 + +- fixes version number + two digit version number like 3.0 cannot be used in Octave-forge + +2015-09-12: Release of NaN-tb v2.8.3 + +- ready for gcc/g++ v5 +- honor environment variables CC and CXX +- fix installer issue on OpenSuse +- support debian hardening flags +- internal improvents (in type and macro usage) +- address a number of compiler warnings +- bug fixes + 2015-07-06: Release of NaN-tb v2.8.1 - fix nantest to avoid crashing octave 4.0.0 on windows diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/VERSION new/NaN/VERSION --- old/NaN/VERSION 2015-07-06 21:43:26.000000000 +0200 +++ new/NaN/VERSION 2016-02-26 16:09:14.000000000 +0100 @@ -1,3 +1,3 @@ # NaN-toolbox http://pub.ist.ac.at/~schloegl/matlab/NaN -# Version: 2.8.1 -# Date: 2015-07-06 +# Version: 3.0.1 +# Date: 2016-02-26 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/inst/trimmean.m new/NaN/inst/trimmean.m --- old/NaN/inst/trimmean.m 2011-11-03 12:00:50.000000000 +0100 +++ new/NaN/inst/trimmean.m 2015-12-16 09:58:57.000000000 +0100 @@ -15,8 +15,7 @@ % [1] http://www.fifi.org/doc/gnumeric-doc/html/C/gnumeric-trimmean.html -% $Id: trimmean.m 8953 2011-11-03 11:00:50Z schloegl $ -% Copyright (C) 2009,2010,2011 by Alois Schloegl <[email protected]> +% Copyright (C) 2009,2010,2011 by Alois Schloegl <[email protected]> % This function is part of the NaN-toolbox % http://pub.ist.ac.at/~schloegl/matlab/NaN/ @@ -64,7 +63,7 @@ for m=1:D2, n = floor(N*p(m)/2); f = sum(t(1+n:N-n))/(N-2*n); - Q(xo + m*D1) = f; + Q(xo + 1 + (m-1)*D1) = f; end; end; end; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/inst/xptopen.m new/NaN/inst/xptopen.m --- old/NaN/inst/xptopen.m 2014-01-12 20:50:10.000000000 +0100 +++ new/NaN/inst/xptopen.m 2015-12-22 01:48:47.000000000 +0100 @@ -1,53 +1,31 @@ % XPTOPEN read of several file formats and writing of the SAS Transport Format (*.xpt) -% Supported are ARFF, SAS-XPT and STATA files. -% XPTOPEN is a mex-file and must be compiled before use. -% More detailed help can be obtained by the command -% xptopen -% without an additional argument -% -% X = xptopen(filename) -% X = xptopen(filename,'r') -% read file with filename and return variables in struct X -% -% X = xptopen(filename,'w',X) -% save fields of struct X in filename. -% -% The fields of X must be column vectors of equal length. -% Each vector is either a numeric vector or a cell array of strings. -% The SAS-XPT format stores Date/Time as numeric value counting the number of days since 1960-01-01. -% -% References: -% [1] TS-140 THE RECORD LAYOUT OF A DATA SET IN SAS TRANSPORT (XPORT) FORMAT -% http://support.sas.com/techsup/technote/ts140.html -% [2] IBM floating point format -% http://en.wikipedia.org/wiki/IBM_Floating_Point_Architecture -% [3] see http://old.nabble.com/Re%3A-IBM-integer-and-double-formats-p20428979.html -% [4] STATA File Format -% http://www.stata.com/help.cgi?dta -% http://www.stata.com/help.cgi?dta_113 - - -% 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: xptopen.m 12495 2014-01-12 19:50:10Z schloegl $ -% Copyright (C) 2010,2011,2012,2014 by Alois Schloegl <[email protected]> -% This is part of the NaN-toolbox. For more details see -% http://pub.ist.ac.at/~schloegl/matlab/NaN/ - - -if exist('xptopen','file')~=3 - error('xptopen.mex is not compiled') -end; +% X = xptopen(filename) +% X = xptopen(filename,'r') +% read filename and return variables in struct X +% Supported are ARFF, SAS-XPT and STATA files. +% +% X = xptopen(filename,'w',X) +% save fields of struct X in filename. +% +% The fields of X must be column vectors of equal length. +% Each vector is either a numeric vector or a cell array of strings. +% +% The SAS-XPT format stores Date/Time as numeric value counting the number of days since 1960-01-01. +% Copyright (C) 2015 by Alois Schloegl <[email protected]> +% This is part of the NaN-toolbox. For more details see +% https://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/>. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/src/Makefile new/NaN/src/Makefile --- old/NaN/src/Makefile 2015-07-06 21:43:26.000000000 +0200 +++ new/NaN/src/Makefile 2016-02-26 16:09:14.000000000 +0100 @@ -1,5 +1,5 @@ #################################################### -# Copyright 2010, 2011,2012 Alois Schloegl +# Copyright 2010,2011,2012,2015 Alois Schloegl # This is part of the NaN-toolbox - a statistics and machine learning toolbox for data with and without missing values. # http://pub.ist.ac.at/~schloegl/matlab/NaN/ #################################################### @@ -31,12 +31,16 @@ # Instead of building "mex shortpath.c" and "mex uigetpath.c", I used empty m-functions within argout=argin; #################################################### MKOCTFILE ?= mkoctfile$(OCTAVE_VERSION) -CC = gcc -CXX = g++ -CFLAGS = -fopenmp -Wall -Wextra -Wconversion -O2 -OCTMEX = $(MKOCTFILE) --mex +CC ?= gcc +CXX ?= g++ +CFLAGS += -fopenmp -Wall -Wextra -Wconversion -O2 +OCTMEX = $(MKOCTFILE) --mex -lgomp RM = rm +# Support Debian Hardening flags +# https://wiki.debian.org/HardeningWalkthrough#Handling_dpkg-buildflags_in_your_upstream_build_system +CFLAGS += $(CPPFLAGS) + ifneq ($(OS),Windows_NT) CFLAGS += -fPIC endif @@ -44,9 +48,9 @@ ifneq (Darwin,$(shell uname)) CFLAGS += -fopenmp MEX_OPTION += -lgomp +MEX_OPTION += CC\#$(CXX) CXX\#$(CXX) CFLAGS\#"$(CFLAGS) " CXXFLAGS\#"$(CFLAGS) " endif -MEX_OPTION += CC\#$(CXX) CXX\#$(CXX) CFLAGS\#"$(CFLAGS) " CXXFLAGS\#"$(CFLAGS) " MATMEX = $(MATLABDIR)/bin/mex $(MEX_OPTION) PROGS = histo_mex.mex covm_mex.mex kth_element.mex sumskipnan_mex.mex str2array.mex train.mex svmtrain_mex.mex svmpredict_mex.mex xptopen.mex @@ -95,12 +99,12 @@ svm_model_octave.o: svm_model_matlab.c env CC=$(CC) $(MKOCTFILE) -o "$@" -c "$<" svm_model_matlab.o: svm_model_matlab.c - $(CC) $(CFLAGS) -I $(MATLABDIR)/extern/include -o "$@" -c "$<" + $(CXX) $(CFLAGS) -I $(MATLABDIR)/extern/include -o "$@" -c "$<" svm.o: svm.cpp $(CC) $(CFLAGS) -c svm.cpp train.$(MEX_EXT) predict.$(MEX_EXT): train.c tron.o linear.o linear_model_matlab.c - $(CC) $(CFLAGS) -I $(MATLABDIR)/extern/include -c linear_model_matlab.c + $(CXX) $(CFLAGS) -I $(MATLABDIR)/extern/include -c linear_model_matlab.c $(MATMEX) -lblas train.c tron.o linear.o linear_model_matlab.o #$(MATMEX) -lblas predict.c tron.o linear.o linear_model_matlab.o train.mex predict.mex: train.c tron.o linear.o linear_model_matlab.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/src/covm_mex.cpp new/NaN/src/covm_mex.cpp --- old/NaN/src/covm_mex.cpp 2015-06-18 17:09:49.000000000 +0200 +++ new/NaN/src/covm_mex.cpp 2015-12-22 11:28:53.000000000 +0100 @@ -29,10 +29,10 @@ // // Output: // - CC = X' * sparse(diag(W)) * Y while NaN's are skipped -// - NN = real(~isnan(X)')*sparse(diag(W))*real(~isnan(Y)) count of valid (non-NaN) elements +// - NN = real(~ISNAN(X)')*sparse(diag(W))*real(~ISNAN(Y)) count of valid (non-NaN) elements // computed more efficiently // -// $Id: covm_mex.cpp 12826 2015-06-18 15:09:49Z schloegl $ +// $Id: covm_mex.cpp 12888 2015-12-22 10:28:53Z schloegl $ // Copyright (C) 2009,2010,2011 Alois Schloegl <[email protected]> // This function is part of the NaN-toolbox // http://pub.ist.ac.at/~schloegl/matlab/NaN/ @@ -48,6 +48,15 @@ /*#define NO_FLAG*/ +/* + math.h has isnan() defined for all sizes of floating point numbers, + but c++ assumes isnan(double), causing possible conversions for float and long double + */ +#define ISNAN(a) (a!=a) + +#ifndef typeof +#define typeof __typeof__ +#endif void mexFunction(int POutputCount, mxArray* POutput[], int PInputCount, const mxArray *PInputs[]) { @@ -163,7 +172,7 @@ w = W[k]; for (i=0; i<cX; i++) { double x = X0[k+i*rX]; - if (isnan(x)) { + if (ISNAN(x)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -171,7 +180,7 @@ } for (j=0; j<cY; j++) { double y = Y0[k+j*rY]; - if (isnan(y)) { + if (ISNAN(y)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -185,7 +194,7 @@ } else for (i=0; i<cX; i++) { double x = X0[k+i*rX]; - if (isnan(x)) { + if (ISNAN(x)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -193,7 +202,7 @@ } for (j=0; j<cY; j++) { double y = Y0[k+j*rY]; - if (isnan(y)) { + if (ISNAN(y)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -230,7 +239,7 @@ size_t k; for (k=0; k<rX; k++) { double z = X[k]*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -254,7 +263,7 @@ size_t k; for (k=0; k<rX; k++) { double z = X[k]*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -283,7 +292,7 @@ size_t k; for (k=0; k<rX; k++) { double z = X[k]*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -314,7 +323,7 @@ size_t k; for (k=0; k<rX; k++) { double z = X[k]*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -353,7 +362,7 @@ size_t k; for (k=0; k<rX; k++) { long double z = ((long double)X[k])*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -362,9 +371,9 @@ cc += z*W[k]; nn += W[k]; } - CC[i] = cc; + CC[i] = (typeof(*CC))cc; if (NN != NULL) - NN[i] = nn; + NN[i] = (typeof(*NN))nn; } else /* no weights, all weights are 1 */ #pragma omp for schedule(dynamic) nowait @@ -377,7 +386,7 @@ size_t k; for (k=0; k<rX; k++) { long double z = ((long double)X[k])*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -386,9 +395,9 @@ cc += z; nn++; } - CC[i] = cc; + CC[i] = (typeof(*CC))cc; if (NN != NULL) - NN[i] = (double)nn; + NN[i] = (typeof(*NN))nn; } else // if (X0==Y0) && (cX==cY) /******** X==Y, output is symetric *******/ @@ -406,7 +415,7 @@ size_t k; for (k=0; k<rX; k++) { long double z = ((long double)X[k])*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -416,11 +425,11 @@ nn += W[k]; } size_t j = jj + ii*cX; - CC[i] = cc; - CC[j] = cc; + CC[i] = (typeof(*CC))cc; + CC[j] = (typeof(*CC))cc; if (NN != NULL) { - NN[i] = nn; - NN[j] = nn; + NN[i] = (typeof(*NN))nn; + NN[j] = (typeof(*NN))nn; } } else /* no weights, all weights are 1 */ @@ -437,7 +446,7 @@ size_t k; for (k=0; k<rX; k++) { long double z = ((long double)X[k])*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -447,11 +456,11 @@ nn++; } size_t j = jj + ii*cX; - CC[i] = cc; - CC[j] = cc; + CC[i] = (typeof(*CC))cc; + CC[j] = (typeof(*CC))cc; if (NN != NULL) { - NN[i] = (double)nn; - NN[j] = (double)nn; + NN[i] = (typeof(*NN))nn; + NN[j] = (typeof(*NN))nn; } } @@ -482,7 +491,7 @@ for (k=0; k<rX; k++) { long double t,y; long double z = ((long double)X[k])*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -500,9 +509,9 @@ rn= (t-nn)-y; nn= t; } - CC[i] = cc; + CC[i] = (typeof(*CC))cc; if (NN != NULL) - NN[i] = nn; + NN[i] = (typeof(*NN))nn; } else /* no weights, all weights are 1 */ #pragma omp for schedule(dynamic) nowait @@ -517,7 +526,7 @@ for (k=0; k<rX; k++) { long double t,y; long double z = ((long double)X[k])*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -531,9 +540,9 @@ nn++; } - CC[i] = cc; + CC[i] = (typeof(*CC))cc; if (NN != NULL) - NN[i] = (double)nn; + NN[i] = (typeof(*NN))nn; } else // if (X0==Y0) && (cX==cY) /******** X==Y, output is symetric *******/ @@ -554,7 +563,7 @@ for (k=0; k<rX; k++) { long double t,y; long double z = ((long double)X[k])*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -573,11 +582,11 @@ nn= t; } size_t j = jj + ii*cX; - CC[i] = cc; - CC[j] = cc; + CC[i] = (typeof(*CC))cc; + CC[j] = (typeof(*CC))cc; if (NN != NULL) { - NN[i] = nn; - NN[j] = nn; + NN[i] = (typeof(*NN))nn; + NN[j] = (typeof(*NN))nn; } } else /* no weights, all weights are 1 */ @@ -596,7 +605,7 @@ for (k=0; k<rX; k++) { long double t,y; long double z = ((long double)X[k])*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -611,11 +620,11 @@ nn++; } size_t j = jj + ii*cX; - CC[i] = cc; - CC[j] = cc; + CC[i] = (typeof(*CC))cc; + CC[j] = (typeof(*CC))cc; if (NN != NULL) { - NN[i] = (double)nn; - NN[j] = (double)nn; + NN[i] = (typeof(*NN))nn; + NN[j] = (typeof(*NN))nn; } } } @@ -645,7 +654,7 @@ for (k=0; k<rX; k++) { double t,y; double z = X[k]*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -680,7 +689,7 @@ for (k=0; k<rX; k++) { double t,y; double z = X[k]*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -717,7 +726,7 @@ for (k=0; k<rX; k++) { double t,y; double z = X[k]*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -759,7 +768,7 @@ for (k=0; k<rX; k++) { double t,y; double z = X[k]*Y[k]; - if (isnan(z)) { + if (ISNAN(z)) { #ifndef NO_FLAG flag_isNaN = 1; #endif @@ -825,7 +834,7 @@ case mxSTRUCT_CLASS: #endif default: - mexPrintf("Type of 3rd input argument cannot be used to return status of NaN occurence."); + mexPrintf("Type of 3rd input argument cannot be used to return status of NaN occurrence."); } } #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/src/histo_mex.cpp new/NaN/src/histo_mex.cpp --- old/NaN/src/histo_mex.cpp 2015-04-23 13:53:02.000000000 +0200 +++ new/NaN/src/histo_mex.cpp 2015-09-12 16:59:20.000000000 +0200 @@ -27,7 +27,7 @@ // HIS.X // HIS.H // -// $Id: histo_mex.cpp 12790 2015-04-23 11:53:02Z schloegl $ +// $Id: histo_mex.cpp 12878 2015-09-12 14:59:20Z schloegl $ // Copyright (C) 2009,2010,2011 Alois Schloegl <[email protected]> // This function is part of the NaN-toolbox // http://pub.ist.ac.at/~schloegl/matlab/NaN/ @@ -46,6 +46,12 @@ #include <string.h> #include "mex.h" +/* + math.h has isnan() defined for all sizes of floating point numbers, + but c++ assumes isnan(double), causing possible conversions for float and long double +*/ +#define ISNAN(a) (a!=a) + #ifdef tmwtypes_h #if (MX_API_VER<=0x07020000) @@ -109,7 +115,7 @@ float f1,f2; f1 = ((float*)Sort.Table)[ix1]; f2 = ((float*)Sort.Table)[ix2]; - z = isnan(f1) - isnan(f2); + z = ISNAN(f1) - ISNAN(f2); if (z) break; if (f1<f2) z = -1; @@ -121,7 +127,7 @@ double f1,f2; f1 = ((double*)Sort.Table)[ix1]; f2 = ((double*)Sort.Table)[ix2]; - z = isnan(f1) - isnan(f2); + z = ISNAN(f1) - ISNAN(f2); if (z) break; if (f1<f2) z = -1; @@ -161,6 +167,8 @@ else if (f1>f2) z = 1; break; } + default: + mexErrMsgTxt("unsupported input type"); } i++; ix1 += Sort.Stride; @@ -176,7 +184,7 @@ const mwSize *SZ; char flag_rows = 0; char done = 0; - mwSize j, k, l; // running indices + size_t j, k, l; // running indices const mxArray *W = NULL; double *w = NULL; @@ -234,8 +242,6 @@ mexErrMsgTxt("Error HISTO.MEX: input must be vector or matrix (no more than two dimensions)"); size_t n = SZ[0]; - size_t sz = 1; - char flag = 0; const char *fnames[] = {"datatype","X","H"}; mxArray *HIS = mxCreateStructMatrix(1, 1, 3, fnames); @@ -335,7 +341,7 @@ int8_t *x; x = (int8_t*)mxGetData(X); for (k=0; k<0x0100; k++) - x[k]=k-128; + x[k]=(int8_t)(k-128); x = (int8_t*)mxGetData(PInputs[0]); double *h = (double*)mxGetData(H); @@ -353,7 +359,7 @@ mxSetField(HIS,0,"X",X); uint8_t *x = (uint8_t*)mxGetData(X); - for (k=0; k<0x0100; k++) x[k]=k; + for (k=0; k<0x0100; k++) x[k]=(uint8_t)k; x = (uint8_t*)mxGetData(PInputs[0]); double *h = (double*)mxGetData(H); @@ -373,7 +379,7 @@ double *h = (double*)mxGetData(H); int16_t *x = (int16_t*)mxGetData(X); for (k=0; k<0x10000; k++) - x[k]=k-0x8000; + x[k]=(int16_t)(k-0x8000); x = (int16_t*)mxGetData(PInputs[0]); for (k=0; k<SZ[0]*SZ[1]; k++) @@ -392,7 +398,7 @@ double *h = (double*)mxGetData(H); int16_t *x = (int16_t*)mxGetData(X); for (k=0; k<0x10000; k++) - x[k]=k-0x8000; + x[k]=(uint16_t)(k-0x8000); uint16_t *x16 = (uint16_t*)mxGetData(PInputs[0]); for (k=0; k<SZ[0]*SZ[1]; k++) @@ -410,12 +416,13 @@ mxSetField(HIS,0,"H",H); mxSetField(HIS,0,"X",X); + /* double *h = (double*)mxGetData(H); int16_t *x = (int16_t*)mxGetData(X); for (n=0; n<SZ[1]; n++) { } - + */ } } // end switch } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/src/kth_element.cpp new/NaN/src/kth_element.cpp --- old/NaN/src/kth_element.cpp 2011-04-20 11:16:06.000000000 +0200 +++ new/NaN/src/kth_element.cpp 2015-09-12 16:59:20.000000000 +0200 @@ -59,20 +59,26 @@ #endif #endif +/* + math.h has isnan() defined for all sizes of floating point numbers, + but c++ assumes isnan(double), causing possible conversions for float and long double +*/ +#define ISNAN(a) (a!=a) + #define SWAP(a,b) {temp = a; a=b; b=temp;} static void findFirstK(double *array, size_t left, size_t right, size_t k) { while (right > left) { - mwIndex pivotIndex = (left + right) / 2; + size_t pivotIndex = (left + right) / 2; /* partition */ double temp; double pivotValue = array[pivotIndex]; SWAP(array[pivotIndex], array[right]); pivotIndex = left; - for (mwIndex i = left; i <= right - 1; ++i ) { + for (size_t i = left; i <= right - 1; ++i ) { // if (array[i] <= pivotValue || isnan(pivotValue)) // needed if data contains NaN's if (array[i] <= pivotValue) { @@ -93,8 +99,8 @@ void mexFunction(int POutputCount, mxArray* POutput[], int PInputCount, const mxArray *PInputs[]) { - mwIndex k, n; // running indices - mwSize szK, szX; + size_t k, n; // running indices + size_t szK, szX; double *T,*X,*Y,*K; char flag = 0; // default value @@ -112,7 +118,7 @@ } else if (PInputCount == 3) { // check value of flag - mwSize N = mxGetNumberOfElements(PInputs[2]); + size_t N = mxGetNumberOfElements(PInputs[2]); if (N>1) mexErrMsgTxt("KTH_ELEMENT: flag argument must be scalar\n"); else if (N==1) { @@ -180,7 +186,7 @@ else { /* do not copy NaN's */ for (k=0,n=0; k < szX; k++) { - if (!isnan(X[k])) T[n++]=X[k]; + if (!ISNAN(X[k])) T[n++]=X[k]; } szX = n; } @@ -190,10 +196,10 @@ POutput[0] = mxCreateDoubleMatrix(mxGetM(PInputs[1]),mxGetN(PInputs[1]),mxREAL); Y = (double*) mxGetData(POutput[0]); for (k=0; k < szK; k++) { - n = K[k]-1; // convert to zero-based indexing - if (n >= szX || n < 0) + if (K[k] > szX || K[k] < 1) Y[k] = 0.0/0.0; // NaN: result undefined else { + n = (size_t)(K[k]-1); // convert to zero-based indexing, round towards 0 findFirstK(T, 0, szX-1, n); Y[k] = T[n]; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/src/linear.h new/NaN/src/linear.h --- old/NaN/src/linear.h 2015-04-12 22:26:42.000000000 +0200 +++ new/NaN/src/linear.h 2016-01-05 11:00:14.000000000 +0100 @@ -63,7 +63,7 @@ struct model { struct parameter param; - int nr_class; /* number of classes */ + unsigned nr_class; /* number of classes */ int nr_feature; double *w; int *label; /* label of each class */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/src/linear_model_matlab.c new/NaN/src/linear_model_matlab.c --- old/NaN/src/linear_model_matlab.c 2011-04-20 11:16:06.000000000 +0200 +++ new/NaN/src/linear_model_matlab.c 2016-01-05 10:53:40.000000000 +0100 @@ -1,6 +1,6 @@ /* -$Id: linear_model_matlab.c 8223 2011-04-20 09:16:06Z schloegl $ +$Id: linear_model_matlab.c 12890 2016-01-05 09:53:40Z schloegl $ Copyright (c) 2007-2009 The LIBLINEAR Project. Copyright (c) 2010 Alois Schloegl <[email protected]> This function is part of the NaN-toolbox @@ -56,12 +56,12 @@ const char *model_to_matlab_structure(mxArray *plhs[], struct model *model_) { - int i; - int nr_w; + size_t i; + size_t nr_w; double *ptr; mxArray *return_model, **rhs; int out_id = 0; - int n, w_size; + size_t n, w_size; rhs = (mxArray **)mxMalloc(sizeof(mxArray *)*NUM_OF_RETURN_FIELD); @@ -135,11 +135,11 @@ const char *matlab_matrix_to_model(struct model *model_, const mxArray *matlab_struct) { - int i, num_of_fields; - int nr_w; + size_t i, num_of_fields; + size_t nr_w; double *ptr; int id = 0; - int n, w_size; + size_t n, w_size; mxArray **rhs; num_of_fields = mxGetNumberOfFields(matlab_struct); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/src/str2array.cpp new/NaN/src/str2array.cpp --- old/NaN/src/str2array.cpp 2014-04-15 17:42:23.000000000 +0200 +++ new/NaN/src/str2array.cpp 2015-09-12 21:19:57.000000000 +0200 @@ -122,7 +122,8 @@ return(2); } } - else if (*endptr && !isspace(*endptr)) { + else //if (*endptr && !isspace(*endptr)) + { // conversion failed return(0); } @@ -131,9 +132,9 @@ void mexFunction( - int nlhs, /* number of expected outputs */ + int nlhs, /* number of expected outputs */ mxArray *plhs[], /* array of pointers to output arguments */ - int nrhs, /* number of inputs */ + int nrhs, /* number of inputs */ const mxArray *prhs[] /* array of pointers to input arguments */ ) @@ -200,7 +201,7 @@ } else { int typ = str2val(s, o+k, &ival); - if ((nlhs>2) && (typ==0)) mxSetCell(plhs[2], k, mxCreateString(s)); + if ((nlhs>2) && (typ==0)) mxSetCell(plhs[2], (mwSize)k, mxCreateString(s)); if ((nlhs>1) && (typ> 0)) v[k] = 0; if (typ==2) { if (mxGetPi(plhs[0])==NULL) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/src/sumskipnan_mex.cpp new/NaN/src/sumskipnan_mex.cpp --- old/NaN/src/sumskipnan_mex.cpp 2015-06-18 17:09:49.000000000 +0200 +++ new/NaN/src/sumskipnan_mex.cpp 2015-12-22 11:28:53.000000000 +0100 @@ -38,7 +38,7 @@ // - sums of squares // // -// $Id: sumskipnan_mex.cpp 12826 2015-06-18 15:09:49Z schloegl $ +// $Id: sumskipnan_mex.cpp 12888 2015-12-22 10:28:53Z schloegl $ // Copyright (C) 2009,2010,2011 Alois Schloegl <[email protected]> // This function is part of the NaN-toolbox // http://pub.ist.ac.at/~schloegl/matlab/NaN/ @@ -52,6 +52,16 @@ #include <stdint.h> #include "mex.h" +/* + math.h has isnan() defined for all sizes of floating point numbers, + but c++ assumes isnan(double), causing possible conversions for float and long double +*/ +#define ISNAN(a) (a!=a) + +#ifndef typeof +#define typeof __typeof__ +#endif + inline void __sumskipnan2w__(double *data, size_t Ni, double *s, double *No, char *flag_anyISNAN, double *W); inline void __sumskipnan3w__(double *data, size_t Ni, double *s, double *s2, double *No, char *flag_anyISNAN, double *W); inline void __sumskipnan2wr__(double *data, size_t Ni, double *s, double *No, char *flag_anyISNAN, double *W); @@ -83,12 +93,12 @@ double x; double* W = NULL; // weight vector - mwSize DIM = 0; - mwSize D1, D2, D3; // NN; // - mwSize ND, ND2; // number of dimensions: input, output - mwSize ix0, ix1, ix2; // index to input and output - mwSize j, l; // running indices - mwSize *SZ2; // size of output + size_t DIM = 0; + size_t D1, D2, D3; // NN; // + size_t ND, ND2; // number of dimensions: input, output + size_t ix0, ix1, ix2; // index to input and output + size_t j, l; // running indices + mwIndex *SZ2; // size of output char flag_isNaN = 0; // check for proper number of input and output arguments @@ -301,7 +311,7 @@ // Inner LOOP: along dimensions < DIM if (W) do { long double x = *LInput; - if (!isnan(x)) { + if (!ISNAN(x)) { LongOutputSum[ix2] += W[j]*x; } #ifndef NO_FLAG @@ -313,7 +323,7 @@ } while (ix2 != (l+1)*D1); else do { long double x = *LInput; - if (!isnan(x)) { + if (!ISNAN(x)) { LongOutputSum[ix2] += x; } #ifndef NO_FLAG @@ -327,7 +337,7 @@ /* copy to output */ for (j=0; j<D1; j++) { - LOutputSum[ix0+j] = LongOutputSum[ix0+j]; + LOutputSum[ix0+j] = (typeof(*LOutputSum))LongOutputSum[ix0+j]; } } } @@ -343,7 +353,7 @@ // Inner LOOP: along dimensions < DIM if (W) do { long double x = *LInput; - if (!isnan(x)) { + if (!ISNAN(x)) { LongOutputCount[ix2] += W[j]; LongOutputSum[ix2] += W[j]*x; } @@ -356,7 +366,7 @@ } while (ix2 != (l+1)*D1); else do { long double x = *LInput; - if (!isnan(x)) { + if (!ISNAN(x)) { LongOutputCount[ix2] += 1.0; LongOutputSum[ix2] += x; } @@ -371,8 +381,8 @@ /* copy to output */ for (j=0; j<D1; j++) { - LOutputSum[ix0+j] = LongOutputSum[ix0+j]; - LOutputCount[ix0+j] = LongOutputCount[ix0+j]; + LOutputSum[ix0+j] = (typeof(*LOutputSum))LongOutputSum[ix0+j]; + LOutputCount[ix0+j] = (typeof(*LOutputCount))LongOutputCount[ix0+j]; } // end else } } @@ -388,9 +398,9 @@ // Inner LOOP: along dimensions < DIM if (W) do { long double x = *LInput; - if (!isnan(x)) { + if (!ISNAN(x)) { LongOutputCount[ix2] += W[j]; - double t = W[j]*x; + long double t = W[j]*x; LongOutputSum[ix2] += t; LongOutputSum2[ix2] += x*t; } @@ -403,7 +413,7 @@ } while (ix2 != (l+1)*D1); else do { long double x = *LInput; - if (!isnan(x)) { + if (!ISNAN(x)) { LongOutputCount[ix2] += 1.0; LongOutputSum[ix2] += x; LongOutputSum2[ix2] += x*x; @@ -419,9 +429,9 @@ /* copy to output */ for (j=0; j<D1; j++) { - LOutputSum[ix0+j] = LongOutputSum[ix0+j]; - LOutputCount[ix0+j] = LongOutputCount[ix0+j]; - LOutputSum2[ix0+j] = LongOutputSum2[ix0+j]; + LOutputSum[ix0+j] = (typeof(*LOutputSum))LongOutputSum[ix0+j]; + LOutputCount[ix0+j] = (typeof(*LOutputCount))LongOutputCount[ix0+j]; + LOutputSum2[ix0+j] = (typeof(*LOutputSum2))LongOutputSum2[ix0+j]; } } } @@ -486,7 +496,7 @@ long double count = 0.0; do { long double x = *data; - if (!isnan(x)) + if (!ISNAN(x)) { count += *W; sum += *W*x; @@ -500,13 +510,13 @@ W++; } while (data < end); - *No = count; + *No = (typeof(*No))count; } else { // w/o weight vector size_t countI = 0; do { long double x = *data; - if (!isnan(x)) + if (!ISNAN(x)) { countI++; sum += x; @@ -518,13 +528,13 @@ data++; // stride=1 } while (data < end); - *No = (double)countI; + *No = (typeof(*No))countI; } #ifndef NO_FLAG if (flag && (flag_anyISNAN != NULL)) *flag_anyISNAN = 1; #endif - *s = sum; + *s = (typeof(*s))sum; } @@ -542,7 +552,7 @@ long double count = 0.0; do { long double x = *data; - if (!isnan(x)) { + if (!ISNAN(x)) { count += *W; long double t = *W*x; sum += t; @@ -556,13 +566,13 @@ W++; } while (data < end); - *No = count; + *No = (typeof(*No))count; } else { // w/o weight vector size_t countI = 0; do { long double x = *data; - if (!isnan(x)) { + if (!ISNAN(x)) { countI++; sum += x; msq += x*x; @@ -574,14 +584,14 @@ data++; // stride=1 } while (data < end); - *No = (double)countI; + *No = (typeof(*No))countI; } #ifndef NO_FLAG if (flag && (flag_anyISNAN != NULL)) *flag_anyISNAN = 1; #endif - *s = sum; - *s2 = msq; + *s = (typeof(*s))sum; + *s2 = (typeof(*s2))msq; } inline void __sumskipnan2wr__(double *data, size_t Ni, double *s, double *No, char *flag_anyISNAN, double *W) @@ -596,7 +606,7 @@ double count = 0.0; do { double x = *data; - if (!isnan(x)) + if (!ISNAN(x)) { count += *W; sum += *W*x; @@ -610,13 +620,13 @@ W++; } while (data < end); - *No = count; + *No = (typeof(*No))count; } else { // w/o weight vector size_t countI = 0; do { double x = *data; - if (!isnan(x)) + if (!ISNAN(x)) { countI++; sum += x; @@ -628,13 +638,13 @@ data++; // stride=1 } while (data < end); - *No = (double)countI; + *No = (typeof(*No))countI; } #ifndef NO_FLAG if (flag && (flag_anyISNAN != NULL)) *flag_anyISNAN = 1; #endif - *s = sum; + *s = (typeof(*s))sum; } @@ -652,7 +662,7 @@ double count = 0.0; do { double x = *data; - if (!isnan(x)) { + if (!ISNAN(x)) { count += *W; double t = *W*x; sum += t; @@ -672,7 +682,7 @@ size_t countI = 0; do { double x = *data; - if (!isnan(x)) { + if (!ISNAN(x)) { countI++; sum += x; msq += x*x; @@ -684,14 +694,14 @@ data++; // stride=1 } while (data < end); - *No = (double)countI; + *No = (typeof(*No))countI; } #ifndef NO_FLAG if (flag && (flag_anyISNAN != NULL)) *flag_anyISNAN = 1; #endif - *s = sum; - *s2 = msq; + *s = (typeof(*s))sum; + *s2 = (typeof(*s2))msq; } @@ -720,7 +730,7 @@ do { long double x = *data; long double t,y; - if (!isnan(x)) + if (!ISNAN(x)) { //count += *W; [1] y = *W-rn; @@ -743,7 +753,7 @@ W++; } while (data < end); - *No = count; + *No = (typeof(*No))count; } else { // w/o weight vector size_t countI = 0; @@ -751,7 +761,7 @@ do { long double x = *data; long double t,y; - if (!isnan(x)) + if (!ISNAN(x)) { countI++; // sum += x; [1] @@ -767,13 +777,13 @@ data++; // stride=1 } while (data < end); - *No = (double)countI; + *No = (typeof(*No))countI; } #ifndef NO_FLAG if (flag && (flag_anyISNAN != NULL)) *flag_anyISNAN = 1; #endif - *s = sum; + *s = (typeof(*s))sum; } @@ -793,7 +803,7 @@ do { long double x = *data; long double t,y; - if (!isnan(x)) { + if (!ISNAN(x)) { //count += *W; [1] y = *W-rn; t = count+y; @@ -821,7 +831,7 @@ W++; } while (data < end); - *No = count; + *No = (typeof(*No))count; } else { // w/o weight vector size_t countI = 0; @@ -829,7 +839,7 @@ do { long double x = *data; long double t,y; - if (!isnan(x)) { + if (!ISNAN(x)) { countI++; //sum += x; [1] y = x-rc; @@ -850,14 +860,14 @@ data++; // stride=1 } while (data < end); - *No = (double)countI; + *No = (typeof(*No))countI; } #ifndef NO_FLAG if (flag && (flag_anyISNAN != NULL)) *flag_anyISNAN = 1; #endif - *s = sum; - *s2 = msq; + *s = (typeof(*s))sum; + *s2 = (typeof(*s))msq; } inline void __sumskipnan2wer__(double *data, size_t Ni, double *s, double *No, char *flag_anyISNAN, double *W) @@ -874,7 +884,7 @@ do { double x = *data; double t,y; - if (!isnan(x)) + if (!ISNAN(x)) { //count += *W; [1] y = *W-rn; @@ -897,7 +907,7 @@ W++; } while (data < end); - *No = count; + *No = (typeof(*No))count; } else { // w/o weight vector size_t countI = 0; @@ -905,7 +915,7 @@ do { double x = *data; double t,y; - if (!isnan(x)) + if (!ISNAN(x)) { countI++; // sum += x; [1] @@ -921,13 +931,13 @@ data++; // stride=1 } while (data < end); - *No = (double)countI; + *No = (typeof(*No))countI; } #ifndef NO_FLAG if (flag && (flag_anyISNAN != NULL)) *flag_anyISNAN = 1; #endif - *s = sum; + *s = (typeof(*s))sum; } @@ -947,7 +957,7 @@ do { double x = *data; double t,y; - if (!isnan(x)) { + if (!ISNAN(x)) { //count += *W; [1] y = *W-rn; t = count+y; @@ -975,7 +985,7 @@ W++; } while (data < end); - *No = count; + *No = (typeof(*No))count; } else { // w/o weight vector size_t countI = 0; @@ -983,7 +993,7 @@ do { double x = *data; double t,y; - if (!isnan(x)) { + if (!ISNAN(x)) { countI++; //sum += x; [1] y = x-rc; @@ -1004,13 +1014,13 @@ data++; // stride=1 } while (data < end); - *No = (double)countI; + *No = (typeof(*No))countI; } #ifndef NO_FLAG if (flag && (flag_anyISNAN != NULL)) *flag_anyISNAN = 1; #endif - *s = sum; - *s2 = msq; + *s = (typeof(*s))sum; + *s2 = (typeof(*s))msq; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/src/xptopen.cpp new/NaN/src/xptopen.cpp --- old/NaN/src/xptopen.cpp 2015-04-03 21:24:52.000000000 +0200 +++ new/NaN/src/xptopen.cpp 2015-12-22 11:28:53.000000000 +0100 @@ -29,7 +29,7 @@ // 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: xptopen.cpp 12770 2015-04-03 19:24:52Z schloegl $ +// $Id: xptopen.cpp 12888 2015-12-22 10:28:53Z schloegl $ // Copyright (C) 2010,2011,2012,2013 Alois Schloegl <[email protected]> // This function is part of the NaN-toolbox // http://pub.ist.ac.at/~schloegl/matlab/NaN/ @@ -63,6 +63,10 @@ #include <time.h> #include "mex.h" +#ifndef typeof +#define typeof __typeof__ +#endif + #ifdef tmwtypes_h #if (MX_API_VER<=0x07020000) typedef int mwSize; @@ -301,7 +305,7 @@ } fid = fopen(fn,Mode); - if (fid < 0) { + if (fid == NULL) { mexErrMsgTxt("Can not open file!\n"); } @@ -372,7 +376,7 @@ } if (rec_type != 2) - ;//error('invalid SPSS file'); + mexErrMsgTxt("invalid SPSS file\n"); c2 += fread(VarNames+9*ns,1,8,fid); VarNames[9*ns+8] = 0; @@ -469,8 +473,8 @@ char typ; int32_t len; char flagSWAP = (((__BYTE_ORDER == __BIG_ENDIAN) && LittleEndian) || ((__BYTE_ORDER == __LITTLE_ENDIAN) && !LittleEndian)); do { - fread(&typ,1,1,fid); - fread(&len,4,1,fid); + if (!fread(&typ,1,1,fid)) break; + if (!fread(&len,4,1,fid)) break; if (flagSWAP) bswap_32(len); fseek(fid,len,SEEK_CUR); } while (len); @@ -510,7 +514,7 @@ switch (typlist[k]) { case 0xfb: R[k] = mxCreateDoubleMatrix(M, 1, mxREAL); - for (size_t m = 0; m < M; m++) { + for (typeof(M) m = 0; m < M; m++) { int8_t d = *(int8_t*)(data+bi[k]+m*bi[NS]); ((double*)mxGetData(R[k]))[m] = (d>100) ? NaN : d; } @@ -521,7 +525,7 @@ int16_t d = (int16_t) bswap_16(*(uint16_t*)(data+bi[k]+m*bi[NS])); ((double*)mxGetData(R[k]))[m] = (d>32740) ? NaN : d; } - else for (size_t m = 0; m < M; m++) { + else for (typeof(M) m = 0; m < M; m++) { int16_t d = *(int16_t*)(data+bi[k]+m*bi[NS]); ((double*)mxGetData(R[k]))[m] = (d>32740) ? NaN : d; } @@ -532,7 +536,7 @@ int32_t d = (int32_t)bswap_32(*(uint32_t*)(data+bi[k]+m*bi[NS])); ((double*)mxGetData(R[k]))[m] = (d>2147483620) ? NaN : d; } - else for (size_t m = 0; m < M; m++) { + else for (typeof(M) m = 0; m < M; m++) { int32_t d = *(int32_t*)(data+bi[k]+m*bi[NS]); ((double*)mxGetData(R[k]))[m] = (d>2147483620) ? NaN : d; } @@ -548,17 +552,17 @@ break; case 0xff: R[k] = mxCreateDoubleMatrix(M, 1, mxREAL); - if (flagSWAP) for (size_t m = 0; m < M; m++) { + if (flagSWAP) for (typeof(M) m = 0; m < M; m++) { ((uint64_t*)mxGetData(R[k]))[m] = bswap_64(*(uint64_t*)(data+bi[k]+m*bi[NS])); } - else for (size_t m = 0; m < M; m++) { + else for (typeof(M) m = 0; m < M; m++) { ((uint64_t*)mxGetData(R[k]))[m] = *(uint64_t*)(data+bi[k]+m*bi[NS]); } break; default: R[k] = mxCreateCellMatrix(M, 1); size_t sz = typlist[k]; - for (size_t m = 0; m < M; m++) { + for (typeof(M) m = 0; m < M; m++) { memcpy(f, data+bi[k]+m*bi[NS], sz); f[sz] = 0; mxSetCell(R[k], m, mxCreateString(f)); @@ -724,7 +728,7 @@ else if (vartyp[ns] == 6) { size_t kk[6],n=0, N=strlen(datestr[ns]); char T0[6][5]; - char ix = 0; + int ix = 0; struct tm t; for (n=0; n < N; n++) { @@ -933,7 +937,7 @@ H2 = (char*) realloc(H2,HeadLen2); memset(H2,0,HeadLen2); - mwIndex M = 0; + size_t M = 0; mxArray **F = (mxArray**) mxMalloc(NS*sizeof(mxArray*)); char **Fstr = (char**) malloc(NS*sizeof(char*)); size_t *MAXLEN = (size_t*) malloc(NS*sizeof(size_t*)); @@ -954,7 +958,7 @@ } else if (mxIsCell(F[k])) { size_t maxlen = 0; - for (mwIndex m = 0; m<M; m++) { + for (size_t m = 0; m<M; m++) { mxArray *f = mxGetCell(F[k],m); if (mxIsChar(f) || mxIsEmpty(f)) { size_t len = mxGetNumberOfElements(f); @@ -978,7 +982,7 @@ count += fwrite(H2, 1, HeadLen2, fid); /* write OBS header line */ count += fwrite(LO, 1, strlen(LO), fid); - for (mwIndex m = 0; m < M; m++) { + for (size_t m = 0; m < M; m++) { for (uint16_t k = 0; k < NS; k++) { if (*(int16_t*)(H2+k*sz2) == b_endian_u16(1)) { @@ -1092,7 +1096,7 @@ mexPrintf("d2xpt(%f)\n",x); #endif // see http://old.nabble.com/Re%3A-IBM-integer-and-double-formats-p20428979.html - m = *(uint64_t*) &x; + memcpy(&m, &x, 8); *(((char*)&m) + 6) &= 0x0f; // if (e) *(((char*)&m) + 6) |= 0x10; // reconstruct implicit leading '1' for normalized numbers m <<= (3-(-e & 3)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NaN/test/test_perf_skipnan.m new/NaN/test/test_perf_skipnan.m --- old/NaN/test/test_perf_skipnan.m 2011-06-24 19:35:07.000000000 +0200 +++ new/NaN/test/test_perf_skipnan.m 2015-09-12 11:03:25.000000000 +0200 @@ -1,7 +1,6 @@ %% TEST_PERF_NANTB -% $Id$ % Copyright (C) 2009,2010 by Alois Schloegl <[email protected]> % This function is part of the NaN-toolbox % http://pub.ist.ac.at/~schloegl/matlab/NaN/ @@ -33,7 +32,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Generate Test data -y = randn(1e7,32); +y = randn(4e5,32); flag=0; N = 10; % repeat the tests 10 times
