Hi Waldek,

before I commit, I decided to change the patch. See new attached patch.

I basically moved the export from UnivariateLaurentConstructorCategory
to UnivariateLaurentSeriesCategory. The latter is a parent category of
the former and completely sufficient to export

    laurent : (I, Stream Coef) -> %
      ++ \spad{laurent(n, st)} returns \spad{xn * series st)} where
      ++ \spad{xn = monomial(1, n)} and \spad{series st} stands for
      ++ the power series with coefficients given by the stream st.

I could even give a default implementation in that category. Maybe, it's
not the most efficient (so I kept the default implementation in the
UnivariateLaurentConstructorCategory). The question arises here, which
of the two default implementations the compiler will choose.

Can I at least assume that the (default) implementation of a function in
a more specific category (here UnivariateLaurentConstructorCategory)
overrides the default implementation of the same function from a parent
category?

Ralf

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
>From d52af318c7098e989a5e7dea1448b9b5e9ee80a7 Mon Sep 17 00:00:00 2001
From: Ralf Hemmecke <[email protected]>
Date: Tue, 10 Feb 2015 00:16:03 +0100
Subject: laurent stream

---
 src/algebra/Makefile.in  |  3 ++-
 src/algebra/laurent.spad |  3 ++-
 src/algebra/pscat.spad   | 12 +++++++++++-
 src/algebra/suls.spad    |  2 +-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/algebra/Makefile.in b/src/algebra/Makefile.in
index 4141165..74d183b 100644
--- a/src/algebra/Makefile.in
+++ b/src/algebra/Makefile.in
@@ -354,7 +354,8 @@ CATDOMS= A1AGG ABELGRP ABELMON ABELSG ACF ACFS AGG ALGEBRA AMR ARR2CAT \
         RCAGG RCFIELD RETFROM RETRACT RING RMATCAT RNG \
         RNS RPOLCAT RRCC RSETCAT \
         SETAGG SETCAT SGROUP SMATCAT SPTCAT SRAGG STAGG TBAGG TENSPC TRANFUN \
-        TRIGCAT TSEREXP TSETCAT UFD ULSCCAT UPOLYC UPSCAT UPXSCCA URAGG \
+        TRIGCAT TSEREXP TSETCAT UFD \
+        ULSCAT ULSCCAT UPOLYC UPSCAT UPXSCCA URAGG \
         UTSCAT VECTCAT VSPACE XF
 
 EXTRASPADS=BPADIC BPADICRT COMMONOP GALUTIL MKFLCFN PADIC PADICRAT \
diff --git a/src/algebra/laurent.spad b/src/algebra/laurent.spad
index 2096967..ae86ca9 100644
--- a/src/algebra/laurent.spad
+++ b/src/algebra/laurent.spad
@@ -69,6 +69,7 @@ UnivariateLaurentSeriesConstructorCategory(Coef, UTS) : _
     zero? x == zero? taylorRep x
     retract(x : %) : UTS == taylor x
     retractIfCan(x:%):Union(UTS,"failed") == taylorIfCan x
+    laurent(n: I, st: Stream Coef): % == laurent(n, series(st)$UTS)
 
 )abbrev domain ULSCONS UnivariateLaurentSeriesConstructor
 ++ Authors: Bill Burge, Clifton J. Williamson
@@ -122,7 +123,7 @@ UnivariateLaurentSeriesConstructor(Coef, UTS) : _
 
 --% creation and destruction
 
-    laurent(n, psr) == [n, psr]
+    laurent(n: I, psr: UTS): % == [n, psr]
     taylorRep x    == getUTS x
     degree x       == getExpon x
 
diff --git a/src/algebra/pscat.spad b/src/algebra/pscat.spad
index 1fb9e7a..6b1a95e 100644
--- a/src/algebra/pscat.spad
+++ b/src/algebra/pscat.spad
@@ -412,6 +412,10 @@ UnivariateLaurentSeriesCategory(Coef) : Category == Definition where
       ++ \spad{series(st)} creates a series from a stream of non-zero terms,
       ++ where a term is an exponent-coefficient pair.  The terms in the
       ++ stream should be ordered by increasing order of exponents.
+    laurent : (I, Stream Coef) -> %
+      ++ \spad{laurent(n, st)} returns \spad{xn * series st)} where
+      ++ \spad{xn = monomial(1, n)} and \spad{series st} stands for
+      ++ the power series with coefficients given by the stream st.
     multiplyCoefficients : (I -> Coef, %) -> %
       ++ \spad{multiplyCoefficients(f, sum(n = n0..infinity, a[n] * x^n)) =
       ++ sum(n = 0..infinity, f(n) * a[n] * x^n)}.
@@ -453,7 +457,13 @@ UnivariateLaurentSeriesCategory(Coef) : Category == Definition where
     if Coef has Field then Field
         --++ Univariate Laurent series over a field form a field.
         --++ In fact, K((x)) is the quotient field of K[[x]].
-
+   add
+    laurentTerms(n: I, st: Stream Coef): Stream Term == delay
+        empty? st => empty()$Stream(Term)
+        c: Coef := frst st
+        zero? c => laurentTerms(n+1, rst st)
+        concat([n, c], laurentTerms(n+1, rst st))
+    laurent(n: I, st: Stream Coef): % == series laurentTerms(n, st)
 
 )abbrev category UPXSCAT UnivariatePuiseuxSeriesCategory
 ++ Author: Clifton J. Williamson
diff --git a/src/algebra/suls.spad b/src/algebra/suls.spad
index 2538981..32d1365 100644
--- a/src/algebra/suls.spad
+++ b/src/algebra/suls.spad
@@ -73,7 +73,7 @@ SparseUnivariateLaurentSeries(Coef, var, cen) : Exports == Implementation where
 
     retractIfCan(x:%):Union(SUTS,"failed") == taylorIfCan x
 
-    laurent(n, uts) == monomial(1, n) * (uts :: %)
+    laurent(n: I, uts: SUTS): % == monomial(1, n) * (uts :: %)
 
     removeZeroes uls    == uls
     removeZeroes(n, uls) == uls
-- 
2.1.0

Reply via email to