[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-mail] Dynamically constructed return types
From: |
Marcus Better |
Subject: |
[Axiom-mail] Dynamically constructed return types |
Date: |
Tue, 04 Jan 2005 15:47:21 +0100 |
User-agent: |
Mozilla Thunderbird 0.9 (X11/20041124) |
Hi all,
I got stuck trying to write a spad function that will take an argument
of a certain type T, construct from this some other type S, and return
an object of type S. I am using the "Any" type to do this, but I have a
problem extracting and using the type and object encapsulated in the Any
object.
Here is a simplified example (yes, Laurent series again!): The function
f takes a univariate Laurent series over the domain K, performs some
calculation, constructs a domain L which is a SimpleAlgebraicExtension
of K (whose defining equation depends on the computed values). The
function then returns some other Laurent series over L.
This is some sample code. (It is not tested, I just removed the
irrelevant parts of my code.)
----------------------------------------------------------------
)abbrev package FOO Foo
Foo(K: CommutativeRing, ULS: UnivariateLaurentSeriesCategory K):
Exports == Implementation where
Exports ==> with
f: ULS -> Any
Implementation ==>
f(x) ==
-- 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
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)
----------------------------------------------------------------------
Now, how can the caller of f retrieve the domain L and, say, extract the
first coefficient of the returned series y?
Regards,
Marcus
PS. Please CC me with any replies, I am not subscribed to the mailing lists.
--
-----------------------------------------------------------------
Marcus Better
Department of Mathematics Tel. +46 8 164539
Stockholm University Fax +46 8 6126717
SE-106 91 Stockholm
Sweden http://www.math.su.se
-----------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Axiom-mail] Dynamically constructed return types,
Marcus Better <=