Tizen 2.1 base
[platform/upstream/libbullet.git] / Extras / simdmathlibrary / ppu / tests / recipf4.c
1 /* Testcase for recipf4
2    Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
3    All rights reserved.
4
5    Redistribution and use in source and binary forms,
6    with or without modification, are permitted provided that the
7    following conditions are met:
8     * Redistributions of source code must retain the above copyright
9       notice, this list of conditions and the following disclaimer.
10     * Redistributions in binary form must reproduce the above copyright
11       notice, this list of conditions and the following disclaimer in the
12       documentation and/or other materials provided with the distribution.
13     * Neither the name of the Sony Computer Entertainment Inc nor the names
14       of its contributors may be used to endorse or promote products derived
15       from this software without specific prior written permission.
16
17    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27    POSSIBILITY OF SUCH DAMAGE.
28  */
29
30
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <math.h>
34 #include "common-test.h"
35 #include "testutils.h"
36 #include "simdmath.h"
37
38
39 int main()
40 {
41    TEST_SET_START("20040920142553EJL","EJL", "recipf4");
42
43    unsigned int i1 = 0xff000000;   // -2^127
44    unsigned int i2 = 0xfe7fffff;   // -2^126 - 1 ulp
45    unsigned int i2r = 0x80800001;  
46    unsigned int i3 =   0x75013340; // random values
47    unsigned int i3r =  0x09fd9f35;
48    unsigned int i4 =   0x75e7753f; 
49    unsigned int i4r =  0x090d9277;
50    unsigned int i5 =   0x4c7fed5a; 
51    unsigned int i5r =  0x32800954;
52    unsigned int i6 =   0x3a0731f0; 
53    unsigned int i6r =  0x44f2602e; 
54    unsigned int i7 =   0x69784a07; 
55    unsigned int i7r =  0x1583f9a3;
56
57    float x1 = hide_float(make_float(i1));
58    float x1r = hide_float(0.0f);
59    float x2 = hide_float(make_float(i2));
60    float x2r = hide_float(make_float(i2r));   
61    float x3 = hide_float(make_float(i3));
62    float x3r = hide_float(make_float(i3r));   
63    float x4 = hide_float(make_float(i4));     
64    float x4r = hide_float(make_float(i4r));   
65    float x5 = hide_float(make_float(i5));     
66    float x5r = hide_float(make_float(i5r));   
67    float x6 = hide_float(make_float(i6));     
68    float x6r = hide_float(make_float(i6r));   
69    float x7 = hide_float(make_float(i7));
70    float x7r = hide_float(make_float(i7r));
71    
72    vec_float4 x1_v = vec_splat_float(x1);
73    vec_float4 x1r_v = vec_splat_float(x1r);
74    vec_float4 x2_v = vec_splat_float(x2);
75    vec_float4 x2r_v = vec_splat_float(x2r);
76    vec_float4 x3_v = vec_splat_float(x3);
77    vec_float4 x3r_v = vec_splat_float(x3r);
78    vec_float4 x4_v = vec_splat_float(x4);
79    vec_float4 x4r_v = vec_splat_float(x4r);
80    vec_float4 x5_v = vec_splat_float(x5);
81    vec_float4 x5r_v = vec_splat_float(x5r);
82    vec_float4 x6_v = vec_splat_float(x6);
83    vec_float4 x6r_v = vec_splat_float(x6r);
84    vec_float4 x7_v = vec_splat_float(x7);
85    vec_float4 x7r_v = vec_splat_float(x7r);
86    
87    vec_float4 res_v;
88
89    TEST_START("recipf4");
90    res_v = recipf4(x1_v);
91    TEST_CHECK("20040920142600EJL", allequal_float4( res_v, x1r_v), 0);
92    res_v = recipf4(x2_v);
93    TEST_CHECK("20040920142602EJL", allequal_ulps_float4( res_v, x2r_v, 2 ), 0);
94    res_v = recipf4(x3_v);
95    TEST_CHECK("20040920142604EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0);
96    res_v = recipf4(x4_v);
97    TEST_CHECK("20040920142606EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0);
98    res_v = recipf4(x5_v);
99    TEST_CHECK("20040920142608EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0);
100    res_v = recipf4(x6_v);
101    TEST_CHECK("20040920142609EJL", allequal_ulps_float4( res_v, x6r_v, 2 ), 0);
102    res_v = recipf4(x7_v);
103    TEST_CHECK("20040920142611EJL", allequal_ulps_float4( res_v, x7r_v, 2 ), 0);
104    
105    TEST_SET_DONE();
106    
107    TEST_EXIT();
108 }