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_zimatcopy.c 22 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  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. struct DATA_ZIMATCOPY {
  32. double a_test[DATASIZE * DATASIZE * 2];
  33. double a_verify[DATASIZE * DATASIZE * 2];
  34. };
  35. #ifdef BUILD_COMPLEX16
  36. static struct DATA_ZIMATCOPY data_zimatcopy;
  37. /**
  38. * Comapare results computed by zimatcopy and reference func
  39. *
  40. * param api specifies tested api (C or Fortran)
  41. * param order specifies row or column major order
  42. * param trans specifies op(A), the transposition operation
  43. * applied to the matrix A
  44. * param rows specifies number of rows of A
  45. * param cols specifies number of columns of A
  46. * param alpha specifies scaling factor for matrix A
  47. * param lda_src - leading dimension of the matrix A
  48. * param lda_dst - leading dimension of output matrix A
  49. * return norm of difference between openblas and reference func
  50. */
  51. static double check_zimatcopy(char api, char order, char trans, blasint rows, blasint cols, double *alpha,
  52. blasint lda_src, blasint lda_dst)
  53. {
  54. blasint m, n;
  55. blasint rows_out, cols_out;
  56. enum CBLAS_ORDER corder;
  57. enum CBLAS_TRANSPOSE ctrans;
  58. int conj = -1;
  59. if (order == 'C') {
  60. n = rows; m = cols;
  61. }
  62. else {
  63. m = rows; n = cols;
  64. }
  65. if(trans == 'T' || trans == 'C') {
  66. rows_out = n; cols_out = m*2;
  67. if (trans == 'C')
  68. conj = 1;
  69. }
  70. else {
  71. rows_out = m; cols_out = n*2;
  72. if (trans == 'R')
  73. conj = 1;
  74. }
  75. drand_generate(data_zimatcopy.a_test, lda_src*m*2);
  76. if (trans == 'T' || trans == 'C') {
  77. ztranspose(m, n, alpha, data_zimatcopy.a_test, lda_src, data_zimatcopy.a_verify, lda_dst, conj);
  78. }
  79. else {
  80. zcopy(m, n, alpha, data_zimatcopy.a_test, lda_src, data_zimatcopy.a_verify, lda_dst, conj);
  81. }
  82. if (api == 'F') {
  83. BLASFUNC(zimatcopy)(&order, &trans, &rows, &cols, alpha, data_zimatcopy.a_test,
  84. &lda_src, &lda_dst);
  85. }
  86. else {
  87. if (order == 'C') corder = CblasColMajor;
  88. if (order == 'R') corder = CblasRowMajor;
  89. if (trans == 'T') ctrans = CblasTrans;
  90. if (trans == 'N') ctrans = CblasNoTrans;
  91. if (trans == 'C') ctrans = CblasConjTrans;
  92. if (trans == 'R') ctrans = CblasConjNoTrans;
  93. cblas_zimatcopy(corder, ctrans, rows, cols, alpha, data_zimatcopy.a_test,
  94. lda_src, lda_dst);
  95. }
  96. // Find the differences between output matrix computed by zimatcopy and reference func
  97. return dmatrix_difference(data_zimatcopy.a_test, data_zimatcopy.a_verify, cols_out, rows_out, lda_dst*2);
  98. }
  99. /**
  100. * Check if error function was called with expected function name
  101. * and param info
  102. *
  103. * param order specifies row or column major order
  104. * param trans specifies op(A), the transposition operation
  105. * applied to the matrix A
  106. * param rows specifies number of rows of A
  107. * param cols specifies number of columns of A
  108. * param lda_src - leading dimension of the matrix A
  109. * param lda_dst - leading dimension of output matrix A
  110. * param expected_info - expected invalid parameter number
  111. * return TRUE if everything is ok, otherwise FALSE
  112. */
  113. static int check_badargs(char order, char trans, blasint rows, blasint cols,
  114. blasint lda_src, blasint lda_dst, int expected_info)
  115. {
  116. double alpha[] = {1.0, 1.0};
  117. set_xerbla("ZIMATCOPY", expected_info);
  118. BLASFUNC(zimatcopy)(&order, &trans, &rows, &cols, alpha, data_zimatcopy.a_test,
  119. &lda_src, &lda_dst);
  120. return check_error();
  121. }
  122. /**
  123. * Fortran API specific test
  124. * Test zimatcopy by comparing it against reference
  125. * with the following options:
  126. *
  127. * Column Major
  128. * Transposition
  129. * Square matrix
  130. * alpha_r = 1.0, alpha_i = 2.0
  131. */
  132. CTEST(zimatcopy, colmajor_trans_col_100_row_100)
  133. {
  134. blasint m = 100, n = 100;
  135. blasint lda_src = 100, lda_dst = 100;
  136. char order = 'C';
  137. char trans = 'T';
  138. double alpha[] = {1.0, 2.0};
  139. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  140. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  141. }
  142. /**
  143. * Fortran API specific test
  144. * Test zimatcopy by comparing it against reference
  145. * with the following options:
  146. *
  147. * Column Major
  148. * Copy only
  149. * Square matrix
  150. * alpha_r = -3.0, alpha_i = 1.0
  151. */
  152. CTEST(zimatcopy, colmajor_notrans_col_100_row_100)
  153. {
  154. blasint m = 100, n = 100;
  155. blasint lda_src = 100, lda_dst = 100;
  156. char order = 'C';
  157. char trans = 'N';
  158. double alpha[] = {-3.0, 1.0};
  159. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  160. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  161. }
  162. /**
  163. * Fortran API specific test
  164. * Test zimatcopy by comparing it against reference
  165. * with the following options:
  166. *
  167. * Column Major
  168. * Copy and conjugate
  169. * alpha_r = 1.0, alpha_i = 2.0
  170. */
  171. CTEST(zimatcopy, colmajor_conj_col_100_row_100)
  172. {
  173. blasint m = 100, n = 100;
  174. blasint lda_src = 100, lda_dst = 100;
  175. char order = 'C';
  176. char trans = 'R';
  177. double alpha[] = {1.0, 2.0};
  178. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  179. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  180. }
  181. /**
  182. * Fortran API specific test
  183. * Test zimatcopy by comparing it against reference
  184. * with the following options:
  185. *
  186. * Column Major
  187. * Transposition and conjugate
  188. * alpha_r = 2.0, alpha_i = 1.0
  189. */
  190. CTEST(zimatcopy, colmajor_conjtrans_col_100_row_100)
  191. {
  192. blasint m = 100, n = 100;
  193. blasint lda_src = 100, lda_dst = 100;
  194. char order = 'C';
  195. char trans = 'C';
  196. double alpha[] = {2.0, 1.0};
  197. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  198. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  199. }
  200. /**
  201. * Fortran API specific test
  202. * Test zimatcopy by comparing it against reference
  203. * with the following options:
  204. *
  205. * Column Major
  206. * Transposition
  207. * Rectangular matrix
  208. * alpha_r = 1.0, alpha_i = 2.0
  209. */
  210. CTEST(zimatcopy, colmajor_trans_col_50_row_100)
  211. {
  212. blasint m = 100, n = 50;
  213. blasint lda_src = 100, lda_dst = 50;
  214. char order = 'C';
  215. char trans = 'T';
  216. double alpha[] = {1.0, 2.0};
  217. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  218. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  219. }
  220. /**
  221. * Fortran API specific test
  222. * Test zimatcopy by comparing it against reference
  223. * with the following options:
  224. *
  225. * Column Major
  226. * Copy only
  227. * Rectangular matrix
  228. * alpha_r = 1.0, alpha_i = 2.0
  229. */
  230. CTEST(zimatcopy, colmajor_notrans_col_100_row_50)
  231. {
  232. blasint m = 50, n = 100;
  233. blasint lda_src = 50, lda_dst = 50;
  234. char order = 'C';
  235. char trans = 'N';
  236. double alpha[] = {1.0, 2.0};
  237. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  238. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  239. }
  240. /**
  241. * Fortran API specific test
  242. * Test zimatcopy by comparing it against reference
  243. * with the following options:
  244. *
  245. * Column Major
  246. * Transposition and conjugate
  247. * Rectangular matrix
  248. * alpha_r = 1.0, alpha_i = 1.0
  249. */
  250. CTEST(zimatcopy, colmajor_conjtrans_col_50_row_100)
  251. {
  252. blasint m = 100, n = 50;
  253. blasint lda_src = 100, lda_dst = 50;
  254. char order = 'C';
  255. char trans = 'C';
  256. double alpha[] = {1.0, 1.0};
  257. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  258. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  259. }
  260. /**
  261. * Fortran API specific test
  262. * Test zimatcopy by comparing it against reference
  263. * with the following options:
  264. *
  265. * Column Major
  266. * Copy and conjugate
  267. * Rectangular matrix
  268. * alpha_r = 1.0, alpha_i = 2.0
  269. */
  270. CTEST(zimatcopy, colmajor_conj_col_100_row_50)
  271. {
  272. blasint m = 50, n = 100;
  273. blasint lda_src = 50, lda_dst = 50;
  274. char order = 'C';
  275. char trans = 'R';
  276. double alpha[] = {1.0, 2.0};
  277. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  278. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  279. }
  280. /**
  281. * Fortran API specific test
  282. * Test zimatcopy by comparing it against reference
  283. * with the following options:
  284. *
  285. * Row Major
  286. * Transposition
  287. * Square matrix
  288. * alpha_r = 1.0, alpha_i = 2.0
  289. */
  290. CTEST(zimatcopy, rowmajor_trans_col_100_row_100)
  291. {
  292. blasint m = 100, n = 100;
  293. blasint lda_src = 100, lda_dst = 100;
  294. char order = 'R';
  295. char trans = 'T';
  296. double alpha[] = {1.0, 2.0};
  297. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  298. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  299. }
  300. /**
  301. * Fortran API specific test
  302. * Test zimatcopy by comparing it against reference
  303. * with the following options:
  304. *
  305. * Row Major
  306. * Copy only
  307. * Square matrix
  308. * alpha_r = 2.0, alpha_i = 3.0
  309. */
  310. CTEST(zimatcopy, rowmajor_notrans_col_100_row_100)
  311. {
  312. blasint m = 100, n = 100;
  313. blasint lda_src = 100, lda_dst = 100;
  314. char order = 'R';
  315. char trans = 'N';
  316. double alpha[] = {2.0, 3.0};
  317. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  318. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  319. }
  320. /**
  321. * Fortran API specific test
  322. * Test zimatcopy by comparing it against reference
  323. * with the following options:
  324. *
  325. * Column Major
  326. * Copy and conjugate
  327. * alpha_r = 1.0, alpha_i = 2.0
  328. */
  329. CTEST(zimatcopy, rowmajor_conj_col_100_row_100)
  330. {
  331. blasint m = 100, n = 100;
  332. blasint lda_src = 100, lda_dst = 100;
  333. char order = 'R';
  334. char trans = 'R';
  335. double alpha[] = {1.0, 2.0};
  336. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  337. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  338. }
  339. /**
  340. * Fortran API specific test
  341. * Test zimatcopy by comparing it against reference
  342. * with the following options:
  343. *
  344. * Column Major
  345. * Transposition and conjugate
  346. * alpha_r = 2.0, alpha_i = 1.0
  347. */
  348. CTEST(zimatcopy, rowmajor_conjtrans_col_100_row_100)
  349. {
  350. blasint m = 100, n = 100;
  351. blasint lda_src = 100, lda_dst = 100;
  352. char order = 'R';
  353. char trans = 'C';
  354. double alpha[] = {2.0, 1.0};
  355. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  356. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  357. }
  358. /**
  359. * Fortran API specific test
  360. * Test zimatcopy by comparing it against reference
  361. * with the following options:
  362. *
  363. * Row Major
  364. * Copy only
  365. * Rectangular matrix
  366. * alpha_r = 2.0, alpha_i = 1.0
  367. */
  368. CTEST(zimatcopy, rowmajor_notrans_col_50_row_100)
  369. {
  370. blasint m = 100, n = 50;
  371. blasint lda_src = 50, lda_dst = 50;
  372. char order = 'R';
  373. char trans = 'N';
  374. double alpha[] = {2.0, 1.0};
  375. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  376. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  377. }
  378. /**
  379. * Fortran API specific test
  380. * Test zimatcopy by comparing it against reference
  381. * with the following options:
  382. *
  383. * Row Major
  384. * Transposition
  385. * Rectangular matrix
  386. * alpha_r = 1.0, alpha_i = 2.0
  387. */
  388. CTEST(zimatcopy, rowmajor_trans_col_50_row_100)
  389. {
  390. blasint m = 100, n = 50;
  391. blasint lda_src = 50, lda_dst = 100;
  392. char order = 'R';
  393. char trans = 'T';
  394. double alpha[] = {1.0, 2.0};
  395. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  396. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  397. }
  398. /**
  399. * Fortran API specific test
  400. * Test zimatcopy by comparing it against reference
  401. * with the following options:
  402. *
  403. * Row Major
  404. * Copy and conjugate
  405. * alpha_r = 1.5, alpha_i = -1.0
  406. */
  407. CTEST(zimatcopy, rowmajor_conj_col_50_row_100)
  408. {
  409. blasint m = 100, n = 50;
  410. blasint lda_src = 50, lda_dst = 50;
  411. char order = 'R';
  412. char trans = 'R';
  413. double alpha[] = {1.5, -1.0};
  414. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  415. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  416. }
  417. /**
  418. * Fortran API specific test
  419. * Test zimatcopy by comparing it against reference
  420. * with the following options:
  421. *
  422. * Row Major
  423. * Transposition and conjugate
  424. * alpha_r = 1.0, alpha_i = 2.0
  425. */
  426. CTEST(zimatcopy, rowmajor_conjtrans_col_50_row_100)
  427. {
  428. blasint m = 100, n = 50;
  429. blasint lda_src = 50, lda_dst = 100;
  430. char order = 'R';
  431. char trans = 'C';
  432. double alpha[] = {1.0, 2.0};
  433. double norm = check_zimatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  434. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  435. }
  436. /**
  437. * C API specific test
  438. * Test zimatcopy by comparing it against reference
  439. * with the following options:
  440. *
  441. * Column Major
  442. * Transposition
  443. * Square matrix
  444. * alpha_r = 3.0, alpha_i = 2.0
  445. */
  446. CTEST(zimatcopy, c_api_colmajor_trans_col_100_row_100)
  447. {
  448. blasint m = 100, n = 100;
  449. blasint lda_src = 100, lda_dst = 100;
  450. char order = 'C';
  451. char trans = 'T';
  452. double alpha[] = {3.0, 2.0};
  453. double norm = check_zimatcopy('C', order, trans, m, n, alpha, lda_src, lda_dst);
  454. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  455. }
  456. /**
  457. * C API specific test
  458. * Test zimatcopy by comparing it against reference
  459. * with the following options:
  460. *
  461. * Column Major
  462. * Copy only
  463. * Square matrix
  464. * alpha_r = 3.0, alpha_i = 1.5
  465. */
  466. CTEST(zimatcopy, c_api_colmajor_notrans_col_100_row_100)
  467. {
  468. blasint m = 100, n = 100;
  469. blasint lda_src = 100, lda_dst = 100;
  470. char order = 'C';
  471. char trans = 'N';
  472. double alpha[] = {3.0, 1.5};
  473. double norm = check_zimatcopy('C', order, trans, m, n, alpha, lda_src, lda_dst);
  474. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  475. }
  476. /**
  477. * C API specific test
  478. * Test zimatcopy by comparing it against reference
  479. * with the following options:
  480. *
  481. * Row Major
  482. * Transposition
  483. * Square matrix
  484. * alpha_r = 3.0, alpha_i = 1.0
  485. */
  486. CTEST(zimatcopy, c_api_rowmajor_trans_col_100_row_100)
  487. {
  488. blasint m = 100, n = 100;
  489. blasint lda_src = 100, lda_dst = 100;
  490. char order = 'R';
  491. char trans = 'T';
  492. double alpha[] = {3.0, 1.0};
  493. double norm = check_zimatcopy('C', order, trans, m, n, alpha, lda_src, lda_dst);
  494. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  495. }
  496. /**
  497. * C API specific test
  498. * Test zimatcopy by comparing it against reference
  499. * with the following options:
  500. *
  501. * Column Major
  502. * Copy and conjugate
  503. * alpha_r = 1.0, alpha_i = 2.0
  504. */
  505. CTEST(zimatcopy, c_api_colmajor_conj_col_100_row_100)
  506. {
  507. blasint m = 100, n = 100;
  508. blasint lda_src = 100, lda_dst = 100;
  509. char order = 'C';
  510. char trans = 'R';
  511. double alpha[] = {1.0, 2.0};
  512. double norm = check_zimatcopy('C', order, trans, m, n, alpha, lda_src, lda_dst);
  513. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  514. }
  515. /**
  516. * C API specific test
  517. * Test zimatcopy by comparing it against reference
  518. * with the following options:
  519. *
  520. * Column Major
  521. * Transposition and conjugate
  522. * alpha_r = 2.0, alpha_i = 1.0
  523. */
  524. CTEST(zimatcopy, c_api_colmajor_conjtrans_col_100_row_100)
  525. {
  526. blasint m = 100, n = 100;
  527. blasint lda_src = 100, lda_dst = 100;
  528. char order = 'C';
  529. char trans = 'C';
  530. double alpha[] = {2.0, 1.0};
  531. double norm = check_zimatcopy('C', order, trans, m, n, alpha, lda_src, lda_dst);
  532. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  533. }
  534. /**
  535. * C API specific test
  536. * Test zimatcopy by comparing it against reference
  537. * with the following options:
  538. *
  539. * Row Major
  540. * Copy only
  541. * Square matrix
  542. * alpha_r = 1.0, alpha_i = 1.0
  543. */
  544. CTEST(zimatcopy, c_api_rowmajor_notrans_col_100_row_100)
  545. {
  546. blasint m = 100, n = 100;
  547. blasint lda_src = 100, lda_dst = 100;
  548. char order = 'R';
  549. char trans = 'N';
  550. double alpha[] = {1.0, 1.0};
  551. double norm = check_zimatcopy('C', order, trans, m, n, alpha, lda_src, lda_dst);
  552. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  553. }
  554. /**
  555. * C API specific test
  556. * Test zimatcopy by comparing it against reference
  557. * with the following options:
  558. *
  559. * Row Major
  560. * Copy and conjugate
  561. * alpha_r = 1.5, alpha_i = -1.0
  562. */
  563. CTEST(zimatcopy, c_api_rowmajor_conj_col_100_row_100)
  564. {
  565. blasint m = 100, n = 100;
  566. blasint lda_src = 100, lda_dst = 100;
  567. char order = 'R';
  568. char trans = 'R';
  569. double alpha[] = {1.5, -1.0};
  570. double norm = check_zimatcopy('C', order, trans, m, n, alpha, lda_src, lda_dst);
  571. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  572. }
  573. /**
  574. * C API specific test
  575. * Test zimatcopy by comparing it against reference
  576. * with the following options:
  577. *
  578. * Row Major
  579. * Transposition and conjugate
  580. * alpha_r = 1.0, alpha_i = 2.0
  581. */
  582. CTEST(zimatcopy, c_api_rowmajor_conjtrans_col_100_row_100)
  583. {
  584. blasint m = 100, n = 100;
  585. blasint lda_src = 100, lda_dst = 100;
  586. char order = 'R';
  587. char trans = 'C';
  588. double alpha[] = {1.0, 2.0};
  589. double norm = check_zimatcopy('C', order, trans, m, n, alpha, lda_src, lda_dst);
  590. ASSERT_DBL_NEAR_TOL(0.0, norm, DOUBLE_EPS);
  591. }
  592. /**
  593. * Test error function for an invalid param order.
  594. * Must be column (C) or row major (R).
  595. */
  596. CTEST(zimatcopy, xerbla_invalid_order)
  597. {
  598. blasint m = 100, n = 100;
  599. blasint lda_src = 100, lda_dst = 100;
  600. char order = 'O';
  601. char trans = 'T';
  602. int expected_info = 1;
  603. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  604. ASSERT_EQUAL(TRUE, passed);
  605. }
  606. /**
  607. * Test error function for an invalid param trans.
  608. * Must be trans (T/C) or no-trans (N/R).
  609. */
  610. CTEST(zimatcopy, xerbla_invalid_trans)
  611. {
  612. blasint m = 100, n = 100;
  613. blasint lda_src = 100, lda_dst = 100;
  614. char order = 'C';
  615. char trans = 'O';
  616. int expected_info = 2;
  617. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  618. ASSERT_EQUAL(TRUE, passed);
  619. }
  620. /**
  621. * Test error function for an invalid param lda_src.
  622. * If matrices are stored using row major layout,
  623. * lda_src must be at least n.
  624. */
  625. CTEST(zimatcopy, xerbla_rowmajor_invalid_lda)
  626. {
  627. blasint m = 50, n = 100;
  628. blasint lda_src = 50, lda_dst = 100;
  629. char order = 'R';
  630. char trans = 'T';
  631. int expected_info = 7;
  632. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  633. ASSERT_EQUAL(TRUE, passed);
  634. }
  635. /**
  636. * Test error function for an invalid param lda_src.
  637. * If matrices are stored using column major layout,
  638. * lda_src must be at least m.
  639. */
  640. CTEST(zimatcopy, xerbla_colmajor_invalid_lda)
  641. {
  642. blasint m = 100, n = 50;
  643. blasint lda_src = 50, lda_dst = 100;
  644. char order = 'C';
  645. char trans = 'T';
  646. int expected_info = 7;
  647. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  648. ASSERT_EQUAL(TRUE, passed);
  649. }
  650. /**
  651. * Test error function for an invalid param lda_dst.
  652. * If matrices are stored using row major layout and
  653. * there is no transposition, lda_dst must be at least n.
  654. */
  655. CTEST(zimatcopy, xerbla_rowmajor_notrans_invalid_ldb)
  656. {
  657. blasint m = 50, n = 100;
  658. blasint lda_src = 100, lda_dst = 50;
  659. char order = 'R';
  660. char trans = 'N';
  661. int expected_info = 9;
  662. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  663. ASSERT_EQUAL(TRUE, passed);
  664. }
  665. /**
  666. * Test error function for an invalid param lda_dst.
  667. * If matrices are stored using row major layout and
  668. * there is transposition, lda_dst must be at least m.
  669. */
  670. CTEST(zimatcopy, xerbla_rowmajor_trans_invalid_ldb)
  671. {
  672. blasint m = 100, n = 50;
  673. blasint lda_src = 100, lda_dst = 50;
  674. char order = 'R';
  675. char trans = 'T';
  676. int expected_info = 9;
  677. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  678. ASSERT_EQUAL(TRUE, passed);
  679. }
  680. /**
  681. * Test error function for an invalid param lda_dst.
  682. * If matrices are stored using column major layout and
  683. * there is no transposition, lda_dst must be at least m.
  684. */
  685. CTEST(zimatcopy, xerbla_colmajor_notrans_invalid_ldb)
  686. {
  687. blasint m = 100, n = 50;
  688. blasint lda_src = 100, lda_dst = 50;
  689. char order = 'C';
  690. char trans = 'N';
  691. int expected_info = 9;
  692. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  693. ASSERT_EQUAL(TRUE, passed);
  694. }
  695. /**
  696. * Test error function for an invalid param lda_dst.
  697. * If matrices are stored using column major layout and
  698. * there is transposition, lda_dst must be at least n.
  699. */
  700. CTEST(zimatcopy, xerbla_colmajor_trans_invalid_ldb)
  701. {
  702. blasint m = 50, n = 100;
  703. blasint lda_src = 100, lda_dst = 50;
  704. char order = 'C';
  705. char trans = 'T';
  706. int expected_info = 9;
  707. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  708. ASSERT_EQUAL(TRUE, passed);
  709. }
  710. #endif