summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2008-07-19 15:11:25 -0700
committerRob Pike <r@golang.org>2008-07-19 15:11:25 -0700
commit6f76bfd7daa11b620ee9e4d70c100ce1815739a3 (patch)
tree77893fb9f9f2bb4a2aafe703b524b06d48c38864
parent69b2181ec3fd2139085c0414e2340d26c83d5d1f (diff)
downloadgolang-6f76bfd7daa11b620ee9e4d70c100ce1815739a3.tar.gz
add an eval function (written by ken)
SVN=128122
-rw-r--r--test/chan/powser1.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/chan/powser1.go b/test/chan/powser1.go
index 1b25d7eef..abafc469b 100644
--- a/test/chan/powser1.go
+++ b/test/chan/powser1.go
@@ -233,6 +233,24 @@ type PS2 *[2] PS; // pair of power series
var Ones PS
var Twos PS
+// print eval in floating point of PS at x=c to n terms
+func
+Evaln(c *rat, U PS, n int)
+{
+ xn := float64(1);
+ x := float64(c.num)/float64(c.den);
+ val := float64(0);
+ for i:=0; i<n; i++ {
+ u := get(U);
+ if end(u) != 0 {
+ break;
+ }
+ val = val + x * float64(u.num)/float64(u.den);
+ xn = xn*x;
+ }
+ print val, "\n";
+}
+
func mkPS() *dch {
return mkdch()
}