os/ossrv/genericopenlibs/liboil/tsrc/testsuite/math/src/math.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/liboil/tsrc/testsuite/math/src/math.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,746 @@
     1.4 +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +//Description:
    1.17 +//
    1.18 +
    1.19 +
    1.20 +
    1.21 +#ifdef HAVE_CONFIG_H
    1.22 +#include "config.h"
    1.23 +#endif
    1.24 +
    1.25 +#include <liboil/liboil.h>
    1.26 +#include <liboil/liboilfunction.h>
    1.27 +#include <stdio.h>
    1.28 +#include <string.h>
    1.29 +#include <globals.h>
    1.30 +
    1.31 +#define LOG_FILE "c:\\logs\\testsuite_math_log.txt"
    1.32 +#include "std_log_result.h"
    1.33 +#include "utils.h"
    1.34 +#define LOG_FILENAME_LINE __FILE__, __LINE__
    1.35 +#define MAX_SIZE 10
    1.36 +#define MAX_SIZE1 8
    1.37 +#define MAX_DSIZE 5
    1.38 +
    1.39 +int16_t arr1[MAX_SIZE], arr2[MAX_SIZE], res1[MAX_SIZE];
    1.40 +uint8_t uarr1[MAX_SIZE],uarr2[MAX_SIZE1],uarr3[MAX_SIZE1], ures1[MAX_SIZE1];
    1.41 +float farr1[MAX_SIZE1], farr2[MAX_SIZE1],fres1[MAX_SIZE1];
    1.42 +double darr1[MAX_DSIZE], darr2[MAX_DSIZE],dres1[MAX_DSIZE];
    1.43 +
    1.44 +void create_xml(int result)
    1.45 +{
    1.46 +    if(result)
    1.47 +        assert_failed = 1;
    1.48 +    
    1.49 +    testResultXml("testsuite_math");
    1.50 +    close_log_file();
    1.51 +}
    1.52 +
    1.53 +void test_add_s16()
    1.54 +    {
    1.55 +    int i;
    1.56 +    int16_t check[MAX_SIZE]={8,13,18,23,28,33,38,43,48,53};
    1.57 +    for(i=0;i<MAX_SIZE;i++)
    1.58 +        {
    1.59 +          res1[i]=0;
    1.60 +          arr1[i]=(i+2) *3;
    1.61 +          arr2[i]=(i+1)*2;
    1.62 +          std_log(LOG_FILENAME_LINE,"arr1[%d] = %d, arr2[%d] = %d", i,arr1[i],i,arr2[i]);
    1.63 +        }
    1.64 +    oil_add_s16(res1,arr1,arr2,MAX_SIZE);
    1.65 +    
    1.66 +    for(i=0;i<MAX_SIZE;i++)
    1.67 +        {
    1.68 +        if(res1[i] == check[i])
    1.69 +            {
    1.70 +            std_log(LOG_FILENAME_LINE,"oil_add_s16 successful, res1[%d]=%d", i,res1[i]);
    1.71 +            }
    1.72 +        else
    1.73 +            {
    1.74 +             assert_failed = 1;
    1.75 +             std_log(LOG_FILENAME_LINE,"oil_add_s16 unsuccessful, Expected =%d,Obtained =%d",check[i],res1[i]);
    1.76 +            }
    1.77 +        }  
    1.78 +    }
    1.79 +
    1.80 +void test_add_s16_u8()
    1.81 +    {
    1.82 +    int i;
    1.83 +    int16_t check[MAX_SIZE]={6,11,16,21,26,31,36,41,46,51};
    1.84 +    for(i=0;i<MAX_SIZE;i++)
    1.85 +        {
    1.86 +          res1[i]=0;
    1.87 +          arr1[i]=(i+2)*3;
    1.88 +          uarr1[i]=i*2;
    1.89 +          std_log(LOG_FILENAME_LINE,"arr1[%d] = %d, uarr1[%d] = %d", i,arr1[i],i,uarr1[i]);
    1.90 +        }
    1.91 +    oil_add_s16_u8(res1,arr1,uarr1,MAX_SIZE);
    1.92 +    
    1.93 +    for(i=0;i<MAX_SIZE;i++)
    1.94 +        {
    1.95 +        if(res1[i] == check[i])
    1.96 +            {
    1.97 +            std_log(LOG_FILENAME_LINE,"oil_add_s16_u8 successful, res1[%d] = %d", i,res1[i]);
    1.98 +            }
    1.99 +        else
   1.100 +            {
   1.101 +             assert_failed = 1;
   1.102 +             std_log(LOG_FILENAME_LINE,"oil_add_s16_u8 unsuccessful,Expected =%d,Obtained =%d",check[i],res1[i]);
   1.103 +            }
   1.104 +        }  
   1.105 +    }
   1.106 +
   1.107 +
   1.108 +
   1.109 +
   1.110 +void test_add_f32()
   1.111 +    {
   1.112 +    int i;
   1.113 +    float fcheck[MAX_SIZE1]={8.30000019073486,12.10000038146973,15.89999961853027,19.70000076293945,23.50000000000000,27.29999923706055,31.10000038146973,34.90000152587891};
   1.114 +    for(i=0;i<MAX_SIZE1;i++)
   1.115 +        {
   1.116 +          fres1[i]=0;
   1.117 +          farr1[i]=(i+2.5)*3;
   1.118 +          farr2[i]=(i+1)*0.8;
   1.119 +          std_log(LOG_FILENAME_LINE,"farr1[%d] = %f, farr2[%d] = %f", i,farr1[i],i,farr2[i]);
   1.120 +        }
   1.121 +    oil_add_f32(fres1,farr1,farr2,MAX_SIZE1);
   1.122 +    
   1.123 +    for(i=0;i<MAX_SIZE1;i++)
   1.124 +        {
   1.125 +        if(comparefloats(fres1[i],fcheck[i])==0)
   1.126 +            {
   1.127 +            std_log(LOG_FILENAME_LINE,"oil_add_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   1.128 +            }
   1.129 +        else
   1.130 +            {
   1.131 +             assert_failed = 1;
   1.132 +             std_log(LOG_FILENAME_LINE,"oil_add_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   1.133 +            }
   1.134 +        }  
   1.135 +    }
   1.136 +
   1.137 +
   1.138 +void test_add_f64()
   1.139 +    {
   1.140 +    int i;
   1.141 +    double dcheck[MAX_DSIZE]={7.51500000000000,10.85500000000000,14.19500000000000,17.53500000000000,20.87500000000000};
   1.142 +    for(i=0;i<MAX_DSIZE;i++)
   1.143 +        {
   1.144 +          fres1[i]=0;
   1.145 +          darr1[i]=(i+2.25)*3.34;
   1.146 +          arr2[i]=(i+1.3)*0.18;
   1.147 +          std_log(LOG_FILENAME_LINE,"farr1[%d] = %15.14f, farr2[%d] = %15.14f", i,darr1[i],i,darr2[i]);
   1.148 +        }
   1.149 +    oil_add_f64(dres1,darr1,darr2,MAX_DSIZE);
   1.150 +    
   1.151 +    for(i=0;i<MAX_DSIZE;i++)
   1.152 +        {
   1.153 +        if(comparefloats(dres1[i],dcheck[i])==0)
   1.154 +            {
   1.155 +            std_log(LOG_FILENAME_LINE,"oil_add_f64 successful, dres1[%d] = %15.14f", i,dres1[i]);
   1.156 +            }
   1.157 +        else
   1.158 +            {
   1.159 +             assert_failed = 1;
   1.160 +             std_log(LOG_FILENAME_LINE,"oil_add_f64 unsuccessful, Expected =%15.14f,Obtained =%15.14f",dcheck[i],dres1[i]);
   1.161 +            } 
   1.162 +        }  
   1.163 +    }
   1.164 +
   1.165 +
   1.166 +void test_sub_s16()
   1.167 +    {
   1.168 +    int i;
   1.169 +    int16_t check[MAX_SIZE]={4,5,6,7,8,9,10,11,12,13};
   1.170 +    for(i=0;i<MAX_SIZE;i++)
   1.171 +        {
   1.172 +          res1[i]=0;
   1.173 +          arr1[i]=(i+2) *3;
   1.174 +          arr2[i]=(i+1)*2;
   1.175 +          std_log(LOG_FILENAME_LINE,"arr1[%d]=%d,arr2[%d]=%d", i,arr1[i],i,arr2[i]);
   1.176 +        }
   1.177 +    
   1.178 +    oil_subtract_s16(res1,arr1,arr2,MAX_SIZE);
   1.179 +    
   1.180 +    for(i=0;i<MAX_SIZE;i++)
   1.181 +        {
   1.182 +        if(res1[i] == check[i])
   1.183 +            {
   1.184 +            std_log(LOG_FILENAME_LINE,"oil_subtract_s16 successful,res1[%d]=%d", i,res1[i]);
   1.185 +            }
   1.186 +        else
   1.187 +            {
   1.188 +             assert_failed = 1;
   1.189 +             std_log(LOG_FILENAME_LINE,"oil_subtract_s16 unsuccessful, Expected =%d,Obtained =%d",check[i],res1[i]);
   1.190 +            }
   1.191 +        }  
   1.192 +    }
   1.193 +
   1.194 +void test_sub_s16_u8()
   1.195 +    {
   1.196 +    int i;
   1.197 +    int16_t check[MAX_SIZE]={6,7,8,9,10,11,12,13,14,15};
   1.198 +    for(i=0;i<MAX_SIZE;i++)
   1.199 +        {
   1.200 +          res1[i]=0;
   1.201 +          arr1[i]=(i+2)*3;
   1.202 +          uarr1[i]=i*2;
   1.203 +          std_log(LOG_FILENAME_LINE,"arr1[%d]=%d, uarr1[%d]=%d",i,arr1[i],i,uarr1[i]);
   1.204 +        }
   1.205 +    oil_subtract_s16_u8(res1,arr1,uarr1,MAX_SIZE);
   1.206 +    
   1.207 +    for(i=0;i<MAX_SIZE;i++)
   1.208 +        {
   1.209 +        if(res1[i] == check[i])
   1.210 +            {
   1.211 +            std_log(LOG_FILENAME_LINE,"oil_subtract_s16_u8 successful, res1[%d] = %d", i,res1[i]);
   1.212 +            }
   1.213 +        else
   1.214 +            {
   1.215 +             assert_failed = 1;
   1.216 +             std_log(LOG_FILENAME_LINE,"oil_subtract_s16_u8 unsuccessful, Expected =%d,Obtained =%d",check[i],res1[i]);
   1.217 +            }
   1.218 +        }  
   1.219 +    }
   1.220 +
   1.221 +
   1.222 +
   1.223 +void test_sub_f32()
   1.224 +    {
   1.225 +    int i;
   1.226 +    float fcheck[MAX_SIZE1]={6.69999980926514,8.89999961853027,11.10000038146973,13.30000019073486,15.50000000000000,17.70000076293945,19.89999961853027,22.10000038146973};
   1.227 +    for(i=0;i<MAX_SIZE1;i++)
   1.228 +        {
   1.229 +          fres1[i]=0;
   1.230 +          farr1[i]=(i+2.5)*3;
   1.231 +          farr2[i]=(i+1)*0.8;
   1.232 +          std_log(LOG_FILENAME_LINE,"farr1[%d]=%f,farr2[%d]=%f", i,farr1[i],i,farr2[i]);
   1.233 +        }
   1.234 +    oil_subtract_f32(fres1,farr1,farr2,MAX_SIZE1);
   1.235 +    
   1.236 +    for(i=0;i<MAX_SIZE1;i++)
   1.237 +        {
   1.238 +        if(comparefloats(fres1[i],fcheck[i])==0)
   1.239 +            {
   1.240 +            std_log(LOG_FILENAME_LINE,"oil_subtract_f32 successful,fres1[%d]=%15.14f", i,fres1[i]);
   1.241 +            }
   1.242 +        else
   1.243 +            {
   1.244 +             assert_failed = 1;
   1.245 +             std_log(LOG_FILENAME_LINE,"oil_subtract_f32 unsuccessful,Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   1.246 +            }
   1.247 +        }  
   1.248 +    }
   1.249 +
   1.250 +
   1.251 +void test_sub_f64()
   1.252 +    {
   1.253 +    int i;
   1.254 +    double dcheck[MAX_DSIZE]={7.28100000000000,10.44100000000000,13.60100000000000,16.76100000000000,19.92100000000000};
   1.255 +    for(i=0;i<MAX_DSIZE;i++)
   1.256 +        {
   1.257 +          dres1[i]=0;
   1.258 +          darr1[i]=(i+2.25)*3.34;
   1.259 +          darr2[i]=(i+1.3)*0.18;
   1.260 +          std_log(LOG_FILENAME_LINE,"darr1[%d] = %15.14f, darr2[%d] = %15.14f", i,darr1[i],i,darr2[i]);
   1.261 +        }
   1.262 +    oil_subtract_f64(dres1,darr1,darr2,MAX_DSIZE);
   1.263 +    
   1.264 +    for(i=0;i<MAX_DSIZE;i++)
   1.265 +        {
   1.266 +        if(comparefloats(dres1[i],dcheck[i])==0)
   1.267 +            {
   1.268 +            std_log(LOG_FILENAME_LINE,"oil_subtract_f64 successful, dres1[%d] = %15.14f", i,dres1[i]);
   1.269 +            }
   1.270 +        else
   1.271 +            {
   1.272 +             assert_failed = 1;
   1.273 +             std_log(LOG_FILENAME_LINE,"oil_subtract_f64 unsuccessful, Expected =%15.14f,Obtained =%15.14f",dcheck[i],dres1[i]);
   1.274 +            } 
   1.275 +        }  
   1.276 +    }
   1.277 +
   1.278 +
   1.279 +void test_mult_f32()
   1.280 +    {
   1.281 +    int i;
   1.282 +    float fcheck[MAX_SIZE1]={0.66799998283386,2.00400018692017,4.00799989700317,6.68000030517578,10.02000045776367,14.02799987792969,18.70399856567383,24.04800033569336};
   1.283 +    for(i=0;i<MAX_SIZE1;i++)
   1.284 +        {
   1.285 +          fres1[i]=0;
   1.286 +          farr1[i]=(i+2)*3.34;
   1.287 +          farr2[i]=(i+1)*0.1;
   1.288 +          std_log(LOG_FILENAME_LINE,"farr1[%d] = %f, farr2[%d] = %f", i,farr1[i],i,farr2[i]);
   1.289 +        }
   1.290 +    oil_multiply_f32(fres1,farr1,farr2,MAX_SIZE1);
   1.291 +    
   1.292 +    for(i=0;i<MAX_SIZE1;i++)
   1.293 +        {
   1.294 +        if(comparefloats(fres1[i],fcheck[i])==0)
   1.295 +            {
   1.296 +              std_log(LOG_FILENAME_LINE,"oil_multiply_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   1.297 +             }
   1.298 +           else
   1.299 +               {
   1.300 +                assert_failed = 1;
   1.301 +                std_log(LOG_FILENAME_LINE,"oil_multiply_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   1.302 +               } 
   1.303 +        }
   1.304 +    }
   1.305 +
   1.306 +void test_mult_f64()
   1.307 +    {
   1.308 +    int i;
   1.309 +    double dcheck[MAX_DSIZE]={1.71943200000000,4.42483200000000,8.33263200000000,13.44283200000000,19.75543200000000};
   1.310 +    for(i=0;i<MAX_DSIZE;i++)
   1.311 +         {
   1.312 +           dres1[i]=0;
   1.313 +           darr1[i]=(i+2.2)*3.34;
   1.314 +           darr2[i]=(i+1.3)*0.18;
   1.315 +           std_log(LOG_FILENAME_LINE,"darr1[%d] = %15.14f, darr2[%d] = %15.14f", i,darr1[i],i,darr2[i]);
   1.316 +         }
   1.317 +    oil_multiply_f64(dres1,darr1,darr2,MAX_DSIZE);
   1.318 +     
   1.319 +    for(i=0;i<MAX_DSIZE;i++)
   1.320 +         {
   1.321 +         if(comparefloats(dres1[i],dcheck[i])==0)
   1.322 +             {
   1.323 +             std_log(LOG_FILENAME_LINE,"oil_multiply_f64 successful, dres1[%d] = %15.14f", i,dres1[i]);
   1.324 +             }
   1.325 +         else
   1.326 +             {
   1.327 +              assert_failed = 1;
   1.328 +              std_log(LOG_FILENAME_LINE,"oil_multiply_f64 unsuccessful, Expected =%15.14f,Obtained =%15.14f",dcheck[i],dres1[i]);
   1.329 +             } 
   1.330 +         }  
   1.331 +    }
   1.332 +
   1.333 +
   1.334 +void test_div_f32()
   1.335 +    {
   1.336 +    int i;
   1.337 +    float fcheck[MAX_SIZE1]={60.00000000000000,45.00000000000000,40.00000000000000,37.50000000000000,36.00000000000000,35.00000000000000,34.28571319580078,33.75000000000000};
   1.338 +    for(i=0;i<MAX_SIZE1;i++)
   1.339 +        {
   1.340 +          fres1[i]=0;
   1.341 +          farr1[i]=(i+2)*3;
   1.342 +          farr2[i]=(i+1)*0.1;
   1.343 +          std_log(LOG_FILENAME_LINE,"farr1[%d] = %f, farr2[%d] = %f", i,farr1[i],i,farr2[i]);
   1.344 +        }
   1.345 +    oil_divide_f32(fres1,farr1,farr2,MAX_SIZE1);
   1.346 +    
   1.347 +    for(i=0;i<MAX_SIZE1;i++)
   1.348 +        {
   1.349 +        if(comparefloats(fres1[i],fcheck[i])==0)
   1.350 +            {
   1.351 +              std_log(LOG_FILENAME_LINE,"oil_divide_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   1.352 +              }
   1.353 +           else
   1.354 +               {
   1.355 +                assert_failed = 1;
   1.356 +                std_log(LOG_FILENAME_LINE,"oil_divide_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   1.357 +               } 
   1.358 +        }
   1.359 +    }
   1.360 +
   1.361 +void test_div_f64()
   1.362 +    {
   1.363 +    int i;
   1.364 +    double dcheck[MAX_DSIZE]={2.82615384615385,2.32347826086957,2.12545454545455,2.01953488372093,1.95358490566038};
   1.365 +    for(i=0;i<MAX_DSIZE;i++)
   1.366 +         {
   1.367 +           dres1[i]=0;
   1.368 +           darr1[i]=(i+2.2)*3.34;
   1.369 +           darr2[i]=(i+1.3)*2;
   1.370 +           std_log(LOG_FILENAME_LINE,"darr1[%d] = %15.14f, darr2[%d] = %15.14f", i,darr1[i],i,darr2[i]);
   1.371 +         }
   1.372 +    oil_divide_f64(dres1,darr1,darr2,MAX_DSIZE);
   1.373 +     
   1.374 +    for(i=0;i<MAX_DSIZE;i++)
   1.375 +         {
   1.376 +         if(comparefloats(dres1[i],dcheck[i])==0)
   1.377 +             {
   1.378 +             std_log(LOG_FILENAME_LINE,"oil_divide_f64 successful, dres1[%d] = %15.14f", i,dres1[i]);
   1.379 +             }
   1.380 +         else
   1.381 +             {
   1.382 +              assert_failed = 1;
   1.383 +              std_log(LOG_FILENAME_LINE,"oil_divide_f64 unsuccessful, Expected =%15.14f,Obtained =%15.14f",dcheck[i],dres1[i]);
   1.384 +             } 
   1.385 +         }  
   1.386 +    }
   1.387 +
   1.388 +
   1.389 +
   1.390 +void test_minimum_f32()
   1.391 +    {
   1.392 +    int i;
   1.393 +    float fmarr1[MAX_SIZE] = {2.10, 0.23123, 532.2, 1, 0908.34, 23432.1, 11.34, 0.0002, 87.2324, 700};
   1.394 +    float fmarr2[MAX_SIZE] = { 86.3423, 1231.11, 65457.2, 0, 10.3, 700, 2.10, 8967.21, 3423.23,211.076 };
   1.395 +    float fmin1[MAX_SIZE];
   1.396 +    float fmcheck[MAX_SIZE]={2.09999990463257,0.23123000562191,532.20001220703125,0.00000000000000,10.30000019073486,700.00000000000000,2.09999990463257,0.00019999999495,87.23239898681641,211.07600402832031};
   1.397 +    for(i=0;i<MAX_SIZE;i++)
   1.398 +        {
   1.399 +          fmin1[i]=0;
   1.400 +          std_log(LOG_FILENAME_LINE,"fmarr1[%d] = %f, fmarr2[%d] = %f", i,fmarr1[i],i,fmarr2[i]);
   1.401 +        }
   1.402 +    oil_minimum_f32(fmin1,fmarr1,fmarr2,MAX_SIZE);
   1.403 +    
   1.404 +    for(i=0;i<MAX_SIZE;i++)
   1.405 +        {
   1.406 +        if(comparefloats(fmin1[i],fmcheck[i])==0)
   1.407 +            {
   1.408 +              std_log(LOG_FILENAME_LINE,"oil_minimum_f32 successful, fmin1[%d] = %15.14f", i,fmin1[i]);
   1.409 +             }
   1.410 +         else
   1.411 +            {
   1.412 +              assert_failed = 1;
   1.413 +              std_log(LOG_FILENAME_LINE,"oil_minimum_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fmcheck[i],fmin1[i]);
   1.414 +            } 
   1.415 +        }
   1.416 +    }
   1.417 +
   1.418 +
   1.419 +void test_minimum_f64()
   1.420 +    {
   1.421 +    int i;
   1.422 +    float dmarr1[MAX_SIZE] = {2324235.10, 0231.3223, 532.2, 1.3423421, 23432.1, 11.3423424, 340.0002, 87342.3424,3243.12,0};
   1.423 +    float dmarr2[MAX_SIZE] = { 2386.3423, 11131.11, 6545.2, 230, 110.31, 400.700, 122.10, 892467.22, 24323.23,3243.12 };
   1.424 +    float dmin1[MAX_SIZE];
   1.425 +    float dmcheck[MAX_SIZE]={2386.34228515625000,231.32229614257812,532.20001220703125,1.34234213829041,110.30999755859375,11.34234237670898,122.09999847412109,87342.34375000000000,3243.12011718750000,0.00000000000000};
   1.426 +    for(i=0;i<MAX_SIZE;i++)
   1.427 +        {
   1.428 +          dmin1[i]=0;
   1.429 +          std_log(LOG_FILENAME_LINE,"fmarr1[%d] = %15.14f, fmarr2[%d] = %15.14f", i,dmarr1[i],i,dmarr2[i]);
   1.430 +        }
   1.431 +    oil_minimum_f64(dmin1,dmarr1,dmarr2,MAX_SIZE);
   1.432 +    
   1.433 +    for(i=0;i<MAX_SIZE;i++)
   1.434 +        {
   1.435 +        if(comparefloats(dmin1[i],dmcheck[i])==0)
   1.436 +            {
   1.437 +              std_log(LOG_FILENAME_LINE,"oil_minimum_f64 successful, dmin1[%d] = %15.14f", i,dmin1[i]);
   1.438 +            }
   1.439 +        else
   1.440 +            {
   1.441 +              assert_failed = 1;
   1.442 +              std_log(LOG_FILENAME_LINE,"oil_minimum_f64 unsuccessful, Expected =%15.14f,Obtained =%15.14f",dmcheck[i],dmin1[i]);
   1.443 +            } 
   1.444 +        }
   1.445 +    }
   1.446 +
   1.447 +
   1.448 +
   1.449 +void test_maximum_f32()
   1.450 +    {
   1.451 +    int i;
   1.452 +    float fmarr1[MAX_SIZE] = {2.10, 0.23123, 532.2, 1, 0908.34, 23432.1, 11.34, 0.0002, 87.2324, 700};
   1.453 +    float fmarr2[MAX_SIZE] = { 86.3423, 1231.11, 65457.2, 0, 10.3, 700, 2.10, 8967.21, 3423.23,211.076 };
   1.454 +    float fmax1[MAX_SIZE];
   1.455 +    float fmcheck[MAX_SIZE]={86.34230041503906,1231.10998535156250,65457.19921875000000,1.00000000000000,908.34002685546875,23432.09960937500000,11.34000015258789,8967.20996093750000,3423.22998046875000,700.00000000000000};
   1.456 +    for(i=0;i<MAX_SIZE;i++)
   1.457 +        {
   1.458 +          fmax1[i]=0;
   1.459 +          std_log(LOG_FILENAME_LINE,"fmarr1[%d] = %f, fmarr2[%d] = %f", i,fmarr1[i],i,fmarr2[i]);
   1.460 +        }
   1.461 +    oil_maximum_f32(fmax1,fmarr1,fmarr2,MAX_SIZE);
   1.462 +    
   1.463 +    for(i=0;i<MAX_SIZE;i++)
   1.464 +        {
   1.465 +        if(comparefloats(fmax1[i],fmcheck[i])==0)
   1.466 +            {
   1.467 +              std_log(LOG_FILENAME_LINE,"oil_maximum_f32 successful, fmax1[%d] = %15.14f", i,fmax1[i]);
   1.468 +            }
   1.469 +        else
   1.470 +            {
   1.471 +              assert_failed = 1;
   1.472 +              std_log(LOG_FILENAME_LINE,"oil_maximum_f32 unsuccessful,Expected =%15.14f,Obtained =%15.14f",fmcheck[i],fmax1[i]);
   1.473 +            } 
   1.474 +        }
   1.475 +    }
   1.476 +
   1.477 +
   1.478 +void test_maximum_f64()
   1.479 +    {
   1.480 +    int i;
   1.481 +    float dmarr1[MAX_SIZE] = {2324235.10, 0231.3223, 532.2, 1.3423421, 23432.1, 11.3423424, 340.0002, 87342.3424,3243.12};
   1.482 +    float dmarr2[MAX_SIZE] = {2386.3423, 11131.11, 6545.2, 230, 110.31, 400.700, 122.10, 892467.22, 24323.23,3243.12 };
   1.483 +    float dmax1[MAX_SIZE];
   1.484 +    float dmcheck[MAX_SIZE]={2324235.00000000000000,11131.11035156250000,6545.20019531250000,230.00000000000000,23432.09960937500000,400.70001220703125,340.00021362304688,892467.25000000000000,24323.23046875000000,3243.12011718750000};
   1.485 +    for(i=0;i<MAX_SIZE;i++)
   1.486 +        {
   1.487 +          dmax1[i]=0;
   1.488 +          std_log(LOG_FILENAME_LINE,"fmarr1[%d] = %15.14f, fmarr2[%d] = %15.14f", i,dmarr1[i],i,dmarr2[i]);
   1.489 +        }
   1.490 +    oil_maximum_f64(dmax1,dmarr1,dmarr2,MAX_SIZE);
   1.491 +    
   1.492 +    for(i=0;i<MAX_SIZE;i++)
   1.493 +        {
   1.494 +        if(comparefloats(dmax1[i],dmcheck[i])==0)
   1.495 +           {
   1.496 +            std_log(LOG_FILENAME_LINE,"oil_maximum_f64 successful, dmax1[%d] = %15.14f", i,dmax1[i]);
   1.497 +           }
   1.498 +        else
   1.499 +          {
   1.500 +           assert_failed = 1;
   1.501 +           std_log(LOG_FILENAME_LINE,"oil_maximum_f64 unsuccessful, Expected =%15.14f,Obtained =%15.14f",dmcheck[i],dmax1[i]);
   1.502 +          } 
   1.503 +        }
   1.504 +    }
   1.505 +
   1.506 +
   1.507 +void test_negative_f32()
   1.508 +    {
   1.509 +    int i;
   1.510 +    float fcheck[MAX_SIZE1]={-6.19999980926514,-9.30000019073486,-12.39999961853027,-15.50000000000000,-18.60000038146973,-21.70000076293945,-24.79999923706055,-27.89999961853027};
   1.511 +    for(i=0;i<MAX_SIZE1;i++)
   1.512 +        {
   1.513 +          fres1[i]=0;
   1.514 +          farr1[i]=(i+2)*3.1;
   1.515 +          std_log(LOG_FILENAME_LINE,"farr1[%d] = %f", i,farr1[i]);
   1.516 +        }
   1.517 +    oil_negative_f32(fres1,farr1,MAX_SIZE1);
   1.518 +    
   1.519 +    for(i=0;i<MAX_SIZE1;i++)
   1.520 +        {
   1.521 +        if(comparefloats(fres1[i],fcheck[i])==0)
   1.522 +            {
   1.523 +              std_log(LOG_FILENAME_LINE,"oil_negative_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   1.524 +            }
   1.525 +           else
   1.526 +            {
   1.527 +             assert_failed = 1;
   1.528 +             std_log(LOG_FILENAME_LINE,"oil_negative_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   1.529 +            } 
   1.530 +        }
   1.531 +    }
   1.532 +
   1.533 +
   1.534 +
   1.535 +void test_inverse_f32()
   1.536 +    {
   1.537 +    int i;
   1.538 +    float fcheck[MAX_SIZE1]={1.00000000000000,0.66666668653488,0.50000000000000,0.40000000596046,0.33333334326744,0.28571429848671,0.25000000000000,0.22222222387791};
   1.539 +    for(i=0;i<MAX_SIZE1;i++)
   1.540 +        {
   1.541 +          fres1[i]=0;
   1.542 +          farr1[i]=(i+2)*0.5;
   1.543 +          std_log(LOG_FILENAME_LINE,"farr1[%d] = %f", i,farr1[i]);
   1.544 +        }
   1.545 +    oil_inverse_f32(fres1,farr1,MAX_SIZE1);
   1.546 +    
   1.547 +    for(i=0;i<MAX_SIZE1;i++)
   1.548 +        {
   1.549 +        if(comparefloats(fres1[i],fcheck[i])==0)
   1.550 +            {
   1.551 +             std_log(LOG_FILENAME_LINE,"oil_inverse_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   1.552 +            }
   1.553 +        else
   1.554 +           {
   1.555 +            assert_failed = 1;
   1.556 +            std_log(LOG_FILENAME_LINE,"oil_inverse_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   1.557 +           } 
   1.558 +        }
   1.559 +    }
   1.560 +
   1.561 +
   1.562 +void test_sign_f32()
   1.563 +    {
   1.564 +    int i;
   1.565 +    float fcheck[MAX_SIZE1]={0.30000001192093,3.29999995231628,6.30000019073486,9.30000019073486,12.30000019073486,15.30000019073486,18.29999923706055,21.29999923706055};
   1.566 +    for(i=0;i<MAX_SIZE1;i++)
   1.567 +        {
   1.568 +          fres1[i]=0;
   1.569 +          farr1[i]=(i+0.1)*3;
   1.570 +          std_log(LOG_FILENAME_LINE,"farr1[%d] = %f", i,farr1[i]);
   1.571 +        }
   1.572 +    oil_sign_f32(fres1,farr1,MAX_SIZE1);
   1.573 +    
   1.574 +    for(i=0;i<MAX_SIZE1;i++)
   1.575 +        {
   1.576 +        if(comparefloats(fres1[i],fcheck[i])==0)
   1.577 +            {
   1.578 +             std_log(LOG_FILENAME_LINE,"oil_sign_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   1.579 +            }
   1.580 +        else
   1.581 +           {
   1.582 +            assert_failed = 1;
   1.583 +            std_log(LOG_FILENAME_LINE,"oil_sign_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   1.584 +           } 
   1.585 +        }
   1.586 +    }
   1.587 +
   1.588 +
   1.589 +void test_floor_f32()
   1.590 +    {
   1.591 +    int i;
   1.592 +    float fcheck[MAX_SIZE1]={3.00000000000000,7.00000000000000,10.00000000000000,14.00000000000000,17.00000000000000,21.00000000000000,24.00000000000000,28.00000000000000};
   1.593 +    for(i=0;i<MAX_SIZE1;i++)
   1.594 +        {
   1.595 +          fres1[i]=0;
   1.596 +          farr1[i]=(i+1)*3.5;
   1.597 +          std_log(LOG_FILENAME_LINE,"farr1[%d] = %f", i,farr1[i]);
   1.598 +        }
   1.599 +    oil_floor_f32(fres1,farr1,MAX_SIZE1);
   1.600 +    
   1.601 +    for(i=0;i<MAX_SIZE1;i++)
   1.602 +        {
   1.603 +        if(comparefloats(fres1[i],fcheck[i])==0)
   1.604 +          {
   1.605 +           std_log(LOG_FILENAME_LINE,"oil_floor_f32 successful, fres1[%d] = %15.14f", i,fres1[i]);
   1.606 +          }
   1.607 +        else
   1.608 +         {
   1.609 +           assert_failed = 1;
   1.610 +           std_log(LOG_FILENAME_LINE,"oil_floor_f32 unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   1.611 +         } 
   1.612 +        }
   1.613 +    }
   1.614 +
   1.615 +void test_scalaradd_f32()
   1.616 +    {
   1.617 +    int i;
   1.618 +    float fcheck[MAX_SIZE1]={18.20000076293945,21.20000076293945,24.20000076293945,27.20000076293945,30.20000076293945,33.20000076293945,36.20000076293945,39.20000076293945}, add1[8] = {3.2};
   1.619 +    for(i=0;i<MAX_SIZE1;i++)
   1.620 +        {
   1.621 +          fres1[i]=0;
   1.622 +          farr1[i]=(i+5)*3;
   1.623 +          std_log(LOG_FILENAME_LINE,"farr1[%d] = %f", i,farr1[i]);
   1.624 +        }
   1.625 +    oil_scalaradd_f32_ns(fres1,farr1,add1,MAX_SIZE1);
   1.626 +    
   1.627 +    for(i=0;i<MAX_SIZE1;i++)
   1.628 +        {
   1.629 +        if(comparefloats(fres1[i],fcheck[i])==0)
   1.630 +            {
   1.631 +              std_log(LOG_FILENAME_LINE,"oil_scalaradd_f32_ns successful, fres1[%d] = %15.14f", i,fres1[i]);
   1.632 +            }
   1.633 +         else
   1.634 +            {
   1.635 +             assert_failed = 1;
   1.636 +             std_log(LOG_FILENAME_LINE,"oil_scalaradd_f32_ns unsuccessful, Expected =%15.14f,Obtained =%15.14f",fcheck[i],fres1[i]);
   1.637 +           } 
   1.638 +        }
   1.639 +    }
   1.640 +
   1.641 +
   1.642 +void test_scalarmult_f64()
   1.643 +    {
   1.644 +    int i;
   1.645 +    double dcheck[MAX_DSIZE]={9.00000000000000,15.00000000000000,21.00000000000000,27.00000000000000,33.00000000000000}, mul1[MAX_DSIZE] = {3};
   1.646 +    for(i=0;i<MAX_DSIZE;i++)
   1.647 +        {
   1.648 +          dres1[i]=0;
   1.649 +          darr1[i]=(i+1.5)*2;
   1.650 +          std_log(LOG_FILENAME_LINE,"darr1[%d] = %15.14f", i,darr1[i]);
   1.651 +        }
   1.652 +    oil_scalarmultiply_f64_ns(dres1,darr1,mul1,MAX_DSIZE);
   1.653 +    
   1.654 +    for(i=0;i<MAX_DSIZE;i++)
   1.655 +        {
   1.656 +        if(comparefloats(dres1[i],dcheck[i])==0)
   1.657 +            {
   1.658 +             std_log(LOG_FILENAME_LINE,"oil_scalarmultiply_f64_ns successful, dres1[%d] = %15.14f", i,dres1[i]);
   1.659 +            }
   1.660 +         else
   1.661 +            {
   1.662 +             assert_failed = 1;
   1.663 +             std_log(LOG_FILENAME_LINE,"oil_scalarmultiply_f64_ns unsuccessful, Expected =%15.14f,Obtained =%15.14f",dcheck[i],dres1[i]);
   1.664 +            } 
   1.665 +        }
   1.666 +    }
   1.667 +
   1.668 +
   1.669 +int main ()
   1.670 +{
   1.671 +
   1.672 +  std_log(LOG_FILENAME_LINE,"Test started testsuite_math");
   1.673 +  oil_init (); 
   1.674 +  
   1.675 +  std_log(LOG_FILENAME_LINE,"ADD_S16 TEST");
   1.676 +  test_add_s16();
   1.677 +  
   1.678 +  std_log(LOG_FILENAME_LINE,"ADD_S16_U8 TEST");
   1.679 +  test_add_s16_u8();
   1.680 +
   1.681 +  std_log(LOG_FILENAME_LINE,"ADD_F32 TEST");
   1.682 +  test_add_f32();
   1.683 +  
   1.684 +  std_log(LOG_FILENAME_LINE,"ADD_F64 TEST");
   1.685 +  test_add_f64();
   1.686 +
   1.687 +  std_log(LOG_FILENAME_LINE,"SUB_S16 TEST");
   1.688 +  test_sub_s16();  
   1.689 +
   1.690 +  std_log(LOG_FILENAME_LINE,"SUB_S16_U8 TEST");
   1.691 +  test_sub_s16_u8();
   1.692 +  
   1.693 +  std_log(LOG_FILENAME_LINE,"SUB_F32 TEST");
   1.694 +  test_sub_f32();
   1.695 +
   1.696 +  std_log(LOG_FILENAME_LINE,"SUB_F64 TEST");
   1.697 +  test_sub_f64();
   1.698 +  
   1.699 +  std_log(LOG_FILENAME_LINE,"MULT_F32 TEST");
   1.700 +  test_mult_f32();
   1.701 +  
   1.702 +  std_log(LOG_FILENAME_LINE,"MULT_F64 TEST");
   1.703 +  test_mult_f64();
   1.704 +  
   1.705 +  std_log(LOG_FILENAME_LINE,"DIV_F32 TEST");
   1.706 +  test_div_f32();
   1.707 +  
   1.708 +  std_log(LOG_FILENAME_LINE,"DIV_F64 TEST");
   1.709 +  test_div_f64();
   1.710 +
   1.711 +  std_log(LOG_FILENAME_LINE,"MIN_F32 TEST");
   1.712 +  test_minimum_f32();
   1.713 +
   1.714 +  std_log(LOG_FILENAME_LINE,"MIN_F64 TEST");
   1.715 +  test_minimum_f64();
   1.716 +  
   1.717 +  std_log(LOG_FILENAME_LINE,"MAX_F32 TEST");
   1.718 +  test_maximum_f32();
   1.719 +
   1.720 +  std_log(LOG_FILENAME_LINE,"MAX_F64 TEST");
   1.721 +  test_maximum_f64();
   1.722 +  
   1.723 +  std_log(LOG_FILENAME_LINE,"NEGATIVE_F32 TEST");
   1.724 +  test_negative_f32();
   1.725 +
   1.726 +  std_log(LOG_FILENAME_LINE,"SIGN_F32 TEST");
   1.727 +  test_sign_f32();
   1.728 +  
   1.729 +  std_log(LOG_FILENAME_LINE,"INVERSE_F32 TEST");
   1.730 +  test_inverse_f32();
   1.731 +
   1.732 +  std_log(LOG_FILENAME_LINE,"FLOOR_F32 TEST");
   1.733 +  test_floor_f32();
   1.734 +  
   1.735 +  std_log(LOG_FILENAME_LINE,"SCALARADD_F32 TEST");
   1.736 +  test_scalaradd_f32();
   1.737 +  
   1.738 +  std_log(LOG_FILENAME_LINE,"SCALARMULT_F64 TEST");
   1.739 +  test_scalarmult_f64();
   1.740 +  
   1.741 +   if(assert_failed)
   1.742 +         std_log(LOG_FILENAME_LINE,"Test Fail");
   1.743 +   else
   1.744 +         std_log(LOG_FILENAME_LINE,"Test Successful");
   1.745 +   
   1.746 +  create_xml(0);
   1.747 +  return 0;
   1.748 +}
   1.749 +