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_daxpby.c 20 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  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_DAXPBY{
  33. double x_test[DATASIZE * INCREMENT];
  34. double x_verify[DATASIZE * INCREMENT];
  35. double y_test[DATASIZE * INCREMENT];
  36. double y_verify[DATASIZE * INCREMENT];
  37. };
  38. #ifdef BUILD_DOUBLE
  39. static struct DATA_DAXPBY data_daxpby;
  40. /**
  41. * Fortran API specific function
  42. * Test daxpby by comparing it with dscal and daxpy.
  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_daxpby(blasint n, double alpha, blasint incx, double beta, blasint incy)
  53. {
  54. blasint i;
  55. // dscal 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_daxpby.x_test, n * incx_abs);
  60. drand_generate(data_daxpby.y_test, n * incy_abs);
  61. // Copy vector x for daxpy
  62. for (i = 0; i < n * incx_abs; i++)
  63. data_daxpby.x_verify[i] = data_daxpby.x_test[i];
  64. // Copy vector y for dscal
  65. for (i = 0; i < n * incy_abs; i++)
  66. data_daxpby.y_verify[i] = data_daxpby.y_test[i];
  67. // Find beta*y
  68. BLASFUNC(dscal)(&n, &beta, data_daxpby.y_verify, &incy_abs);
  69. // Find sum of alpha*x and beta*y
  70. BLASFUNC(daxpy)(&n, &alpha, data_daxpby.x_verify, &incx,
  71. data_daxpby.y_verify, &incy);
  72. BLASFUNC(daxpby)(&n, &alpha, data_daxpby.x_test, &incx,
  73. &beta, data_daxpby.y_test, &incy);
  74. // Find the differences between output vector caculated by daxpby and daxpy
  75. for (i = 0; i < n * incy_abs; i++)
  76. data_daxpby.y_test[i] -= data_daxpby.y_verify[i];
  77. // Find the norm of differences
  78. return BLASFUNC(dnrm2)(&n, data_daxpby.y_test, &incy_abs);
  79. }
  80. /**
  81. * C API specific function
  82. * Test daxpby by comparing it with dscal and daxpy.
  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_daxpby(blasint n, double alpha, blasint incx, double beta, blasint incy)
  93. {
  94. blasint i;
  95. // dscal accept only positive increments
  96. blasint incx_abs = labs(incx);
  97. blasint incy_abs = labs(incy);
  98. // Copy vector x for daxpy
  99. for (i = 0; i < n * incx_abs; i++)
  100. data_daxpby.x_verify[i] = data_daxpby.x_test[i];
  101. // Copy vector y for dscal
  102. for (i = 0; i < n * incy_abs; i++)
  103. data_daxpby.y_verify[i] = data_daxpby.y_test[i];
  104. // Find beta*y
  105. cblas_dscal(n, beta, data_daxpby.y_verify, incy_abs);
  106. // Find sum of alpha*x and beta*y
  107. cblas_daxpy(n, alpha, data_daxpby.x_verify, incx,
  108. data_daxpby.y_verify, incy);
  109. cblas_daxpby(n, alpha, data_daxpby.x_test, incx,
  110. beta, data_daxpby.y_test, incy);
  111. // Find the differences between output vector caculated by daxpby and daxpy
  112. for (i = 0; i < n * incy_abs; i++)
  113. data_daxpby.y_test[i] -= data_daxpby.y_verify[i];
  114. // Find the norm of differences
  115. return cblas_dnrm2(n, data_daxpby.y_test, incy_abs);
  116. }
  117. /**
  118. * Fortran API specific test
  119. * Test daxpby by comparing it with dscal and daxpy.
  120. * Test with the following options:
  121. *
  122. * Size of vectors x, y is 100
  123. * Stride of vector x is 1
  124. * Stride of vector y is 1
  125. */
  126. CTEST(daxpby, inc_x_1_inc_y_1_N_100)
  127. {
  128. blasint n = DATASIZE, incx = 1, incy = 1;
  129. double alpha = 1.0;
  130. double beta = 1.0;
  131. double norm = check_daxpby(n, alpha, incx, beta, incy);
  132. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  133. }
  134. /**
  135. * Fortran API specific test
  136. * Test daxpby by comparing it with dscal and daxpy.
  137. * Test with the following options:
  138. *
  139. * Size of vectors x, y is 100
  140. * Stride of vector x is 2
  141. * Stride of vector y is 1
  142. */
  143. CTEST(daxpby, inc_x_2_inc_y_1_N_100)
  144. {
  145. blasint n = DATASIZE, incx = 2, incy = 1;
  146. double alpha = 2.0;
  147. double beta = 1.0;
  148. double norm = check_daxpby(n, alpha, incx, beta, incy);
  149. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  150. }
  151. /**
  152. * Fortran API specific test
  153. * Test daxpby by comparing it with dscal and daxpy.
  154. * Test with the following options:
  155. *
  156. * Size of vectors x, y is 100
  157. * Stride of vector x is 1
  158. * Stride of vector y is 2
  159. */
  160. CTEST(daxpby, inc_x_1_inc_y_2_N_100)
  161. {
  162. blasint n = DATASIZE, incx = 1, incy = 2;
  163. double alpha = 1.0;
  164. double beta = 2.0;
  165. double norm = check_daxpby(n, alpha, incx, beta, incy);
  166. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  167. }
  168. /**
  169. * Fortran API specific test
  170. * Test daxpby by comparing it with dscal and daxpy.
  171. * Test with the following options:
  172. *
  173. * Size of vectors x, y is 100
  174. * Stride of vector x is 2
  175. * Stride of vector y is 2
  176. */
  177. CTEST(daxpby, inc_x_2_inc_y_2_N_100)
  178. {
  179. blasint n = DATASIZE, incx = 2, incy = 2;
  180. double alpha = 3.0;
  181. double beta = 4.0;
  182. double norm = check_daxpby(n, alpha, incx, beta, incy);
  183. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  184. }
  185. /**
  186. * Fortran API specific test
  187. * Test daxpby by comparing it with dscal and daxpy.
  188. * Test with the following options:
  189. *
  190. * Size of vectors x, y is 100
  191. * Stride of vector x is -1
  192. * Stride of vector y is 2
  193. */
  194. CTEST(daxpby, inc_x_neg_1_inc_y_2_N_100)
  195. {
  196. blasint n = DATASIZE, incx = -1, incy = 2;
  197. double alpha = 5.0;
  198. double beta = 4.0;
  199. double norm = check_daxpby(n, alpha, incx, beta, incy);
  200. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  201. }
  202. /**
  203. * Fortran API specific test
  204. * Test daxpby by comparing it with dscal and daxpy.
  205. * Test with the following options:
  206. *
  207. * Size of vectors x, y is 100
  208. * Stride of vector x is 2
  209. * Stride of vector y is -1
  210. */
  211. CTEST(daxpby, inc_x_2_inc_y_neg_1_N_100)
  212. {
  213. blasint n = DATASIZE, incx = 2, incy = -1;
  214. double alpha = 1.0;
  215. double beta = 6.0;
  216. double norm = check_daxpby(n, alpha, incx, beta, incy);
  217. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  218. }
  219. /**
  220. * Fortran API specific test
  221. * Test daxpby by comparing it with dscal and daxpy.
  222. * Test with the following options:
  223. *
  224. * Size of vectors x, y is 100
  225. * Stride of vector x is -2
  226. * Stride of vector y is -1
  227. */
  228. CTEST(daxpby, inc_x_neg_2_inc_y_neg_1_N_100)
  229. {
  230. blasint n = DATASIZE, incx = -2, incy = -1;
  231. double alpha = 7.0;
  232. double beta = 3.5;
  233. double norm = check_daxpby(n, alpha, incx, beta, incy);
  234. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  235. }
  236. /**
  237. * Fortran API specific test
  238. * Test daxpby by comparing it with dscal and daxpy.
  239. * Test with the following options:
  240. *
  241. * Size of vectors x, y is 100
  242. * Stride of vector x is 1
  243. * Stride of vector y is 1
  244. * Scalar alpha is zero
  245. */
  246. CTEST(daxpby, inc_x_1_inc_y_1_N_100_alpha_zero)
  247. {
  248. blasint n = DATASIZE, incx = 1, incy = 1;
  249. double alpha = 0.0;
  250. double beta = 1.0;
  251. double norm = check_daxpby(n, alpha, incx, beta, incy);
  252. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  253. }
  254. /**
  255. * Fortran API specific test
  256. * Test daxpby by comparing it with dscal and daxpy.
  257. * Test with the following options:
  258. *
  259. * Size of vectors x, y is 100
  260. * Stride of vector x is 1
  261. * Stride of vector y is 2
  262. * Scalar alpha is zero
  263. */
  264. CTEST(daxpby, inc_x_1_inc_y_2_N_100_alpha_zero)
  265. {
  266. blasint n = DATASIZE, incx = 1, incy = 2;
  267. double alpha = 0.0;
  268. double beta = 1.0;
  269. double norm = check_daxpby(n, alpha, incx, beta, incy);
  270. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  271. }
  272. /**
  273. * Fortran API specific test
  274. * Test daxpby by comparing it with dscal and daxpy.
  275. * Test with the following options:
  276. *
  277. * Size of vectors x, y is 100
  278. * Stride of vector x is 1
  279. * Stride of vector y is 1
  280. * Scalar beta is zero
  281. */
  282. CTEST(daxpby, inc_x_1_inc_y_1_N_100_beta_zero)
  283. {
  284. blasint n = DATASIZE, incx = 1, incy = 1;
  285. double alpha = 1.0;
  286. double beta = 0.0;
  287. double norm = check_daxpby(n, alpha, incx, beta, incy);
  288. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  289. }
  290. /**
  291. * Fortran API specific test
  292. * Test daxpby by comparing it with dscal and daxpy.
  293. * Test with the following options:
  294. *
  295. * Size of vectors x, y is 100
  296. * Stride of vector x is 2
  297. * Stride of vector y is 1
  298. * Scalar beta is zero
  299. */
  300. CTEST(daxpby, inc_x_2_inc_y_1_N_100_beta_zero)
  301. {
  302. blasint n = DATASIZE, incx = 2, incy = 1;
  303. double alpha = 1.0;
  304. double beta = 0.0;
  305. double norm = check_daxpby(n, alpha, incx, beta, incy);
  306. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  307. }
  308. /**
  309. * Fortran API specific test
  310. * Test daxpby by comparing it with dscal and daxpy.
  311. * Test with the following options:
  312. *
  313. * Size of vectors x, y is 100
  314. * Stride of vector x is 1
  315. * Stride of vector y is 2
  316. * Scalar beta is zero
  317. */
  318. CTEST(daxpby, inc_x_1_inc_y_2_N_100_beta_zero)
  319. {
  320. blasint n = DATASIZE, incx = 1, incy = 2;
  321. double alpha = 1.0;
  322. double beta = 0.0;
  323. double norm = check_daxpby(n, alpha, incx, beta, incy);
  324. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  325. }
  326. /**
  327. * Fortran API specific test
  328. * Test daxpby by comparing it with dscal and daxpy.
  329. * Test with the following options:
  330. *
  331. * Size of vectors x, y is 100
  332. * Stride of vector x is 2
  333. * Stride of vector y is 2
  334. * Scalar beta is zero
  335. */
  336. CTEST(daxpby, inc_x_2_inc_y_2_N_100_beta_zero)
  337. {
  338. blasint n = DATASIZE, incx = 2, incy = 2;
  339. double alpha = 1.0;
  340. double beta = 0.0;
  341. double norm = check_daxpby(n, alpha, incx, beta, incy);
  342. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  343. }
  344. /**
  345. * Fortran API specific test
  346. * Test daxpby by comparing it with dscal and daxpy.
  347. * Test with the following options:
  348. *
  349. * Size of vectors x, y is 100
  350. * Stride of vector x is 1
  351. * Stride of vector y is 1
  352. * Scalar alpha is zero
  353. * Scalar beta is zero
  354. */
  355. CTEST(daxpby, inc_x_1_inc_y_1_N_100_alpha_beta_zero)
  356. {
  357. blasint n = DATASIZE, incx = 1, incy = 1;
  358. double alpha = 0.0;
  359. double beta = 0.0;
  360. double norm = check_daxpby(n, alpha, incx, beta, incy);
  361. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  362. }
  363. /**
  364. * Fortran API specific test
  365. * Test daxpby by comparing it with dscal and daxpy.
  366. * Test with the following options:
  367. *
  368. * Size of vectors x, y is 100
  369. * Stride of vector x is 1
  370. * Stride of vector y is 2
  371. * Scalar alpha is zero
  372. * Scalar beta is zero
  373. */
  374. CTEST(daxpby, inc_x_1_inc_y_2_N_100_alpha_beta_zero)
  375. {
  376. blasint n = DATASIZE, incx = 1, incy = 2;
  377. double alpha = 0.0;
  378. double beta = 0.0;
  379. double norm = check_daxpby(n, alpha, incx, beta, incy);
  380. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  381. }
  382. /**
  383. * Fortran API specific test
  384. * Check if n - size of vectors x, y is zero
  385. */
  386. CTEST(daxpby, check_n_zero)
  387. {
  388. blasint n = 0, incx = 1, incy = 1;
  389. double alpha = 1.0;
  390. double beta = 1.0;
  391. double norm = check_daxpby(n, alpha, incx, beta, incy);
  392. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  393. }
  394. /**
  395. * C API specific test
  396. * Test daxpby by comparing it with dscal and daxpy.
  397. * Test with the following options:
  398. *
  399. * Size of vectors x, y is 100
  400. * Stride of vector x is 1
  401. * Stride of vector y is 1
  402. */
  403. CTEST(daxpby, c_api_inc_x_1_inc_y_1_N_100)
  404. {
  405. blasint n = DATASIZE, incx = 1, incy = 1;
  406. double alpha = 1.0;
  407. double beta = 1.0;
  408. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  409. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  410. }
  411. /**
  412. * C API specific test
  413. * Test daxpby by comparing it with dscal and daxpy.
  414. * Test with the following options:
  415. *
  416. * Size of vectors x, y is 100
  417. * Stride of vector x is 2
  418. * Stride of vector y is 1
  419. */
  420. CTEST(daxpby, c_api_inc_x_2_inc_y_1_N_100)
  421. {
  422. blasint n = DATASIZE, incx = 2, incy = 1;
  423. double alpha = 2.0;
  424. double beta = 1.0;
  425. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  426. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  427. }
  428. /**
  429. * C API specific test
  430. * Test daxpby by comparing it with dscal and daxpy.
  431. * Test with the following options:
  432. *
  433. * Size of vectors x, y is 100
  434. * Stride of vector x is 1
  435. * Stride of vector y is 2
  436. */
  437. CTEST(daxpby, c_api_inc_x_1_inc_y_2_N_100)
  438. {
  439. blasint n = DATASIZE, incx = 1, incy = 2;
  440. double alpha = 1.0;
  441. double beta = 2.0;
  442. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  443. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  444. }
  445. /**
  446. * C API specific test
  447. * Test daxpby by comparing it with dscal and daxpy.
  448. * Test with the following options:
  449. *
  450. * Size of vectors x, y is 100
  451. * Stride of vector x is 2
  452. * Stride of vector y is 2
  453. */
  454. CTEST(daxpby, c_api_inc_x_2_inc_y_2_N_100)
  455. {
  456. blasint n = DATASIZE, incx = 2, incy = 2;
  457. double alpha = 3.0;
  458. double beta = 4.0;
  459. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  460. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  461. }
  462. /**
  463. * C API specific test
  464. * Test daxpby by comparing it with dscal and daxpy.
  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 2
  470. */
  471. CTEST(daxpby, c_api_inc_x_neg_1_inc_y_2_N_100)
  472. {
  473. blasint n = DATASIZE, incx = -1, incy = 2;
  474. double alpha = 5.0;
  475. double beta = 4.0;
  476. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  477. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  478. }
  479. /**
  480. * C API specific test
  481. * Test daxpby by comparing it with dscal and daxpy.
  482. * Test with the following options:
  483. *
  484. * Size of vectors x, y is 100
  485. * Stride of vector x is 2
  486. * Stride of vector y is -1
  487. */
  488. CTEST(daxpby, c_api_inc_x_2_inc_y_neg_1_N_100)
  489. {
  490. blasint n = DATASIZE, incx = 2, incy = -1;
  491. double alpha = 1.0;
  492. double beta = 6.0;
  493. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  494. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  495. }
  496. /**
  497. * C API specific test
  498. * Test daxpby by comparing it with dscal and daxpy.
  499. * Test with the following options:
  500. *
  501. * Size of vectors x, y is 100
  502. * Stride of vector x is -2
  503. * Stride of vector y is -1
  504. */
  505. CTEST(daxpby, c_api_inc_x_neg_2_inc_y_neg_1_N_100)
  506. {
  507. blasint n = DATASIZE, incx = -2, incy = -1;
  508. double alpha = 7.0;
  509. double beta = 3.5;
  510. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  511. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  512. }
  513. /**
  514. * C API specific test
  515. * Test daxpby by comparing it with dscal and daxpy.
  516. * Test with the following options:
  517. *
  518. * Size of vectors x, y is 100
  519. * Stride of vector x is 1
  520. * Stride of vector y is 1
  521. * Scalar alpha is zero
  522. */
  523. CTEST(daxpby, c_api_inc_x_1_inc_y_1_N_100_alpha_zero)
  524. {
  525. blasint n = DATASIZE, incx = 1, incy = 1;
  526. double alpha = 0.0;
  527. double beta = 1.0;
  528. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  529. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  530. }
  531. /**
  532. * C API specific test
  533. * Test daxpby by comparing it with dscal and daxpy.
  534. * Test with the following options:
  535. *
  536. * Size of vectors x, y is 100
  537. * Stride of vector x is 1
  538. * Stride of vector y is 2
  539. * Scalar alpha is zero
  540. */
  541. CTEST(daxpby, c_api_inc_x_1_inc_y_2_N_100_alpha_zero)
  542. {
  543. blasint n = DATASIZE, incx = 1, incy = 2;
  544. double alpha = 0.0;
  545. double beta = 1.0;
  546. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  547. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  548. }
  549. /**
  550. * C API specific test
  551. *
  552. * Test daxpby by comparing it with dscal and daxpy.
  553. * Test with the following options:
  554. *
  555. * Size of vectors x, y is 100
  556. * Stride of vector x is 1
  557. * Stride of vector y is 1
  558. * Scalar beta is zero
  559. */
  560. CTEST(daxpby, c_api_inc_x_1_inc_y_1_N_100_beta_zero)
  561. {
  562. blasint n = DATASIZE, incx = 1, incy = 1;
  563. double alpha = 1.0;
  564. double beta = 0.0;
  565. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  566. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  567. }
  568. /**
  569. * C API specific test
  570. * Test daxpby by comparing it with dscal and daxpy.
  571. * Test with the following options:
  572. *
  573. * Size of vectors x, y is 100
  574. * Stride of vector x is 2
  575. * Stride of vector y is 1
  576. * Scalar beta is zero
  577. */
  578. CTEST(daxpby, c_api_inc_x_2_inc_y_1_N_100_beta_zero)
  579. {
  580. blasint n = DATASIZE, incx = 2, incy = 1;
  581. double alpha = 1.0;
  582. double beta = 0.0;
  583. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  584. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  585. }
  586. /**
  587. * C API specific test
  588. *
  589. * Test daxpby by comparing it with dscal and daxpy.
  590. * Test with the following options:
  591. *
  592. * Size of vectors x, y is 100
  593. * Stride of vector x is 1
  594. * Stride of vector y is 2
  595. * Scalar beta is zero
  596. */
  597. CTEST(daxpby, c_api_inc_x_1_inc_y_2_N_100_beta_zero)
  598. {
  599. blasint n = DATASIZE, incx = 1, incy = 2;
  600. double alpha = 1.0;
  601. double beta = 0.0;
  602. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  603. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  604. }
  605. /**
  606. * C API specific test
  607. *
  608. * Test daxpby by comparing it with dscal and daxpy.
  609. * Test with the following options:
  610. *
  611. * Size of vectors x, y is 100
  612. * Stride of vector x is 2
  613. * Stride of vector y is 2
  614. * Scalar beta is zero
  615. */
  616. CTEST(daxpby, c_api_inc_x_2_inc_y_2_N_100_beta_zero)
  617. {
  618. blasint n = DATASIZE, incx = 2, incy = 2;
  619. double alpha = 1.0;
  620. double beta = 0.0;
  621. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  622. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  623. }
  624. /**
  625. * C API specific test
  626. *
  627. * Test daxpby by comparing it with dscal and daxpy.
  628. * Test with the following options:
  629. *
  630. * Size of vectors x, y is 100
  631. * Stride of vector x is 1
  632. * Stride of vector y is 1
  633. * Scalar alpha is zero
  634. * Scalar beta is zero
  635. */
  636. CTEST(daxpby, c_api_inc_x_1_inc_y_1_N_100_alpha_beta_zero)
  637. {
  638. blasint n = DATASIZE, incx = 1, incy = 1;
  639. double alpha = 0.0;
  640. double beta = 0.0;
  641. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  642. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  643. }
  644. /**
  645. * C API specific test
  646. * Test daxpby by comparing it with dscal and daxpy.
  647. * Test with the following options:
  648. *
  649. * Size of vectors x, y is 100
  650. * Stride of vector x is 1
  651. * Stride of vector y is 2
  652. * Scalar alpha is zero
  653. * Scalar beta is zero
  654. */
  655. CTEST(daxpby, c_api_inc_x_1_inc_y_2_N_100_alpha_beta_zero)
  656. {
  657. blasint n = DATASIZE, incx = 1, incy = 2;
  658. double alpha = 0.0;
  659. double beta = 0.0;
  660. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  661. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  662. }
  663. /**
  664. * C API specific test
  665. * Check if n - size of vectors x, y is zero
  666. */
  667. CTEST(daxpby, c_api_check_n_zero)
  668. {
  669. blasint n = 0, incx = 1, incy = 1;
  670. double alpha = 1.0;
  671. double beta = 1.0;
  672. double norm = c_api_check_daxpby(n, alpha, incx, beta, incy);
  673. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  674. }
  675. #endif