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

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