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

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