source: trunk/Softwares/MiBench/src/c/basicmath-basicmath_small.c @ 128

Last change on this file since 128 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: 2.3 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_small(void)
8{
9  double  a1 = 1.0, b1 = -10.5, c1 = 32.0, d1 = -30.0;
10  double  a2 = 1.0, b2 = -4.5, c2 = 17.0, d2 = -30.0;
11  double  a3 = 1.0, b3 = -3.5, c3 = 22.0, d3 = -31.0;
12  double  a4 = 1.0, b4 = -13.7, c4 = 1.0, d4 = -35.0;
13  double  x[3];
14  double X;
15  int     solutions;
16  int i;
17  unsigned long l = 0x3fed0169L;
18  struct int_sqrt q;
19//long n = 0;
20
21  /* solve soem cubic functions */
22  printf("********* CUBIC FUNCTIONS ***********\n");
23  /* should get 3 solutions: 2, 6 & 2.5   */
24  SolveCubic(a1, b1, c1, d1, &solutions, x); 
25  printf("Solutions:");
26  for(i=0;i<solutions;i++)
27    printf(" %f",x[i]);
28  printf("\n");
29  /* should get 1 solution: 2.5           */
30  SolveCubic(a2, b2, c2, d2, &solutions, x); 
31  printf("Solutions:");
32  for(i=0;i<solutions;i++)
33    printf(" %f",x[i]);
34  printf("\n");
35  SolveCubic(a3, b3, c3, d3, &solutions, x);
36  printf("Solutions:");
37  for(i=0;i<solutions;i++)
38    printf(" %f",x[i]);
39  printf("\n");
40  SolveCubic(a4, b4, c4, d4, &solutions, x);
41  printf("Solutions:");
42  for(i=0;i<solutions;i++)
43    printf(" %f",x[i]);
44  printf("\n");
45  /* Now solve some random equations */
46  for(a1=1;a1<10;a1++) {
47    for(b1=10;b1>0;b1--) {
48      for(c1=5;c1<15;c1+=0.5) {
49        for(d1=-1;d1>-11;d1--) {
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      }
57    }
58  }
59 
60  printf("********* INTEGER SQR ROOTS ***********\n");
61  /* perform some integer square roots */
62  for (i = 0; i < 1001; ++i)
63    {
64      usqrt(i, &q);
65                        // remainder differs on some machines
66     // printf("sqrt(%3d) = %2d, remainder = %2d\n",
67     printf("sqrt(%3d) = %2d\n",
68             i, q.sqrt);
69    }
70  usqrt(l, &q);
71  //printf("\nsqrt(%lX) = %X, remainder = %X\n", l, q.sqrt, q.frac);
72  printf("\nsqrt(%lX) = %X\n", l, q.sqrt);
73
74
75  printf("********* ANGLE CONVERSION ***********\n");
76  /* convert some rads to degrees */
77  for (X = 0.0; X <= 360.0; X += 1.0)
78    printf("%3.0f degrees = %.12f radians\n", X, deg2rad(X));
79  puts("");
80  for (X = 0.0; X <= (2 * PI + 1e-6); X += (PI / 180))
81    printf("%.12f radians = %3.0f degrees\n", X, rad2deg(X));
82 
83 
84  return 0;
85}
Note: See TracBrowser for help on using the repository browser.