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

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