OpenCores
URL https://opencores.org/ocsvn/mlite/mlite/trunk

Subversion Repositories mlite

[/] [mlite/] [trunk/] [kernel/] [math.c] - Diff between revs 197 and 302

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 197 Rev 302
Line 591... Line 591...
 
 
/*************** Test *****************/
/*************** Test *****************/
#ifdef WIN32
#ifdef WIN32
#include <math.h>
#include <math.h>
#undef printf
#undef printf
 
#undef getch
int printf(const char *, ...);
int printf(const char *, ...);
struct {
struct {
   char *name;
   char *name;
   float low, high;
   float low, high;
   double (*func1)(double);
   double (*func1)(double);
Line 626... Line 627...
      c = FP_Div(a, b);
      c = FP_Div(a, b);
      d = a / b - c;
      d = a / b - c;
      printf("%10f %10f %10f %10f %10f\n",
      printf("%10f %10f %10f %10f %10f\n",
         (double)a, (double)b, (double)(a/b), (double)c, (double)(a/b-c));
         (double)a, (double)b, (double)(a/b), (double)c, (double)(a/b-c));
   }
   }
   getch();
   //getch();
 
 
   for(test = 0; test < 6; ++test)
   for(test = 0; test < 6; ++test)
   {
   {
      printf("\nTesting %s\n", test_info[test].name);
      printf("\nTesting %s\n", test_info[test].name);
      for(a = test_info[test].low;
      for(a = test_info[test].low;
Line 640... Line 641...
         b = (float)test_info[test].func1(a);
         b = (float)test_info[test].func1(a);
         c = test_info[test].func2(a);
         c = test_info[test].func2(a);
         d = b - c;
         d = b - c;
         printf("%s %10f %10f %10f %10f\n", test_info[test].name, a, b, c, d);
         printf("%s %10f %10f %10f %10f\n", test_info[test].name, a, b, c, d);
      }
      }
      getch();
      //getch();
   }
   }
 
 
   a = FP_ToFloat((long)6.0);
   a = FP_ToFloat((long)6.0);
   b = FP_ToFloat((long)2.0);
   b = FP_ToFloat((long)2.0);
   printf("%f %f\n", (double)a, (double)b);
   printf("%f %f\n", (double)a, (double)b);
Line 654... Line 655...
   printf("sub %f %f\n", (double)(a - b), (double)c);
   printf("sub %f %f\n", (double)(a - b), (double)c);
   c = FP_Mult(a, b);
   c = FP_Mult(a, b);
   printf("mult %f %f\n", (double)(a * b), (double)c);
   printf("mult %f %f\n", (double)(a * b), (double)c);
   c = FP_Div(a, b);
   c = FP_Div(a, b);
   printf("div %f %f\n", (double)(a / b), (double)c);
   printf("div %f %f\n", (double)(a / b), (double)c);
   getch();
   //getch();
 
 
   for(a = (float)-13756.54; a < (float)17400.0; a += (float)64.45)
   for(a = (float)-13756.54; a < (float)17400.0; a += (float)64.45)
   {
   {
      for(b = (float)-875.36; b < (float)935.8; b += (float)36.7)
      for(b = (float)-875.36; b < (float)935.8; b += (float)36.7)
      {
      {
Line 676... Line 677...
         printf("  a/b=%f %f\n", (double)(a/b), (double)FP_Div(a, b));
         printf("  a/b=%f %f\n", (double)(a/b), (double)FP_Div(a, b));
         printf("  a=%f %ld %f\n", (double)a, FP_ToLong(a),
         printf("  a=%f %ld %f\n", (double)a, FP_ToLong(a),
                                   (double)FP_ToFloat((long)a));
                                   (double)FP_ToFloat((long)a));
         printf("  %f %f %f %f\n", (double)error1, (double)error2,
         printf("  %f %f %f %f\n", (double)error1, (double)error2,
            (double)error3, (double)error4);
            (double)error3, (double)error4);
         if(error5 > 0.001)
         //if(error5 > 0.001) 
            getch();
         //   getch();
      }
      }
   }
   }
   printf("done.\n");
   printf("done.\n");
   getch();
   //getch();
}
}
#endif
#endif
 
 
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.