os/ossrv/genericopenlibs/liboil/tsrc/testsuite/math/src/math.c
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 //Description:
    14 //
    15 
    16 
    17 
    18 #ifdef HAVE_CONFIG_H
    19 #include "config.h"
    20 #endif
    21 
    22 #include <liboil/liboil.h>
    23 #include <liboil/liboilfunction.h>
    24 #include <stdio.h>
    25 #include <string.h>
    26 #include <globals.h>
    27 
    28 #define LOG_FILE "c:\\logs\\testsuite_math_log.txt"
    29 #include "std_log_result.h"
    30 #include "utils.h"
    31 #define LOG_FILENAME_LINE __FILE__, __LINE__
    32 #define MAX_SIZE 10
    33 #define MAX_SIZE1 8
    34 #define MAX_DSIZE 5
    35 
    36 int16_t arr1[MAX_SIZE], arr2[MAX_SIZE], res1[MAX_SIZE];
    37 uint8_t uarr1[MAX_SIZE],uarr2[MAX_SIZE1],uarr3[MAX_SIZE1], ures1[MAX_SIZE1];
    38 float farr1[MAX_SIZE1], farr2[MAX_SIZE1],fres1[MAX_SIZE1];
    39 double darr1[MAX_DSIZE], darr2[MAX_DSIZE],dres1[MAX_DSIZE];
    40 
    41 void create_xml(int result)
    42 {
    43     if(result)
    44         assert_failed = 1;
    45     
    46     testResultXml("testsuite_math");
    47     close_log_file();
    48 }
    49 
    50 void test_add_s16()
    51     {
    52     int i;
    53     int16_t check[MAX_SIZE]={8,13,18,23,28,33,38,43,48,53};
    54     for(i=0;i<MAX_SIZE;i++)
    55         {
    56           res1[i]=0;
    57           arr1[i]=(i+2) *3;
    58           arr2[i]=(i+1)*2;
    59           std_log(LOG_FILENAME_LINE,"arr1[%d] = %d, arr2[%d] = %d", i,arr1[i],i,arr2[i]);
    60         }
    61     oil_add_s16(res1,arr1,arr2,MAX_SIZE);
    62     
    63     for(i=0;i<MAX_SIZE;i++)
    64         {
    65         if(res1[i] == check[i])
    66             {
    67             std_log(LOG_FILENAME_LINE,"oil_add_s16 successful, res1[%d]=%d", i,res1[i]);
    68             }
    69         else
    70             {
    71              assert_failed = 1;
    72              std_log(LOG_FILENAME_LINE,"oil_add_s16 unsuccessful, Expected =%d,Obtained =%d",check[i],res1[i]);
    73             }
    74         }  
    75     }
    76 
    77 void test_add_s16_u8()
    78     {
    79     int i;
    80     int16_t check[MAX_SIZE]={6,11,16,21,26,31,36,41,46,51};
    81     for(i=0;i<MAX_SIZE;i++)
    82         {
    83           res1[i]=0;
    84           arr1[i]=(i+2)*3;
    85           uarr1[i]=i*2;
    86           std_log(LOG_FILENAME_LINE,"arr1[%d] = %d, uarr1[%d] = %d", i,arr1[i],i,uarr1[i]);
    87         }
    88     oil_add_s16_u8(res1,arr1,uarr1,MAX_SIZE);
    89     
    90     for(i=0;i<MAX_SIZE;i++)
    91         {
    92         if(res1[i] == check[i])
    93             {
    94             std_log(LOG_FILENAME_LINE,"oil_add_s16_u8 successful, res1[%d] = %d", i,res1[i]);
    95             }
    96         else
    97             {
    98              assert_failed = 1;
    99              std_log(LOG_FILENAME_LINE,"oil_add_s16_u8 unsuccessful,Expected =%d,Obtained =%d",check[i],res1[i]);
   100             }
   101         }  
   102     }
   103 
   104 
   105 
   106 
   107 void test_add_f32()
   108     {
   109     int i;
   110     float fcheck[MAX_SIZE1]={8.30000019073486,12.10000038146973,15.89999961853027,19.70000076293945,23.50000000000000,27.29999923706055,31.10000038146973,34.90000152587891};
   111     for(i=0;i<MAX_SIZE1;i++)
   112         {
   113           fres1[i]=0;
   114           farr1[i]=(i+2.5)*3;
   115           farr2[i]=(i+1)*0.8;
   116           std_log(LOG_FILENAME_LINE,"farr1[%d] = %f, farr2[%d] = %f", i,farr1[i],i,farr2[i]);
   117         }
   118     oil_add_f32(fres1,farr1,farr2,MAX_SIZE1);
   119     
   120     for(i=0;i<MAX_SIZE1;i++)
   121         {
   122         if(comparefloats(fres1[i],fcheck[i])==0)
   123             {
   124             std_log(LOG_FILENAME_LINE,"oil_add_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   125             }
   126         else
   127             {
   128              assert_failed = 1;
   129              std_log(LOG_FILENAME_LINE,"oil_add_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   130             }
   131         }  
   132     }
   133 
   134 
   135 void test_add_f64()
   136     {
   137     int i;
   138     double dcheck[MAX_DSIZE]={7.51500000000000,10.85500000000000,14.19500000000000,17.53500000000000,20.87500000000000};
   139     for(i=0;i<MAX_DSIZE;i++)
   140         {
   141           fres1[i]=0;
   142           darr1[i]=(i+2.25)*3.34;
   143           arr2[i]=(i+1.3)*0.18;
   144           std_log(LOG_FILENAME_LINE,"farr1[%d] = %15.14f, farr2[%d] = %15.14f", i,darr1[i],i,darr2[i]);
   145         }
   146     oil_add_f64(dres1,darr1,darr2,MAX_DSIZE);
   147     
   148     for(i=0;i<MAX_DSIZE;i++)
   149         {
   150         if(comparefloats(dres1[i],dcheck[i])==0)
   151             {
   152             std_log(LOG_FILENAME_LINE,"oil_add_f64 successful, dres1[%d] = %15.14f", i,dres1[i]);
   153             }
   154         else
   155             {
   156              assert_failed = 1;
   157              std_log(LOG_FILENAME_LINE,"oil_add_f64 unsuccessful, Expected =%15.14f,Obtained =%15.14f",dcheck[i],dres1[i]);
   158             } 
   159         }  
   160     }
   161 
   162 
   163 void test_sub_s16()
   164     {
   165     int i;
   166     int16_t check[MAX_SIZE]={4,5,6,7,8,9,10,11,12,13};
   167     for(i=0;i<MAX_SIZE;i++)
   168         {
   169           res1[i]=0;
   170           arr1[i]=(i+2) *3;
   171           arr2[i]=(i+1)*2;
   172           std_log(LOG_FILENAME_LINE,"arr1[%d]=%d,arr2[%d]=%d", i,arr1[i],i,arr2[i]);
   173         }
   174     
   175     oil_subtract_s16(res1,arr1,arr2,MAX_SIZE);
   176     
   177     for(i=0;i<MAX_SIZE;i++)
   178         {
   179         if(res1[i] == check[i])
   180             {
   181             std_log(LOG_FILENAME_LINE,"oil_subtract_s16 successful,res1[%d]=%d", i,res1[i]);
   182             }
   183         else
   184             {
   185              assert_failed = 1;
   186              std_log(LOG_FILENAME_LINE,"oil_subtract_s16 unsuccessful, Expected =%d,Obtained =%d",check[i],res1[i]);
   187             }
   188         }  
   189     }
   190 
   191 void test_sub_s16_u8()
   192     {
   193     int i;
   194     int16_t check[MAX_SIZE]={6,7,8,9,10,11,12,13,14,15};
   195     for(i=0;i<MAX_SIZE;i++)
   196         {
   197           res1[i]=0;
   198           arr1[i]=(i+2)*3;
   199           uarr1[i]=i*2;
   200           std_log(LOG_FILENAME_LINE,"arr1[%d]=%d, uarr1[%d]=%d",i,arr1[i],i,uarr1[i]);
   201         }
   202     oil_subtract_s16_u8(res1,arr1,uarr1,MAX_SIZE);
   203     
   204     for(i=0;i<MAX_SIZE;i++)
   205         {
   206         if(res1[i] == check[i])
   207             {
   208             std_log(LOG_FILENAME_LINE,"oil_subtract_s16_u8 successful, res1[%d] = %d", i,res1[i]);
   209             }
   210         else
   211             {
   212              assert_failed = 1;
   213              std_log(LOG_FILENAME_LINE,"oil_subtract_s16_u8 unsuccessful, Expected =%d,Obtained =%d",check[i],res1[i]);
   214             }
   215         }  
   216     }
   217 
   218 
   219 
   220 void test_sub_f32()
   221     {
   222     int i;
   223     float fcheck[MAX_SIZE1]={6.69999980926514,8.89999961853027,11.10000038146973,13.30000019073486,15.50000000000000,17.70000076293945,19.89999961853027,22.10000038146973};
   224     for(i=0;i<MAX_SIZE1;i++)
   225         {
   226           fres1[i]=0;
   227           farr1[i]=(i+2.5)*3;
   228           farr2[i]=(i+1)*0.8;
   229           std_log(LOG_FILENAME_LINE,"farr1[%d]=%f,farr2[%d]=%f", i,farr1[i],i,farr2[i]);
   230         }
   231     oil_subtract_f32(fres1,farr1,farr2,MAX_SIZE1);
   232     
   233     for(i=0;i<MAX_SIZE1;i++)
   234         {
   235         if(comparefloats(fres1[i],fcheck[i])==0)
   236             {
   237             std_log(LOG_FILENAME_LINE,"oil_subtract_f32 successful,fres1[%d]=%15.14f", i,fres1[i]);
   238             }
   239         else
   240             {
   241              assert_failed = 1;
   242              std_log(LOG_FILENAME_LINE,"oil_subtract_f32 unsuccessful,Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   243             }
   244         }  
   245     }
   246 
   247 
   248 void test_sub_f64()
   249     {
   250     int i;
   251     double dcheck[MAX_DSIZE]={7.28100000000000,10.44100000000000,13.60100000000000,16.76100000000000,19.92100000000000};
   252     for(i=0;i<MAX_DSIZE;i++)
   253         {
   254           dres1[i]=0;
   255           darr1[i]=(i+2.25)*3.34;
   256           darr2[i]=(i+1.3)*0.18;
   257           std_log(LOG_FILENAME_LINE,"darr1[%d] = %15.14f, darr2[%d] = %15.14f", i,darr1[i],i,darr2[i]);
   258         }
   259     oil_subtract_f64(dres1,darr1,darr2,MAX_DSIZE);
   260     
   261     for(i=0;i<MAX_DSIZE;i++)
   262         {
   263         if(comparefloats(dres1[i],dcheck[i])==0)
   264             {
   265             std_log(LOG_FILENAME_LINE,"oil_subtract_f64 successful, dres1[%d] = %15.14f", i,dres1[i]);
   266             }
   267         else
   268             {
   269              assert_failed = 1;
   270              std_log(LOG_FILENAME_LINE,"oil_subtract_f64 unsuccessful, Expected =%15.14f,Obtained =%15.14f",dcheck[i],dres1[i]);
   271             } 
   272         }  
   273     }
   274 
   275 
   276 void test_mult_f32()
   277     {
   278     int i;
   279     float fcheck[MAX_SIZE1]={0.66799998283386,2.00400018692017,4.00799989700317,6.68000030517578,10.02000045776367,14.02799987792969,18.70399856567383,24.04800033569336};
   280     for(i=0;i<MAX_SIZE1;i++)
   281         {
   282           fres1[i]=0;
   283           farr1[i]=(i+2)*3.34;
   284           farr2[i]=(i+1)*0.1;
   285           std_log(LOG_FILENAME_LINE,"farr1[%d] = %f, farr2[%d] = %f", i,farr1[i],i,farr2[i]);
   286         }
   287     oil_multiply_f32(fres1,farr1,farr2,MAX_SIZE1);
   288     
   289     for(i=0;i<MAX_SIZE1;i++)
   290         {
   291         if(comparefloats(fres1[i],fcheck[i])==0)
   292             {
   293               std_log(LOG_FILENAME_LINE,"oil_multiply_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   294              }
   295            else
   296                {
   297                 assert_failed = 1;
   298                 std_log(LOG_FILENAME_LINE,"oil_multiply_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   299                } 
   300         }
   301     }
   302 
   303 void test_mult_f64()
   304     {
   305     int i;
   306     double dcheck[MAX_DSIZE]={1.71943200000000,4.42483200000000,8.33263200000000,13.44283200000000,19.75543200000000};
   307     for(i=0;i<MAX_DSIZE;i++)
   308          {
   309            dres1[i]=0;
   310            darr1[i]=(i+2.2)*3.34;
   311            darr2[i]=(i+1.3)*0.18;
   312            std_log(LOG_FILENAME_LINE,"darr1[%d] = %15.14f, darr2[%d] = %15.14f", i,darr1[i],i,darr2[i]);
   313          }
   314     oil_multiply_f64(dres1,darr1,darr2,MAX_DSIZE);
   315      
   316     for(i=0;i<MAX_DSIZE;i++)
   317          {
   318          if(comparefloats(dres1[i],dcheck[i])==0)
   319              {
   320              std_log(LOG_FILENAME_LINE,"oil_multiply_f64 successful, dres1[%d] = %15.14f", i,dres1[i]);
   321              }
   322          else
   323              {
   324               assert_failed = 1;
   325               std_log(LOG_FILENAME_LINE,"oil_multiply_f64 unsuccessful, Expected =%15.14f,Obtained =%15.14f",dcheck[i],dres1[i]);
   326              } 
   327          }  
   328     }
   329 
   330 
   331 void test_div_f32()
   332     {
   333     int i;
   334     float fcheck[MAX_SIZE1]={60.00000000000000,45.00000000000000,40.00000000000000,37.50000000000000,36.00000000000000,35.00000000000000,34.28571319580078,33.75000000000000};
   335     for(i=0;i<MAX_SIZE1;i++)
   336         {
   337           fres1[i]=0;
   338           farr1[i]=(i+2)*3;
   339           farr2[i]=(i+1)*0.1;
   340           std_log(LOG_FILENAME_LINE,"farr1[%d] = %f, farr2[%d] = %f", i,farr1[i],i,farr2[i]);
   341         }
   342     oil_divide_f32(fres1,farr1,farr2,MAX_SIZE1);
   343     
   344     for(i=0;i<MAX_SIZE1;i++)
   345         {
   346         if(comparefloats(fres1[i],fcheck[i])==0)
   347             {
   348               std_log(LOG_FILENAME_LINE,"oil_divide_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   349               }
   350            else
   351                {
   352                 assert_failed = 1;
   353                 std_log(LOG_FILENAME_LINE,"oil_divide_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   354                } 
   355         }
   356     }
   357 
   358 void test_div_f64()
   359     {
   360     int i;
   361     double dcheck[MAX_DSIZE]={2.82615384615385,2.32347826086957,2.12545454545455,2.01953488372093,1.95358490566038};
   362     for(i=0;i<MAX_DSIZE;i++)
   363          {
   364            dres1[i]=0;
   365            darr1[i]=(i+2.2)*3.34;
   366            darr2[i]=(i+1.3)*2;
   367            std_log(LOG_FILENAME_LINE,"darr1[%d] = %15.14f, darr2[%d] = %15.14f", i,darr1[i],i,darr2[i]);
   368          }
   369     oil_divide_f64(dres1,darr1,darr2,MAX_DSIZE);
   370      
   371     for(i=0;i<MAX_DSIZE;i++)
   372          {
   373          if(comparefloats(dres1[i],dcheck[i])==0)
   374              {
   375              std_log(LOG_FILENAME_LINE,"oil_divide_f64 successful, dres1[%d] = %15.14f", i,dres1[i]);
   376              }
   377          else
   378              {
   379               assert_failed = 1;
   380               std_log(LOG_FILENAME_LINE,"oil_divide_f64 unsuccessful, Expected =%15.14f,Obtained =%15.14f",dcheck[i],dres1[i]);
   381              } 
   382          }  
   383     }
   384 
   385 
   386 
   387 void test_minimum_f32()
   388     {
   389     int i;
   390     float fmarr1[MAX_SIZE] = {2.10, 0.23123, 532.2, 1, 0908.34, 23432.1, 11.34, 0.0002, 87.2324, 700};
   391     float fmarr2[MAX_SIZE] = { 86.3423, 1231.11, 65457.2, 0, 10.3, 700, 2.10, 8967.21, 3423.23,211.076 };
   392     float fmin1[MAX_SIZE];
   393     float fmcheck[MAX_SIZE]={2.09999990463257,0.23123000562191,532.20001220703125,0.00000000000000,10.30000019073486,700.00000000000000,2.09999990463257,0.00019999999495,87.23239898681641,211.07600402832031};
   394     for(i=0;i<MAX_SIZE;i++)
   395         {
   396           fmin1[i]=0;
   397           std_log(LOG_FILENAME_LINE,"fmarr1[%d] = %f, fmarr2[%d] = %f", i,fmarr1[i],i,fmarr2[i]);
   398         }
   399     oil_minimum_f32(fmin1,fmarr1,fmarr2,MAX_SIZE);
   400     
   401     for(i=0;i<MAX_SIZE;i++)
   402         {
   403         if(comparefloats(fmin1[i],fmcheck[i])==0)
   404             {
   405               std_log(LOG_FILENAME_LINE,"oil_minimum_f32 successful, fmin1[%d] = %15.14f", i,fmin1[i]);
   406              }
   407          else
   408             {
   409               assert_failed = 1;
   410               std_log(LOG_FILENAME_LINE,"oil_minimum_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fmcheck[i],fmin1[i]);
   411             } 
   412         }
   413     }
   414 
   415 
   416 void test_minimum_f64()
   417     {
   418     int i;
   419     float dmarr1[MAX_SIZE] = {2324235.10, 0231.3223, 532.2, 1.3423421, 23432.1, 11.3423424, 340.0002, 87342.3424,3243.12,0};
   420     float dmarr2[MAX_SIZE] = { 2386.3423, 11131.11, 6545.2, 230, 110.31, 400.700, 122.10, 892467.22, 24323.23,3243.12 };
   421     float dmin1[MAX_SIZE];
   422     float dmcheck[MAX_SIZE]={2386.34228515625000,231.32229614257812,532.20001220703125,1.34234213829041,110.30999755859375,11.34234237670898,122.09999847412109,87342.34375000000000,3243.12011718750000,0.00000000000000};
   423     for(i=0;i<MAX_SIZE;i++)
   424         {
   425           dmin1[i]=0;
   426           std_log(LOG_FILENAME_LINE,"fmarr1[%d] = %15.14f, fmarr2[%d] = %15.14f", i,dmarr1[i],i,dmarr2[i]);
   427         }
   428     oil_minimum_f64(dmin1,dmarr1,dmarr2,MAX_SIZE);
   429     
   430     for(i=0;i<MAX_SIZE;i++)
   431         {
   432         if(comparefloats(dmin1[i],dmcheck[i])==0)
   433             {
   434               std_log(LOG_FILENAME_LINE,"oil_minimum_f64 successful, dmin1[%d] = %15.14f", i,dmin1[i]);
   435             }
   436         else
   437             {
   438               assert_failed = 1;
   439               std_log(LOG_FILENAME_LINE,"oil_minimum_f64 unsuccessful, Expected =%15.14f,Obtained =%15.14f",dmcheck[i],dmin1[i]);
   440             } 
   441         }
   442     }
   443 
   444 
   445 
   446 void test_maximum_f32()
   447     {
   448     int i;
   449     float fmarr1[MAX_SIZE] = {2.10, 0.23123, 532.2, 1, 0908.34, 23432.1, 11.34, 0.0002, 87.2324, 700};
   450     float fmarr2[MAX_SIZE] = { 86.3423, 1231.11, 65457.2, 0, 10.3, 700, 2.10, 8967.21, 3423.23,211.076 };
   451     float fmax1[MAX_SIZE];
   452     float fmcheck[MAX_SIZE]={86.34230041503906,1231.10998535156250,65457.19921875000000,1.00000000000000,908.34002685546875,23432.09960937500000,11.34000015258789,8967.20996093750000,3423.22998046875000,700.00000000000000};
   453     for(i=0;i<MAX_SIZE;i++)
   454         {
   455           fmax1[i]=0;
   456           std_log(LOG_FILENAME_LINE,"fmarr1[%d] = %f, fmarr2[%d] = %f", i,fmarr1[i],i,fmarr2[i]);
   457         }
   458     oil_maximum_f32(fmax1,fmarr1,fmarr2,MAX_SIZE);
   459     
   460     for(i=0;i<MAX_SIZE;i++)
   461         {
   462         if(comparefloats(fmax1[i],fmcheck[i])==0)
   463             {
   464               std_log(LOG_FILENAME_LINE,"oil_maximum_f32 successful, fmax1[%d] = %15.14f", i,fmax1[i]);
   465             }
   466         else
   467             {
   468               assert_failed = 1;
   469               std_log(LOG_FILENAME_LINE,"oil_maximum_f32 unsuccessful,Expected =%15.14f,Obtained =%15.14f",fmcheck[i],fmax1[i]);
   470             } 
   471         }
   472     }
   473 
   474 
   475 void test_maximum_f64()
   476     {
   477     int i;
   478     float dmarr1[MAX_SIZE] = {2324235.10, 0231.3223, 532.2, 1.3423421, 23432.1, 11.3423424, 340.0002, 87342.3424,3243.12};
   479     float dmarr2[MAX_SIZE] = {2386.3423, 11131.11, 6545.2, 230, 110.31, 400.700, 122.10, 892467.22, 24323.23,3243.12 };
   480     float dmax1[MAX_SIZE];
   481     float dmcheck[MAX_SIZE]={2324235.00000000000000,11131.11035156250000,6545.20019531250000,230.00000000000000,23432.09960937500000,400.70001220703125,340.00021362304688,892467.25000000000000,24323.23046875000000,3243.12011718750000};
   482     for(i=0;i<MAX_SIZE;i++)
   483         {
   484           dmax1[i]=0;
   485           std_log(LOG_FILENAME_LINE,"fmarr1[%d] = %15.14f, fmarr2[%d] = %15.14f", i,dmarr1[i],i,dmarr2[i]);
   486         }
   487     oil_maximum_f64(dmax1,dmarr1,dmarr2,MAX_SIZE);
   488     
   489     for(i=0;i<MAX_SIZE;i++)
   490         {
   491         if(comparefloats(dmax1[i],dmcheck[i])==0)
   492            {
   493             std_log(LOG_FILENAME_LINE,"oil_maximum_f64 successful, dmax1[%d] = %15.14f", i,dmax1[i]);
   494            }
   495         else
   496           {
   497            assert_failed = 1;
   498            std_log(LOG_FILENAME_LINE,"oil_maximum_f64 unsuccessful, Expected =%15.14f,Obtained =%15.14f",dmcheck[i],dmax1[i]);
   499           } 
   500         }
   501     }
   502 
   503 
   504 void test_negative_f32()
   505     {
   506     int i;
   507     float fcheck[MAX_SIZE1]={-6.19999980926514,-9.30000019073486,-12.39999961853027,-15.50000000000000,-18.60000038146973,-21.70000076293945,-24.79999923706055,-27.89999961853027};
   508     for(i=0;i<MAX_SIZE1;i++)
   509         {
   510           fres1[i]=0;
   511           farr1[i]=(i+2)*3.1;
   512           std_log(LOG_FILENAME_LINE,"farr1[%d] = %f", i,farr1[i]);
   513         }
   514     oil_negative_f32(fres1,farr1,MAX_SIZE1);
   515     
   516     for(i=0;i<MAX_SIZE1;i++)
   517         {
   518         if(comparefloats(fres1[i],fcheck[i])==0)
   519             {
   520               std_log(LOG_FILENAME_LINE,"oil_negative_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   521             }
   522            else
   523             {
   524              assert_failed = 1;
   525              std_log(LOG_FILENAME_LINE,"oil_negative_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   526             } 
   527         }
   528     }
   529 
   530 
   531 
   532 void test_inverse_f32()
   533     {
   534     int i;
   535     float fcheck[MAX_SIZE1]={1.00000000000000,0.66666668653488,0.50000000000000,0.40000000596046,0.33333334326744,0.28571429848671,0.25000000000000,0.22222222387791};
   536     for(i=0;i<MAX_SIZE1;i++)
   537         {
   538           fres1[i]=0;
   539           farr1[i]=(i+2)*0.5;
   540           std_log(LOG_FILENAME_LINE,"farr1[%d] = %f", i,farr1[i]);
   541         }
   542     oil_inverse_f32(fres1,farr1,MAX_SIZE1);
   543     
   544     for(i=0;i<MAX_SIZE1;i++)
   545         {
   546         if(comparefloats(fres1[i],fcheck[i])==0)
   547             {
   548              std_log(LOG_FILENAME_LINE,"oil_inverse_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   549             }
   550         else
   551            {
   552             assert_failed = 1;
   553             std_log(LOG_FILENAME_LINE,"oil_inverse_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   554            } 
   555         }
   556     }
   557 
   558 
   559 void test_sign_f32()
   560     {
   561     int i;
   562     float fcheck[MAX_SIZE1]={0.30000001192093,3.29999995231628,6.30000019073486,9.30000019073486,12.30000019073486,15.30000019073486,18.29999923706055,21.29999923706055};
   563     for(i=0;i<MAX_SIZE1;i++)
   564         {
   565           fres1[i]=0;
   566           farr1[i]=(i+0.1)*3;
   567           std_log(LOG_FILENAME_LINE,"farr1[%d] = %f", i,farr1[i]);
   568         }
   569     oil_sign_f32(fres1,farr1,MAX_SIZE1);
   570     
   571     for(i=0;i<MAX_SIZE1;i++)
   572         {
   573         if(comparefloats(fres1[i],fcheck[i])==0)
   574             {
   575              std_log(LOG_FILENAME_LINE,"oil_sign_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   576             }
   577         else
   578            {
   579             assert_failed = 1;
   580             std_log(LOG_FILENAME_LINE,"oil_sign_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   581            } 
   582         }
   583     }
   584 
   585 
   586 void test_floor_f32()
   587     {
   588     int i;
   589     float fcheck[MAX_SIZE1]={3.00000000000000,7.00000000000000,10.00000000000000,14.00000000000000,17.00000000000000,21.00000000000000,24.00000000000000,28.00000000000000};
   590     for(i=0;i<MAX_SIZE1;i++)
   591         {
   592           fres1[i]=0;
   593           farr1[i]=(i+1)*3.5;
   594           std_log(LOG_FILENAME_LINE,"farr1[%d] = %f", i,farr1[i]);
   595         }
   596     oil_floor_f32(fres1,farr1,MAX_SIZE1);
   597     
   598     for(i=0;i<MAX_SIZE1;i++)
   599         {
   600         if(comparefloats(fres1[i],fcheck[i])==0)
   601           {
   602            std_log(LOG_FILENAME_LINE,"oil_floor_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   603           }
   604         else
   605          {
   606            assert_failed = 1;
   607            std_log(LOG_FILENAME_LINE,"oil_floor_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   608          } 
   609         }
   610     }
   611 
   612 void test_scalaradd_f32()
   613     {
   614     int i;
   615     float fcheck[MAX_SIZE1]={18.20000076293945,21.20000076293945,24.20000076293945,27.20000076293945,30.20000076293945,33.20000076293945,36.20000076293945,39.20000076293945}, add1[8] = {3.2};
   616     for(i=0;i<MAX_SIZE1;i++)
   617         {
   618           fres1[i]=0;
   619           farr1[i]=(i+5)*3;
   620           std_log(LOG_FILENAME_LINE,"farr1[%d] = %f", i,farr1[i]);
   621         }
   622     oil_scalaradd_f32_ns(fres1,farr1,add1,MAX_SIZE1);
   623     
   624     for(i=0;i<MAX_SIZE1;i++)
   625         {
   626         if(comparefloats(fres1[i],fcheck[i])==0)
   627             {
   628               std_log(LOG_FILENAME_LINE,"oil_scalaradd_f32_ns successful, fres1[%d] = %15.14f", i,fres1[i]);
   629             }
   630          else
   631             {
   632              assert_failed = 1;
   633              std_log(LOG_FILENAME_LINE,"oil_scalaradd_f32_ns unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   634            } 
   635         }
   636     }
   637 
   638 
   639 void test_scalarmult_f64()
   640     {
   641     int i;
   642     double dcheck[MAX_DSIZE]={9.00000000000000,15.00000000000000,21.00000000000000,27.00000000000000,33.00000000000000}, mul1[MAX_DSIZE] = {3};
   643     for(i=0;i<MAX_DSIZE;i++)
   644         {
   645           dres1[i]=0;
   646           darr1[i]=(i+1.5)*2;
   647           std_log(LOG_FILENAME_LINE,"darr1[%d] = %15.14f", i,darr1[i]);
   648         }
   649     oil_scalarmultiply_f64_ns(dres1,darr1,mul1,MAX_DSIZE);
   650     
   651     for(i=0;i<MAX_DSIZE;i++)
   652         {
   653         if(comparefloats(dres1[i],dcheck[i])==0)
   654             {
   655              std_log(LOG_FILENAME_LINE,"oil_scalarmultiply_f64_ns successful, dres1[%d] = %15.14f", i,dres1[i]);
   656             }
   657          else
   658             {
   659              assert_failed = 1;
   660              std_log(LOG_FILENAME_LINE,"oil_scalarmultiply_f64_ns unsuccessful, Expected =%15.14f,Obtained =%15.14f",dcheck[i],dres1[i]);
   661             } 
   662         }
   663     }
   664 
   665 
   666 int main ()
   667 {
   668 
   669   std_log(LOG_FILENAME_LINE,"Test started testsuite_math");
   670   oil_init (); 
   671   
   672   std_log(LOG_FILENAME_LINE,"ADD_S16 TEST");
   673   test_add_s16();
   674   
   675   std_log(LOG_FILENAME_LINE,"ADD_S16_U8 TEST");
   676   test_add_s16_u8();
   677 
   678   std_log(LOG_FILENAME_LINE,"ADD_F32 TEST");
   679   test_add_f32();
   680   
   681   std_log(LOG_FILENAME_LINE,"ADD_F64 TEST");
   682   test_add_f64();
   683 
   684   std_log(LOG_FILENAME_LINE,"SUB_S16 TEST");
   685   test_sub_s16();  
   686 
   687   std_log(LOG_FILENAME_LINE,"SUB_S16_U8 TEST");
   688   test_sub_s16_u8();
   689   
   690   std_log(LOG_FILENAME_LINE,"SUB_F32 TEST");
   691   test_sub_f32();
   692 
   693   std_log(LOG_FILENAME_LINE,"SUB_F64 TEST");
   694   test_sub_f64();
   695   
   696   std_log(LOG_FILENAME_LINE,"MULT_F32 TEST");
   697   test_mult_f32();
   698   
   699   std_log(LOG_FILENAME_LINE,"MULT_F64 TEST");
   700   test_mult_f64();
   701   
   702   std_log(LOG_FILENAME_LINE,"DIV_F32 TEST");
   703   test_div_f32();
   704   
   705   std_log(LOG_FILENAME_LINE,"DIV_F64 TEST");
   706   test_div_f64();
   707 
   708   std_log(LOG_FILENAME_LINE,"MIN_F32 TEST");
   709   test_minimum_f32();
   710 
   711   std_log(LOG_FILENAME_LINE,"MIN_F64 TEST");
   712   test_minimum_f64();
   713   
   714   std_log(LOG_FILENAME_LINE,"MAX_F32 TEST");
   715   test_maximum_f32();
   716 
   717   std_log(LOG_FILENAME_LINE,"MAX_F64 TEST");
   718   test_maximum_f64();
   719   
   720   std_log(LOG_FILENAME_LINE,"NEGATIVE_F32 TEST");
   721   test_negative_f32();
   722 
   723   std_log(LOG_FILENAME_LINE,"SIGN_F32 TEST");
   724   test_sign_f32();
   725   
   726   std_log(LOG_FILENAME_LINE,"INVERSE_F32 TEST");
   727   test_inverse_f32();
   728 
   729   std_log(LOG_FILENAME_LINE,"FLOOR_F32 TEST");
   730   test_floor_f32();
   731   
   732   std_log(LOG_FILENAME_LINE,"SCALARADD_F32 TEST");
   733   test_scalaradd_f32();
   734   
   735   std_log(LOG_FILENAME_LINE,"SCALARMULT_F64 TEST");
   736   test_scalarmult_f64();
   737   
   738    if(assert_failed)
   739          std_log(LOG_FILENAME_LINE,"Test Fail");
   740    else
   741          std_log(LOG_FILENAME_LINE,"Test Successful");
   742    
   743   create_xml(0);
   744   return 0;
   745 }
   746