source: trunk/Softwares/MiBench/src/c/basicmath-basicmath_large.c

Last change on this file was 117, checked in by rosiere, 15 years ago

1) Platforms : add new organization for test
2) Load_Store_Unit : add array to count nb_check in store_queue
3) Issue_queue and Core_Glue : rewrite the issue network
4) Special_Register_Unit : add reset value to register CID
5) Softwares : add multicontext test
6) Softwares : add SPECINT
7) Softwares : add MiBench?
7) Read_queue : inhib access for r0
8) Change Core_Glue (network) - dont yet support priority and load balancing scheme

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1#include "basicmath-snipmath.h"
2#include <math.h>
3#include <stdio.h>
4
5/* The printf's may be removed to isolate just the math calculations */
6
7int main_basicmath_large(void)
8{
9  double  a1 = 1.0, b1 = -10.5, c1 = 32.0, d1 = -30.0;
10  double  x[3];
11  double X;
12  int     solutions;
13  int i;
14  unsigned long l = 0x3fed0169L;
15  struct int_sqrt q;
16//long n = 0;
17
18  /* solve soem cubic functions */
19  printf("********* CUBIC FUNCTIONS ***********\n");
20  /* should get 3 solutions: 2, 6 & 2.5   */
21  SolveCubic(a1, b1, c1, d1, &solutions, x); 
22  printf("Solutions:");
23  for(i=0;i<solutions;i++)
24    printf(" %f",x[i]);
25  printf("\n");
26
27  a1 = 1.0; b1 = -4.5; c1 = 17.0; d1 = -30.0;
28  /* should get 1 solution: 2.5           */
29  SolveCubic(a1, b1, c1, d1, &solutions, x); 
30  printf("Solutions:");
31  for(i=0;i<solutions;i++)
32    printf(" %f",x[i]);
33  printf("\n");
34
35  a1 = 1.0; b1 = -3.5; c1 = 22.0; d1 = -31.0;
36  SolveCubic(a1, b1, c1, d1, &solutions, x);
37  printf("Solutions:");
38  for(i=0;i<solutions;i++)
39    printf(" %f",x[i]);
40  printf("\n");
41
42  a1 = 1.0; b1 = -13.7; c1 = 1.0; d1 = -35.0;
43  SolveCubic(a1, b1, c1, d1, &solutions, x);
44  printf("Solutions:");
45  for(i=0;i<solutions;i++)
46    printf(" %f",x[i]);
47  printf("\n");
48
49  a1 = 3.0; b1 = 12.34; c1 = 5.0; d1 = 12.0;
50  SolveCubic(a1, b1, c1, d1, &solutions, x);
51  printf("Solutions:");
52  for(i=0;i<solutions;i++)
53    printf(" %f",x[i]);
54  printf("\n");
55
56  a1 = -8.0; b1 = -67.89; c1 = 6.0; d1 = -23.6;
57  SolveCubic(a1, b1, c1, d1, &solutions, x);
58  printf("Solutions:");
59  for(i=0;i<solutions;i++)
60    printf(" %f",x[i]);
61  printf("\n");
62
63  a1 = 45.0; b1 = 8.67; c1 = 7.5; d1 = 34.0;
64  SolveCubic(a1, b1, c1, d1, &solutions, x);
65  printf("Solutions:");
66  for(i=0;i<solutions;i++)
67    printf(" %f",x[i]);
68  printf("\n");
69
70  a1 = -12.0; b1 = -1.7; c1 = 5.3; d1 = 16.0;
71  SolveCubic(a1, b1, c1, d1, &solutions, x);
72  printf("Solutions:");
73  for(i=0;i<solutions;i++)
74    printf(" %f",x[i]);
75  printf("\n");
76
77  /* Now solve some random equations */
78  for(a1=1;a1<10;a1+=1) {
79    for(b1=10;b1>0;b1-=.25) {
80      for(c1=5;c1<15;c1+=0.61) {
81           for(d1=-1;d1>-5;d1-=.451) {
82                SolveCubic(a1, b1, c1, d1, &solutions, x); 
83                printf("Solutions:");
84                for(i=0;i<solutions;i++)
85                  printf(" %f",x[i]);
86                printf("\n");
87           }
88      }
89    }
90  }
91
92
93  printf("********* INTEGER SQR ROOTS ***********\n");
94  /* perform some integer square roots */
95  for (i = 0; i < 100000; i+=2)
96    {
97      usqrt(i, &q);
98                        // remainder differs on some machines
99     // printf("sqrt(%3d) = %2d, remainder = %2d\n",
100     printf("sqrt(%3d) = %2d\n",
101             i, q.sqrt);
102    }
103  printf("\n");
104  for (l = 0x3fed0169L; l < 0x3fed4169L; l++)
105    {
106         usqrt(l, &q);
107         //printf("\nsqrt(%lX) = %X, remainder = %X\n", l, q.sqrt, q.frac);
108         printf("sqrt(%lX) = %X\n", l, q.sqrt);
109    }
110
111
112  printf("********* ANGLE CONVERSION ***********\n");
113  /* convert some rads to degrees */
114/*   for (X = 0.0; X <= 360.0; X += 1.0) */
115  for (X = 0.0; X <= 360.0; X += .001)
116    printf("%3.0f degrees = %.12f radians\n", X, deg2rad(X));
117  puts("");
118/*   for (X = 0.0; X <= (2 * PI + 1e-6); X += (PI / 180)) */
119  for (X = 0.0; X <= (2 * PI + 1e-6); X += (PI / 5760))
120    printf("%.12f radians = %3.0f degrees\n", X, rad2deg(X));
121 
122 
123  return 0;
124}
Note: See TracBrowser for help on using the repository browser.