[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-math] Re: [Axiom-mail] Dynamically constructed return types
From: |
Stephen Wilson |
Subject: |
Re: [Axiom-math] Re: [Axiom-mail] Dynamically constructed return types |
Date: |
Fri, 7 Jan 2005 13:47:57 -0500 |
User-agent: |
Mutt/1.5.6+20040907i |
Martin, Marcus,
On Fri, Jan 07, 2005 at 07:08:26PM +0100, Martin Rubey wrote:
> example. I started to make your example below compile, due to lack of time I
> took a shortcut -- I hope I captured the essential. (I couldn't get taylorRep
> to work)
I took a stab at this as well, but a few other things pushed this
issue onto the back-burner for now. Here is the modified package code
I came up with to investigate the problem. Perhaps it can be of use to
you.
======================================================================
SUP ==> SparseUnivariatePolynomial
UTS ==> UnivariateTaylorSeries
SAE ==> SimpleAlgebraicExtension
utsRep ==> Record(expon:I,ps:UTS)
)abbrev package FOO Foo
Foo(K: CommutativeRing, ULS: UnivariateLaurentSeriesCategory K):
Exports == Implementation where
Exports == with
f: ULS -> Any
Implementation == add
taylorRep(x: ULS): UTS(K, variable x, center x) ==
(x pretend Record(expon:Integer,
ps:UTS(K,variable x, center x))).ps
f(x:ULS): Any ==
-- Compute some equation over K.
eq := monomial(1,2)$SUP(K) _
- monomial(first coefficients taylorRep x, 0)$SUP(K)
-- Create an extension L of K.
L := SimpleAlgebraicExtension(K, SUP K, eq)
-- Create and return a new Laurent series over L.
-- The 'zero' variable is necessary due to a compiler bug...
zero := 0::L
z := "z"::Symbol
TS := UnivariateTaylorSeries(L,z,zero)
LS := UnivariateLaurentSeries(L,z,zero)
y := map(#1::L, coefficients taylorRep x)$StreamFunctions2(K,L)
coerce(laurent(-2, series(y)$TS)$LS)$AnyFunctions1(LS)
======================================================================
btw, I dont feel this is a weakness in axioms static typing (its not
really static since we can produce new types at runtime). In my mind,
it is more a weakness w.r.t axioms ability express dependent
signatures. If we could write things like:
SAE ==> SimpleAlgebraicExtension
f: (ULS, eq: SUP) -> SAE(K, SUP K, eq)
Then we would could write this kind of function without the loss of
type information.
Sincerely,
Steve
[Axiom-math] Re: [Axiom-mail] Dynamically constructed return types, Marcus Better, 2005/01/10
- Message not available
- Message not available