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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  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_ZAXPBY {
  33. double x_test[DATASIZE * INCREMENT * 2];
  34. double x_verify[DATASIZE * INCREMENT * 2];
  35. double y_test[DATASIZE * INCREMENT * 2];
  36. double y_verify[DATASIZE * INCREMENT * 2];
  37. };
  38. #ifdef BUILD_COMPLEX16
  39. static struct DATA_ZAXPBY data_zaxpby;
  40. /**
  41. * Fortran API specific function
  42. * Test zaxpby by comparing it with zscal and zaxpy.
  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 double check_zaxpby(blasint n, double *alpha, blasint incx, double *beta, blasint incy)
  53. {
  54. blasint i;
  55. // zscal accept only positive increments
  56. blasint incx_abs = labs(incx);
  57. blasint incy_abs = labs(incy);
  58. // Fill vectors x, y
  59. drand_generate(data_zaxpby.x_test, n * incx_abs * 2);
  60. drand_generate(data_zaxpby.y_test, n * incy_abs * 2);
  61. // Copy vector x for zaxpy
  62. for (i = 0; i < n * incx_abs * 2; i++)
  63. data_zaxpby.x_verify[i] = data_zaxpby.x_test[i];
  64. // Copy vector y for zscal
  65. for (i = 0; i < n * incy_abs * 2; i++)
  66. data_zaxpby.y_verify[i] = data_zaxpby.y_test[i];
  67. // Find beta*y
  68. BLASFUNC(zscal)(&n, beta, data_zaxpby.y_verify, &incy_abs);
  69. // Find sum of alpha*x and beta*y
  70. BLASFUNC(zaxpy)(&n, alpha, data_zaxpby.x_verify, &incx,
  71. data_zaxpby.y_verify, &incy);
  72. BLASFUNC(zaxpby)(&n, alpha, data_zaxpby.x_test, &incx,
  73. beta, data_zaxpby.y_test, &incy);
  74. // Find the differences between output vector caculated by zaxpby and zaxpy
  75. for (i = 0; i < n * incy_abs * 2; i++)
  76. data_zaxpby.y_test[i] -= data_zaxpby.y_verify[i];
  77. // Find the norm of differences
  78. return BLASFUNC(dznrm2)(&n, data_zaxpby.y_test, &incy_abs);
  79. }
  80. /**
  81. * C API specific function
  82. * Test zaxpby by comparing it with zscal and zaxpy.
  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 double c_api_check_zaxpby(blasint n, double *alpha, blasint incx, double *beta, blasint incy)
  93. {
  94. blasint i;
  95. // zscal accept only positive increments
  96. blasint incx_abs = labs(incx);
  97. blasint incy_abs = labs(incy);
  98. // Fill vectors x, y
  99. drand_generate(data_zaxpby.x_test, n * incx_abs * 2);
  100. drand_generate(data_zaxpby.y_test, n * incy_abs * 2);
  101. // Copy vector x for zaxpy
  102. for (i = 0; i < n * incx_abs * 2; i++)
  103. data_zaxpby.x_verify[i] = data_zaxpby.x_test[i];
  104. // Copy vector y for zscal
  105. for (i = 0; i < n * incy_abs * 2; i++)
  106. data_zaxpby.y_verify[i] = data_zaxpby.y_test[i];
  107. // Find beta*y
  108. cblas_zscal(n, beta, data_zaxpby.y_verify, incy_abs);
  109. // Find sum of alpha*x and beta*y
  110. cblas_zaxpy(n, alpha, data_zaxpby.x_verify, incx,
  111. data_zaxpby.y_verify, incy);
  112. cblas_zaxpby(n, alpha, data_zaxpby.x_test, incx,
  113. beta, data_zaxpby.y_test, incy);
  114. // Find the differences between output vector caculated by zaxpby and zaxpy
  115. for (i = 0; i < n * incy_abs * 2; i++)
  116. data_zaxpby.y_test[i] -= data_zaxpby.y_verify[i];
  117. // Find the norm of differences
  118. return cblas_dznrm2(n, data_zaxpby.y_test, incy_abs);
  119. }
  120. /**
  121. * Fortran API specific test
  122. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, inc_x_1_inc_y_1_N_100)
  130. {
  131. blasint n = DATASIZE, incx = 1, incy = 1;
  132. double alpha[] = {1.0, 1.0};
  133. double beta[] = {1.0, 1.0};
  134. double norm = check_zaxpby(n, alpha, incx, beta, incy);
  135. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  136. }
  137. /**
  138. * Fortran API specific test
  139. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, inc_x_2_inc_y_1_N_100)
  147. {
  148. blasint n = DATASIZE, incx = 2, incy = 1;
  149. double alpha[] = {2.0, 1.0};
  150. double beta[] = {1.0, 1.0};
  151. double norm = check_zaxpby(n, alpha, incx, beta, incy);
  152. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  153. }
  154. /**
  155. * Fortran API specific test
  156. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, inc_x_1_inc_y_2_N_100)
  164. {
  165. blasint n = DATASIZE, incx = 1, incy = 2;
  166. double alpha[] = {1.0, 1.0};
  167. double beta[] = {2.0, 1.0};
  168. double norm = check_zaxpby(n, alpha, incx, beta, incy);
  169. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  170. }
  171. /**
  172. * Fortran API specific test
  173. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, inc_x_2_inc_y_2_N_100)
  181. {
  182. blasint n = DATASIZE, incx = 2, incy = 2;
  183. double alpha[] = {3.0, 1.0};
  184. double beta[] = {4.0, 3.0};
  185. double norm = check_zaxpby(n, alpha, incx, beta, incy);
  186. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  187. }
  188. /**
  189. * Fortran API specific test
  190. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, inc_x_neg_1_inc_y_2_N_100)
  198. {
  199. blasint n = DATASIZE, incx = -1, incy = 2;
  200. double alpha[] = {5.0, 2.2};
  201. double beta[] = {4.0, 5.0};
  202. double norm = check_zaxpby(n, alpha, incx, beta, incy);
  203. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  204. }
  205. /**
  206. * Fortran API specific test
  207. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, inc_x_2_inc_y_neg_1_N_100)
  215. {
  216. blasint n = DATASIZE, incx = 2, incy = -1;
  217. double alpha[] = {1.0, 1.0};
  218. double beta[] = {6.0, 3.0};
  219. double norm = check_zaxpby(n, alpha, incx, beta, incy);
  220. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  221. }
  222. /**
  223. * Fortran API specific test
  224. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, inc_x_neg_2_inc_y_neg_1_N_100)
  232. {
  233. blasint n = DATASIZE, incx = -2, incy = -1;
  234. double alpha[] = {7.0, 2.0};
  235. double beta[] = {3.5, 1.3};
  236. double norm = check_zaxpby(n, alpha, incx, beta, incy);
  237. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  238. }
  239. /**
  240. * Fortran API specific test
  241. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, inc_x_1_inc_y_1_N_100_alpha_zero)
  250. {
  251. blasint n = DATASIZE, incx = 1, incy = 1;
  252. double alpha[] = {0.0, 0.0};
  253. double beta[] = {1.0, 1.0};
  254. double norm = check_zaxpby(n, alpha, incx, beta, incy);
  255. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  256. }
  257. /**
  258. * Fortran API specific test
  259. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, inc_x_1_inc_y_1_N_100_beta_zero)
  268. {
  269. blasint n = DATASIZE, incx = 1, incy = 1;
  270. double alpha[] = {1.0, 1.0};
  271. double beta[] = {0.0, 0.0};
  272. double norm = check_zaxpby(n, alpha, incx, beta, incy);
  273. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  274. }
  275. /**
  276. * Fortran API specific test
  277. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, inc_x_1_inc_y_1_N_100_alpha_beta_zero)
  287. {
  288. blasint n = DATASIZE, incx = 1, incy = 1;
  289. double alpha[] = {0.0, 0.0};
  290. double beta[] = {0.0, 0.0};
  291. double norm = check_zaxpby(n, alpha, incx, beta, incy);
  292. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  293. }
  294. /**
  295. * Fortran API specific test
  296. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, inc_x_1_inc_y_2_N_100_alpha_beta_zero)
  306. {
  307. blasint n = DATASIZE, incx = 1, incy = 2;
  308. double alpha[] = {0.0, 0.0};
  309. double beta[] = {0.0, 0.0};
  310. double norm = check_zaxpby(n, alpha, incx, beta, incy);
  311. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  312. }
  313. /**
  314. * Fortran API specific test
  315. * Check if n - size of vectors x, y is zero
  316. */
  317. CTEST(zaxpby, check_n_zero)
  318. {
  319. blasint n = 0, incx = 1, incy = 1;
  320. double alpha[] = {1.0, 1.0};
  321. double beta[] = {1.0, 1.0};
  322. double norm = check_zaxpby(n, alpha, incx, beta, incy);
  323. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  324. }
  325. /**
  326. * C API specific test
  327. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, c_api_inc_x_1_inc_y_1_N_100)
  335. {
  336. blasint n = DATASIZE, incx = 1, incy = 1;
  337. double alpha[] = {1.0, 1.0};
  338. double beta[] = {1.0, 1.0};
  339. double norm = c_api_check_zaxpby(n, alpha, incx, beta, incy);
  340. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  341. }
  342. /**
  343. * C API specific test
  344. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, c_api_inc_x_2_inc_y_1_N_100)
  352. {
  353. blasint n = DATASIZE, incx = 2, incy = 1;
  354. double alpha[] = {2.0, 1.0};
  355. double beta[] = {1.0, 1.0};
  356. double norm = c_api_check_zaxpby(n, alpha, incx, beta, incy);
  357. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  358. }
  359. /**
  360. * C API specific test
  361. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, c_api_inc_x_1_inc_y_2_N_100)
  369. {
  370. blasint n = DATASIZE, incx = 1, incy = 2;
  371. double alpha[] = {1.0, 1.0};
  372. double beta[] = {2.0, 2.1};
  373. double norm = c_api_check_zaxpby(n, alpha, incx, beta, incy);
  374. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  375. }
  376. /**
  377. * C API specific test
  378. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, c_api_inc_x_2_inc_y_2_N_100)
  386. {
  387. blasint n = DATASIZE, incx = 2, incy = 2;
  388. double alpha[] = {3.0, 2.0};
  389. double beta[] = {4.0, 3.0};
  390. double norm = c_api_check_zaxpby(n, alpha, incx, beta, incy);
  391. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  392. }
  393. /**
  394. * C API specific test
  395. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, c_api_inc_x_neg_1_inc_y_2_N_100)
  403. {
  404. blasint n = DATASIZE, incx = -1, incy = 2;
  405. double alpha[] = {5.0, 2.0};
  406. double beta[] = {4.0, 3.1};
  407. double norm = c_api_check_zaxpby(n, alpha, incx, beta, incy);
  408. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  409. }
  410. /**
  411. * C API specific test
  412. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, c_api_inc_x_2_inc_y_neg_1_N_100)
  420. {
  421. blasint n = DATASIZE, incx = 2, incy = -1;
  422. double alpha[] = {1.0, 1.0};
  423. double beta[] = {6.0, 2.3};
  424. double norm = c_api_check_zaxpby(n, alpha, incx, beta, incy);
  425. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  426. }
  427. /**
  428. * C API specific test
  429. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, c_api_inc_x_neg_2_inc_y_neg_1_N_100)
  437. {
  438. blasint n = DATASIZE, incx = -2, incy = -1;
  439. double alpha[] = {7.0, 1.0};
  440. double beta[] = {3.5, 1.0};
  441. double norm = c_api_check_zaxpby(n, alpha, incx, beta, incy);
  442. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  443. }
  444. /**
  445. * C API specific test
  446. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, c_api_inc_x_1_inc_y_1_N_100_alpha_zero)
  455. {
  456. blasint n = DATASIZE, incx = 1, incy = 1;
  457. double alpha[] = {0.0, 0.0};
  458. double beta[] = {1.0, 1.0};
  459. double norm = c_api_check_zaxpby(n, alpha, incx, beta, incy);
  460. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  461. }
  462. /**
  463. * C API specific test
  464. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, c_api_inc_x_1_inc_y_1_N_100_beta_zero)
  473. {
  474. blasint n = DATASIZE, incx = 1, incy = 1;
  475. double alpha[] = {1.0, 1.0};
  476. double beta[] = {0.0, 0.0};
  477. double norm = c_api_check_zaxpby(n, alpha, incx, beta, incy);
  478. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  479. }
  480. /**
  481. * C API specific test
  482. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, c_api_inc_x_1_inc_y_1_N_100_alpha_beta_zero)
  492. {
  493. blasint n = DATASIZE, incx = 1, incy = 1;
  494. double alpha[] = {0.0, 0.0};
  495. double beta[] = {0.0, 0.0};
  496. double norm = c_api_check_zaxpby(n, alpha, incx, beta, incy);
  497. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  498. }
  499. /**
  500. * C API specific test
  501. * Test zaxpby by comparing it with zscal and zaxpy.
  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(zaxpby, c_api_inc_x_1_inc_y_2_N_100_alpha_beta_zero)
  511. {
  512. blasint n = DATASIZE, incx = 1, incy = 2;
  513. double alpha[] = {0.0, 0.0};
  514. double beta[] = {0.0, 0.0};
  515. double norm = c_api_check_zaxpby(n, alpha, incx, beta, incy);
  516. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  517. }
  518. /**
  519. * C API specific test
  520. * Check if n - size of vectors x, y is zero
  521. */
  522. CTEST(zaxpby, c_api_check_n_zero)
  523. {
  524. blasint n = 0, incx = 1, incy = 1;
  525. double alpha[] = {1.0, 1.0};
  526. double beta[] = {1.0, 1.0};
  527. double norm = c_api_check_zaxpby(n, alpha, incx, beta, incy);
  528. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  529. }
  530. #endif