Skip to content

Commit

Permalink
rint is mandated by C99
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Nov 17, 2024
1 parent 47345ee commit 0d61b11
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 74 deletions.
3 changes: 1 addition & 2 deletions Basic/Math/Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ my %source = qw(
yn yn
erfi ndtri
ndtri ndtri
rint rint
nan quiet_nan
infinity infinity
polyroots cpoly
Expand All @@ -33,7 +32,7 @@ my %included = ();

# test for library features
my (@sfuncs) = qw(nan infinity);
my (@ufuncs2) = qw(acosh asinh atanh erf erfc rint);
my (@ufuncs2) = qw(acosh asinh atanh erf erfc);
my (@besufuncs) = qw(j0 j1 y0 y1);
my (@besbifuncs) = qw(jn yn);
my ($libs) = $^O =~ /MSWin/ ? '' : $^O =~ /cygwin/ ? getcyglib('m') : '-lm';
Expand Down
18 changes: 3 additions & 15 deletions Basic/Math/math.pd
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,9 @@ q/=for ref
Round to integer values in floating-point format.
=for method
rint uses the 'round half to even' rounding method (also known as
banker's rounding). Half-integers are rounded to the nearest even
number. This avoids a slight statistical bias inherent in always
rounding half-integers up or away from zero.
This is the C99 function; previous to 2.096, the doc referred to a
bespoke function that did banker's rounding, but this was not used
as a system version will have been detected and used.
If you are looking to round half-integers up (regardless of sign), try
C<floor($x+0.5)>. If you want to round half-integers away from zero,
Expand Down Expand Up @@ -139,15 +136,6 @@ pp_addhdr('
extern double ndtri(double);
');

if ($^O =~ /MSWin/) {
pp_addhdr('
#include <float.h>
#ifdef _MSC_VER
double rint (double);
#endif
');
}

# Standard `-lm'
my (@ufuncs1) = qw(acos asin atan cosh sinh tan tanh); # F,D only
my (@ufuncs1g) = qw(ceil floor rint); # Any real type
Expand Down
42 changes: 0 additions & 42 deletions Basic/Math/rint.c

This file was deleted.

8 changes: 0 additions & 8 deletions Libtmp/Image2D/Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ my @pack = (["image2d.pd", qw(Image2D PDL::Image2D)]);

my %hash = pdlpp_stdargs_int( @pack );
$hash{LIBS} = [ '-lm' ];

# On windows we do not have an rint function (at least on VC++)
# Should do a proper test for rint similar to that done for
# PDL::Math. For now, simply test architecture
if ($^O =~ /MSWin/i) {
$hash{DEFINE} = " -DNEEDS_RINT";
}

$hash{OBJECT} .= " $_\$(OBJ_EXT)" for qw(rotate resample select misc);

# Add genpp rule
Expand Down
6 changes: 0 additions & 6 deletions Libtmp/Image2D/image2d.pd
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ pp_addhdr('
#define REALMOD(a,b) {while ((a)>=(b)) (a) -= (b); while ((a)<0) (a) += (b);}
/* rint is missing on some platforms (eg Win32) */
#ifdef NEEDS_RINT
#define rint(X) floor( X + 0.5 )
#endif
#define X(symbol, ctype, ppsym, ...) \
ctype quick_select_ ## ppsym(ctype arr[], int n);
PDL_TYPELIST_REAL(X)
Expand Down
1 change: 0 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ Basic/Math/NOTES
Basic/Math/polevl.c
Basic/Math/protos.h
Basic/Math/quiet_nan.c
Basic/Math/rint.c
Basic/Math/yn.c
Basic/MatrixOps/eigen.c
Basic/MatrixOps/eigen.h
Expand Down

0 comments on commit 0d61b11

Please sign in to comment.