Subject: Adding new object types WAS: Operations on inf
From: Richard Fateman
Date: Sun, 11 Mar 2007 10:51:26 -0700
OK, to clarify the generic stuff, since no one seems to have read what I
wrote in lisp...
1. If you have arithmetic to do on objects a,b,c in a sum, Convert a+b+c
(etc) to (a+b)+c.
2. Define a set of operations. In this case,
(defmethod two-arg-+ ((x integer) (y integer)) (+ x y)) ;; just add 2
integers
(defmethod two-arg-+ ((x integer) (y bigfloat)) (bfloat-+ (into-bigfloat x)
y) ; convert integer to bigfloat
This can take a while to do. It can be made more compact by inheritance. If
you are lucky enough to have a good hierarchy. We don't. Consider
bigfloats, rationals, integers, intervals, inf, und, complex [of what?]
Symbols, CRE forms, matrices, 1X1 matrices, expressions like radicals, trig,
log.
You also have to define *, -, /, zero, one, min, max, =, >, and conversion
functions such as round, truncate, ... and where appropriate,
Sin cos tan log exp atan etc. And for some domains like intervals,
contains, excludes, overlaps..., definitely greater.
I think this sort of gets about 1/3 of where Axiom is going. (The other 2/3
has to do with associating algebraic categories and associated properties
and theorems with such things.) Finding out what Axiom does with inf and und
might be more useful; my guess is it does several possible things, depending
on the context.
RJF