genericopenlibs/liboil/tsrc/testsuite/ref/src/mult8x8.c
changeset 50 79045913e4e9
equal deleted inserted replaced
49:e5d77a29bdca 50:79045913e4e9
       
     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_mult8x8_log.txt"
       
    29 #include "std_log_result.h"
       
    30 #include "utils.h"
       
    31 #define LOG_FILENAME_LINE __FILE__, __LINE__
       
    32 #define MAX_SIZE 64
       
    33 #define MAX_SIZE1 10
       
    34 #define RES_SIZE 1
       
    35 
       
    36 void create_xml(int result)
       
    37 {
       
    38     if(result)
       
    39         assert_failed = 1;
       
    40     
       
    41     testResultXml("testsuite_mult8x8");
       
    42     close_log_file();
       
    43 }
       
    44 
       
    45 
       
    46 void test_mult8x8_s16()
       
    47     {
       
    48     int i;
       
    49     int16_t mult1[MAX_SIZE],mult2[MAX_SIZE],res[MAX_SIZE],check[MAX_SIZE]={2,16,42,80,108,130,154,180,208,238,14,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
       
    50     
       
    51     for(i=0;i<MAX_SIZE;i++)
       
    52         {
       
    53         mult1[i]=i+1;
       
    54         mult2[i]=i+2;
       
    55         res[i]=0;
       
    56         }
       
    57     
       
    58     oil_mult8x8_s16(res,mult1,mult2,1,3,2);
       
    59     
       
    60     for(i=0;i<MAX_SIZE;i++)
       
    61     if(res[i] == check[i])
       
    62           {
       
    63           std_log(LOG_FILENAME_LINE,"oil_mult8x8_s16 successful, res[%d] = %d",i,res[i]);
       
    64           }
       
    65      else
       
    66          {
       
    67          assert_failed=1;
       
    68          std_log(LOG_FILENAME_LINE,"oil_mult8x8_s16 unsuccessful,Expected =%d,Obtained =%d",check[i],res[i]);
       
    69          }
       
    70     }
       
    71 
       
    72 void test_multsum_f32()
       
    73     {
       
    74     float mult1[MAX_SIZE1],mult2[MAX_SIZE1];
       
    75     float res[RES_SIZE]={0},check[RES_SIZE]={404307968.00000000000000};
       
    76     int i;
       
    77     
       
    78     for(i=0;i<MAX_SIZE1;i++)
       
    79         {
       
    80          mult1[i]=(i+0.1)*3;
       
    81          mult2[i]=(i+2)*2;
       
    82         }
       
    83     oil_multsum_f32(res,mult1,3,mult2,1,MAX_SIZE1);
       
    84     
       
    85     if(comparefloats(res[0],check[0])==0)
       
    86         {
       
    87         std_log(LOG_FILENAME_LINE,"oil_multsum_f32 successful, res = %15.14f",res[0]);
       
    88         }
       
    89     else
       
    90         {
       
    91         assert_failed=1;
       
    92         std_log(LOG_FILENAME_LINE,"oil_multsum_f32 unsuccessful,Expected =%15.14f,Obtained =%15.14f",check[0],res[0]);
       
    93         }  
       
    94     }
       
    95 
       
    96 
       
    97 void test_multsum_f64()
       
    98     {
       
    99     double mult1[MAX_SIZE1],mult2[MAX_SIZE1];
       
   100     double res[RES_SIZE]={0},check[RES_SIZE]={111.60000000000001};
       
   101     int i;
       
   102     
       
   103     for(i=0;i<MAX_SIZE1;i++)
       
   104         {
       
   105          mult1[i]=(i+1.1)*3;
       
   106          mult2[i]=(i+2)*2;
       
   107         }
       
   108     oil_multsum_f64(res,mult1,3,mult2,2,MAX_SIZE1);
       
   109     
       
   110     if(comparefloats(res[0],check[0])==0)
       
   111         {
       
   112         std_log(LOG_FILENAME_LINE,"oil_multsum_f64 successful, res = %15.14f",res[0]);
       
   113         }
       
   114     else
       
   115         {
       
   116         assert_failed=1;
       
   117         std_log(LOG_FILENAME_LINE,"oil_multsum_f64 unsuccessful,Expected =%15.14f,Obtained =%15.14f",check[0],res[0]);
       
   118         }  
       
   119     }
       
   120 
       
   121 int main ()
       
   122 {
       
   123   std_log(LOG_FILENAME_LINE,"Test started testsuite_mult8x8");
       
   124   oil_init ();
       
   125   
       
   126   std_log(LOG_FILENAME_LINE,"oil_mult8x8_s16");
       
   127   test_mult8x8_s16();
       
   128  
       
   129   std_log(LOG_FILENAME_LINE,"oil_multsum_f32");
       
   130   test_multsum_f32();
       
   131   
       
   132   std_log(LOG_FILENAME_LINE,"oil_multsum_f64");
       
   133   test_multsum_f64();
       
   134   
       
   135   if(assert_failed)
       
   136          std_log(LOG_FILENAME_LINE,"Test Fail");
       
   137   else
       
   138          std_log(LOG_FILENAME_LINE,"Test Successful");
       
   139    
       
   140   create_xml(0);
       
   141   return 0;
       
   142 }
       
   143