login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for Lisp's Fraction Integer Domain revision 1 of 1

1
Editor: page
Time: 2007/11/12 23:01:14 GMT-8
Note: transferred from axiom-developer.org

changed:
-
Original Date: Fri, 25 Mar 2005 12:01:44 -0600

Here is a serie of patch to enhance computation that involves fraction integer.
Do
<pre>
download gcl source, decompress this archive apply gcl.patch (this patch come from gcl-2.6.5 but can probably be applied on 2.6.6).
recompress gcl, copy it to zips directory  (keep the same name)
remove gcldir and gcl-2.6.* in lsp directory
patch the interpreter with interp.patch. (change behavior of coercion of fraction(integer))
patch fraction.spad.pamphlet (handle fraction(integer) as integer i.e by gcl)
remove mnt/linux/algebra/FRAC.o, int/algebra/FRAC.NRLIB/code.o and int/algebra/FRAC.spad
type make
remove mnt/linux/algebra/FRAC.o, int/algebra/FRAC.NRLIB/code.o and int/algebra/FRAC.spad
type touch src/algebra/fraction.spad.pamphlet or open it in an editor and resave it
type make
Have fun
</pre>

This involves one patch (gcl.patch) backported from gcl-2.7.0-cvs. It 's a request made to use algorithm from libgmp in cancellation of gcd.
Copying of this patch is GNU LIBRARY GENERAL PUBLIC LICENSE       Version 2, June 1991


<a href="gcl.patch">gcl.patch</a>


<a href="interp.patch">interp.patch</a>


<a href="fraction.patch">fraction.patch</a>


From unknown Fri Mar 25 12:06:22 -0600 2005
From: unknown
Date: Fri, 25 Mar 2005 12:06:22 -0600
Subject: How to patch
Message-ID: <20050325120622-0600@page.axiom-developer.org>

Change in root of application to patch (for example with gcl cd gcl-2.6.5) and type cat gcl.patch |patch -p0
If that doesn't work type cat gcl.patch |patch -p1
<pre>
p0 or p1 depends of your place in the tree
</pre>


From unknown Fri Mar 25 12:13:42 -0600 2005
From: unknown
Date: Fri, 25 Mar 2005 12:13:42 -0600
Subject: Timing
Message-ID: <20050325121342-0600@page.axiom-developer.org>

This patch is just a code optimization (same algorithm is used).
<br>
<pre>
  a:=matrix [[j^1/(j-i) for i in  1..50] for j in 51..100];
  a*a;
  before:    2.10 sec
  after:     0.53 sec
  factor: 0.25

  a:=matrix [[j^1/(j-i) for i in  1..50] for j in 1000000001..1000000050];
  a*a;
  before:    3.69
  after:     1.56
  factor: 0.42
</pre>
Cheers
From unknown Sat Mar 26 04:03:05 -0600 2005
From: unknown
Date: Sat, 26 Mar 2005 04:03:05 -0600
Subject: New page
Message-ID: <20050326040305-0600@page.axiom-developer.org>
In-Reply-To: <20050325191622-0600@page.axiom-developer.org>

seems that the changes to axiom only work with gcl. Is this correct? J Weiss

From unknown Sat Mar 26 06:02:15 -0600 2005
From: unknown
Date: Sat, 26 Mar 2005 06:02:15 -0600
Subject: No
Message-ID: <20050326060215-0600@page.axiom-developer.org>

Work with all implementations of common lisp. I use lisp rational. I just asked to change some algorithms (euclidean) in gcl.

From unknown Fri Mar 25 19:16:22 -0600 2005
From: unknown
Date: Fri, 25 Mar 2005 19:16:22 -0600
Subject: New page
Message-ID: <20050325191622-0600@page.axiom-developer.org>

Bill, Can you make a new page for this?
This looks strange... tested for several months.



From BillPage Sun Mar 27 12:58:23 -0600 2005
From: Bill Page
Date: Sun, 27 Mar 2005 12:58:23 -0600
Subject: Anyone can make a new page
Message-ID: <20050327125823-0600@page.axiom-developer.org>

It is not necessary to ask me to make a new page... but I did it for you
this time :)

What do you mean: "This looks strange"?

What has been "tested for several months"?

Please explain in detail.

From unknown Sun Mar 27 14:21:20 -0600 2005
From: unknown
Date: Sun, 27 Mar 2005 14:21:20 -0600
Subject: Pass all test
Message-ID: <20050327142120-0600@page.axiom-developer.org>

I have worked with this modified domain for 6 months.
<br/>
Strange : In axiom nearly all computations involve spad code. Here I use gcl.

From BillPage Sun Mar 27 16:32:03 -0600 2005
From: Bill Page
Date: Sun, 27 Mar 2005 16:32:03 -0600
Subject: What is strange?
Message-ID: <20050327163203-0600@page.axiom-developer.org>

What do you work with for 6 months? Do you mean this proposed patch?
Do you have any specific unit test programs to show that it works
properly?

Yes, Axiom library is written using spad code. Axiom itself,
including the spad compiler is written in lisp and one of the
versions of lisp that supports Axiom is GCL. This is not strange.

I wish you would take the time to explain what you are talking
about. Short sentences with no background background information
do not make any sense. I think your work deserves to be described
in detail so that other people will understand. Please provide a
detailed description.


From unknown Mon Mar 28 12:10:43 -0600 2005
From: unknown

Date: Mon, 28 Mar 2005 12:10:43 -0600
Subject: A little background
Message-ID: <20050328121043-0600@page.axiom-developer.org>

Bill and all,

While I haven't used nor fully digested the axiom related patches, the author is apparently the same individual who so helpfully suggested an improvement to GCL ratio arithmetic recently, which has been implemented in CVS head (2.7.0).  Rational arithmetic is now much faster in many regards, as GCL makes use of more functionality in the highly optimized gmp library.  The bulk of the axiom patch appears to be intended to call the lisp arithmetic functions directly - apparently the spad compilation process results in a number of layers between axiom and lisp here (not verified).  This is of course not particular to any implementation of lisp, it is just that one can at least expect significant performance advantages when GCL is the lisp.  There are still calls to cancelGcd -- perhaps it would be useful to bring forward the gmp library function GCL uses internally for this purpose.

Take care,

From unknown Thu Jun 9 11:21:04 -0500 2005
From: unknown
Date: Thu, 09 Jun 2005 11:21:04 -0500
Subject: It's alpha code
Message-ID: <20050609112104-0500@page.axiom-developer.org>

Example: (* -2147483648/2203319546073 4926328811737/4294967296) => Error: Caught fatal error [memory may be damaged]
on my machine (AMD64 (kernel 2.6.11.11 => which works around a bug in the AMD K8 CPUs.))


From BillPage Thu Jun 9 12:08:59 -0500 2005
From: Bill Page
Date: Thu, 09 Jun 2005 12:08:59 -0500
Subject: Seems to work for me...
Message-ID: <20050609120859-0500@page.axiom-developer.org>

I don't really understand your example, but this works for me:
\begin{axiom}
[-2147483648/2203319546073, 4926328811737/4294967296]
(-2147483648/2203319546073) * (4926328811737/4294967296)
\end{axiom}


From unknown Thu Jun 9 13:06:17 -0500 2005
From: unknown
Date: Thu, 09 Jun 2005 13:06:17 -0500
Subject: Come probably from the gcl.patch
Message-ID: <20050609130617-0500@page.axiom-developer.org>

With this patch on 64bits_kernel/Debian_AMD64/gcc-3.3 gcl caught a fatal error

From unknown Mon Jun 13 14:37:35 -0500 2005
From: unknown
Date: Mon, 13 Jun 2005 14:37:35 -0500
Subject: Update gcl.patch
Message-ID: <20050613143735-0500@page.axiom-developer.org>

About (* -2147483648/2203319546073 4926328811737/4294967296) bug, -2147483648 
is the MOST-NEGATIVE-FIXNUM. If we negate it, it become a bignum
and it is handled differently.
</br>
This new patch (for gcl-2.6.6) fix this bug.
For old gcl,  edit the old gcl.patch and change
<pre>
  if (type_of(y)==t_fixnum && type_of(x)==t_fixnum) 
    return make_fixnum(fix(x)/fix(y)); /* no in_place for fixnums as could be small */;
</pre>
to
<pre>
  if (type_of(x)==t_fixnum){
    if (type_of(y)==t_fixnum)
       return make_fixnum(fix(x)/fix(y)); /* no in_place for fixnums as could be small */;
    // ABS (MOST-NEGATIVE-FIXNUM) => BIGNUM
    return make_fixnum(-1);
  }
</pre>
in integer_exact_quotient function.

<a href="gcl-2.6.6.rationals.patch">gcl-2.6.6.rationals.patch</a>


From unknown Tue Jun 14 09:25:19 -0500 2005
From: unknown
Date: Tue, 14 Jun 2005 09:25:19 -0500
Subject: Update gcl.patch
Message-ID: <20050614092519-0500@page.axiom-developer.org>

This is correct -- equivalent being committed to CVS head.

Take care,
Camm Maguire			     			camm@enhanced.com
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah


From gregr Mon Aug 15 08:43:01 -0500 2005
From: gregr
Date: Mon, 15 Aug 2005 08:43:01 -0500
Subject: Typo error in interp.patch
Message-ID: <20050815084301-0500@page.axiom-developer.org>

There was a typo error in interp.patch.
Corrected in this new patch.

<a href="interp.patch2">interp.patch2</a>


Original Date: Fri, 25 Mar 2005 12:01:44 -0600

Here is a serie of patch to enhance computation that involves fraction integer. Do

download gcl source, decompress this archive apply gcl.patch (this patch come from gcl-2.6.5 but can probably be applied on 2.6.6).
recompress gcl, copy it to zips directory  (keep the same name)
remove gcldir and gcl-2.6.* in lsp directory
patch the interpreter with interp.patch. (change behavior of coercion of fraction(integer))
patch fraction.spad.pamphlet (handle fraction(integer) as integer i.e by gcl)
remove mnt/linux/algebra/FRAC.o, int/algebra/FRAC.NRLIB/code.o and int/algebra/FRAC.spad
type make
remove mnt/linux/algebra/FRAC.o, int/algebra/FRAC.NRLIB/code.o and int/algebra/FRAC.spad
type touch src/algebra/fraction.spad.pamphlet or open it in an editor and resave it
type make
Have fun

This involves one patch (gcl.patch) backported from gcl-2.7.0-cvs. It 's a request made to use algorithm from libgmp in cancellation of gcd. Copying of this patch is GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991

gcl.patch

interp.patch

fraction.patch

How to patch --unknown, Fri, 25 Mar 2005 12:06:22 -0600 reply
Change in root of application to patch (for example with gcl cd gcl-2.6.5) and type cat gcl.patch |patch -p0 If that doesn't work type cat gcl.patch |patch -p1
p0 or p1 depends of your place in the tree

This patch is just a code optimization (same algorithm is used).
  a:=matrix [[j^1/(j-i) for i in  1..50] for j in 51..100];
  a*a;
  before:    2.10 sec
  after:     0.53 sec
  factor: 0.25

a:=matrix [[j^1/(j-i) for i in 1..50] for j in 1000000001..1000000050]; a*a; before: 3.69 after: 1.56 factor: 0.42

Cheers

seems that the changes to axiom only work with gcl. Is this correct? J Weiss

Work with all implementations of common lisp. I use lisp rational. I just asked to change some algorithms (euclidean) in gcl.

Bill, Can you make a new page for this? This looks strange... tested for several months.

Anyone can make a new page --Bill Page, Sun, 27 Mar 2005 12:58:23 -0600 reply
It is not necessary to ask me to make a new page... but I did it for you this time :)

What do you mean: "This looks strange"?

What has been "tested for several months"?

Please explain in detail.

Pass all test --unknown, Sun, 27 Mar 2005 14:21:20 -0600 reply
I have worked with this modified domain for 6 months.
Strange : In axiom nearly all computations involve spad code. Here I use gcl.

What is strange? --Bill Page, Sun, 27 Mar 2005 16:32:03 -0600 reply
What do you work with for 6 months? Do you mean this proposed patch? Do you have any specific unit test programs to show that it works properly?

Yes, Axiom library is written using spad code. Axiom itself, including the spad compiler is written in lisp and one of the versions of lisp that supports Axiom is GCL. This is not strange.

I wish you would take the time to explain what you are talking about. Short sentences with no background background information do not make any sense. I think your work deserves to be described in detail so that other people will understand. Please provide a detailed description.

... --unknown, None reply
Date: Mon, 28 Mar 2005 12:10:43 -0600 Subject: A little background Message-ID: <20050328121043-0600@page.axiom-developer.org>

Bill and all,

While I haven't used nor fully digested the axiom related patches, the author is apparently the same individual who so helpfully suggested an improvement to GCL ratio arithmetic recently, which has been implemented in CVS head (2.7.0). Rational arithmetic is now much faster in many regards, as GCL makes use of more functionality in the highly optimized gmp library. The bulk of the axiom patch appears to be intended to call the lisp arithmetic functions directly - apparently the spad compilation process results in a number of layers between axiom and lisp here (not verified). This is of course not particular to any implementation of lisp, it is just that one can at least expect significant performance advantages when GCL is the lisp. There are still calls to cancelGcd
perhaps it would be useful to bring forward the gmp library function GCL uses internally for this purpose.

Take care,

It's alpha code --unknown, Thu, 09 Jun 2005 11:21:04 -0500 reply
Example: (* -2147483648/2203319546073 4926328811737/4294967296) => Error: Caught fatal error [memory may be damaged]? on my machine (AMD64 (kernel 2.6.11.11 => which works around a bug in the AMD K8 CPUs?.))

Seems to work for me... --Bill Page, Thu, 09 Jun 2005 12:08:59 -0500 reply
I don't really understand your example, but this works for me:
fricas
[-2147483648/2203319546073, 4926328811737/4294967296]

\label{eq1}\left[ -{{2147483648}\over{2203319546073}}, \:{{4926328811737}\over{4
294967296}}\right](1)
Type: List(Fraction(Integer))
fricas
(-2147483648/2203319546073) * (4926328811737/4294967296)

\label{eq2}-{{4926328811737}\over{4406639092146}}(2)
Type: Fraction(Integer)

Come probably from the gcl.patch --unknown, Thu, 09 Jun 2005 13:06:17 -0500 reply
With this patch on 64bits_kernel/Debian_AMD64/gcc-3.3 gcl caught a fatal error

Update gcl.patch --unknown, Mon, 13 Jun 2005 14:37:35 -0500 reply
About (* -2147483648/2203319546073 4926328811737/4294967296) bug, -2147483648 is the MOST-NEGATIVE-FIXNUM. If we negate it, it become a bignum and it is handled differently.
This new patch (for gcl-2.6.6) fix this bug. For old gcl, edit the old gcl.patch and change
  if (type_of(y)==t_fixnum && type_of(x)==t_fixnum) 
    return make_fixnum(fix(x)/fix(y)); / no in_place for fixnums as could be small /;
to
  if (type_of(x)==t_fixnum){
    if (type_of(y)==t_fixnum)
       return make_fixnum(fix(x)/fix(y)); / no in_place for fixnums as could be small /;
    // ABS (MOST-NEGATIVE-FIXNUM) => BIGNUM
    return make_fixnum(-1);
  }
in integer_exact_quotient function.

gcl-2.6.6.rationals.patch

Update gcl.patch --unknown, Tue, 14 Jun 2005 09:25:19 -0500 reply
This is correct
equivalent being committed to CVS head.

Take care, Camm Maguire camm@enhanced.com ========================================================================== "The earth is but one country, and mankind its citizens." -- Baha'u'llah

Typo error in interp.patch --gregr, Mon, 15 Aug 2005 08:43:01 -0500 reply
There was a typo error in interp.patch. Corrected in this new patch.

interp.patch2