Update dgemm_kernel_4x8_haswell.S
[platform/upstream/openblas.git] / utest / test_swap.c
1 /*****************************************************************************
2 Copyright (c) 2011-2014, The OpenBLAS Project
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8
9    1. Redistributions of source code must retain the above copyright
10       notice, this list of conditions and the following disclaimer.
11
12    2. Redistributions in binary form must reproduce the above copyright
13       notice, this list of conditions and the following disclaimer in
14       the documentation and/or other materials provided with the
15       distribution.
16    3. Neither the name of the OpenBLAS project nor the names of 
17       its contributors may be used to endorse or promote products 
18       derived from this software without specific prior written 
19       permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
30 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 **********************************************************************************/
33
34 #include "openblas_utest.h"
35
36 CTEST(swap,dswap_inc_0)
37 {
38         blasint i=0;
39         blasint N=4,incX=0,incY=0;
40         double x1[]={1.0,3.0,5.0,7.0};
41         double y1[]={2.0,4.0,6.0,8.0};
42         double x2[]={1.0,3.0,5.0,7.0};
43         double y2[]={2.0,4.0,6.0,8.0};
44         
45         //OpenBLAS
46         BLASFUNC(dswap)(&N,x1,&incX,y1,&incY);
47
48         for(i=0; i<N; i++){
49                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], DOUBLE_EPS);
50                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
51         }
52 }
53
54 CTEST(swap,zswap_inc_0)
55 {
56         blasint i=0;
57         blasint N=4,incX=0,incY=0;
58         double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
59         double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
60         double x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
61         double y2[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
62
63         //OpenBLAS
64         BLASFUNC(zswap)(&N,x1,&incX,y1,&incY);
65
66         for(i=0; i<2*N; i++){
67                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], DOUBLE_EPS);
68                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], DOUBLE_EPS);
69         }
70 }
71
72 CTEST(swap,sswap_inc_0)
73 {
74         blasint i=0;
75         blasint N=4,incX=0,incY=0;
76         float x1[]={1.0,3.0,5.0,7.0};
77         float y1[]={2.0,4.0,6.0,8.0};
78         float x2[]={1.0,3.0,5.0,7.0};
79         float y2[]={2.0,4.0,6.0,8.0};
80
81         //OpenBLAS
82         BLASFUNC(sswap)(&N,x1,&incX,y1,&incY);
83
84         for(i=0; i<N; i++){
85                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], SINGLE_EPS);
86                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
87         }
88 }
89
90 CTEST(swap,cswap_inc_0)
91 {
92         blasint i=0;
93         blasint N=4,incX=0,incY=0;
94         float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
95         float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
96         float x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
97         float y2[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
98
99         //OpenBLAS
100         BLASFUNC(cswap)(&N,x1,&incX,y1,&incY);
101
102         for(i=0; i<2*N; i++){
103                 ASSERT_DBL_NEAR_TOL(x2[i], x1[i], SINGLE_EPS);
104                 ASSERT_DBL_NEAR_TOL(y2[i], y1[i], SINGLE_EPS);
105         }
106 }