~ubuntu-branches/ubuntu/trusty/bc/trusty

« back to all changes in this revision

Viewing changes to Test/testfn.b

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2002-04-13 11:33:49 UTC
  • Revision ID: james.westby@ubuntu.com-20020413113349-hl2r1t730b91ov68
Tags: upstream-1.06
ImportĀ upstreamĀ versionĀ 1.06

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This function "t" tests the function "f" to see if computing at
 
2
   two different scales has much effect on the accuracy. 
 
3
   test from f(x) to f(y) incrementing the index by d.  f(i) is
 
4
   computed at two scales, scale s and then scale t, where t>s.
 
5
   the result from scale t is divided by 1 at scale s and the
 
6
   results are compared.  If they are different, the function is
 
7
   said to have failed.  It will then print out the value of i
 
8
   (called index) and the two original values val1 (scale s) and
 
9
   val2 (scale t) */
 
10
 
 
11
define t (x,y,d,s,t) {
 
12
   auto u, v, w, i, b, c;
 
13
 
 
14
   if (s >= t) {
 
15
     "Bad Scales. Try again.
 
16
";   return;
 
17
   }
 
18
 
 
19
   for (i = x; i < y; i += d) {
 
20
     scale = s;
 
21
     u = f(i);
 
22
     scale = t;
 
23
     v = f(i);
 
24
     scale = s;
 
25
     w = v / 1;
 
26
     b += 1;
 
27
     if (u != w) {
 
28
       c += 1;
 
29
"
 
30
Failed:  
 
31
"
 
32
       "  index = "; i;
 
33
       "  val1 = "; u;
 
34
       "  val2 = "; v;
 
35
"
 
36
"
 
37
     }
 
38
   }
 
39
 
 
40
"
 
41
Total tests:    "; b;
 
42
"
 
43
Total failures: "; c;
 
44
"
 
45
Percent failed: "; scale = 2; c*100/b;
 
46
 
 
47
}