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_zrot.c 19 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  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_ZROT {
  33. double x_test[DATASIZE * INCREMENT * 2];
  34. double y_test[DATASIZE * INCREMENT * 2];
  35. double x_verify[DATASIZE * INCREMENT * 2];
  36. double y_verify[DATASIZE * INCREMENT * 2];
  37. };
  38. #ifdef BUILD_COMPLEX16
  39. static struct DATA_ZROT data_zrot;
  40. /**
  41. * Comapare results computed by zdrot and zaxpby
  42. *
  43. * param n specifies size of vector x
  44. * param inc_x specifies increment of vector x
  45. * param inc_y specifies increment of vector y
  46. * param c specifies cosine
  47. * param s specifies sine
  48. * return norm of differences
  49. */
  50. static double check_zdrot(blasint n, blasint inc_x, blasint inc_y, double *c, double *s)
  51. {
  52. blasint i;
  53. double norm = 0;
  54. double s_neg[] = {-s[0], s[1]};
  55. blasint inc_x_abs = labs(inc_x);
  56. blasint inc_y_abs = labs(inc_y);
  57. // Fill vectors x, y
  58. drand_generate(data_zrot.x_test, n * inc_x_abs * 2);
  59. drand_generate(data_zrot.y_test, n * inc_y_abs * 2);
  60. if (inc_x == 0 && inc_y == 0) {
  61. drand_generate(data_zrot.x_test, n * 2);
  62. drand_generate(data_zrot.y_test, n * 2);
  63. }
  64. // Copy vector x for zaxpby
  65. for (i = 0; i < n * inc_x_abs * 2; i++)
  66. data_zrot.x_verify[i] = data_zrot.x_test[i];
  67. // Copy vector y for zaxpby
  68. for (i = 0; i < n * inc_y_abs * 2; i++)
  69. data_zrot.y_verify[i] = data_zrot.y_test[i];
  70. // Find cx = c*x + s*y
  71. BLASFUNC(zaxpby)(&n, s, data_zrot.y_test, &inc_y, c, data_zrot.x_verify, &inc_x);
  72. // Find cy = -conjg(s)*x + c*y
  73. BLASFUNC(zaxpby)(&n, s_neg, data_zrot.x_test, &inc_x, c, data_zrot.y_verify, &inc_y);
  74. BLASFUNC(zdrot)(&n, data_zrot.x_test, &inc_x, data_zrot.y_test, &inc_y, c, s);
  75. // Find the differences between vector x caculated by zaxpby and zdrot
  76. for (i = 0; i < n * 2 * inc_x_abs; i++)
  77. data_zrot.x_test[i] -= data_zrot.x_verify[i];
  78. // Find the differences between vector y caculated by zaxpby and zdrot
  79. for (i = 0; i < n * 2 * inc_y_abs; i++)
  80. data_zrot.y_test[i] -= data_zrot.y_verify[i];
  81. // Find the norm of differences
  82. norm += BLASFUNC(dznrm2)(&n, data_zrot.x_test, &inc_x_abs);
  83. norm += BLASFUNC(dznrm2)(&n, data_zrot.y_test, &inc_y_abs);
  84. return (norm / 2);
  85. }
  86. #ifndef NO_CBLAS
  87. /**
  88. * C API specific function
  89. * Comapare results computed by zdrot and zaxpby
  90. *
  91. * param n specifies size of vector x
  92. * param inc_x specifies increment of vector x
  93. * param inc_y specifies increment of vector y
  94. * param c specifies cosine
  95. * param s specifies sine
  96. * return norm of differences
  97. */
  98. static double c_api_check_zdrot(blasint n, blasint inc_x, blasint inc_y, double *c, double *s)
  99. {
  100. blasint i;
  101. double norm = 0;
  102. double s_neg[] = {-s[0], s[1]};
  103. blasint inc_x_abs = labs(inc_x);
  104. blasint inc_y_abs = labs(inc_y);
  105. // Fill vectors x, y
  106. drand_generate(data_zrot.x_test, n * inc_x_abs * 2);
  107. drand_generate(data_zrot.y_test, n * inc_y_abs * 2);
  108. if (inc_x == 0 && inc_y == 0) {
  109. drand_generate(data_zrot.x_test, n * 2);
  110. drand_generate(data_zrot.y_test, n * 2);
  111. }
  112. // Copy vector x for zaxpby
  113. for (i = 0; i < n * inc_x_abs * 2; i++)
  114. data_zrot.x_verify[i] = data_zrot.x_test[i];
  115. // Copy vector y for zaxpby
  116. for (i = 0; i < n * inc_y_abs * 2; i++)
  117. data_zrot.y_verify[i] = data_zrot.y_test[i];
  118. // Find cx = c*x + s*y
  119. cblas_zaxpby(n, s, data_zrot.y_test, inc_y, c, data_zrot.x_verify, inc_x);
  120. // Find cy = -conjg(s)*x + c*y
  121. cblas_zaxpby(n, s_neg, data_zrot.x_test, inc_x, c, data_zrot.y_verify, inc_y);
  122. cblas_zdrot(n, data_zrot.x_test, inc_x, data_zrot.y_test, inc_y, c[0], s[0]);
  123. // Find the differences between vector x caculated by zaxpby and zdrot
  124. for (i = 0; i < n * 2 * inc_x_abs; i++)
  125. data_zrot.x_test[i] -= data_zrot.x_verify[i];
  126. // Find the differences between vector y caculated by zaxpby and zdrot
  127. for (i = 0; i < n * 2 * inc_y_abs; i++)
  128. data_zrot.y_test[i] -= data_zrot.y_verify[i];
  129. // Find the norm of differences
  130. norm += cblas_dznrm2(n, data_zrot.x_test, inc_x_abs);
  131. norm += cblas_dznrm2(n, data_zrot.y_test, inc_y_abs);
  132. return (norm / 2);
  133. }
  134. #if 0
  135. /**
  136. * Fortran API specific test
  137. * Test zrot by comparing it with zaxpby.
  138. * Test with the following options:
  139. *
  140. * Size of vectors x, y is 100
  141. * Stride of vector x is 0
  142. * Stride of vector y is 0
  143. * c = 1.0
  144. * s = 2.0
  145. */
  146. CTEST(zrot, inc_x_0_inc_y_0)
  147. {
  148. blasint n = 100;
  149. blasint inc_x = 0;
  150. blasint inc_y = 0;
  151. // Imaginary part for zaxpby
  152. double c[] = {1.0, 0.0};
  153. double s[] = {2.0, 0.0};
  154. double norm = check_zdrot(n, inc_x, inc_y, c, s);
  155. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  156. }
  157. #endif
  158. /**
  159. * Fortran API specific test
  160. * Test zrot by comparing it with zaxpby.
  161. * Test with the following options:
  162. *
  163. * Size of vectors x, y is 100
  164. * Stride of vector x is 1
  165. * Stride of vector y is 1
  166. * c = 1.0
  167. * s = 1.0
  168. */
  169. CTEST(zrot, inc_x_1_inc_y_1)
  170. {
  171. blasint n = 100;
  172. blasint inc_x = 1;
  173. blasint inc_y = 1;
  174. // Imaginary part for zaxpby
  175. double c[] = {1.0, 0.0};
  176. double s[] = {1.0, 0.0};
  177. double norm = check_zdrot(n, inc_x, inc_y, c, s);
  178. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  179. }
  180. /**
  181. * Fortran API specific test
  182. * Test zrot by comparing it with zaxpby.
  183. * Test with the following options:
  184. *
  185. * Size of vectors x, y is 100
  186. * Stride of vector x is -1
  187. * Stride of vector y is -1
  188. * c = 1.0
  189. * s = 1.0
  190. */
  191. CTEST(zrot, inc_x_neg_1_inc_y_neg_1)
  192. {
  193. blasint n = 100;
  194. blasint inc_x = -1;
  195. blasint inc_y = -1;
  196. // Imaginary part for zaxpby
  197. double c[] = {1.0, 0.0};
  198. double s[] = {1.0, 0.0};
  199. double norm = check_zdrot(n, inc_x, inc_y, c, s);
  200. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  201. }
  202. /**
  203. * Fortran API specific test
  204. * Test zrot by comparing it with zaxpby.
  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. * c = 3.0
  211. * s = 2.0
  212. */
  213. CTEST(zrot, inc_x_2_inc_y_1)
  214. {
  215. blasint n = 100;
  216. blasint inc_x = 2;
  217. blasint inc_y = 1;
  218. // Imaginary part for zaxpby
  219. double c[] = {3.0, 0.0};
  220. double s[] = {2.0, 0.0};
  221. double norm = check_zdrot(n, inc_x, inc_y, c, s);
  222. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  223. }
  224. /**
  225. * Fortran API specific test
  226. * Test zrot by comparing it with zaxpby.
  227. * Test with the following options:
  228. *
  229. * Size of vectors x, y is 100
  230. * Stride of vector x is -2
  231. * Stride of vector y is 1
  232. * c = 1.0
  233. * s = 1.0
  234. */
  235. CTEST(zrot, inc_x_neg_2_inc_y_1)
  236. {
  237. blasint n = 100;
  238. blasint inc_x = -2;
  239. blasint inc_y = 1;
  240. // Imaginary part for zaxpby
  241. double c[] = {1.0, 0.0};
  242. double s[] = {1.0, 0.0};
  243. double norm = check_zdrot(n, inc_x, inc_y, c, s);
  244. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  245. }
  246. /**
  247. * Fortran API specific test
  248. * Test zrot by comparing it with zaxpby.
  249. * Test with the following options:
  250. *
  251. * Size of vectors x, y is 100
  252. * Stride of vector x is 1
  253. * Stride of vector y is 2
  254. * c = 1.0
  255. * s = 1.0
  256. */
  257. CTEST(zrot, inc_x_1_inc_y_2)
  258. {
  259. blasint n = 100;
  260. blasint inc_x = 1;
  261. blasint inc_y = 2;
  262. // Imaginary part for zaxpby
  263. double c[] = {1.0, 0.0};
  264. double s[] = {1.0, 0.0};
  265. double norm = check_zdrot(n, inc_x, inc_y, c, s);
  266. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  267. }
  268. /**
  269. * Fortran API specific test
  270. * Test zrot by comparing it with zaxpby.
  271. * Test with the following options:
  272. *
  273. * Size of vectors x, y is 100
  274. * Stride of vector x is 1
  275. * Stride of vector y is -2
  276. * c = 2.0
  277. * s = 1.0
  278. */
  279. CTEST(zrot, inc_x_1_inc_y_neg_2)
  280. {
  281. blasint n = 100;
  282. blasint inc_x = 1;
  283. blasint inc_y = -2;
  284. // Imaginary part for zaxpby
  285. double c[] = {2.0, 0.0};
  286. double s[] = {1.0, 0.0};
  287. double norm = check_zdrot(n, inc_x, inc_y, c, s);
  288. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  289. }
  290. /**
  291. * Fortran API specific test
  292. * Test zrot by comparing it with zaxpby.
  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 2
  298. * c = 1.0
  299. * s = 2.0
  300. */
  301. CTEST(zrot, inc_x_2_inc_y_2)
  302. {
  303. blasint n = 100;
  304. blasint inc_x = 2;
  305. blasint inc_y = 2;
  306. // Imaginary part for zaxpby
  307. double c[] = {1.0, 0.0};
  308. double s[] = {2.0, 0.0};
  309. double norm = check_zdrot(n, inc_x, inc_y, c, s);
  310. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  311. }
  312. /**
  313. * Fortran API specific test
  314. * Test zrot by comparing it with zaxpby.
  315. * Test with the following options:
  316. *
  317. * Size of vectors x, y is 100
  318. * Stride of vector x is 2
  319. * Stride of vector y is 2
  320. * c = 1.0
  321. * s = 1.0
  322. */
  323. CTEST(zrot, inc_x_neg_2_inc_y_neg_2)
  324. {
  325. blasint n = 100;
  326. blasint inc_x = -2;
  327. blasint inc_y = -2;
  328. // Imaginary part for zaxpby
  329. double c[] = {1.0, 0.0};
  330. double s[] = {1.0, 0.0};
  331. double norm = check_zdrot(n, inc_x, inc_y, c, s);
  332. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  333. }
  334. /**
  335. * Fortran API specific test
  336. * Test zrot by comparing it with zaxpby.
  337. * Test with the following options:
  338. *
  339. * Size of vectors x, y is 100
  340. * Stride of vector x is 2
  341. * Stride of vector y is 2
  342. * c = 0.0
  343. * s = 1.0
  344. */
  345. CTEST(zrot, inc_x_2_inc_y_2_c_zero)
  346. {
  347. blasint n = 100;
  348. blasint inc_x = 2;
  349. blasint inc_y = 2;
  350. // Imaginary part for zaxpby
  351. double c[] = {0.0, 0.0};
  352. double s[] = {1.0, 0.0};
  353. double norm = check_zdrot(n, inc_x, inc_y, c, s);
  354. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  355. }
  356. /**
  357. * Fortran API specific test
  358. * Test zrot by comparing it with zaxpby.
  359. * Test with the following options:
  360. *
  361. * Size of vectors x, y is 100
  362. * Stride of vector x is 2
  363. * Stride of vector y is 2
  364. * c = 1.0
  365. * s = 0.0
  366. */
  367. CTEST(zrot, inc_x_2_inc_y_2_s_zero)
  368. {
  369. blasint n = 100;
  370. blasint inc_x = 2;
  371. blasint inc_y = 2;
  372. // Imaginary part for zaxpby
  373. double c[] = {1.0, 0.0};
  374. double s[] = {0.0, 0.0};
  375. double norm = check_zdrot(n, inc_x, inc_y, c, s);
  376. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  377. }
  378. /**
  379. * Fortran API specific test
  380. * Test zrot by comparing it with zaxpby.
  381. * Test with the following options:
  382. *
  383. * Size of vectors x, y is 0
  384. * Stride of vector x is 1
  385. * Stride of vector y is 1
  386. * c = 1.0
  387. * s = 1.0
  388. */
  389. CTEST(zrot, check_n_zero)
  390. {
  391. blasint n = 0;
  392. blasint inc_x = 1;
  393. blasint inc_y = 1;
  394. // Imaginary part for zaxpby
  395. double c[] = {1.0, 0.0};
  396. double s[] = {1.0, 0.0};
  397. double norm = check_zdrot(n, inc_x, inc_y, c, s);
  398. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  399. }
  400. #if 0
  401. /**
  402. * C API specific test
  403. * Test zrot by comparing it with zaxpby.
  404. * Test with the following options:
  405. *
  406. * Size of vectors x, y is 100
  407. * Stride of vector x is 0
  408. * Stride of vector y is 0
  409. * c = 1.0
  410. * s = 2.0
  411. */
  412. CTEST(zrot, c_api_inc_x_0_inc_y_0)
  413. {
  414. blasint n = 100;
  415. blasint inc_x = 0;
  416. blasint inc_y = 0;
  417. // Imaginary part for zaxpby
  418. double c[] = {3.0, 0.0};
  419. double s[] = {2.0, 0.0};
  420. double norm = c_api_check_zdrot(n, inc_x, inc_y, c, s);
  421. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  422. }
  423. #endif
  424. /**
  425. * C API specific test
  426. * Test zrot by comparing it with zaxpby.
  427. * Test with the following options:
  428. *
  429. * Size of vectors x, y is 100
  430. * Stride of vector x is 1
  431. * Stride of vector y is 1
  432. * c = 1.0
  433. * s = 1.0
  434. */
  435. CTEST(zrot, c_api_inc_x_1_inc_y_1)
  436. {
  437. blasint n = 100;
  438. blasint inc_x = 1;
  439. blasint inc_y = 1;
  440. // Imaginary part for zaxpby
  441. double c[] = {1.0, 0.0};
  442. double s[] = {1.0, 0.0};
  443. double norm = c_api_check_zdrot(n, inc_x, inc_y, c, s);
  444. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  445. }
  446. /**
  447. * C API specific test
  448. * Test zrot by comparing it with zaxpby.
  449. * Test with the following options:
  450. *
  451. * Size of vectors x, y is 100
  452. * Stride of vector x is -1
  453. * Stride of vector y is -1
  454. * c = 1.0
  455. * s = 1.0
  456. */
  457. CTEST(zrot, c_api_inc_x_neg_1_inc_y_neg_1)
  458. {
  459. blasint n = 100;
  460. blasint inc_x = -1;
  461. blasint inc_y = -1;
  462. // Imaginary part for zaxpby
  463. double c[] = {1.0, 0.0};
  464. double s[] = {1.0, 0.0};
  465. double norm = c_api_check_zdrot(n, inc_x, inc_y, c, s);
  466. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  467. }
  468. /**
  469. * C API specific test
  470. * Test zrot by comparing it with zaxpby.
  471. * Test with the following options:
  472. *
  473. * Size of vectors x, y is 100
  474. * Stride of vector x is 2
  475. * Stride of vector y is 1
  476. * c = 3.0
  477. * s = 2.0
  478. */
  479. CTEST(zrot, c_api_inc_x_2_inc_y_1)
  480. {
  481. blasint n = 100;
  482. blasint inc_x = 2;
  483. blasint inc_y = 1;
  484. // Imaginary part for zaxpby
  485. double c[] = {3.0, 0.0};
  486. double s[] = {2.0, 0.0};
  487. double norm = c_api_check_zdrot(n, inc_x, inc_y, c, s);
  488. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  489. }
  490. /**
  491. * C API specific test
  492. * Test zrot by comparing it with zaxpby.
  493. * Test with the following options:
  494. *
  495. * Size of vectors x, y is 100
  496. * Stride of vector x is -2
  497. * Stride of vector y is 1
  498. * c = 1.0
  499. * s = 1.0
  500. */
  501. CTEST(zrot, c_api_inc_x_neg_2_inc_y_1)
  502. {
  503. blasint n = 100;
  504. blasint inc_x = -2;
  505. blasint inc_y = 1;
  506. // Imaginary part for zaxpby
  507. double c[] = {1.0, 0.0};
  508. double s[] = {1.0, 0.0};
  509. double norm = c_api_check_zdrot(n, inc_x, inc_y, c, s);
  510. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  511. }
  512. /**
  513. * C API specific test
  514. * Test zrot by comparing it with zaxpby.
  515. * Test with the following options:
  516. *
  517. * Size of vectors x, y is 100
  518. * Stride of vector x is 1
  519. * Stride of vector y is 2
  520. * c = 1.0
  521. * s = 1.0
  522. */
  523. CTEST(zrot, c_api_inc_x_1_inc_y_2)
  524. {
  525. blasint n = 100;
  526. blasint inc_x = 1;
  527. blasint inc_y = 2;
  528. // Imaginary part for zaxpby
  529. double c[] = {1.0, 0.0};
  530. double s[] = {1.0, 0.0};
  531. double norm = c_api_check_zdrot(n, inc_x, inc_y, c, s);
  532. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  533. }
  534. /**
  535. * C API specific test
  536. * Test zrot by comparing it with zaxpby.
  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. * c = 2.0
  543. * s = 1.0
  544. */
  545. CTEST(zrot, c_api_inc_x_1_inc_y_neg_2)
  546. {
  547. blasint n = 100;
  548. blasint inc_x = 1;
  549. blasint inc_y = -2;
  550. // Imaginary part for zaxpby
  551. double c[] = {2.0, 0.0};
  552. double s[] = {1.0, 0.0};
  553. double norm = c_api_check_zdrot(n, inc_x, inc_y, c, s);
  554. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  555. }
  556. /**
  557. * C API specific test
  558. * Test zrot by comparing it with zaxpby.
  559. * Test with the following options:
  560. *
  561. * Size of vectors x, y is 100
  562. * Stride of vector x is 2
  563. * Stride of vector y is 2
  564. * c = 1.0
  565. * s = 2.0
  566. */
  567. CTEST(zrot, c_api_inc_x_2_inc_y_2)
  568. {
  569. blasint n = 100;
  570. blasint inc_x = 2;
  571. blasint inc_y = 2;
  572. // Imaginary part for zaxpby
  573. double c[] = {1.0, 0.0};
  574. double s[] = {2.0, 0.0};
  575. double norm = c_api_check_zdrot(n, inc_x, inc_y, c, s);
  576. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  577. }
  578. /**
  579. * C API specific test
  580. * Test zrot by comparing it with zaxpby.
  581. * Test with the following options:
  582. *
  583. * Size of vectors x, y is 100
  584. * Stride of vector x is 2
  585. * Stride of vector y is 2
  586. * c = 1.0
  587. * s = 1.0
  588. */
  589. CTEST(zrot, c_api_inc_x_neg_2_inc_y_neg_2)
  590. {
  591. blasint n = 100;
  592. blasint inc_x = -2;
  593. blasint inc_y = -2;
  594. // Imaginary part for zaxpby
  595. double c[] = {1.0, 0.0};
  596. double s[] = {1.0, 0.0};
  597. double norm = c_api_check_zdrot(n, inc_x, inc_y, c, s);
  598. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  599. }
  600. /**
  601. * C API specific test
  602. * Test zrot by comparing it with zaxpby.
  603. * Test with the following options:
  604. *
  605. * Size of vectors x, y is 100
  606. * Stride of vector x is 2
  607. * Stride of vector y is 2
  608. * c = 0.0
  609. * s = 1.0
  610. */
  611. CTEST(zrot, c_api_inc_x_2_inc_y_2_c_zero)
  612. {
  613. blasint n = 100;
  614. blasint inc_x = 2;
  615. blasint inc_y = 2;
  616. // Imaginary part for zaxpby
  617. double c[] = {0.0, 0.0};
  618. double s[] = {1.0, 0.0};
  619. double norm = c_api_check_zdrot(n, inc_x, inc_y, c, s);
  620. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  621. }
  622. /**
  623. * C API specific test
  624. * Test zrot by comparing it with zaxpby.
  625. * Test with the following options:
  626. *
  627. * Size of vectors x, y is 100
  628. * Stride of vector x is 2
  629. * Stride of vector y is 2
  630. * c = 1.0
  631. * s = 0.0
  632. */
  633. CTEST(zrot, c_api_inc_x_2_inc_y_2_s_zero)
  634. {
  635. blasint n = 100;
  636. blasint inc_x = 2;
  637. blasint inc_y = 2;
  638. // Imaginary part for zaxpby
  639. double c[] = {1.0, 0.0};
  640. double s[] = {0.0, 0.0};
  641. double norm = c_api_check_zdrot(n, inc_x, inc_y, c, s);
  642. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  643. }
  644. /**
  645. * C API specific test
  646. * Test zrot by comparing it with zaxpby.
  647. * Test with the following options:
  648. *
  649. * Size of vectors x, y is 0
  650. * Stride of vector x is 1
  651. * Stride of vector y is 1
  652. * c = 1.0
  653. * s = 1.0
  654. */
  655. CTEST(zrot, c_api_check_n_zero)
  656. {
  657. blasint n = 0;
  658. blasint inc_x = 1;
  659. blasint inc_y = 1;
  660. // Imaginary part for zaxpby
  661. double c[] = {1.0, 0.0};
  662. double s[] = {1.0, 0.0};
  663. double norm = c_api_check_zdrot(n, inc_x, inc_y, c, s);
  664. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  665. }
  666. #endif
  667. #endif