Dear all,

sorry about the noise.  I have to stop now, here is what I got so far.  The
patch below shows how that we need to explicitely trap errors outside the
calculation of the function, these are mostly calculations of length.

However, sin(1/x)*exp(-1/x) will not be drawn nicely with this patch, even with
clipping on.  If we pass adaptive==false, then we get a plot, though.

I think that it should be possible to get an image even with adaptive==true,
but I have no time to analyse the adaptivePlot algorithm.  Probably one also
needs to analyse the clipping algorithm.

This patch does not fix the issue with

g:DFLOAT->DFLOAT := x +-> 10^300
draw(g, -1..1)

taking forever.  Possibly this is an issue of the plotting routines (written in
C) themselves.


Martin


Index: plot.spad.pamphlet
===================================================================
--- plot.spad.pamphlet  (revision 419)
+++ plot.spad.pamphlet  (working copy)
@@ -279,8 +279,11 @@
       [ f, [nRange,xRange,yRange], c, q]
 
     adaptivePlot(curve,tRange,xRange,yRange,pixelfraction) ==
+      output("adaptivePlot")$OutputPackage
       xDiff := hi xRange - lo xRange
+      output(xDiff::OutputForm)$OutputPackage
       yDiff := hi yRange - lo yRange
+      output(yDiff::OutputForm)$OutputPackage
       xDiff = 0 or yDiff = 0 => curve
       l := lo tRange; h := hi tRange
       (tDiff := h-l) = 0 => curve
@@ -316,6 +319,7 @@
       todo1 := todot; todo2 := todop
       n : I := 0
       while not null todo1 repeat
+        output("adaptivePlot: while")$OutputPackage
         st := first(todo1)
         t0 := first(st); t1 := second(st); t2 := third(st)
         if t2 > h then leave
@@ -329,8 +333,18 @@
         x2 := xCoord third(sp); y2 := yCoord third(sp)
         a1 := (x1-x0)/xDiff; b1 := (y1-y0)/yDiff
         a2 := (x2-x1)/xDiff; b2 := (y2-y1)/yDiff
-        s1 := sqrt(a1**2+b1**2); s2 := sqrt(a2**2+b2**2)
-        dp := a1*a2+b1*b2
+        output("adaptivePlot: norms")$OutputPackage
+        output(a1::OutputForm)$OutputPackage
+        output(a2::OutputForm)$OutputPackage
+        output(b1::OutputForm)$OutputPackage
+        output(b2::OutputForm)$OutputPackage
+        s1Safe := trapNumericErrors(sqrt(a1**2+b1**2))$Lisp::Union(F,
"failed")
+        if s1Safe case "failed" then s1 := max()$F else s1 := s1Safe::F
+        s2Safe := trapNumericErrors(sqrt(a2**2+b2**2))$Lisp::Union(F,
"failed")
+        if s2Safe case "failed" then s2 := max()$F else s2 := s2Safe::F
+        dpSafe := trapNumericErrors(a1*a2+b1*b2)$Lisp::Union(F, "failed")
+        if dpSafe case "failed" then dp := max()$F else dp := dpSafe::F
+        output("adaptivePlot: norms done")$OutputPackage
 
         s1 < maxLength and s2 < maxLength and _
           (s1 = 0::F or s2 = 0::F or
@@ -387,6 +401,7 @@
           todo1 := rest todo1
           todo2 := rest todo2
           if not null todo1 then (t := first(todo1); p := first(todo2))
+      output("adaptivePlot: while finished")$OutputPackage
       n > 0 =>
         NUMFUNEVALS := NUMFUNEVALS + n
         t := curve.knots; p := curve.points
@@ -512,6 +527,7 @@
       p
 
     pointPlot(f:F -> P,tRange:R) ==
+      output("pointPlot1")$OutputPackage
       p := basicPlot(f,tRange)
       r := p.ranges
       NUMFUNEVALS := minPoints()
@@ -521,6 +537,7 @@
       [ true, rest r, r, nil(), [ p ] ]
 
     pointPlot(f:F -> P,tRange:R,xRange:R,yRange:R) ==
+      output("pointPlot2")$OutputPackage
       p := pointPlot(f,tRange)
       p.display := [checkRange xRange,checkRange yRange]
       p


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to fricas-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to