On 06/16/2015 10:18 AM, Abhinav Baid wrote:
> So, here for the left factor, the coefficient of d^0 is 0. Hence, the
> corresponding stream of coefficients should be empty.
> But, for some reason, the stream of coefficients/Laurent series st (that
> is equal to [0, 0, 0, ..] of the part of the operator d^0 does not
> satisfy eq?(st, rst st) and the my_map function goes into an infinite
> loop without the extra parallel iterator i that I added but should not
> be present ideally. Please see lines 289-329 for what I mean. Could you
> please suggest a solution?

Of course, it is to be expected that it is (in general) impossible to
compare to streams.

eq?(st, rst st) is actually a trick that relies on a circular structure
of the underlying linked data structure.

Unfortunately, I don't see a clear specification of what my_map should
actually do, so I cannot even say that there is a bug or not. I don't
like guessing.

>From what I see in the while loop of my_map, you seem to rely on the
fact that the Laurent series 0 is always represented by the empty
stream. That is not the case.

Look at this...

(1) -> L ==> UnivariateLaurentSeries(Fraction Integer, 'x, 0)
                                                                   Type:
Void
(2) -> x: L := 'x

   (2)  x
                         Type:
UnivariateLaurentSeries(Fraction(Integer),x,0)
(3) -> l1 := 1+x

   (3)  1 + x
                         Type:
UnivariateLaurentSeries(Fraction(Integer),x,0)
(4) -> z := l1 -l1

   (4)  0
                         Type:
UnivariateLaurentSeries(Fraction(Integer),x,0)
(5) -> z := l1 -l1

   (5)  0
                         Type:
UnivariateLaurentSeries(Fraction(Integer),x,0)
(6) -> empty?(terms z)

   (6)  []
                        Type: Stream(Record(k: Integer,c:
Fraction(Integer)))
(7) -> empty?(terms z)

   (7)  true
                                                                Type:
Boolean
(8) -> l2 := 1/l1

                 2    3    4    5    6    7    8    9    10      11
   (8)  1 - x + x  - x  + x  - x  + x  - x  + x  - x  + x   + O(x  )
                         Type:
UnivariateLaurentSeries(Fraction(Integer),x,0)
(9) -> z2 := l2 -l2

           21
   (9)  O(x  )
                         Type:
UnivariateLaurentSeries(Fraction(Integer),x,0)
(10) -> empty?(terms z2)

The last test for emptyness runs (of course) forever.
Testing emptyness of the stream should only be done if you can make sure
in advance that this test will ever stop.

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.

Reply via email to