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_caxpby.c 17 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. /*****************************************************************************
  2. Copyright (c) 2023, 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 "utest/openblas_utest.h"
  29. #include "common.h"
  30. #define DATASIZE 100
  31. #define INCREMENT 2
  32. struct DATA_CAXPBY {
  33. float x_test[DATASIZE * INCREMENT * 2];
  34. float x_verify[DATASIZE * INCREMENT * 2];
  35. float y_test[DATASIZE * INCREMENT * 2];
  36. float y_verify[DATASIZE * INCREMENT * 2];
  37. };
  38. #ifdef BUILD_COMPLEX
  39. static struct DATA_CAXPBY data_caxpby;
  40. /**
  41. * Fortran API specific function
  42. * Test caxpby by comparing it with cscal and caxpy.
  43. * Compare with the following options:
  44. *
  45. * param n - number of elements in vectors x and y
  46. * param alpha - scalar alpha
  47. * param incx - increment for the elements of x
  48. * param beta - scalar beta
  49. * param incy - increment for the elements of y
  50. * return norm of difference
  51. */
  52. static float check_caxpby(blasint n, float *alpha, blasint incx, float *beta, blasint incy)
  53. {
  54. blasint i;
  55. // cscal accept only positive increments
  56. blasint incx_abs = labs(incx);
  57. blasint incy_abs = labs(incy);
  58. // Fill vectors x, y
  59. srand_generate(data_caxpby.x_test, n * incx_abs * 2);
  60. srand_generate(data_caxpby.y_test, n * incy_abs * 2);
  61. // Copy vector x for caxpy
  62. for (i = 0; i < n * incx_abs * 2; i++)
  63. data_caxpby.x_verify[i] = data_caxpby.x_test[i];
  64. // Copy vector y for cscal
  65. for (i = 0; i < n * incy_abs * 2; i++)
  66. data_caxpby.y_verify[i] = data_caxpby.y_test[i];
  67. // Find beta*y
  68. BLASFUNC(cscal)(&n, beta, data_caxpby.y_verify, &incy_abs);
  69. // Find sum of alpha*x and beta*y
  70. BLASFUNC(caxpy)(&n, alpha, data_caxpby.x_verify, &incx,
  71. data_caxpby.y_verify, &incy);
  72. BLASFUNC(caxpby)(&n, alpha, data_caxpby.x_test, &incx,
  73. beta, data_caxpby.y_test, &incy);
  74. // Find the differences between output vector caculated by caxpby and caxpy
  75. for (i = 0; i < n * incy_abs * 2; i++)
  76. data_caxpby.y_test[i] -= data_caxpby.y_verify[i];
  77. // Find the norm of differences
  78. return BLASFUNC(scnrm2)(&n, data_caxpby.y_test, &incy_abs);
  79. }
  80. /**
  81. * C API specific function
  82. * Test caxpby by comparing it with cscal and caxpy.
  83. * Compare with the following options:
  84. *
  85. * param n - number of elements in vectors x and y
  86. * param alpha - scalar alpha
  87. * param incx - increment for the elements of x
  88. * param beta - scalar beta
  89. * param incy - increment for the elements of y
  90. * return norm of difference
  91. */
  92. static float c_api_check_caxpby(blasint n, float *alpha, blasint incx, float *beta, blasint incy)
  93. {
  94. blasint i;
  95. // cscal accept only positive increments
  96. blasint incx_abs = labs(incx);
  97. blasint incy_abs = labs(incy);
  98. // Fill vectors x, y
  99. srand_generate(data_caxpby.x_test, n * incx_abs * 2);
  100. srand_generate(data_caxpby.y_test, n * incy_abs * 2);
  101. // Copy vector x for caxpy
  102. for (i = 0; i < n * incx_abs * 2; i++)
  103. data_caxpby.x_verify[i] = data_caxpby.x_test[i];
  104. // Copy vector y for cscal
  105. for (i = 0; i < n * incy_abs * 2; i++)
  106. data_caxpby.y_verify[i] = data_caxpby.y_test[i];
  107. // Find beta*y
  108. cblas_cscal(n, beta, data_caxpby.y_verify, incy_abs);
  109. // Find sum of alpha*x and beta*y
  110. cblas_caxpy(n, alpha, data_caxpby.x_verify, incx,
  111. data_caxpby.y_verify, incy);
  112. cblas_caxpby(n, alpha, data_caxpby.x_test, incx,
  113. beta, data_caxpby.y_test, incy);
  114. // Find the differences between output vector caculated by caxpby and caxpy
  115. for (i = 0; i < n * incy_abs * 2; i++)
  116. data_caxpby.y_test[i] -= data_caxpby.y_verify[i];
  117. // Find the norm of differences
  118. return cblas_scnrm2(n, data_caxpby.y_test, incy_abs);
  119. }
  120. /**
  121. * Fortran API specific test
  122. * Test caxpby by comparing it with cscal and caxpy.
  123. * Test with the following options:
  124. *
  125. * Size of vectors x, y is 100
  126. * Stride of vector x is 1
  127. * Stride of vector y is 1
  128. */
  129. CTEST(caxpby, inc_x_1_inc_y_1_N_100)
  130. {
  131. blasint n = DATASIZE, incx = 1, incy = 1;
  132. float alpha[] = {1.0f, 1.0f};
  133. float beta[] = {1.0f, 1.0f};
  134. float norm = check_caxpby(n, alpha, incx, beta, incy);
  135. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  136. }
  137. /**
  138. * Fortran API specific test
  139. * Test caxpby by comparing it with cscal and caxpy.
  140. * Test with the following options:
  141. *
  142. * Size of vectors x, y is 100
  143. * Stride of vector x is 2
  144. * Stride of vector y is 1
  145. */
  146. CTEST(caxpby, inc_x_2_inc_y_1_N_100)
  147. {
  148. blasint n = DATASIZE, incx = 2, incy = 1;
  149. float alpha[] = {2.0f, 1.0f};
  150. float beta[] = {1.0f, 1.0f};
  151. float norm = check_caxpby(n, alpha, incx, beta, incy);
  152. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  153. }
  154. /**
  155. * Fortran API specific test
  156. * Test caxpby by comparing it with cscal and caxpy.
  157. * Test with the following options:
  158. *
  159. * Size of vectors x, y is 100
  160. * Stride of vector x is 1
  161. * Stride of vector y is 2
  162. */
  163. CTEST(caxpby, inc_x_1_inc_y_2_N_100)
  164. {
  165. blasint n = DATASIZE, incx = 1, incy = 2;
  166. float alpha[] = {1.0f, 1.0f};
  167. float beta[] = {2.0f, 1.0f};
  168. float norm = check_caxpby(n, alpha, incx, beta, incy);
  169. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  170. }
  171. /**
  172. * Fortran API specific test
  173. * Test caxpby by comparing it with cscal and caxpy.
  174. * Test with the following options:
  175. *
  176. * Size of vectors x, y is 100
  177. * Stride of vector x is 2
  178. * Stride of vector y is 2
  179. */
  180. CTEST(caxpby, inc_x_2_inc_y_2_N_100)
  181. {
  182. blasint n = DATASIZE, incx = 2, incy = 2;
  183. float alpha[] = {3.0f, 1.0f};
  184. float beta[] = {4.0f, 3.0f};
  185. float norm = check_caxpby(n, alpha, incx, beta, incy);
  186. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  187. }
  188. /**
  189. * Fortran API specific test
  190. * Test caxpby by comparing it with cscal and caxpy.
  191. * Test with the following options:
  192. *
  193. * Size of vectors x, y is 100
  194. * Stride of vector x is -1
  195. * Stride of vector y is 2
  196. */
  197. CTEST(caxpby, inc_x_neg_1_inc_y_2_N_100)
  198. {
  199. blasint n = DATASIZE, incx = -1, incy = 2;
  200. float alpha[] = {5.0f, 2.2f};
  201. float beta[] = {4.0f, 5.0f};
  202. float norm = check_caxpby(n, alpha, incx, beta, incy);
  203. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  204. }
  205. /**
  206. * Fortran API specific test
  207. * Test caxpby by comparing it with cscal and caxpy.
  208. * Test with the following options:
  209. *
  210. * Size of vectors x, y is 100
  211. * Stride of vector x is 2
  212. * Stride of vector y is -1
  213. */
  214. CTEST(caxpby, inc_x_2_inc_y_neg_1_N_100)
  215. {
  216. blasint n = DATASIZE, incx = 2, incy = -1;
  217. float alpha[] = {1.0f, 1.0f};
  218. float beta[] = {6.0f, 3.0f};
  219. float norm = check_caxpby(n, alpha, incx, beta, incy);
  220. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  221. }
  222. /**
  223. * Fortran API specific test
  224. * Test caxpby by comparing it with cscal and caxpy.
  225. * Test with the following options:
  226. *
  227. * Size of vectors x, y is 100
  228. * Stride of vector x is -2
  229. * Stride of vector y is -1
  230. */
  231. CTEST(caxpby, inc_x_neg_2_inc_y_neg_1_N_100)
  232. {
  233. blasint n = DATASIZE, incx = -2, incy = -1;
  234. float alpha[] = {7.0f, 2.0f};
  235. float beta[] = {3.5f, 1.3f};
  236. float norm = check_caxpby(n, alpha, incx, beta, incy);
  237. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  238. }
  239. /**
  240. * Fortran API specific test
  241. * Test caxpby by comparing it with cscal and caxpy.
  242. * Test with the following options:
  243. *
  244. * Size of vectors x, y is 100
  245. * Stride of vector x is 1
  246. * Stride of vector y is 1
  247. * Scalar alpha is zero
  248. */
  249. CTEST(caxpby, inc_x_1_inc_y_1_N_100_alpha_zero)
  250. {
  251. blasint n = DATASIZE, incx = 1, incy = 1;
  252. float alpha[] = {0.0f, 0.0f};
  253. float beta[] = {1.0f, 1.0f};
  254. float norm = check_caxpby(n, alpha, incx, beta, incy);
  255. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  256. }
  257. /**
  258. * Fortran API specific test
  259. * Test caxpby by comparing it with cscal and caxpy.
  260. * Test with the following options:
  261. *
  262. * Size of vectors x, y is 100
  263. * Stride of vector x is 1
  264. * Stride of vector y is 1
  265. * Scalar beta is zero
  266. */
  267. CTEST(caxpby, inc_x_1_inc_y_1_N_100_beta_zero)
  268. {
  269. blasint n = DATASIZE, incx = 1, incy = 1;
  270. float alpha[] = {1.0f, 1.0f};
  271. float beta[] = {0.0f, 0.0f};
  272. float norm = check_caxpby(n, alpha, incx, beta, incy);
  273. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  274. }
  275. /**
  276. * Fortran API specific test
  277. * Test caxpby by comparing it with cscal and caxpy.
  278. * Test with the following options:
  279. *
  280. * Size of vectors x, y is 100
  281. * Stride of vector x is 1
  282. * Stride of vector y is 1
  283. * Scalar alpha is zero
  284. * Scalar beta is zero
  285. */
  286. CTEST(caxpby, inc_x_1_inc_y_1_N_100_a_beta_zero)
  287. {
  288. blasint n = DATASIZE, incx = 1, incy = 1;
  289. float alpha[] = {0.0f, 0.0f};
  290. float beta[] = {0.0f, 0.0f};
  291. float norm = check_caxpby(n, alpha, incx, beta, incy);
  292. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  293. }
  294. /**
  295. * Fortran API specific test
  296. * Test caxpby by comparing it with cscal and caxpy.
  297. * Test with the following options:
  298. *
  299. * Size of vectors x, y is 100
  300. * Stride of vector x is 1
  301. * Stride of vector y is 2
  302. * Scalar alpha is zero
  303. * Scalar beta is zero
  304. */
  305. CTEST(caxpby, inc_x_1_inc_y_2_N_100_alpha_beta_zero)
  306. {
  307. blasint n = DATASIZE, incx = 1, incy = 2;
  308. float alpha[] = {0.0f, 0.0f};
  309. float beta[] = {0.0f, 0.0f};
  310. float norm = check_caxpby(n, alpha, incx, beta, incy);
  311. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  312. }
  313. /**
  314. * Fortran API specific test
  315. * Check if n - size of vectors x, y is zero
  316. */
  317. CTEST(caxpby, check_n_zero)
  318. {
  319. blasint n = 0, incx = 1, incy = 1;
  320. float alpha[] = {1.0f, 1.0f};
  321. float beta[] = {1.0f, 1.0f};
  322. float norm = check_caxpby(n, alpha, incx, beta, incy);
  323. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  324. }
  325. /**
  326. * C API specific test
  327. * Test caxpby by comparing it with cscal and caxpy.
  328. * Test with the following options:
  329. *
  330. * Size of vectors x, y is 100
  331. * Stride of vector x is 1
  332. * Stride of vector y is 1
  333. */
  334. CTEST(caxpby, c_api_inc_x_1_inc_y_1_N_100)
  335. {
  336. blasint n = DATASIZE, incx = 1, incy = 1;
  337. float alpha[] = {1.0f, 1.0f};
  338. float beta[] = {1.0f, 1.0f};
  339. float norm = c_api_check_caxpby(n, alpha, incx, beta, incy);
  340. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  341. }
  342. /**
  343. * C API specific test
  344. * Test caxpby by comparing it with cscal and caxpy.
  345. * Test with the following options:
  346. *
  347. * Size of vectors x, y is 100
  348. * Stride of vector x is 2
  349. * Stride of vector y is 1
  350. */
  351. CTEST(caxpby, c_api_inc_x_2_inc_y_1_N_100)
  352. {
  353. blasint n = DATASIZE, incx = 2, incy = 1;
  354. float alpha[] = {2.0f, 1.0f};
  355. float beta[] = {1.0f, 1.0f};
  356. float norm = c_api_check_caxpby(n, alpha, incx, beta, incy);
  357. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  358. }
  359. /**
  360. * C API specific test
  361. * Test caxpby by comparing it with cscal and caxpy.
  362. * Test with the following options:
  363. *
  364. * Size of vectors x, y is 100
  365. * Stride of vector x is 1
  366. * Stride of vector y is 2
  367. */
  368. CTEST(caxpby, c_api_inc_x_1_inc_y_2_N_100)
  369. {
  370. blasint n = DATASIZE, incx = 1, incy = 2;
  371. float alpha[] = {1.0f, 1.0f};
  372. float beta[] = {2.0f, 2.1f};
  373. float norm = c_api_check_caxpby(n, alpha, incx, beta, incy);
  374. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  375. }
  376. /**
  377. * C API specific test
  378. * Test caxpby by comparing it with cscal and caxpy.
  379. * Test with the following options:
  380. *
  381. * Size of vectors x, y is 100
  382. * Stride of vector x is 2
  383. * Stride of vector y is 2
  384. */
  385. CTEST(caxpby, c_api_inc_x_2_inc_y_2_N_100)
  386. {
  387. blasint n = DATASIZE, incx = 2, incy = 2;
  388. float alpha[] = {3.0f, 2.0f};
  389. float beta[] = {4.0f, 3.0f};
  390. float norm = c_api_check_caxpby(n, alpha, incx, beta, incy);
  391. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  392. }
  393. /**
  394. * C API specific test
  395. * Test caxpby by comparing it with cscal and caxpy.
  396. * Test with the following options:
  397. *
  398. * Size of vectors x, y is 100
  399. * Stride of vector x is -1
  400. * Stride of vector y is 2
  401. */
  402. CTEST(caxpby, c_api_inc_x_neg_1_inc_y_2_N_100)
  403. {
  404. blasint n = DATASIZE, incx = -1, incy = 2;
  405. float alpha[] = {5.0f, 2.0f};
  406. float beta[] = {4.0f, 3.1f};
  407. float norm = c_api_check_caxpby(n, alpha, incx, beta, incy);
  408. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  409. }
  410. /**
  411. * C API specific test
  412. * Test caxpby by comparing it with cscal and caxpy.
  413. * Test with the following options:
  414. *
  415. * Size of vectors x, y is 100
  416. * Stride of vector x is 2
  417. * Stride of vector y is -1
  418. */
  419. CTEST(caxpby, c_api_inc_x_2_inc_y_neg_1_N_100)
  420. {
  421. blasint n = DATASIZE, incx = 2, incy = -1;
  422. float alpha[] = {1.0f, 1.0f};
  423. float beta[] = {6.0f, 2.3f};
  424. float norm = c_api_check_caxpby(n, alpha, incx, beta, incy);
  425. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  426. }
  427. /**
  428. * C API specific test
  429. * Test caxpby by comparing it with cscal and caxpy.
  430. * Test with the following options:
  431. *
  432. * Size of vectors x, y is 100
  433. * Stride of vector x is -2
  434. * Stride of vector y is -1
  435. */
  436. CTEST(caxpby, c_api_inc_x_neg_2_inc_y_neg_1_N_100)
  437. {
  438. blasint n = DATASIZE, incx = -2, incy = -1;
  439. float alpha[] = {7.0f, 1.0f};
  440. float beta[] = {3.5f, 1.0f};
  441. float norm = c_api_check_caxpby(n, alpha, incx, beta, incy);
  442. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  443. }
  444. /**
  445. * C API specific test
  446. * Test caxpby by comparing it with cscal and caxpy.
  447. * Test with the following options:
  448. *
  449. * Size of vectors x, y is 100
  450. * Stride of vector x is 1
  451. * Stride of vector y is 1
  452. * Scalar alpha is zero
  453. */
  454. CTEST(caxpby, c_api_inc_x_1_inc_y_1_N_100_alpha_zero)
  455. {
  456. blasint n = DATASIZE, incx = 1, incy = 1;
  457. float alpha[] = {0.0f, 0.0f};
  458. float beta[] = {1.0f, 1.0f};
  459. float norm = c_api_check_caxpby(n, alpha, incx, beta, incy);
  460. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  461. }
  462. /**
  463. * C API specific test
  464. * Test caxpby by comparing it with cscal and caxpy.
  465. * Test with the following options:
  466. *
  467. * Size of vectors x, y is 100
  468. * Stride of vector x is 1
  469. * Stride of vector y is 1
  470. * Scalar beta is zero
  471. */
  472. CTEST(caxpby, c_api_inc_x_1_inc_y_1_N_100_beta_zero)
  473. {
  474. blasint n = DATASIZE, incx = 1, incy = 1;
  475. float alpha[] = {1.0f, 1.0f};
  476. float beta[] = {0.0f, 0.0f};
  477. float norm = c_api_check_caxpby(n, alpha, incx, beta, incy);
  478. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  479. }
  480. /**
  481. * C API specific test
  482. * Test caxpby by comparing it with cscal and caxpy.
  483. * Test with the following options:
  484. *
  485. * Size of vectors x, y is 100
  486. * Stride of vector x is 1
  487. * Stride of vector y is 1
  488. * Scalar alpha is zero
  489. * Scalar beta is zero
  490. */
  491. CTEST(caxpby, c_api_inc_x_1_inc_y_1_N_100_a_beta_zero)
  492. {
  493. blasint n = DATASIZE, incx = 1, incy = 1;
  494. float alpha[] = {0.0f, 0.0f};
  495. float beta[] = {0.0f, 0.0f};
  496. float norm = c_api_check_caxpby(n, alpha, incx, beta, incy);
  497. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  498. }
  499. /**
  500. * C API specific test
  501. * Test caxpby by comparing it with cscal and caxpy.
  502. * Test with the following options:
  503. *
  504. * Size of vectors x, y is 100
  505. * Stride of vector x is 1
  506. * Stride of vector y is 2
  507. * Scalar alpha is zero
  508. * Scalar beta is zero
  509. */
  510. CTEST(caxpby, c_api_inc_x_1_inc_y_2_N_100_alpha_beta_zero)
  511. {
  512. blasint n = DATASIZE, incx = 1, incy = 2;
  513. float alpha[] = {0.0f, 0.0f};
  514. float beta[] = {0.0f, 0.0f};
  515. float norm = c_api_check_caxpby(n, alpha, incx, beta, incy);
  516. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  517. }
  518. /**
  519. * C API specific test
  520. * Check if n - size of vectors x, y is zero
  521. */
  522. CTEST(caxpby, c_api_check_n_zero)
  523. {
  524. blasint n = 0, incx = 1, incy = 1;
  525. float alpha[] = {1.0f, 1.0f};
  526. float beta[] = {1.0f, 1.0f};
  527. float norm = c_api_check_caxpby(n, alpha, incx, beta, incy);
  528. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  529. }
  530. #endif