Initialize libbullet git in 2.0_beta.
[platform/upstream/libbullet.git] / Extras / simdmathlibrary / ppu / tests / sqrtf4.c
1 /* Testcase for sqrtf4
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 #include <stdio.h>
31 #include <stdlib.h>
32 #include <math.h>
33 #include "common-test.h"
34 #include "testutils.h"
35 #include "simdmath.h"
36
37
38 int main()
39 {
40    TEST_SET_START("20040928182549EJL","EJL", "sqrtf4");
41
42    unsigned int i3 =   0x742c4455;
43    unsigned int i3r =  0x59d20034;
44    unsigned int i4 =   0x75e7753f; 
45    unsigned int i4r =  0x5aac1fb5;
46    unsigned int i5 =   0x4baa9e3c; 
47    unsigned int i5r =  0x4593c7d8;
48    unsigned int i6 =   0x39344296; 
49    unsigned int i6r =  0x3c56d14c; 
50    unsigned int i7 =   0x68a586b0; 
51    unsigned int i7r =  0x54118f09;
52
53    float x0 = hide_float(0.0f);
54    float x0r = hide_float(0.0f);   
55
56    float x3 = hide_float(make_float(i3));
57    float x3r = hide_float(make_float(i3r));   
58    float x4 = hide_float(make_float(i4));     
59    float x4r = hide_float(make_float(i4r));   
60    float x5 = hide_float(make_float(i5));     
61    float x5r = hide_float(make_float(i5r));   
62    float x6 = hide_float(make_float(i6));     
63    float x6r = hide_float(make_float(i6r));   
64    float x7 = hide_float(make_float(i7));
65    float x7r = hide_float(make_float(i7r));
66    
67    vec_float4 x0_v = vec_splat_float(x0);
68    vec_float4 x0r_v = vec_splat_float(x0r);
69
70    vec_float4 x3_v = vec_splat_float(x3);
71    vec_float4 x3r_v = vec_splat_float(x3r);
72    vec_float4 x4_v = vec_splat_float(x4);
73    vec_float4 x4r_v = vec_splat_float(x4r);
74    vec_float4 x5_v = vec_splat_float(x5);
75    vec_float4 x5r_v = vec_splat_float(x5r);
76    vec_float4 x6_v = vec_splat_float(x6);
77    vec_float4 x6r_v = vec_splat_float(x6r);
78    vec_float4 x7_v = vec_splat_float(x7);
79    vec_float4 x7r_v = vec_splat_float(x7r);
80    
81    vec_float4 res_v;
82
83    TEST_START("sqrtf4");
84    res_v = sqrtf4(x0_v);
85    TEST_CHECK("20040928182551EJL", allequal_float4( res_v, x0r_v ), 0);
86    res_v = sqrtf4(x3_v);
87    TEST_CHECK("20040928182552EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0);
88    res_v = sqrtf4(x4_v);
89    TEST_CHECK("20040928182554EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0);
90    res_v = sqrtf4(x5_v);
91    TEST_CHECK("20040928182556EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0);
92    res_v = sqrtf4(x6_v);
93    TEST_CHECK("20040928182557EJL", allequal_ulps_float4( res_v, x6r_v, 2 ), 0);
94    res_v = sqrtf4(x7_v);
95    TEST_CHECK("20040928182559EJL", allequal_ulps_float4( res_v, x7r_v, 2 ), 0);
96    
97    TEST_SET_DONE();
98    
99    TEST_EXIT();
100 }