Re: languages for CAS .. was: Re: Which is the best CAS



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
.



Relevant Pages

  • Re: An example of a complete but undecidable theory
    ... >there is an algorithm for determining, for any sentence A, whether or ... set of numbers which correspond to the negation of a theorem ... are those of the Statistics Department or of Purdue University. ... Herman Rubin, Department of Statistics, Purdue University ...
    (sci.math)
  • Re: An example of a complete but undecidable theory
    ... >there is an algorithm for determining, for any sentence A, whether or ... set of numbers which correspond to the negation of a theorem ... are those of the Statistics Department or of Purdue University. ... Herman Rubin, Department of Statistics, Purdue University ...
    (sci.logic)
  • Re: Exchange algorithm (Remez or Parks-McClellan)
    ... are those of the Statistics Department or of Purdue University. ... Herman Rubin, Department of Statistics, Purdue University ... minimax polynomial approximations up to 8 parameters and degree 15 ... regression with my algorithm posted above. ...
    (sci.math.num-analysis)
  • Re: question: random number in residue number representation
    ... I saw in a paper that r can be generated in residue ... algorithm. ... are those of the Statistics Department or of Purdue University. ... Herman Rubin, Department of Statistics, Purdue University ...
    (sci.crypt)
  • Re: Why to call it pseudorandom?
    ... predictive power when tested against the algorithm. ... I do not claim that these views are those of the Statistics Department or of Purdue University. ...
    (sci.math)