You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_swap.c 3.5 kB

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