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_dimatcopy.c 24 kB

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