* Re: [PATCH] Miscellaneous for 2.0
[not found] <941810.39891.qm@web114116.mail.gq1.yahoo.com>
@ 2011-02-14 20:39 ` Andy Wingo
2011-02-14 22:02 ` Mark H Weaver
0 siblings, 1 reply; 5+ messages in thread
From: Andy Wingo @ 2011-02-14 20:39 UTC (permalink / raw)
To: Mark H. Weaver; +Cc: guile-devel
Hi Mark,
I saw your message and thought this should hit the list:
On Sat 12 Feb 2011 20:45, Mark Weaver <mark_weaver_45@yahoo.com> writes:
> BTW, this is all based on my experience adding new number types to
> guile. I have a local branch in which both arbitrary precision floats
> and complex numbers with arbitrary component types are implemented
> entirely in scheme, and all the core numeric procedures are
> implemented to full precision, including transcendental operations,
> and all of it passes numbers.test. Even things like the numeric type
> predicates (number?, real? et al), and eqv? and equal? work as they
> should for these numbers. I was trying to get it ready for 2.0, but
> decided to wait.
Very neat stuff!
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Miscellaneous for 2.0
2011-02-14 20:39 ` Andy Wingo
@ 2011-02-14 22:02 ` Mark H Weaver
0 siblings, 0 replies; 5+ messages in thread
From: Mark H Weaver @ 2011-02-14 22:02 UTC (permalink / raw)
To: guile-devel
Andy Wingo <wingo@pobox.com> writes:
> I saw your message and thought this should hit the list:
>
> On Sat 12 Feb 2011 20:45, Mark Weaver <WEBMAIL_ADDRESS_REMOVED> writes:
>
>> BTW, this is all based on my experience adding new number types to
>> guile. I have a local branch in which both arbitrary precision floats
>> and complex numbers with arbitrary component types are implemented
>> entirely in scheme, and all the core numeric procedures are
>> implemented to full precision, including transcendental operations,
>> and all of it passes numbers.test. Even things like the numeric type
>> predicates (number?, real? et al), and eqv? and equal? work as they
>> should for these numbers. I was trying to get it ready for 2.0, but
>> decided to wait.
>
> Very neat stuff!
Thanks, Andy. I'll post patches and write more about this soon, but for
now I don't want to distract from the 2.0 release.
BTW, please don't expect me to see anything you send to that webmail
account. I created it for emergency use only, and check it once per
blue moon, probably less.
Best,
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Miscellaneous for 2.0
@ 2011-03-01 18:55 Mark H Weaver
2011-03-08 22:46 ` Andy Wingo
0 siblings, 1 reply; 5+ messages in thread
From: Mark H Weaver @ 2011-03-01 18:55 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1: Type: text/plain, Size: 158 bytes --]
Here are a few simple patches for 2.0 which should be non-controversial.
I'd like to apply these to both stable-2.0 and master. Any objections?
Mark
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Fix bytevectors VALIDATE_REAL to test for reals, not rationals --]
[-- Type: text/x-diff, Size: 1881 bytes --]
From d8fa1a889ab3335fff2a4b468cf3e809f05d1add Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
Date: Tue, 1 Mar 2011 12:46:38 -0500
Subject: [PATCH 1/4] Fix bytevectors VALIDATE_REAL to test for reals, not rationals
Reported and fixed by Daniel Llorens <dll@bluewin.ch>.
* libguile/bytevectors.c (VALIDATE_REAL): Test for reals, not rationals.
* test-suite/tests/srfi-4.test (f32 vectors, f64 vectors): Add tests.
---
libguile/bytevectors.c | 2 +-
test-suite/tests/srfi-4.test | 10 ++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c
index f014697..a969e3b 100644
--- a/libguile/bytevectors.c
+++ b/libguile/bytevectors.c
@@ -1667,7 +1667,7 @@ double_from_foreign_endianness (const union scm_ieee754_double *source)
/* FIXME: SCM_VALIDATE_REAL rejects integers, etc. grrr */
#define VALIDATE_REAL(pos, v) \
do { \
- SCM_ASSERT_TYPE (scm_is_true (scm_rational_p (v)), v, pos, FUNC_NAME, "real"); \
+ SCM_ASSERT_TYPE (scm_is_real (v), v, pos, FUNC_NAME, "real"); \
} while (0)
/* Templace getters and setters. */
diff --git a/test-suite/tests/srfi-4.test b/test-suite/tests/srfi-4.test
index d7e5b1a..0cdfb66 100644
--- a/test-suite/tests/srfi-4.test
+++ b/test-suite/tests/srfi-4.test
@@ -352,7 +352,10 @@
(pass-if "make-f32vector"
(equal? (list->f32vector '(7 7 7 7))
- (make-f32vector 4 7))))
+ (make-f32vector 4 7)))
+
+ (pass-if "+inf.0, -inf.0, +nan.0 in f32vector"
+ (f32vector? #f32(+inf.0 -inf.0 +nan.0))))
(with-test-prefix "f64 vectors"
@@ -389,4 +392,7 @@
(pass-if "make-f64vector"
(equal? (list->f64vector '(7 7 7 7))
- (make-f64vector 4 7))))
+ (make-f64vector 4 7)))
+
+ (pass-if "+inf.0, -inf.0, +nan.0 in f64vector"
+ (f64vector? #f64(+inf.0 -inf.0 +nan.0))))
--
1.7.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: Fix description of the R6RS `finite?' in manual --]
[-- Type: text/x-diff, Size: 1937 bytes --]
From 1fe145a563def1a115db8c810b6c3446ebe94538 Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
Date: Tue, 1 Mar 2011 12:37:01 -0500
Subject: [PATCH 2/4] Fix description of the R6RS `finite?' in manual
* doc/ref/r6rs.texi (rnrs base): `(finite? x)' returns true iff x is
neither infinite nor a NaN. Previously, it stated that `finite?' was
the negation of `infinite?', which was incorrect because NaNs are
neither finite nor infinite. Combine description of 'nan?' with those
of `finite?' and `infinite?'.
---
doc/ref/r6rs.texi | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/doc/ref/r6rs.texi b/doc/ref/r6rs.texi
index c1ac541..8f89286 100644
--- a/doc/ref/r6rs.texi
+++ b/doc/ref/r6rs.texi
@@ -356,7 +356,6 @@ grouped below by the existing manual sections to which they correspond.
@deffn {Scheme Procedure} real? x
@deffnx {Scheme Procedure} rational? x
-@deffnx {Scheme Procedure} nan? x
@deffnx {Scheme Procedure} numerator x
@deffnx {Scheme Procedure} denominator x
@deffnx {Scheme Procedure} rationalize x eps
@@ -542,11 +541,15 @@ loss of numerical precision.
imaginary parts are zero.
@end deffn
-@deffn {Scheme Procedure} finite? x
+@deffn {Scheme Procedure} nan? x
@deffnx {Scheme Procedure} infinite? x
-@code{infinite?} returns @code{#t} if @var{x} is an infinite value,
-@code{#f} otherwise. @code{finite?} returns the negation of
-@code{infinite?}.
+@deffnx {Scheme Procedure} finite? x
+@code{nan?} returns @code{#t} if @var{x} is a NaN value, @code{#f}
+otherwise. @code{infinite?} returns @code{#t} if @var{x} is an infinite
+value, @code{#f} otherwise. @code{finite?} returns @code{#t} if @var{x}
+is neither infinite nor a NaN value, otherwise it returns @code{#f}.
+Every real number satisfies exactly one of these predicates. An
+exception is raised if @var{x} is not real.
@end deffn
@deffn {Scheme Syntax} assert expr
--
1.7.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: Update comments regarding GMP earlier than 4.2. --]
[-- Type: text/x-diff, Size: 3370 bytes --]
From d929345ce019187bad5184e6ff3c31693ae1dddb Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
Date: Tue, 22 Feb 2011 21:39:37 -0500
Subject: [PATCH 3/4] Update comments regarding GMP earlier than 4.2.
* libguile/numbers.c: Update comments regarding GMP earlier than 4.2.
Remove speculations about versions of GMP that had not yet been
released when the comments were written. Replace them with facts that
are now known about the changes made in GMP 4.2.
---
libguile/numbers.c | 32 ++++++++++++++++++--------------
1 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/libguile/numbers.c b/libguile/numbers.c
index b8cfa5d..be86eb5 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -134,9 +134,9 @@ static double acosh (double x) { return log (x + sqrt (x * x - 1)); }
static double atanh (double x) { return 0.5 * log ((1 + x) / (1 - x)); }
#endif
-/* mpz_cmp_d in gmp 4.1.3 doesn't recognise infinities, so xmpz_cmp_d uses
- an explicit check. In some future gmp (don't know what version number),
- mpz_cmp_d is supposed to do this itself. */
+/* mpz_cmp_d in GMP before 4.2 didn't recognise infinities, so
+ xmpz_cmp_d uses an explicit check. Starting with GMP 4.2 (released
+ in March 2006), mpz_cmp_d now handles infinities properly. */
#if 1
#define xmpz_cmp_d(z, d) \
(isinf (d) ? (d < 0.0 ? 1 : -1) : mpz_cmp_d (z, d))
@@ -316,16 +316,15 @@ scm_i_dbl2num (double u)
we need to use mpz_getlimbn. mpz_tstbit is not right, it treats
negatives as twos complement.
- In current gmp 4.1.3, mpz_get_d rounding is unspecified. It ends up
- following the hardware rounding mode, but applied to the absolute value
- of the mpz_t operand. This is not what we want so we put the high
- DBL_MANT_DIG bits into a temporary. In some future gmp, don't know when,
- mpz_get_d is supposed to always truncate towards zero.
+ In GMP before 4.2, mpz_get_d rounding was unspecified. It ended up
+ following the hardware rounding mode, but applied to the absolute
+ value of the mpz_t operand. This is not what we want so we put the
+ high DBL_MANT_DIG bits into a temporary. Starting with GMP 4.2
+ (released in March 2006) mpz_get_d now always truncates towards zero.
- ENHANCE-ME: The temporary init+clear to force the rounding in gmp 4.1.3
- is a slowdown. It'd be faster to pick out the relevant high bits with
- mpz_getlimbn if we could be bothered coding that, and if the new
- truncating gmp doesn't come out. */
+ ENHANCE-ME: The temporary init+clear to force the rounding in GMP
+ before 4.2 is a slowdown. It'd be faster to pick out the relevant
+ high bits with mpz_getlimbn. */
double
scm_i_big2dbl (SCM b)
@@ -337,7 +336,12 @@ scm_i_big2dbl (SCM b)
#if 1
{
- /* Current GMP, eg. 4.1.3, force truncation towards zero */
+ /* For GMP earlier than 4.2, force truncation towards zero */
+
+ /* FIXME: DBL_MANT_DIG is the number of base-`FLT_RADIX' digits,
+ _not_ the number of bits, so this code will break badly on a
+ system with non-binary doubles. */
+
mpz_t tmp;
if (bits > DBL_MANT_DIG)
{
@@ -353,7 +357,7 @@ scm_i_big2dbl (SCM b)
}
}
#else
- /* Future GMP */
+ /* GMP 4.2 or later */
result = mpz_get_d (SCM_I_BIG_MPZ (b));
#endif
--
1.7.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: Remove incorrect footnote from GOOPS manual --]
[-- Type: text/x-diff, Size: 1065 bytes --]
From 4c912a67e14847f3bb70fd23bdb72e768735dbb3 Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
Date: Tue, 1 Mar 2011 13:46:08 -0500
Subject: [PATCH 4/4] Remove incorrect footnote from GOOPS manual
* doc/ref/goops.texi (Inheritance): Remove footnote which incorrectly
stated that <complex> was not shown in the class hierarchy figure.
---
doc/ref/goops.texi | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/doc/ref/goops.texi b/doc/ref/goops.texi
index 95e71da..362a6e3 100644
--- a/doc/ref/goops.texi
+++ b/doc/ref/goops.texi
@@ -1104,9 +1104,7 @@ Those class definitions define a hierarchy which is shown in
@ref{fig:hier}. In this figure, the class @code{<top>} is also shown;
this class is the superclass of all Scheme objects. In particular,
@code{<top>} is the superclass of all standard Scheme
-types.@footnote{@code{<complex>}, which is the direct subclass of
-@code{<number>} and the direct superclass of @code{<real>}, has been
-omitted in this figure.}
+types.
@float Figure,fig:hier
@iftex
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Miscellaneous for 2.0
[not found] <09.78.00574.7187E6D4@mx15>
@ 2011-03-07 10:41 ` Daniel Llorens
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Llorens @ 2011-03-07 10:41 UTC (permalink / raw)
To: guile-devel
Hello list,
Any chance these patches could be committed? they seem to have been lost in the stream…
Thanks,
Daniel
On Mar 2, 2011, at 18:00, guile-devel-request@gnu.org wrote:
> 1. [PATCH] Miscellaneous for 2.0 (Mark H Weaver)
> 2. [PATCH 1/4] Fix bytevectors VALIDATE_REAL to test for reals,
> not rationals (Mark H Weaver)
> 3. [PATCH 2/4] Fix description of the R6RS `finite?' in manual
> (Mark H Weaver)
> 4. [PATCH 3/4] Update comments regarding GMP earlier than 4.2.
> (Mark H Weaver)
> 5. [PATCH 4/4] Remove incorrect footnote from GOOPS manual
> (Mark H Weaver)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Miscellaneous for 2.0
2011-03-01 18:55 [PATCH] Miscellaneous for 2.0 Mark H Weaver
@ 2011-03-08 22:46 ` Andy Wingo
0 siblings, 0 replies; 5+ messages in thread
From: Andy Wingo @ 2011-03-08 22:46 UTC (permalink / raw)
To: Mark H Weaver; +Cc: guile-devel
On Tue 01 Mar 2011 19:55, Mark H Weaver <mhw@netris.org> writes:
> I'd like to apply these to both stable-2.0 and master. Any
> objections?
Go ahead, and feel free to push trivial patches like this to
stable-2.0. They'll land on master as we merge stable-2.0 back there.
Thanks!
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-03-08 22:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-01 18:55 [PATCH] Miscellaneous for 2.0 Mark H Weaver
2011-03-08 22:46 ` Andy Wingo
[not found] <09.78.00574.7187E6D4@mx15>
2011-03-07 10:41 ` Daniel Llorens
[not found] <941810.39891.qm@web114116.mail.gq1.yahoo.com>
2011-02-14 20:39 ` Andy Wingo
2011-02-14 22:02 ` Mark H Weaver
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).