mat_mul_real.cpp 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927
  1. // Copyright 2015 Conrad Sanderson (http://conradsanderson.id.au)
  2. // Copyright 2015 National ICT Australia (NICTA)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // ------------------------------------------------------------------------
  15. #include <armadillo>
  16. #include "catch.hpp"
  17. using namespace arma;
  18. TEST_CASE("mat_mul_real_1")
  19. {
  20. mat A =
  21. "\
  22. 0.061198 0.201990 0.019678 -0.493936 -0.126745 0.051408;\
  23. 0.437242 0.058956 -0.149362 -0.045465 0.296153 0.035437;\
  24. -0.492474 -0.031309 0.314156 0.419733 0.068317 -0.454499;\
  25. 0.336352 0.411541 0.458476 -0.393139 -0.135040 0.373833;\
  26. 0.239585 -0.428913 -0.406953 -0.291020 -0.353768 0.258704;\
  27. ";
  28. mat A00 = A( 0,0, size(0,0) );
  29. mat A11 = A( 0,0, size(1,1) );
  30. mat A22 = A( 0,0, size(2,2) );
  31. mat A33 = A( 0,0, size(3,3) );
  32. mat A44 = A( 0,0, size(4,4) );
  33. mat A55 = A( 0,0, size(5,5) );
  34. mat B = fliplr(A);
  35. mat B00 = B( 0,0, size(0,0) );
  36. mat B11 = B( 0,0, size(1,1) );
  37. mat B22 = B( 0,0, size(2,2) );
  38. mat B33 = B( 0,0, size(3,3) );
  39. mat B44 = B( 0,0, size(4,4) );
  40. mat B55 = B( 0,0, size(5,5) );
  41. mat A00_times_B00(0,0);
  42. mat A11_times_B11 =
  43. "\
  44. 0.003146066784;\
  45. ";
  46. mat A22_times_B22 =
  47. "\
  48. 0.010304 0.052063;\
  49. 0.024567 -0.037958;\
  50. ";
  51. mat A33_times_B33 =
  52. "\
  53. 0.0013604 0.0534077 -0.0311519;\
  54. 0.0924518 -0.0481622 -0.2813422;\
  55. -0.1692102 0.0746086 0.3765357;\
  56. ";
  57. mat A44_times_B44 =
  58. "\
  59. -0.183289 0.120109 0.163034 -0.249241;\
  60. 0.075456 -0.042023 -0.263468 -0.067969;\
  61. -0.012300 0.017928 0.211522 0.286117;\
  62. -0.323470 0.163659 0.162149 -0.091062;\
  63. ";
  64. mat A55_times_B55 =
  65. "\
  66. -0.2160787 0.1649472 0.1999190 -0.1976620 -0.1252585;\
  67. 0.1520715 -0.1467921 -0.3496545 -0.1884897 -0.0492639;\
  68. 0.0053737 -0.0062406 0.1916407 0.2583152 0.0322787;\
  69. -0.3584056 0.2114322 0.2014480 -0.0361067 -0.0260243;\
  70. -0.0182371 -0.0207407 -0.0522859 -0.0485276 0.0678171;\
  71. ";
  72. REQUIRE( accu(abs( (A00*B00) - A00_times_B00 )) == Approx(0.0) );
  73. REQUIRE( accu(abs( (A11*B11) - A11_times_B11 )) == Approx(0.0) );
  74. REQUIRE( accu(abs( (A22*B22) - A22_times_B22 )) == Approx(0.0) );
  75. REQUIRE( accu(abs( (A33*B33) - A33_times_B33 )) == Approx(0.0) );
  76. REQUIRE( accu(abs( (A44*B44) - A44_times_B44 )) == Approx(0.0) );
  77. REQUIRE( accu(abs( (A55*B55) - A55_times_B55 )) == Approx(0.0) );
  78. mat X;
  79. REQUIRE_THROWS( X = A22*B44 );
  80. }
  81. TEST_CASE("mat_mul_real_2")
  82. {
  83. mat A =
  84. "\
  85. 0.061198 0.201990 0.019678 -0.493936 -0.126745 0.051408;\
  86. 0.437242 0.058956 -0.149362 -0.045465 0.296153 0.035437;\
  87. -0.492474 -0.031309 0.314156 0.419733 0.068317 -0.454499;\
  88. 0.336352 0.411541 0.458476 -0.393139 -0.135040 0.373833;\
  89. 0.239585 -0.428913 -0.406953 -0.291020 -0.353768 0.258704;\
  90. ";
  91. mat A00 = A( 0,0, size(0,0) );
  92. mat A11 = A( 0,0, size(1,1) );
  93. mat A22 = A( 0,0, size(2,2) );
  94. mat A33 = A( 0,0, size(3,3) );
  95. mat A44 = A( 0,0, size(4,4) );
  96. mat A55 = A( 0,0, size(5,5) );
  97. mat B = fliplr(A);
  98. mat B00 = B( 0,0, size(0,0) );
  99. mat B11 = B( 0,0, size(1,1) );
  100. mat B22 = B( 0,0, size(2,2) );
  101. mat B33 = B( 0,0, size(3,3) );
  102. mat B44 = B( 0,0, size(4,4) );
  103. mat B55 = B( 0,0, size(5,5) );
  104. colvec q0( uword(0) );
  105. colvec q1 = B11.col(0);
  106. colvec q2 = B22.col(0);
  107. colvec q3 = B33.col(0);
  108. colvec q4 = B44.col(0);
  109. colvec q5 = B55.col(0);
  110. rowvec r0( uword(0) );
  111. rowvec r1 = B11.row(0);
  112. rowvec r2 = B22.row(0);
  113. rowvec r3 = B33.row(0);
  114. rowvec r4 = B44.row(0);
  115. rowvec r5 = B55.row(0);
  116. mat A00_times_q0(0,1);
  117. mat A11_times_q1 =
  118. "\
  119. 0.0031461;\
  120. ";
  121. mat A22_times_q2 =
  122. "\
  123. 0.010304;\
  124. 0.024567;\
  125. ";
  126. mat A33_times_q3 =
  127. "\
  128. 0.0013604;\
  129. 0.0924518;\
  130. -0.1692102;\
  131. ";
  132. mat A44_times_q4 =
  133. "\
  134. -0.183289;\
  135. 0.075456;\
  136. -0.012300;\
  137. -0.323470;\
  138. ";
  139. mat A55_times_q5 =
  140. "\
  141. -0.2160787;\
  142. 0.1520715;\
  143. 0.0053737;\
  144. -0.3584056;\
  145. -0.0182371;\
  146. ";
  147. mat r0_times_A00(1,0);
  148. mat r1_times_A11 =
  149. "\
  150. 0.0031461;\
  151. ";
  152. mat r2_times_A22 =
  153. "\
  154. -0.0522722 0.0029115;\
  155. ";
  156. mat r3_times_A33 =
  157. "\
  158. 0.190978 0.018376 -0.135230;\
  159. ";
  160. mat r4_times_A44 =
  161. "\
  162. 0.197597 0.026474 -0.126209 -0.234687;\
  163. ";
  164. mat r5_times_A55 =
  165. "\
  166. 0.245991 -0.060162 -0.208409 -0.293470 -0.151911;\
  167. ";
  168. REQUIRE( accu(abs( (A00*q0) - A00_times_q0 )) == Approx(0.0) );
  169. REQUIRE( accu(abs( (A11*q1) - A11_times_q1 )) == Approx(0.0) );
  170. REQUIRE( accu(abs( (A22*q2) - A22_times_q2 )) == Approx(0.0) );
  171. REQUIRE( accu(abs( (A33*q3) - A33_times_q3 )) == Approx(0.0) );
  172. REQUIRE( accu(abs( (A44*q4) - A44_times_q4 )) == Approx(0.0) );
  173. REQUIRE( accu(abs( (A55*q5) - A55_times_q5 )) == Approx(0.0) );
  174. REQUIRE( accu(abs( (r0*A00) - r0_times_A00 )) == Approx(0.0) );
  175. REQUIRE( accu(abs( (r1*A11) - r1_times_A11 )) == Approx(0.0) );
  176. REQUIRE( accu(abs( (r2*A22) - r2_times_A22 )) == Approx(0.0) );
  177. REQUIRE( accu(abs( (r3*A33) - r3_times_A33 )) == Approx(0.0) );
  178. REQUIRE( accu(abs( (r4*A44) - r4_times_A44 )) == Approx(0.0) );
  179. REQUIRE( accu(abs( (r5*A55) - r5_times_A55 )) == Approx(0.0) );
  180. mat X;
  181. REQUIRE_THROWS( X = A22*q4 );
  182. }
  183. TEST_CASE("mat_mul_real_3")
  184. {
  185. mat A =
  186. "\
  187. 0.061198 0.201990 0.019678 -0.493936 -0.126745 0.051408;\
  188. 0.437242 0.058956 -0.149362 -0.045465 0.296153 0.035437;\
  189. -0.492474 -0.031309 0.314156 0.419733 0.068317 -0.454499;\
  190. 0.336352 0.411541 0.458476 -0.393139 -0.135040 0.373833;\
  191. 0.239585 -0.428913 -0.406953 -0.291020 -0.353768 0.258704;\
  192. ";
  193. mat A00 = A( 0,0, size(0,0) );
  194. mat A11 = A( 0,0, size(1,1) );
  195. mat A22 = A( 0,0, size(2,2) );
  196. mat A33 = A( 0,0, size(3,3) );
  197. mat A44 = A( 0,0, size(4,4) );
  198. mat A55 = A( 0,0, size(5,5) );
  199. mat B = fliplr(A);
  200. mat B00 = B( 0,0, size(0,0) );
  201. mat B11 = B( 0,0, size(1,1) );
  202. mat B22 = B( 0,0, size(2,2) );
  203. mat B33 = B( 0,0, size(3,3) );
  204. mat B44 = B( 0,0, size(4,4) );
  205. mat B55 = B( 0,0, size(5,5) );
  206. colvec q0( uword(0) );
  207. colvec q1 = B11.col(0);
  208. colvec q2 = B22.col(0);
  209. colvec q3 = B33.col(0);
  210. colvec q4 = B44.col(0);
  211. colvec q5 = B55.col(0);
  212. rowvec r0( uword(0) );
  213. rowvec r1 = B11.row(0);
  214. rowvec r2 = B22.row(0);
  215. rowvec r3 = B33.row(0);
  216. rowvec r4 = B44.row(0);
  217. rowvec r5 = B55.row(0);
  218. mat q0_t_times_A00(1,0);
  219. mat q1_t_times_A11 =
  220. "\
  221. 0.0031461;\
  222. ";
  223. mat q2_t_times_A22 =
  224. "\
  225. 0.018641 0.012473;\
  226. ";
  227. mat q3_t_times_A33 =
  228. "\
  229. 0.242470 0.026703 -0.147065;\
  230. ";
  231. mat q4_t_times_A44 =
  232. "\
  233. 0.368209 0.180551 0.024329 -0.364740;\
  234. ";
  235. mat q5_t_times_A55 =
  236. "\
  237. 0.430191 0.069589 -0.080952 -0.440028 -0.169075;\
  238. ";
  239. mat A00_times_r0_t(0,1);
  240. mat A11_times_r1_t =
  241. "\
  242. 0.0031461;\
  243. ";
  244. mat A22_times_r2_t =
  245. "\
  246. -0.022455;\
  247. 0.015005;\
  248. ";
  249. mat A33_times_r3_t =
  250. "\
  251. -0.032175;\
  252. 0.088781;\
  253. -0.176522;\
  254. ";
  255. mat A44_times_r4_t =
  256. "\
  257. -0.041895;\
  258. 0.087886;\
  259. -0.168262;\
  260. -0.269064;\
  261. ";
  262. mat A55_times_r5_t =
  263. "\
  264. -0.067496;\
  265. 0.147706;\
  266. -0.154463;\
  267. -0.296340;\
  268. 0.190504;\
  269. ";
  270. REQUIRE( accu(abs( (q0.t()*A00) - q0_t_times_A00 )) == Approx(0.0) );
  271. REQUIRE( accu(abs( (q1.t()*A11) - q1_t_times_A11 )) == Approx(0.0) );
  272. REQUIRE( accu(abs( (q2.t()*A22) - q2_t_times_A22 )) == Approx(0.0) );
  273. REQUIRE( accu(abs( (q3.t()*A33) - q3_t_times_A33 )) == Approx(0.0) );
  274. REQUIRE( accu(abs( (q4.t()*A44) - q4_t_times_A44 )) == Approx(0.0) );
  275. REQUIRE( accu(abs( (q5.t()*A55) - q5_t_times_A55 )) == Approx(0.0) );
  276. REQUIRE( accu(abs( (A00*r0.t()) - A00_times_r0_t )) == Approx(0.0) );
  277. REQUIRE( accu(abs( (A11*r1.t()) - A11_times_r1_t )) == Approx(0.0) );
  278. REQUIRE( accu(abs( (A22*r2.t()) - A22_times_r2_t )) == Approx(0.0) );
  279. REQUIRE( accu(abs( (A33*r3.t()) - A33_times_r3_t )) == Approx(0.0) );
  280. REQUIRE( accu(abs( (A44*r4.t()) - A44_times_r4_t )) == Approx(0.0) );
  281. REQUIRE( accu(abs( (A55*r5.t()) - A55_times_r5_t )) == Approx(0.0) );
  282. REQUIRE( accu(abs( (q0.t().eval()*A00) - q0_t_times_A00 )) == Approx(0.0) );
  283. REQUIRE( accu(abs( (q1.t().eval()*A11) - q1_t_times_A11 )) == Approx(0.0) );
  284. REQUIRE( accu(abs( (q2.t().eval()*A22) - q2_t_times_A22 )) == Approx(0.0) );
  285. REQUIRE( accu(abs( (q3.t().eval()*A33) - q3_t_times_A33 )) == Approx(0.0) );
  286. REQUIRE( accu(abs( (q4.t().eval()*A44) - q4_t_times_A44 )) == Approx(0.0) );
  287. REQUIRE( accu(abs( (q5.t().eval()*A55) - q5_t_times_A55 )) == Approx(0.0) );
  288. REQUIRE( accu(abs( (A00*r0.t().eval()) - A00_times_r0_t )) == Approx(0.0) );
  289. REQUIRE( accu(abs( (A11*r1.t().eval()) - A11_times_r1_t )) == Approx(0.0) );
  290. REQUIRE( accu(abs( (A22*r2.t().eval()) - A22_times_r2_t )) == Approx(0.0) );
  291. REQUIRE( accu(abs( (A33*r3.t().eval()) - A33_times_r3_t )) == Approx(0.0) );
  292. REQUIRE( accu(abs( (A44*r4.t().eval()) - A44_times_r4_t )) == Approx(0.0) );
  293. REQUIRE( accu(abs( (A55*r5.t().eval()) - A55_times_r5_t )) == Approx(0.0) );
  294. mat X;
  295. REQUIRE_THROWS( X = A22*r4.t() );
  296. }
  297. TEST_CASE("mat_mul_real_4")
  298. {
  299. mat A =
  300. "\
  301. 0.061198 0.201990 0.019678 -0.493936 -0.126745 0.051408;\
  302. 0.437242 0.058956 -0.149362 -0.045465 0.296153 0.035437;\
  303. -0.492474 -0.031309 0.314156 0.419733 0.068317 -0.454499;\
  304. 0.336352 0.411541 0.458476 -0.393139 -0.135040 0.373833;\
  305. 0.239585 -0.428913 -0.406953 -0.291020 -0.353768 0.258704;\
  306. ";
  307. mat A44 = A( 0,0, size(4,4) );
  308. mat B = fliplr(A);
  309. mat B44 = B( 0,0, size(4,4) );
  310. //
  311. mat A44_times_B44 =
  312. "\
  313. -0.183289 0.120109 0.163034 -0.249241;\
  314. 0.075456 -0.042023 -0.263468 -0.067969;\
  315. -0.012300 0.017928 0.211522 0.286117;\
  316. -0.323470 0.163659 0.162149 -0.091062;\
  317. ";
  318. mat A44_t_times_B44 =
  319. "\
  320. 0.368209 0.042669 -0.389048 -0.064607;\
  321. 0.180551 -0.065855 -0.277385 0.174015;\
  322. 0.024329 -0.087178 -0.051312 0.331590;\
  323. -0.364740 0.130904 0.576774 -0.051312;\
  324. ";
  325. mat A44_times_B44_t =
  326. "\
  327. -0.041895 0.134869 -0.160929 -0.238593;\
  328. 0.087886 0.046536 -0.271674 0.193369;\
  329. -0.168262 -0.103699 0.485413 -0.110945;\
  330. -0.269064 0.171674 -0.055826 -0.290325;\
  331. ";
  332. mat A44_t_times_B44_t =
  333. "\
  334. 0.1975972 0.1038113 -0.0989840 0.3116527;\
  335. 0.0264745 -0.0354272 0.0283701 0.2685396;\
  336. -0.1262086 -0.1262987 0.2567470 0.1142194;\
  337. -0.2346872 0.0086687 0.2740562 -0.5237682;\
  338. ";
  339. //
  340. mat two_times_A44_times_B44 =
  341. "\
  342. -0.366578 0.240218 0.326067 -0.498482;\
  343. 0.150911 -0.084045 -0.526936 -0.135939;\
  344. -0.024600 0.035856 0.423045 0.572234;\
  345. -0.646941 0.327319 0.324297 -0.182123;\
  346. ";
  347. mat two_times_A44_t_times_B44 =
  348. "\
  349. 0.736418 0.085337 -0.778096 -0.129215;\
  350. 0.361101 -0.131709 -0.554770 0.348029;\
  351. 0.048657 -0.174357 -0.102624 0.663181;\
  352. -0.729480 0.261807 1.153548 -0.102624;\
  353. ";
  354. mat two_times_A44_times_B44_t =
  355. "\
  356. -0.083789 0.269738 -0.321857 -0.477186;\
  357. 0.175772 0.093072 -0.543347 0.386739;\
  358. -0.336525 -0.207399 0.970827 -0.221889;\
  359. -0.538127 0.343348 -0.111652 -0.580649;\
  360. ";
  361. mat two_times_A44_t_times_B44_t =
  362. "\
  363. 0.395194 0.207623 -0.197968 0.623305;\
  364. 0.052949 -0.070854 0.056740 0.537079;\
  365. -0.252417 -0.252597 0.513494 0.228439;\
  366. -0.469374 0.017337 0.548112 -1.047536;\
  367. ";
  368. //
  369. mat A44_times_two_times_B44 =
  370. "\
  371. -0.366578 0.240218 0.326067 -0.498482;\
  372. 0.150911 -0.084045 -0.526936 -0.135939;\
  373. -0.024600 0.035856 0.423045 0.572234;\
  374. -0.646941 0.327319 0.324297 -0.182123;\
  375. ";
  376. mat A44_t_times_two_times_B44 =
  377. "\
  378. 0.736418 0.085337 -0.778096 -0.129215;\
  379. 0.361101 -0.131709 -0.554770 0.348029;\
  380. 0.048657 -0.174357 -0.102624 0.663181;\
  381. -0.729480 0.261807 1.153548 -0.102624;\
  382. ";
  383. mat A44_times_two_times_B44_t =
  384. "\
  385. -0.083789 0.269738 -0.321857 -0.477186;\
  386. 0.175772 0.093072 -0.543347 0.386739;\
  387. -0.336525 -0.207399 0.970827 -0.221889;\
  388. -0.538127 0.343348 -0.111652 -0.580649;\
  389. ";
  390. mat A44_t_times_two_times_B44_t =
  391. "\
  392. 0.395194 0.207623 -0.197968 0.623305;\
  393. 0.052949 -0.070854 0.056740 0.537079;\
  394. -0.252417 -0.252597 0.513494 0.228439;\
  395. -0.469374 0.017337 0.548112 -1.047536;\
  396. ";
  397. //
  398. mat two_times_A44_times_two_times_B44 =
  399. "\
  400. -0.733157 0.480435 0.652135 -0.996965;\
  401. 0.301822 -0.168090 -1.053872 -0.271877;\
  402. -0.049201 0.071711 0.846089 1.144468;\
  403. -1.293881 0.654637 0.648595 -0.364247;\
  404. ";
  405. mat two_times_A44_t_times_two_times_B44 =
  406. "\
  407. 1.472836 0.170675 -1.556191 -0.258430;\
  408. 0.722203 -0.263419 -1.109539 0.696059;\
  409. 0.097314 -0.348714 -0.205248 1.326362;\
  410. -1.458960 0.523615 2.307096 -0.205248;\
  411. ";
  412. mat two_times_A44_times_two_times_B44_t =
  413. "\
  414. -0.167578003928 0.539476906232 -0.643714124056 -0.95437155377;\
  415. 0.351543868312 0.186144110728 -1.086694470368 0.77347794529;\
  416. -0.673049184916 -0.414797273204 1.941653137076 -0.44377813703;\
  417. -1.076254284828 0.686695294300 -0.223303479708 -1.16129844700;\
  418. ";
  419. mat two_times_A44_t_times_two_times_B44_t =
  420. "\
  421. 0.790389 0.415245 -0.395936 1.246611;\
  422. 0.105898 -0.141709 0.113480 1.074158;\
  423. -0.504834 -0.505195 1.026988 0.456878;\
  424. -0.938749 0.034675 1.096225 -2.095073;\
  425. ";
  426. //
  427. REQUIRE( accu(abs( A44 * B44 - A44_times_B44 )) == Approx(0.0) );
  428. REQUIRE( accu(abs( A44.t() * B44 - A44_t_times_B44 )) == Approx(0.0) );
  429. REQUIRE( accu(abs( A44 * B44.t() - A44_times_B44_t )) == Approx(0.0) );
  430. REQUIRE( accu(abs( A44.t() * B44.t() - A44_t_times_B44_t )) == Approx(0.0) );
  431. REQUIRE( accu(abs( 2*A44 * B44 - two_times_A44_times_B44 )) == Approx(0.0) );
  432. REQUIRE( accu(abs( 2*A44.t() * B44 - two_times_A44_t_times_B44 )) == Approx(0.0) );
  433. REQUIRE( accu(abs( 2*A44 * B44.t() - two_times_A44_times_B44_t )) == Approx(0.0) );
  434. REQUIRE( accu(abs( 2*A44.t() * B44.t() - two_times_A44_t_times_B44_t )) == Approx(0.0) );
  435. REQUIRE( accu(abs( A44 * 2 * B44 - A44_times_two_times_B44 )) == Approx(0.0) );
  436. REQUIRE( accu(abs( A44.t() * 2 * B44 - A44_t_times_two_times_B44 )) == Approx(0.0) );
  437. REQUIRE( accu(abs( A44 * 2 * B44.t() - A44_times_two_times_B44_t )) == Approx(0.0) );
  438. REQUIRE( accu(abs( A44.t() * 2 * B44.t() - A44_t_times_two_times_B44_t )) == Approx(0.0) );
  439. REQUIRE( accu(abs( 2*A44 * 2*B44 - two_times_A44_times_two_times_B44 )) == Approx(0.0) );
  440. REQUIRE( accu(abs( 2*A44.t() * 2*B44 - two_times_A44_t_times_two_times_B44 )) == Approx(0.0) );
  441. REQUIRE( accu(abs( 2*A44 * 2*B44.t() - two_times_A44_times_two_times_B44_t )) == Approx(0.0) );
  442. REQUIRE( accu(abs( 2*A44.t() * 2*B44.t() - two_times_A44_t_times_two_times_B44_t )) == Approx(0.0) );
  443. REQUIRE( accu(abs( A44 * B44 - A44_times_B44 )) == Approx(0.0) );
  444. REQUIRE( accu(abs( A44.t().eval() * B44 - A44_t_times_B44 )) == Approx(0.0) );
  445. REQUIRE( accu(abs( A44 * B44.t().eval() - A44_times_B44_t )) == Approx(0.0) );
  446. REQUIRE( accu(abs( A44.t() * B44.t().eval() - A44_t_times_B44_t )) == Approx(0.0) );
  447. REQUIRE( accu(abs( (2*A44).eval() * B44 - two_times_A44_times_B44 )) == Approx(0.0) );
  448. REQUIRE( accu(abs( (2*A44.t()).eval() * B44 - two_times_A44_t_times_B44 )) == Approx(0.0) );
  449. REQUIRE( accu(abs( (2*A44).eval() * B44.t().eval() - two_times_A44_times_B44_t )) == Approx(0.0) );
  450. REQUIRE( accu(abs( (2*A44.t()).eval() * B44.t().eval() - two_times_A44_t_times_B44_t )) == Approx(0.0) );
  451. REQUIRE( accu(abs( A44 * (2 * B44).eval() - A44_times_two_times_B44 )) == Approx(0.0) );
  452. REQUIRE( accu(abs( A44.t().eval() * (2 * B44).eval() - A44_t_times_two_times_B44 )) == Approx(0.0) );
  453. REQUIRE( accu(abs( A44 * (2 * B44.t()).eval() - A44_times_two_times_B44_t )) == Approx(0.0) );
  454. REQUIRE( accu(abs( A44.t().eval() * (2 * B44.t()).eval() - A44_t_times_two_times_B44_t )) == Approx(0.0) );
  455. REQUIRE( accu(abs( (2*A44).eval() * (2*B44).eval() - two_times_A44_times_two_times_B44 )) == Approx(0.0) );
  456. REQUIRE( accu(abs( (2*A44.t()).eval() * (2*B44).eval() - two_times_A44_t_times_two_times_B44 )) == Approx(0.0) );
  457. REQUIRE( accu(abs( (2*A44).eval() * (2*B44.t()).eval() - two_times_A44_times_two_times_B44_t )) == Approx(0.0) );
  458. REQUIRE( accu(abs( (2*A44.t()).eval() * (2*B44.t()).eval() - two_times_A44_t_times_two_times_B44_t )) == Approx(0.0) );
  459. }
  460. TEST_CASE("mat_mul_real_5")
  461. {
  462. mat A =
  463. "\
  464. 0.061198 0.201990 0.019678 -0.493936 -0.126745 0.051408;\
  465. 0.437242 0.058956 -0.149362 -0.045465 0.296153 0.035437;\
  466. -0.492474 -0.031309 0.314156 0.419733 0.068317 -0.454499;\
  467. 0.336352 0.411541 0.458476 -0.393139 -0.135040 0.373833;\
  468. 0.239585 -0.428913 -0.406953 -0.291020 -0.353768 0.258704;\
  469. ";
  470. mat B = fliplr(A);
  471. mat A55 = A( 0,0, size(5,5) );
  472. mat B55 = B( 0,0, size(5,5) );
  473. mat A55_times_B55 =
  474. "\
  475. -0.2160787 0.1649472 0.1999190 -0.1976620 -0.1252585;\
  476. 0.1520715 -0.1467921 -0.3496545 -0.1884897 -0.0492639;\
  477. 0.0053737 -0.0062406 0.1916407 0.2583152 0.0322787;\
  478. -0.3584056 0.2114322 0.2014480 -0.0361067 -0.0260243;\
  479. -0.0182371 -0.0207407 -0.0522859 -0.0485276 0.0678171;\
  480. ";
  481. mat A55_t_times_B55 =
  482. "\
  483. 0.430191 -0.042089 -0.458772 -0.162107 0.089220;\
  484. 0.069589 0.085881 -0.152563 0.348562 0.398588;\
  485. -0.080952 0.056788 0.067119 0.497201 0.348562;\
  486. -0.440028 0.233857 0.661467 0.067119 -0.152563;\
  487. -0.169075 0.251826 0.233857 0.056788 0.085881;\
  488. ";
  489. mat A55_times_B55_t =
  490. "\
  491. -0.067496 0.127397 -0.156960 -0.290754 0.194019;\
  492. 0.147706 0.063996 -0.280946 0.315249 0.027205;\
  493. -0.154463 -0.099672 0.483274 -0.082829 -0.407868;\
  494. -0.296340 0.163712 -0.051598 -0.345899 0.025909;\
  495. 0.190504 -0.077421 -0.389354 0.028459 0.602316;\
  496. ";
  497. mat A55_t_times_B55_t =
  498. "\
  499. 0.2459910 0.1179363 -0.1064851 0.4102518 -0.2351709;\
  500. -0.0601617 -0.0607142 0.0417989 0.0920243 0.0569989;\
  501. -0.2084090 -0.1502910 0.2694883 -0.0532584 -0.0455262;\
  502. -0.2934704 -0.0084887 0.2831677 -0.6435349 0.0509615;\
  503. -0.1519108 0.0794222 0.0751652 -0.3217347 0.0492501;\
  504. ";
  505. //
  506. mat two_times_A55_times_B55 =
  507. "\
  508. -0.432157 0.329894 0.399838 -0.395324 -0.250517;\
  509. 0.304143 -0.293584 -0.699309 -0.376979 -0.098528;\
  510. 0.010747 -0.012481 0.383281 0.516630 0.064557;\
  511. -0.716811 0.422864 0.402896 -0.072213 -0.052049;\
  512. -0.036474 -0.041481 -0.104572 -0.097055 0.135634;\
  513. ";
  514. mat two_times_A55_t_times_B55 =
  515. "\
  516. 0.860381 -0.084178 -0.917544 -0.324215 0.178440;\
  517. 0.139178 0.171762 -0.305125 0.697124 0.797177;\
  518. -0.161904 0.113577 0.134239 0.994402 0.697124;\
  519. -0.880056 0.467715 1.322933 0.134239 -0.305125;\
  520. -0.338149 0.503651 0.467715 0.113577 0.171762;\
  521. ";
  522. mat two_times_A55_times_B55_t =
  523. "\
  524. -0.134991 0.254794 -0.313921 -0.581507 0.388038;\
  525. 0.295412 0.127992 -0.561892 0.630497 0.054410;\
  526. -0.308926 -0.199343 0.966549 -0.165659 -0.815736;\
  527. -0.592681 0.327425 -0.103196 -0.691798 0.051819;\
  528. 0.381007 -0.154842 -0.778709 0.056917 1.204632;\
  529. ";
  530. mat two_times_A55_t_times_B55_t =
  531. "\
  532. 0.491982 0.235873 -0.212970 0.820504 -0.470342;\
  533. -0.120323 -0.121428 0.083598 0.184049 0.113998;\
  534. -0.416818 -0.300582 0.538977 -0.106517 -0.091052;\
  535. -0.586941 -0.016977 0.566335 -1.287070 0.101923;\
  536. -0.303822 0.158844 0.150330 -0.643469 0.098500;\
  537. ";
  538. //
  539. mat A55_times_two_times_B55 =
  540. "\
  541. -0.432157 0.329894 0.399838 -0.395324 -0.250517;\
  542. 0.304143 -0.293584 -0.699309 -0.376979 -0.098528;\
  543. 0.010747 -0.012481 0.383281 0.516630 0.064557;\
  544. -0.716811 0.422864 0.402896 -0.072213 -0.052049;\
  545. -0.036474 -0.041481 -0.104572 -0.097055 0.135634;\
  546. ";
  547. mat A55_t_times_two_times_B55 =
  548. "\
  549. 0.860381 -0.084178 -0.917544 -0.324215 0.178440;\
  550. 0.139178 0.171762 -0.305125 0.697124 0.797177;\
  551. -0.161904 0.113577 0.134239 0.994402 0.697124;\
  552. -0.880056 0.467715 1.322933 0.134239 -0.305125;\
  553. -0.338149 0.503651 0.467715 0.113577 0.171762;\
  554. ";
  555. mat A55_times_two_times_B55_t =
  556. "\
  557. -0.134991 0.254794 -0.313921 -0.581507 0.388038;\
  558. 0.295412 0.127992 -0.561892 0.630497 0.054410;\
  559. -0.308926 -0.199343 0.966549 -0.165659 -0.815736;\
  560. -0.592681 0.327425 -0.103196 -0.691798 0.051819;\
  561. 0.381007 -0.154842 -0.778709 0.056917 1.204632;\
  562. ";
  563. mat A55_t_times_two_times_B55_t =
  564. "\
  565. 0.491982 0.235873 -0.212970 0.820504 -0.470342;\
  566. -0.120323 -0.121428 0.083598 0.184049 0.113998;\
  567. -0.416818 -0.300582 0.538977 -0.106517 -0.091052;\
  568. -0.586941 -0.016977 0.566335 -1.287070 0.101923;\
  569. -0.303822 0.158844 0.150330 -0.643469 0.098500;\
  570. ";
  571. //
  572. mat two_times_A55_times_two_times_B55 =
  573. "\
  574. -0.864315 0.659789 0.799676 -0.790648 -0.501034;\
  575. 0.608286 -0.587168 -1.398618 -0.753959 -0.197056;\
  576. 0.021495 -0.024962 0.766563 1.033261 0.129115;\
  577. -1.433623 0.845729 0.805792 -0.144427 -0.104097;\
  578. -0.072949 -0.082963 -0.209143 -0.194110 0.271268;\
  579. ";
  580. mat two_times_A55_t_times_two_times_B55 =
  581. "\
  582. 1.720762508480000 -0.168355348408000 -1.835087231712000 -0.648429049028000 0.356879236660000;\
  583. 0.278356531136000 0.343524137236000 -0.610250174464000 1.394248666196000 1.594353519068000;\
  584. -0.323807331272000 0.227153811280000 0.268477507864000 1.988804839396000 1.394248666196000;\
  585. -1.760112014908000 0.935429101824000 2.645866173324000 0.268477507864000 -0.610250174464000;\
  586. -0.676298185096000 1.007302825388000 0.935429101824000 0.227153811280000 0.343524137236000;\
  587. ";
  588. mat two_times_A55_times_two_times_B55_t =
  589. "\
  590. -0.269982894128000 0.509587393352000 -0.627841087236000 -1.163014609956000 0.776076770820000;\
  591. 0.590823646192000 0.255984095800000 -1.123783487476000 1.260994352388000 0.108820335424000;\
  592. -0.617851781596000 -0.398686484996000 1.933097389264000 -0.331317151044000 -1.631472813896000;\
  593. -1.185361203228000 0.654849621340000 -0.206391610268000 -1.383596433568000 0.103637571148000;\
  594. 0.762014443972000 -0.309683987468000 -1.557417410772000 0.113834257136000 2.409263641312000;\
  595. ";
  596. mat two_times_A55_t_times_two_times_B55_t =
  597. "\
  598. 0.9839639038560000 0.4717451991920000 -0.4259405015320001 1.6410071127080001 -0.9406834141800000;\
  599. -0.2406466685920000 -0.2428568083480000 0.1671957402319999 0.3680971398560001 0.2279957477119999;\
  600. -0.8336360417759999 -0.6011639640800001 1.0779532920199999 -0.2130337897080000 -0.1821046293240000;\
  601. -1.1738814343720001 -0.0339548592960000 1.1326709857760002 -2.5741394118360001 0.2038460089720001;\
  602. -0.6076430403880000 0.3176888108440000 0.3006606227560001 -1.2869387091840001 0.1970004839200000;\
  603. ";
  604. //
  605. REQUIRE( accu(abs( A55 * B55 - A55_times_B55 )) == Approx(0.0) );
  606. REQUIRE( accu(abs( A55.t() * B55 - A55_t_times_B55 )) == Approx(0.0) );
  607. REQUIRE( accu(abs( A55 * B55.t() - A55_times_B55_t )) == Approx(0.0) );
  608. REQUIRE( accu(abs( A55.t() * B55.t() - A55_t_times_B55_t )) == Approx(0.0) );
  609. REQUIRE( accu(abs( 2*A55 * B55 - two_times_A55_times_B55 )) == Approx(0.0) );
  610. REQUIRE( accu(abs( 2*A55.t() * B55 - two_times_A55_t_times_B55 )) == Approx(0.0) );
  611. REQUIRE( accu(abs( 2*A55 * B55.t() - two_times_A55_times_B55_t )) == Approx(0.0) );
  612. REQUIRE( accu(abs( 2*A55.t() * B55.t() - two_times_A55_t_times_B55_t )) == Approx(0.0) );
  613. REQUIRE( accu(abs( A55 * 2 * B55 - A55_times_two_times_B55 )) == Approx(0.0) );
  614. REQUIRE( accu(abs( A55.t() * 2 * B55 - A55_t_times_two_times_B55 )) == Approx(0.0) );
  615. REQUIRE( accu(abs( A55 * 2 * B55.t() - A55_times_two_times_B55_t )) == Approx(0.0) );
  616. REQUIRE( accu(abs( A55.t() * 2 * B55.t() - A55_t_times_two_times_B55_t )) == Approx(0.0) );
  617. REQUIRE( accu(abs( 2*A55 * 2*B55 - two_times_A55_times_two_times_B55 )) == Approx(0.0) );
  618. REQUIRE( accu(abs( 2*A55.t() * 2*B55 - two_times_A55_t_times_two_times_B55 )) == Approx(0.0) );
  619. REQUIRE( accu(abs( 2*A55 * 2*B55.t() - two_times_A55_times_two_times_B55_t )) == Approx(0.0) );
  620. REQUIRE( accu(abs( 2*A55.t() * 2*B55.t() - two_times_A55_t_times_two_times_B55_t )) == Approx(0.0) );
  621. //
  622. REQUIRE( accu(abs( A55 * B55 - A55_times_B55 )) == Approx(0.0) );
  623. REQUIRE( accu(abs( A55.t().eval() * B55 - A55_t_times_B55 )) == Approx(0.0) );
  624. REQUIRE( accu(abs( A55 * B55.t().eval() - A55_times_B55_t )) == Approx(0.0) );
  625. REQUIRE( accu(abs( A55.t().eval() * B55.t().eval() - A55_t_times_B55_t )) == Approx(0.0) );
  626. REQUIRE( accu(abs( (2*A55).eval() * B55 - two_times_A55_times_B55 )) == Approx(0.0) );
  627. REQUIRE( accu(abs( (2*A55.t()).eval() * B55 - two_times_A55_t_times_B55 )) == Approx(0.0) );
  628. REQUIRE( accu(abs( (2*A55).eval() * B55.t().eval() - two_times_A55_times_B55_t )) == Approx(0.0) );
  629. REQUIRE( accu(abs( (2*A55.t()).eval() * B55.t().eval() - two_times_A55_t_times_B55_t )) == Approx(0.0) );
  630. REQUIRE( accu(abs( A55 * (2 * B55).eval() - A55_times_two_times_B55 )) == Approx(0.0) );
  631. REQUIRE( accu(abs( A55.t().eval() * (2 * B55).eval() - A55_t_times_two_times_B55 )) == Approx(0.0) );
  632. REQUIRE( accu(abs( A55 * (2 * B55.t()).eval() - A55_times_two_times_B55_t )) == Approx(0.0) );
  633. REQUIRE( accu(abs( A55.t().eval() * (2 * B55.t()).eval() - A55_t_times_two_times_B55_t )) == Approx(0.0) );
  634. REQUIRE( accu(abs( (2*A55).eval() * (2*B55).eval() - two_times_A55_times_two_times_B55 )) == Approx(0.0) );
  635. REQUIRE( accu(abs( (2*A55.t()).eval() * (2*B55).eval() - two_times_A55_t_times_two_times_B55 )) == Approx(0.0) );
  636. REQUIRE( accu(abs( (2*A55).eval() * (2*B55.t()).eval() - two_times_A55_times_two_times_B55_t )) == Approx(0.0) );
  637. REQUIRE( accu(abs( (2*A55.t()).eval() * (2*B55.t()).eval() - two_times_A55_t_times_two_times_B55_t )) == Approx(0.0) );
  638. }
  639. TEST_CASE("mat_mul_real_6")
  640. {
  641. mat A =
  642. "\
  643. 0.061198 0.201990 0.019678 -0.493936 -0.126745 0.051408;\
  644. 0.437242 0.058956 -0.149362 -0.045465 0.296153 0.035437;\
  645. -0.492474 -0.031309 0.314156 0.419733 0.068317 -0.454499;\
  646. 0.336352 0.411541 0.458476 -0.393139 -0.135040 0.373833;\
  647. 0.239585 -0.428913 -0.406953 -0.291020 -0.353768 0.258704;\
  648. ";
  649. mat B = fliplr(A);
  650. //
  651. mat A_times_B_t =
  652. "\
  653. -0.064350 0.149875 -0.182277 -0.273462 0.206336;\
  654. 0.149875 0.079491 -0.298398 0.327168 0.035695;\
  655. -0.182277 -0.298398 0.707103 -0.235701 -0.516759;\
  656. -0.273462 0.327168 -0.235701 -0.220160 0.115474;\
  657. 0.206336 0.035695 -0.516759 0.115474 0.664298;\
  658. ";
  659. mat A_t_times_B =
  660. "\
  661. 0.430191 -0.042089 -0.458772 -0.162107 0.089220 0.607990;\
  662. 0.069589 0.085881 -0.152563 0.348562 0.398588 0.089220;\
  663. -0.080952 0.056788 0.067119 0.497201 0.348562 -0.162107;\
  664. -0.440028 0.233857 0.661467 0.067119 -0.152563 -0.458772;\
  665. -0.169075 0.251826 0.233857 0.056788 0.085881 -0.042089;\
  666. 0.417147 -0.169075 -0.440028 -0.080952 0.069589 0.430191;\
  667. ";
  668. //
  669. mat two_times_A_times_B_t =
  670. "\
  671. -0.128699 0.299749 -0.364555 -0.546925 0.412672;\
  672. 0.299749 0.158981 -0.596795 0.654336 0.071391;\
  673. -0.364555 -0.596795 1.414207 -0.471402 -1.033519;\
  674. -0.546925 0.654336 -0.471402 -0.440319 0.230948;\
  675. 0.412672 0.071391 -1.033519 0.230948 1.328595;\
  676. ";
  677. mat two_times_A_t_times_B =
  678. "\
  679. 0.860381 -0.084178 -0.917544 -0.324215 0.178440 1.215980;\
  680. 0.139178 0.171762 -0.305125 0.697124 0.797177 0.178440;\
  681. -0.161904 0.113577 0.134239 0.994402 0.697124 -0.324215;\
  682. -0.880056 0.467715 1.322933 0.134239 -0.305125 -0.917544;\
  683. -0.338149 0.503651 0.467715 0.113577 0.171762 -0.084178;\
  684. 0.834294 -0.338149 -0.880056 -0.161904 0.139178 0.860381;\
  685. ";
  686. //
  687. mat A_times_two_times_B_t =
  688. "\
  689. -0.128699 0.299749 -0.364555 -0.546925 0.412672;\
  690. 0.299749 0.158981 -0.596795 0.654336 0.071391;\
  691. -0.364555 -0.596795 1.414207 -0.471402 -1.033519;\
  692. -0.546925 0.654336 -0.471402 -0.440319 0.230948;\
  693. 0.412672 0.071391 -1.033519 0.230948 1.328595;\
  694. ";
  695. mat A_t_times_two_times_B =
  696. "\
  697. 0.860381 -0.084178 -0.917544 -0.324215 0.178440 1.215980;\
  698. 0.139178 0.171762 -0.305125 0.697124 0.797177 0.178440;\
  699. -0.161904 0.113577 0.134239 0.994402 0.697124 -0.324215;\
  700. -0.880056 0.467715 1.322933 0.134239 -0.305125 -0.917544;\
  701. -0.338149 0.503651 0.467715 0.113577 0.171762 -0.084178;\
  702. 0.834294 -0.338149 -0.880056 -0.161904 0.139178 0.860381;\
  703. ";
  704. //
  705. mat two_times_A_times_two_times_B_t =
  706. "\
  707. -0.257398626992 0.599498340296 -0.729109500804 -1.093849875492 0.825343113540;\
  708. 0.599498340296 0.317962274816 -1.193590692028 1.308671575684 0.142781030004;\
  709. -0.729109500804 -1.193590692028 2.828413151368 -0.942803741636 -2.067037385556;\
  710. -1.093849875492 1.308671575684 -0.942803741636 -0.880638524704 0.461896688368;\
  711. 0.825343113540 0.142781030004 -2.067037385556 0.461896688368 2.657190032672;\
  712. ";
  713. mat two_times_A_t_times_two_times_B =
  714. "\
  715. 1.720762508480 -0.168355348408 -1.835087231712 -0.648429049028 0.356879236660 2.431960170292;\
  716. 0.278356531136 0.343524137236 -0.610250174464 1.394248666196 1.594353519068 0.356879236660;\
  717. -0.323807331272 0.227153811280 0.268477507864 1.988804839396 1.394248666196 -0.648429049028;\
  718. -1.760112014908 0.935429101824 2.645866173324 0.268477507864 -0.610250174464 -1.835087231712;\
  719. -0.676298185096 1.007302825388 0.935429101824 0.227153811280 0.343524137236 -0.168355348408;\
  720. 1.668587103756 -0.676298185096 -1.760112014908 -0.323807331272 0.278356531136 1.720762508480;\
  721. ";
  722. //
  723. REQUIRE( accu(abs( A*B.t() - A_times_B_t )) == Approx(0.0) );
  724. REQUIRE( accu(abs( A.t()*B - A_t_times_B )) == Approx(0.0) );
  725. REQUIRE( accu(abs( 2*A*B.t() - two_times_A_times_B_t )) == Approx(0.0) );
  726. REQUIRE( accu(abs( (2*A)*B.t() - two_times_A_times_B_t )) == Approx(0.0) );
  727. REQUIRE( accu(abs( 2*A.t()*B - two_times_A_t_times_B )) == Approx(0.0) );
  728. REQUIRE( accu(abs( (2*A).t()*B - two_times_A_t_times_B )) == Approx(0.0) );
  729. REQUIRE( accu(abs( A*2*B.t() - A_times_two_times_B_t )) == Approx(0.0) );
  730. REQUIRE( accu(abs( A*(2*B).t() - A_times_two_times_B_t )) == Approx(0.0) );
  731. REQUIRE( accu(abs( A.t()*2*B - A_t_times_two_times_B )) == Approx(0.0) );
  732. REQUIRE( accu(abs( A.t()*(2*B) - A_t_times_two_times_B )) == Approx(0.0) );
  733. REQUIRE( accu(abs( 2*A*2*B.t() - two_times_A_times_two_times_B_t )) == Approx(0.0) );
  734. REQUIRE( accu(abs( (2*A)*2*B.t() - two_times_A_times_two_times_B_t )) == Approx(0.0) );
  735. REQUIRE( accu(abs( 2*A.t()*2*B - two_times_A_t_times_two_times_B )) == Approx(0.0) );
  736. REQUIRE( accu(abs( (2*A).t()*2*B - two_times_A_t_times_two_times_B )) == Approx(0.0) );
  737. REQUIRE( accu(abs( 2*A*(2*B).t() - two_times_A_times_two_times_B_t )) == Approx(0.0) );
  738. REQUIRE( accu(abs( (2*A)*(2*B).t() - two_times_A_times_two_times_B_t )) == Approx(0.0) );
  739. REQUIRE( accu(abs( 2*A.t()*(2*B) - two_times_A_t_times_two_times_B )) == Approx(0.0) );
  740. REQUIRE( accu(abs( (2*A).t()*(2*B) - two_times_A_t_times_two_times_B )) == Approx(0.0) );
  741. //
  742. REQUIRE( accu(abs( A*B.t().eval() - A_times_B_t )) == Approx(0.0) );
  743. REQUIRE( accu(abs( A.t().eval()*B - A_t_times_B )) == Approx(0.0) );
  744. REQUIRE( accu(abs( 2*A*B.t().eval() - two_times_A_times_B_t )) == Approx(0.0) );
  745. REQUIRE( accu(abs( (2*A)*B.t().eval() - two_times_A_times_B_t )) == Approx(0.0) );
  746. REQUIRE( accu(abs( (2*A.t()).eval()*B - two_times_A_t_times_B )) == Approx(0.0) );
  747. REQUIRE( accu(abs( (2*A).t().eval()*B - two_times_A_t_times_B )) == Approx(0.0) );
  748. REQUIRE( accu(abs( A*2*(B.t().eval()) - A_times_two_times_B_t )) == Approx(0.0) );
  749. REQUIRE( accu(abs( A*(2*B).t().eval() - A_times_two_times_B_t )) == Approx(0.0) );
  750. REQUIRE( accu(abs( A.t().eval()*2*B - A_t_times_two_times_B )) == Approx(0.0) );
  751. REQUIRE( accu(abs( A.t().eval()*(2*B).eval() - A_t_times_two_times_B )) == Approx(0.0) );
  752. REQUIRE( accu(abs( 2*A*2*(B.t()).eval() - two_times_A_times_two_times_B_t )) == Approx(0.0) );
  753. REQUIRE( accu(abs( (2*A)*(2*B.t()).eval() - two_times_A_times_two_times_B_t )) == Approx(0.0) );
  754. REQUIRE( accu(abs( 2*A.t().eval()*2*B - two_times_A_t_times_two_times_B )) == Approx(0.0) );
  755. REQUIRE( accu(abs( (2*A).t().eval()*2*B - two_times_A_t_times_two_times_B )) == Approx(0.0) );
  756. REQUIRE( accu(abs( 2*A*(2*B).t().eval() - two_times_A_times_two_times_B_t )) == Approx(0.0) );
  757. REQUIRE( accu(abs( (2*A)*(2*B).t().eval() - two_times_A_times_two_times_B_t )) == Approx(0.0) );
  758. REQUIRE( accu(abs( 2*A.t().eval()*(2*B) - two_times_A_t_times_two_times_B )) == Approx(0.0) );
  759. REQUIRE( accu(abs( (2*A).t().eval()*(2*B) - two_times_A_t_times_two_times_B )) == Approx(0.0) );
  760. }