axiom-math
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-math] Re: [Axiom-mail] Dynamically constructed return types


From: Marcus Better
Subject: [Axiom-math] Re: [Axiom-mail] Dynamically constructed return types
Date: Mon, 10 Jan 2005 19:21:17 +0100
User-agent: Mozilla Thunderbird 0.9 (X11/20041124)

Martin,

Aldor is not that much of a problem: the languages are nearly identical.

Ok, I might give it a try then, once they fix their download page (the link to the Linux binary is broken).

 > Perhaps I will just inline the functions, and do without function calls.

To be precise: I unrolled the function calls, replacing them with the function's code inlined. That means replacing recursive function calls with iteration, which is uglier.

Unfortunately it still won't compile, but I hope this is just a matter of correct syntax. Here is the code, I would be grateful if someone can give me a hint:

-------------------------------------------------------------------
)abbrev package LOCPARM LocalParam
LocalParam: Exports == Implementation where
  INT    ==> Integer
  POSINT ==> PositiveInteger
  NNI    ==> NonNegativeInteger
  UTS    ==> UnivariateTaylorSeries
  ULS    ==> UnivariateLaurentSeries
  SUP    ==> SparseUnivariatePolynomial
  ANY1   ==> AnyFunctions1

  Exports ==> with

    localParam: (POSINT, NNI) -> Any

  Implementation ==> add

    localParam(p, n) ==
      K := Fraction Polynomial(PrimeField p)
      -- The zero variable is used here due to a compiler bug
      zero := 0::K
      var := new()$Symbol
      LS := ULS(K, var, zero)
      x := monomial(1, -1)$LS
      for i in 1..n repeat
        a := new()$Symbol
        b := new()$Symbol
        rhs := a::LS*x + b::LS*x**3

        f := coefficients taylorRep rhs
        d := degree rhs
        -- Reduce the pole to minimal possible order.
        while negative? d and zero? (d rem p) repeat
          eq := monomial(1,p)$SUP(K) - monomial(first f, 0)$SUP(K)
          L := SimpleAlgebraicExtension(K, SUP K, eq)
          f1 := map(#1::L, f)$StreamFunctions2(K,L)
          -- subtract w^p-w from f1
          f1.1 := 0
          j := 1 + (d quo p) - d
          f1.j := f1.j + (basis()$L).p
          while (negative? d and zero? first f1) repeat
            f1 := rest f1
            d := d+1
          f: Stream L := f1
          K := L
-------------------------------------------------------------

Explanation: I have a ring K. I create another ring L which is a SimpleAlgebraicExtension of K. I then want to replace K with L and iterate. But Axiom won't allow the assignment K:=L.

The while loop would have been replaced with a recursive function in my original attempt, if Axiom had allowed it.

(This code will also need a coercion of the return value to Any before it compiles correctly, but never mind...)

I get the following compiler error:
------------------------------------------------
       ....stuff removed here
     (|exit| 1 | << | (LET K L) | >> |))
****** level 3  ******
$x:= (LET K L)
$m:= NoValueMode
$f:=
((((|f| # # #) (|d| # #) (|f1| # #) (#:G1496 #) ...)))

   >> Apparent user error:
   Cannot coerce L
      of mode (MonogenicAlgebra K (SparseUnivariatePolynomial K))
to mode (Join (QuotientFieldCategory (Polynomial (PrimeField p))) (CATEGORY package (IF (has (Polynomial (PrimeField p)) (IntegerNumberSystem)) (IF (has (Polynomial (PrimeField p)) (OpenMath)) (ATTRIBUTE (OpenMath)) noBranch) noBranch) (IF (has (Polynomial (PrimeField p)) (ATTRIBUTE canonical)) (IF (has (Polynomial (PrimeField p)) (GcdDomain)) (IF (has (Polynomial (PrimeField p)) (ATTRIBUTEcanonicalUnitNormal)) (ATTRIBUTE canonical) noBranch) noBranch) noBranch)))
------------------------------------------------

Which is understandable. I suppose the variable K needs to be cleared somehow.

Marcus




reply via email to

[Prev in Thread] Current Thread [Next in Thread]