Would the attached test be enough?

Ralf

On 11/28/23 01:15, hebisch wrote:
On Mon, Nov 27, 2023 at 01:43:50PM -0800, Ralf Hemmecke wrote:


https://github.com/fricas/fricas/pull/143.patch
https://github.com/fricas/fricas/pull/143.diff

Change looks good.  But we should also add tests.


--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/126548ff-2982-436f-b01e-6ba08120aeae%40hemmecke.org.
From a8000441ed52274f5592ee2486749a31c64d2ade Mon Sep 17 00:00:00 2001
From: Ralf Hemmecke <[email protected]>
Date: Mon, 27 Nov 2023 22:34:20 +0100
Subject: fix issue #142

The problem is independent of ")set stream calc 1".
It just happened to be hidden.

Before this commit the code below resulted in the values 0, 5, 3
for the last 3 commands.

ZZ ==> Integer
SULS ==> SparseUnivariateLaurentSeries(ZZ, 'q, 0)
Rec ==> Record(k: ZZ, c: ZZ)
S ==> Stream Rec
st := cons([0,3]$Rec, cons([1,5]$Rec, cons([2,7]$Rec,empty()$S)))$S
s := series(st)$SULS;
i x ==> x pretend InnerSparseUnivariatePowerSeries ZZ
explicitEntries?(getStream i s)
getRef i s
coefficient(s,0)
coefficient(s,1)
coefficient(s,0)
---
 src/algebra/sups.spad    | 2 +-
 src/input/bugs2023.input | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/algebra/sups.spad b/src/algebra/sups.spad
index 922eb0f2..78e99d03 100644
--- a/src/algebra/sups.spad
+++ b/src/algebra/sups.spad
@@ -215,7 +215,7 @@ InnerSparseUnivariatePowerSeries(Coef) : Exports == Implementation where
 
     series(x : ST) ==
       empty? x => 0
-      n := getExpon frst x; refer := ref(n :: COM)
+      n := getExpon frst x; refer := ref((n-1) :: COM)
       makeSeries(refer, iSeries(x, refer))
 
 --% values
diff --git a/src/input/bugs2023.input b/src/input/bugs2023.input
index f5bd1201..f60c37ed 100644
--- a/src/input/bugs2023.input
+++ b/src/input/bugs2023.input
@@ -110,4 +110,8 @@ testcase "polynomial roots"
 
 testEquals("rootSimp((4*a^6)^(1/4))", "a*sqrt(2*a)")
 
+testcase "initial coefficients of sparse univariate power series"
+
+testEquals("st:=[[n,n+42]@Record(k:INT,c:INT) for n in 0..];s:=series(st)$InnerSparseUnivariatePowerSeries(INT);coefficient(s,0)", "42")
+
 statistics()
-- 
2.34.1

Reply via email to