[Aldor-l] recursive polynomial
Ralf Hemmecke
ralf at hemmecke.de
Sat Jul 29 11:21:44 EDT 2006
Hello Helmut,
On 07/29/2006 04:39 PM, Preininger wrote:
> I need a recursive datastructure for a multivariate polynomial in aldor
> 1.0.2 (without algebra).
> Something like:
>
> Record(variable:String,List(Record(exponent:MachineInteger,factor:Union(%,fa
> ct:Integer))))
>
> I am not able to compile a new function, like new("x",2,5) - any idea?
If you really don't want to use libalgebra, then I would go the
following way...
---BEGIN multpol.as
#include "aldor"
define CoefCat: Category == with {...}
define RecPolCat: Category == CoefCat with {...}
define UPCat: Category == RecPolCat with {...}
UP(R: CoefCat): UPCat R == add {
Rep == Array R -- dense representation
-- or you make it like
-- ExpoCoeff == Record(ex: Integer, co: R);
-- Rep == List ExpoCoeff;
-- implement univariate polynomials here
}
RecPol(R: Coeff): RecPolCat R == UP ( RecPol R ) add;
---END multpol.as
Of course that file does not compile (because it is incomplete), but it
should if the missing details are filled in. In particular it shows, why
recursive polynomials are called recursive polynomials.
Well, there is some "minor" detail missing which I cannot solve
immediately, namely how you make the variables known. But perhaps you
should consider RecPol as a datastructure and then say:
RecursivePolynomials(R: CoefCat, vars: List Symbol): RecPolCat with {
-- some more functionality
} == RecPol R add {
-- Here you should implement your functionality and
-- also implement a nice output of a polynomial because now you know
-- how the variables are named. It is completely unnecessary to
-- store an entry "variable: String" into the datastructure as you
-- suggested above.
}
Hope that lets you go on.
Ralf
More information about the Aldor-l
mailing list