Re: languages for CAS .. was: Re: Which is the best CAS
- From: hrubin@xxxxxxxxxxxxxxxxxxxx (Herman Rubin)
- Date: 21 May 2009 15:18:08 -0400
In article <d9octovobd.fsf@xxxxxxxxxxxxxxxxxxxxxxxxx>,
Martin Rubey <axiomize@xxxxxxxx> wrote:
hrubin@xxxxxxxxxxxxxxxxxxxx (Herman Rubin) writes:
Eg., you find that there is a default implementation of the Euclidean
algorithm in the "Category" (warning: category is not used in the
mathematical sense here. In SPAD, it rather means something like
"interface"):
EuclideanDomain(): Category == PrincipalIdealDomain with
--operations
<snip>
"rem": (%,%) -> %
++ x rem y is the same as \spad{divide(x,y).remainder}.
++ See \spadfunFrom{divide}{EuclideanDomain}.
<snip>
add
x,y: %
<snip>
gcd(x,y) == --Euclidean Algorithm
x := unitCanonical x
y := unitCanonical y
while not zero? y repeat
(x,y) := (y,x rem y)
y := unitCanonical y -- this doesn't affect the
-- correctness of Euclid's algorithm,
-- but
-- a) may improve performance
-- b) ensures gcd(x,y)=gcd(y,x)
-- if canonicalUnitNormal
x
I can guess what most of this means, but it fails the
test of a clear concise notation. The equivalent in
C or Fortran is easier to understand.
I'd be interested, could you provide the equivalent in C or Fortran? (I
don't know Fortran at all, so maybe C would be better...)
I do not know the C notation for remainder, so I will
use %% for it. Also, my C may be a little rusty.
u = x; v = y;
while (){w = u%%v;
if(w ==0) {return v; exit}
u = v; v = w}
No; I mean that if a function produced three appropriately
designated outputs, they are stored as convenient. For
example, if one wants to get the exponent and the normalized
mantissa of a float, the way to write it would be
(xp, man) = unpack(x).a
SPAD (well, to tell the truth: Aldor, the successor of SPAD) can do
exactly this. (Except that Aldor uses := for assignment...)
Martin
--
This address is for information only. I do not claim that these views
are those of the Statistics Department or of Purdue University.
Herman Rubin, Department of Statistics, Purdue University
hrubin@xxxxxxxxxxxxxxx Phone: (765)494-6054 FAX: (765)494-0558
.
- Follow-Ups:
- Re: languages for CAS .. was: Re: Which is the best CAS
- From: Waldek Hebisch
- Re: languages for CAS .. was: Re: Which is the best CAS
- References:
- Which is the best CAS
- From: Francogrex
- Re: languages for CAS .. was: Re: Which is the best CAS
- From: Martin Rubey
- Re: languages for CAS .. was: Re: Which is the best CAS
- From: Herman Rubin
- Re: languages for CAS .. was: Re: Which is the best CAS
- From: Martin Rubey
- Which is the best CAS
- Prev by Date: Re: languages for CAS .. was: Re: Which is the best CAS
- Next by Date: Re: languages for CAS .. was: Re: Which is the best CAS
- Previous by thread: Re: languages for CAS .. was: Re: Which is the best CAS
- Next by thread: Re: languages for CAS .. was: Re: Which is the best CAS
- Index(es):
Relevant Pages
|