mat_operations2.hpp 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714
  1. #ifndef BOOST_QVM_GEN_MAT_OPERATIONS2_HPP_INCLUDED
  2. #define BOOST_QVM_GEN_MAT_OPERATIONS2_HPP_INCLUDED
  3. // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc.
  4. // This file was generated by a program. Do not edit manually.
  5. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. #include <boost/qvm/assert.hpp>
  8. #include <boost/qvm/deduce_mat.hpp>
  9. #include <boost/qvm/deduce_vec.hpp>
  10. #include <boost/qvm/error.hpp>
  11. #include <boost/qvm/gen/mat_assign2.hpp>
  12. #include <boost/qvm/throw_exception.hpp>
  13. namespace boost { namespace qvm {
  14. template <class A,class B>
  15. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  16. typename lazy_enable_if_c<
  17. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  18. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  19. deduce_mat2<A,B,2,2> >::type
  20. operator+( A const & a, B const & b )
  21. {
  22. typedef typename deduce_mat2<A,B,2,2>::type R;
  23. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==2);
  24. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==2);
  25. R r;
  26. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a)+mat_traits<B>::template read_element<0,0>(b));
  27. write_mat_element<0,1>(r,mat_traits<A>::template read_element<0,1>(a)+mat_traits<B>::template read_element<0,1>(b));
  28. write_mat_element<1,0>(r,mat_traits<A>::template read_element<1,0>(a)+mat_traits<B>::template read_element<1,0>(b));
  29. write_mat_element<1,1>(r,mat_traits<A>::template read_element<1,1>(a)+mat_traits<B>::template read_element<1,1>(b));
  30. return r;
  31. }
  32. namespace
  33. sfinae
  34. {
  35. using ::boost::qvm::operator+;
  36. }
  37. namespace
  38. qvm_detail
  39. {
  40. template <int R,int C>
  41. struct plus_mm_defined;
  42. template <>
  43. struct
  44. plus_mm_defined<2,2>
  45. {
  46. static bool const value=true;
  47. };
  48. }
  49. template <class A,class B>
  50. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  51. typename lazy_enable_if_c<
  52. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  53. mat_traits<A>::cols==1 && mat_traits<B>::cols==1,
  54. deduce_mat2<A,B,2,1> >::type
  55. operator+( A const & a, B const & b )
  56. {
  57. typedef typename deduce_mat2<A,B,2,1>::type R;
  58. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==2);
  59. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==1);
  60. R r;
  61. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a)+mat_traits<B>::template read_element<0,0>(b));
  62. write_mat_element<1,0>(r,mat_traits<A>::template read_element<1,0>(a)+mat_traits<B>::template read_element<1,0>(b));
  63. return r;
  64. }
  65. namespace
  66. sfinae
  67. {
  68. using ::boost::qvm::operator+;
  69. }
  70. namespace
  71. qvm_detail
  72. {
  73. template <int R,int C>
  74. struct plus_mm_defined;
  75. template <>
  76. struct
  77. plus_mm_defined<2,1>
  78. {
  79. static bool const value=true;
  80. };
  81. }
  82. template <class A,class B>
  83. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  84. typename lazy_enable_if_c<
  85. mat_traits<A>::rows==1 && mat_traits<B>::rows==1 &&
  86. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  87. deduce_mat2<A,B,1,2> >::type
  88. operator+( A const & a, B const & b )
  89. {
  90. typedef typename deduce_mat2<A,B,1,2>::type R;
  91. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==1);
  92. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==2);
  93. R r;
  94. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a)+mat_traits<B>::template read_element<0,0>(b));
  95. write_mat_element<0,1>(r,mat_traits<A>::template read_element<0,1>(a)+mat_traits<B>::template read_element<0,1>(b));
  96. return r;
  97. }
  98. namespace
  99. sfinae
  100. {
  101. using ::boost::qvm::operator+;
  102. }
  103. namespace
  104. qvm_detail
  105. {
  106. template <int R,int C>
  107. struct plus_mm_defined;
  108. template <>
  109. struct
  110. plus_mm_defined<1,2>
  111. {
  112. static bool const value=true;
  113. };
  114. }
  115. template <class A,class B>
  116. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  117. typename lazy_enable_if_c<
  118. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  119. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  120. deduce_mat2<A,B,2,2> >::type
  121. operator-( A const & a, B const & b )
  122. {
  123. typedef typename deduce_mat2<A,B,2,2>::type R;
  124. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==2);
  125. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==2);
  126. R r;
  127. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a)-mat_traits<B>::template read_element<0,0>(b));
  128. write_mat_element<0,1>(r,mat_traits<A>::template read_element<0,1>(a)-mat_traits<B>::template read_element<0,1>(b));
  129. write_mat_element<1,0>(r,mat_traits<A>::template read_element<1,0>(a)-mat_traits<B>::template read_element<1,0>(b));
  130. write_mat_element<1,1>(r,mat_traits<A>::template read_element<1,1>(a)-mat_traits<B>::template read_element<1,1>(b));
  131. return r;
  132. }
  133. namespace
  134. sfinae
  135. {
  136. using ::boost::qvm::operator-;
  137. }
  138. namespace
  139. qvm_detail
  140. {
  141. template <int R,int C>
  142. struct minus_mm_defined;
  143. template <>
  144. struct
  145. minus_mm_defined<2,2>
  146. {
  147. static bool const value=true;
  148. };
  149. }
  150. template <class A,class B>
  151. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  152. typename lazy_enable_if_c<
  153. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  154. mat_traits<A>::cols==1 && mat_traits<B>::cols==1,
  155. deduce_mat2<A,B,2,1> >::type
  156. operator-( A const & a, B const & b )
  157. {
  158. typedef typename deduce_mat2<A,B,2,1>::type R;
  159. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==2);
  160. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==1);
  161. R r;
  162. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a)-mat_traits<B>::template read_element<0,0>(b));
  163. write_mat_element<1,0>(r,mat_traits<A>::template read_element<1,0>(a)-mat_traits<B>::template read_element<1,0>(b));
  164. return r;
  165. }
  166. namespace
  167. sfinae
  168. {
  169. using ::boost::qvm::operator-;
  170. }
  171. namespace
  172. qvm_detail
  173. {
  174. template <int R,int C>
  175. struct minus_mm_defined;
  176. template <>
  177. struct
  178. minus_mm_defined<2,1>
  179. {
  180. static bool const value=true;
  181. };
  182. }
  183. template <class A,class B>
  184. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  185. typename lazy_enable_if_c<
  186. mat_traits<A>::rows==1 && mat_traits<B>::rows==1 &&
  187. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  188. deduce_mat2<A,B,1,2> >::type
  189. operator-( A const & a, B const & b )
  190. {
  191. typedef typename deduce_mat2<A,B,1,2>::type R;
  192. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==1);
  193. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==2);
  194. R r;
  195. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a)-mat_traits<B>::template read_element<0,0>(b));
  196. write_mat_element<0,1>(r,mat_traits<A>::template read_element<0,1>(a)-mat_traits<B>::template read_element<0,1>(b));
  197. return r;
  198. }
  199. namespace
  200. sfinae
  201. {
  202. using ::boost::qvm::operator-;
  203. }
  204. namespace
  205. qvm_detail
  206. {
  207. template <int R,int C>
  208. struct minus_mm_defined;
  209. template <>
  210. struct
  211. minus_mm_defined<1,2>
  212. {
  213. static bool const value=true;
  214. };
  215. }
  216. template <class A,class B>
  217. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  218. typename enable_if_c<
  219. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  220. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  221. A &>::type
  222. operator+=( A & a, B const & b )
  223. {
  224. write_mat_element<0,0>(a,mat_traits<A>::template read_element<0,0>(a)+mat_traits<B>::template read_element<0,0>(b));
  225. write_mat_element<0,1>(a,mat_traits<A>::template read_element<0,1>(a)+mat_traits<B>::template read_element<0,1>(b));
  226. write_mat_element<1,0>(a,mat_traits<A>::template read_element<1,0>(a)+mat_traits<B>::template read_element<1,0>(b));
  227. write_mat_element<1,1>(a,mat_traits<A>::template read_element<1,1>(a)+mat_traits<B>::template read_element<1,1>(b));
  228. return a;
  229. }
  230. namespace
  231. sfinae
  232. {
  233. using ::boost::qvm::operator+=;
  234. }
  235. namespace
  236. qvm_detail
  237. {
  238. template <int R,int C>
  239. struct plus_eq_mm_defined;
  240. template <>
  241. struct
  242. plus_eq_mm_defined<2,2>
  243. {
  244. static bool const value=true;
  245. };
  246. }
  247. template <class A,class B>
  248. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  249. typename enable_if_c<
  250. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  251. mat_traits<A>::cols==1 && mat_traits<B>::cols==1,
  252. A &>::type
  253. operator+=( A & a, B const & b )
  254. {
  255. write_mat_element<0,0>(a,mat_traits<A>::template read_element<0,0>(a)+mat_traits<B>::template read_element<0,0>(b));
  256. write_mat_element<1,0>(a,mat_traits<A>::template read_element<1,0>(a)+mat_traits<B>::template read_element<1,0>(b));
  257. return a;
  258. }
  259. namespace
  260. sfinae
  261. {
  262. using ::boost::qvm::operator+=;
  263. }
  264. namespace
  265. qvm_detail
  266. {
  267. template <int R,int C>
  268. struct plus_eq_mm_defined;
  269. template <>
  270. struct
  271. plus_eq_mm_defined<2,1>
  272. {
  273. static bool const value=true;
  274. };
  275. }
  276. template <class A,class B>
  277. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  278. typename enable_if_c<
  279. mat_traits<A>::rows==1 && mat_traits<B>::rows==1 &&
  280. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  281. A &>::type
  282. operator+=( A & a, B const & b )
  283. {
  284. write_mat_element<0,0>(a,mat_traits<A>::template read_element<0,0>(a)+mat_traits<B>::template read_element<0,0>(b));
  285. write_mat_element<0,1>(a,mat_traits<A>::template read_element<0,1>(a)+mat_traits<B>::template read_element<0,1>(b));
  286. return a;
  287. }
  288. namespace
  289. sfinae
  290. {
  291. using ::boost::qvm::operator+=;
  292. }
  293. namespace
  294. qvm_detail
  295. {
  296. template <int R,int C>
  297. struct plus_eq_mm_defined;
  298. template <>
  299. struct
  300. plus_eq_mm_defined<1,2>
  301. {
  302. static bool const value=true;
  303. };
  304. }
  305. template <class A,class B>
  306. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  307. typename enable_if_c<
  308. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  309. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  310. A &>::type
  311. operator-=( A & a, B const & b )
  312. {
  313. write_mat_element<0,0>(a,mat_traits<A>::template read_element<0,0>(a)-mat_traits<B>::template read_element<0,0>(b));
  314. write_mat_element<0,1>(a,mat_traits<A>::template read_element<0,1>(a)-mat_traits<B>::template read_element<0,1>(b));
  315. write_mat_element<1,0>(a,mat_traits<A>::template read_element<1,0>(a)-mat_traits<B>::template read_element<1,0>(b));
  316. write_mat_element<1,1>(a,mat_traits<A>::template read_element<1,1>(a)-mat_traits<B>::template read_element<1,1>(b));
  317. return a;
  318. }
  319. namespace
  320. sfinae
  321. {
  322. using ::boost::qvm::operator-=;
  323. }
  324. namespace
  325. qvm_detail
  326. {
  327. template <int R,int C>
  328. struct minus_eq_mm_defined;
  329. template <>
  330. struct
  331. minus_eq_mm_defined<2,2>
  332. {
  333. static bool const value=true;
  334. };
  335. }
  336. template <class A,class B>
  337. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  338. typename enable_if_c<
  339. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  340. mat_traits<A>::cols==1 && mat_traits<B>::cols==1,
  341. A &>::type
  342. operator-=( A & a, B const & b )
  343. {
  344. write_mat_element<0,0>(a,mat_traits<A>::template read_element<0,0>(a)-mat_traits<B>::template read_element<0,0>(b));
  345. write_mat_element<1,0>(a,mat_traits<A>::template read_element<1,0>(a)-mat_traits<B>::template read_element<1,0>(b));
  346. return a;
  347. }
  348. namespace
  349. sfinae
  350. {
  351. using ::boost::qvm::operator-=;
  352. }
  353. namespace
  354. qvm_detail
  355. {
  356. template <int R,int C>
  357. struct minus_eq_mm_defined;
  358. template <>
  359. struct
  360. minus_eq_mm_defined<2,1>
  361. {
  362. static bool const value=true;
  363. };
  364. }
  365. template <class A,class B>
  366. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  367. typename enable_if_c<
  368. mat_traits<A>::rows==1 && mat_traits<B>::rows==1 &&
  369. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  370. A &>::type
  371. operator-=( A & a, B const & b )
  372. {
  373. write_mat_element<0,0>(a,mat_traits<A>::template read_element<0,0>(a)-mat_traits<B>::template read_element<0,0>(b));
  374. write_mat_element<0,1>(a,mat_traits<A>::template read_element<0,1>(a)-mat_traits<B>::template read_element<0,1>(b));
  375. return a;
  376. }
  377. namespace
  378. sfinae
  379. {
  380. using ::boost::qvm::operator-=;
  381. }
  382. namespace
  383. qvm_detail
  384. {
  385. template <int R,int C>
  386. struct minus_eq_mm_defined;
  387. template <>
  388. struct
  389. minus_eq_mm_defined<1,2>
  390. {
  391. static bool const value=true;
  392. };
  393. }
  394. template <class A,class B>
  395. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  396. typename lazy_enable_if_c<
  397. mat_traits<A>::rows==2 && mat_traits<A>::cols==2 && is_scalar<B>::value,
  398. deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols> >::type
  399. operator*( A const & a, B b )
  400. {
  401. typedef typename deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols>::type R;
  402. R r;
  403. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a)*b);
  404. write_mat_element<0,1>(r,mat_traits<A>::template read_element<0,1>(a)*b);
  405. write_mat_element<1,0>(r,mat_traits<A>::template read_element<1,0>(a)*b);
  406. write_mat_element<1,1>(r,mat_traits<A>::template read_element<1,1>(a)*b);
  407. return r;
  408. }
  409. namespace
  410. sfinae
  411. {
  412. using ::boost::qvm::operator*;
  413. }
  414. namespace
  415. qvm_detail
  416. {
  417. template <int R,int C>
  418. struct mul_ms_defined;
  419. template <>
  420. struct
  421. mul_ms_defined<2,2>
  422. {
  423. static bool const value=true;
  424. };
  425. }
  426. template <class A,class B>
  427. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  428. typename lazy_enable_if_c<
  429. is_scalar<A>::value && mat_traits<B>::rows==2 && mat_traits<B>::cols==2,
  430. deduce_mat2<A,B,mat_traits<B>::rows,mat_traits<B>::cols> >::type
  431. operator*( A a, B const & b )
  432. {
  433. typedef typename deduce_mat2<A,B,mat_traits<B>::rows,mat_traits<B>::cols>::type R;
  434. R r;
  435. write_mat_element<0,0>(r,a*mat_traits<B>::template read_element<0,0>(b));
  436. write_mat_element<0,1>(r,a*mat_traits<B>::template read_element<0,1>(b));
  437. write_mat_element<1,0>(r,a*mat_traits<B>::template read_element<1,0>(b));
  438. write_mat_element<1,1>(r,a*mat_traits<B>::template read_element<1,1>(b));
  439. return r;
  440. }
  441. namespace
  442. sfinae
  443. {
  444. using ::boost::qvm::operator*;
  445. }
  446. namespace
  447. qvm_detail
  448. {
  449. template <int R,int C>
  450. struct mul_sm_defined;
  451. template <>
  452. struct
  453. mul_sm_defined<2,2>
  454. {
  455. static bool const value=true;
  456. };
  457. }
  458. template <class A,class B>
  459. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  460. typename lazy_enable_if_c<
  461. mat_traits<A>::rows==2 && mat_traits<A>::cols==1 && is_scalar<B>::value,
  462. deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols> >::type
  463. operator*( A const & a, B b )
  464. {
  465. typedef typename deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols>::type R;
  466. R r;
  467. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a)*b);
  468. write_mat_element<1,0>(r,mat_traits<A>::template read_element<1,0>(a)*b);
  469. return r;
  470. }
  471. namespace
  472. sfinae
  473. {
  474. using ::boost::qvm::operator*;
  475. }
  476. namespace
  477. qvm_detail
  478. {
  479. template <int R,int C>
  480. struct mul_ms_defined;
  481. template <>
  482. struct
  483. mul_ms_defined<2,1>
  484. {
  485. static bool const value=true;
  486. };
  487. }
  488. template <class A,class B>
  489. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  490. typename lazy_enable_if_c<
  491. is_scalar<A>::value && mat_traits<B>::rows==2 && mat_traits<B>::cols==1,
  492. deduce_mat2<A,B,mat_traits<B>::rows,mat_traits<B>::cols> >::type
  493. operator*( A a, B const & b )
  494. {
  495. typedef typename deduce_mat2<A,B,mat_traits<B>::rows,mat_traits<B>::cols>::type R;
  496. R r;
  497. write_mat_element<0,0>(r,a*mat_traits<B>::template read_element<0,0>(b));
  498. write_mat_element<1,0>(r,a*mat_traits<B>::template read_element<1,0>(b));
  499. return r;
  500. }
  501. namespace
  502. sfinae
  503. {
  504. using ::boost::qvm::operator*;
  505. }
  506. namespace
  507. qvm_detail
  508. {
  509. template <int R,int C>
  510. struct mul_sm_defined;
  511. template <>
  512. struct
  513. mul_sm_defined<2,1>
  514. {
  515. static bool const value=true;
  516. };
  517. }
  518. template <class A,class B>
  519. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  520. typename lazy_enable_if_c<
  521. mat_traits<A>::rows==1 && mat_traits<A>::cols==2 && is_scalar<B>::value,
  522. deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols> >::type
  523. operator*( A const & a, B b )
  524. {
  525. typedef typename deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols>::type R;
  526. R r;
  527. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a)*b);
  528. write_mat_element<0,1>(r,mat_traits<A>::template read_element<0,1>(a)*b);
  529. return r;
  530. }
  531. namespace
  532. sfinae
  533. {
  534. using ::boost::qvm::operator*;
  535. }
  536. namespace
  537. qvm_detail
  538. {
  539. template <int R,int C>
  540. struct mul_ms_defined;
  541. template <>
  542. struct
  543. mul_ms_defined<1,2>
  544. {
  545. static bool const value=true;
  546. };
  547. }
  548. template <class A,class B>
  549. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  550. typename lazy_enable_if_c<
  551. is_scalar<A>::value && mat_traits<B>::rows==1 && mat_traits<B>::cols==2,
  552. deduce_mat2<A,B,mat_traits<B>::rows,mat_traits<B>::cols> >::type
  553. operator*( A a, B const & b )
  554. {
  555. typedef typename deduce_mat2<A,B,mat_traits<B>::rows,mat_traits<B>::cols>::type R;
  556. R r;
  557. write_mat_element<0,0>(r,a*mat_traits<B>::template read_element<0,0>(b));
  558. write_mat_element<0,1>(r,a*mat_traits<B>::template read_element<0,1>(b));
  559. return r;
  560. }
  561. namespace
  562. sfinae
  563. {
  564. using ::boost::qvm::operator*;
  565. }
  566. namespace
  567. qvm_detail
  568. {
  569. template <int R,int C>
  570. struct mul_sm_defined;
  571. template <>
  572. struct
  573. mul_sm_defined<1,2>
  574. {
  575. static bool const value=true;
  576. };
  577. }
  578. template <class A,class B>
  579. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  580. typename enable_if_c<
  581. mat_traits<A>::rows==2 && mat_traits<A>::cols==2 && is_scalar<B>::value,
  582. A &>::type
  583. operator*=( A & a, B b )
  584. {
  585. write_mat_element<0,0>(a,mat_traits<A>::template read_element<0,0>(a)*b);
  586. write_mat_element<0,1>(a,mat_traits<A>::template read_element<0,1>(a)*b);
  587. write_mat_element<1,0>(a,mat_traits<A>::template read_element<1,0>(a)*b);
  588. write_mat_element<1,1>(a,mat_traits<A>::template read_element<1,1>(a)*b);
  589. return a;
  590. }
  591. namespace
  592. sfinae
  593. {
  594. using ::boost::qvm::operator*=;
  595. }
  596. namespace
  597. qvm_detail
  598. {
  599. template <int R,int C>
  600. struct mul_eq_ms_defined;
  601. template <>
  602. struct
  603. mul_eq_ms_defined<2,2>
  604. {
  605. static bool const value=true;
  606. };
  607. }
  608. template <class A,class B>
  609. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  610. typename enable_if_c<
  611. mat_traits<A>::rows==2 && mat_traits<A>::cols==1 && is_scalar<B>::value,
  612. A &>::type
  613. operator*=( A & a, B b )
  614. {
  615. write_mat_element<0,0>(a,mat_traits<A>::template read_element<0,0>(a)*b);
  616. write_mat_element<1,0>(a,mat_traits<A>::template read_element<1,0>(a)*b);
  617. return a;
  618. }
  619. namespace
  620. sfinae
  621. {
  622. using ::boost::qvm::operator*=;
  623. }
  624. namespace
  625. qvm_detail
  626. {
  627. template <int R,int C>
  628. struct mul_eq_ms_defined;
  629. template <>
  630. struct
  631. mul_eq_ms_defined<2,1>
  632. {
  633. static bool const value=true;
  634. };
  635. }
  636. template <class A,class B>
  637. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  638. typename enable_if_c<
  639. mat_traits<A>::rows==1 && mat_traits<A>::cols==2 && is_scalar<B>::value,
  640. A &>::type
  641. operator*=( A & a, B b )
  642. {
  643. write_mat_element<0,0>(a,mat_traits<A>::template read_element<0,0>(a)*b);
  644. write_mat_element<0,1>(a,mat_traits<A>::template read_element<0,1>(a)*b);
  645. return a;
  646. }
  647. namespace
  648. sfinae
  649. {
  650. using ::boost::qvm::operator*=;
  651. }
  652. namespace
  653. qvm_detail
  654. {
  655. template <int R,int C>
  656. struct mul_eq_ms_defined;
  657. template <>
  658. struct
  659. mul_eq_ms_defined<1,2>
  660. {
  661. static bool const value=true;
  662. };
  663. }
  664. template <class A,class B>
  665. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  666. typename lazy_enable_if_c<
  667. mat_traits<A>::rows==2 && mat_traits<A>::cols==2 && is_scalar<B>::value,
  668. deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols> >::type
  669. operator/( A const & a, B b )
  670. {
  671. typedef typename deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols>::type R;
  672. R r;
  673. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a)/b);
  674. write_mat_element<0,1>(r,mat_traits<A>::template read_element<0,1>(a)/b);
  675. write_mat_element<1,0>(r,mat_traits<A>::template read_element<1,0>(a)/b);
  676. write_mat_element<1,1>(r,mat_traits<A>::template read_element<1,1>(a)/b);
  677. return r;
  678. }
  679. namespace
  680. sfinae
  681. {
  682. using ::boost::qvm::operator/;
  683. }
  684. namespace
  685. qvm_detail
  686. {
  687. template <int R,int C>
  688. struct div_ms_defined;
  689. template <>
  690. struct
  691. div_ms_defined<2,2>
  692. {
  693. static bool const value=true;
  694. };
  695. }
  696. template <class A,class B>
  697. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  698. typename lazy_enable_if_c<
  699. is_scalar<A>::value && mat_traits<B>::rows==2 && mat_traits<B>::cols==2,
  700. deduce_mat2<A,B,mat_traits<B>::rows,mat_traits<B>::cols> >::type
  701. operator/( A a, B const & b )
  702. {
  703. typedef typename deduce_mat2<A,B,mat_traits<B>::rows,mat_traits<B>::cols>::type R;
  704. R r;
  705. write_mat_element<0,0>(r,a/mat_traits<B>::template read_element<0,0>(b));
  706. write_mat_element<0,1>(r,a/mat_traits<B>::template read_element<0,1>(b));
  707. write_mat_element<1,0>(r,a/mat_traits<B>::template read_element<1,0>(b));
  708. write_mat_element<1,1>(r,a/mat_traits<B>::template read_element<1,1>(b));
  709. return r;
  710. }
  711. namespace
  712. sfinae
  713. {
  714. using ::boost::qvm::operator/;
  715. }
  716. namespace
  717. qvm_detail
  718. {
  719. template <int R,int C>
  720. struct div_sm_defined;
  721. template <>
  722. struct
  723. div_sm_defined<2,2>
  724. {
  725. static bool const value=true;
  726. };
  727. }
  728. template <class A,class B>
  729. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  730. typename lazy_enable_if_c<
  731. mat_traits<A>::rows==2 && mat_traits<A>::cols==1 && is_scalar<B>::value,
  732. deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols> >::type
  733. operator/( A const & a, B b )
  734. {
  735. typedef typename deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols>::type R;
  736. R r;
  737. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a)/b);
  738. write_mat_element<1,0>(r,mat_traits<A>::template read_element<1,0>(a)/b);
  739. return r;
  740. }
  741. namespace
  742. sfinae
  743. {
  744. using ::boost::qvm::operator/;
  745. }
  746. namespace
  747. qvm_detail
  748. {
  749. template <int R,int C>
  750. struct div_ms_defined;
  751. template <>
  752. struct
  753. div_ms_defined<2,1>
  754. {
  755. static bool const value=true;
  756. };
  757. }
  758. template <class A,class B>
  759. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  760. typename lazy_enable_if_c<
  761. is_scalar<A>::value && mat_traits<B>::rows==2 && mat_traits<B>::cols==1,
  762. deduce_mat2<A,B,mat_traits<B>::rows,mat_traits<B>::cols> >::type
  763. operator/( A a, B const & b )
  764. {
  765. typedef typename deduce_mat2<A,B,mat_traits<B>::rows,mat_traits<B>::cols>::type R;
  766. R r;
  767. write_mat_element<0,0>(r,a/mat_traits<B>::template read_element<0,0>(b));
  768. write_mat_element<1,0>(r,a/mat_traits<B>::template read_element<1,0>(b));
  769. return r;
  770. }
  771. namespace
  772. sfinae
  773. {
  774. using ::boost::qvm::operator/;
  775. }
  776. namespace
  777. qvm_detail
  778. {
  779. template <int R,int C>
  780. struct div_sm_defined;
  781. template <>
  782. struct
  783. div_sm_defined<2,1>
  784. {
  785. static bool const value=true;
  786. };
  787. }
  788. template <class A,class B>
  789. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  790. typename lazy_enable_if_c<
  791. mat_traits<A>::rows==1 && mat_traits<A>::cols==2 && is_scalar<B>::value,
  792. deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols> >::type
  793. operator/( A const & a, B b )
  794. {
  795. typedef typename deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols>::type R;
  796. R r;
  797. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a)/b);
  798. write_mat_element<0,1>(r,mat_traits<A>::template read_element<0,1>(a)/b);
  799. return r;
  800. }
  801. namespace
  802. sfinae
  803. {
  804. using ::boost::qvm::operator/;
  805. }
  806. namespace
  807. qvm_detail
  808. {
  809. template <int R,int C>
  810. struct div_ms_defined;
  811. template <>
  812. struct
  813. div_ms_defined<1,2>
  814. {
  815. static bool const value=true;
  816. };
  817. }
  818. template <class A,class B>
  819. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  820. typename enable_if_c<
  821. mat_traits<A>::rows==2 && mat_traits<A>::cols==2 && is_scalar<B>::value,
  822. A &>::type
  823. operator/=( A & a, B b )
  824. {
  825. write_mat_element<0,0>(a,mat_traits<A>::template read_element<0,0>(a)/b);
  826. write_mat_element<0,1>(a,mat_traits<A>::template read_element<0,1>(a)/b);
  827. write_mat_element<1,0>(a,mat_traits<A>::template read_element<1,0>(a)/b);
  828. write_mat_element<1,1>(a,mat_traits<A>::template read_element<1,1>(a)/b);
  829. return a;
  830. }
  831. namespace
  832. sfinae
  833. {
  834. using ::boost::qvm::operator/=;
  835. }
  836. namespace
  837. qvm_detail
  838. {
  839. template <int R,int C>
  840. struct div_eq_ms_defined;
  841. template <>
  842. struct
  843. div_eq_ms_defined<2,2>
  844. {
  845. static bool const value=true;
  846. };
  847. }
  848. template <class A,class B>
  849. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  850. typename enable_if_c<
  851. mat_traits<A>::rows==2 && mat_traits<A>::cols==1 && is_scalar<B>::value,
  852. A &>::type
  853. operator/=( A & a, B b )
  854. {
  855. write_mat_element<0,0>(a,mat_traits<A>::template read_element<0,0>(a)/b);
  856. write_mat_element<1,0>(a,mat_traits<A>::template read_element<1,0>(a)/b);
  857. return a;
  858. }
  859. namespace
  860. sfinae
  861. {
  862. using ::boost::qvm::operator/=;
  863. }
  864. namespace
  865. qvm_detail
  866. {
  867. template <int R,int C>
  868. struct div_eq_ms_defined;
  869. template <>
  870. struct
  871. div_eq_ms_defined<2,1>
  872. {
  873. static bool const value=true;
  874. };
  875. }
  876. template <class A,class B>
  877. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  878. typename enable_if_c<
  879. mat_traits<A>::rows==1 && mat_traits<A>::cols==2 && is_scalar<B>::value,
  880. A &>::type
  881. operator/=( A & a, B b )
  882. {
  883. write_mat_element<0,0>(a,mat_traits<A>::template read_element<0,0>(a)/b);
  884. write_mat_element<0,1>(a,mat_traits<A>::template read_element<0,1>(a)/b);
  885. return a;
  886. }
  887. namespace
  888. sfinae
  889. {
  890. using ::boost::qvm::operator/=;
  891. }
  892. namespace
  893. qvm_detail
  894. {
  895. template <int R,int C>
  896. struct div_eq_ms_defined;
  897. template <>
  898. struct
  899. div_eq_ms_defined<1,2>
  900. {
  901. static bool const value=true;
  902. };
  903. }
  904. template <class R,class A>
  905. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  906. typename enable_if_c<
  907. mat_traits<R>::rows==2 && mat_traits<A>::rows==2 &&
  908. mat_traits<R>::cols==2 && mat_traits<A>::cols==2,
  909. R>::type
  910. convert_to( A const & a )
  911. {
  912. R r;
  913. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a));
  914. write_mat_element<0,1>(r,mat_traits<A>::template read_element<0,1>(a));
  915. write_mat_element<1,0>(r,mat_traits<A>::template read_element<1,0>(a));
  916. write_mat_element<1,1>(r,mat_traits<A>::template read_element<1,1>(a));
  917. return r;
  918. }
  919. namespace
  920. sfinae
  921. {
  922. using ::boost::qvm::convert_to;
  923. }
  924. namespace
  925. qvm_detail
  926. {
  927. template <int R,int C>
  928. struct convert_to_m_defined;
  929. template <>
  930. struct
  931. convert_to_m_defined<2,2>
  932. {
  933. static bool const value=true;
  934. };
  935. }
  936. template <class R,class A>
  937. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  938. typename enable_if_c<
  939. mat_traits<R>::rows==2 && mat_traits<A>::rows==2 &&
  940. mat_traits<R>::cols==1 && mat_traits<A>::cols==1,
  941. R>::type
  942. convert_to( A const & a )
  943. {
  944. R r;
  945. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a));
  946. write_mat_element<1,0>(r,mat_traits<A>::template read_element<1,0>(a));
  947. return r;
  948. }
  949. namespace
  950. sfinae
  951. {
  952. using ::boost::qvm::convert_to;
  953. }
  954. namespace
  955. qvm_detail
  956. {
  957. template <int R,int C>
  958. struct convert_to_m_defined;
  959. template <>
  960. struct
  961. convert_to_m_defined<2,1>
  962. {
  963. static bool const value=true;
  964. };
  965. }
  966. template <class R,class A>
  967. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  968. typename enable_if_c<
  969. mat_traits<R>::rows==1 && mat_traits<A>::rows==1 &&
  970. mat_traits<R>::cols==2 && mat_traits<A>::cols==2,
  971. R>::type
  972. convert_to( A const & a )
  973. {
  974. R r;
  975. write_mat_element<0,0>(r,mat_traits<A>::template read_element<0,0>(a));
  976. write_mat_element<0,1>(r,mat_traits<A>::template read_element<0,1>(a));
  977. return r;
  978. }
  979. namespace
  980. sfinae
  981. {
  982. using ::boost::qvm::convert_to;
  983. }
  984. namespace
  985. qvm_detail
  986. {
  987. template <int R,int C>
  988. struct convert_to_m_defined;
  989. template <>
  990. struct
  991. convert_to_m_defined<1,2>
  992. {
  993. static bool const value=true;
  994. };
  995. }
  996. template <class A,class B>
  997. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  998. typename enable_if_c<
  999. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  1000. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  1001. bool>::type
  1002. operator==( A const & a, B const & b )
  1003. {
  1004. return
  1005. mat_traits<A>::template read_element<0,0>(a)==mat_traits<B>::template read_element<0,0>(b) &&
  1006. mat_traits<A>::template read_element<0,1>(a)==mat_traits<B>::template read_element<0,1>(b) &&
  1007. mat_traits<A>::template read_element<1,0>(a)==mat_traits<B>::template read_element<1,0>(b) &&
  1008. mat_traits<A>::template read_element<1,1>(a)==mat_traits<B>::template read_element<1,1>(b);
  1009. }
  1010. namespace
  1011. sfinae
  1012. {
  1013. using ::boost::qvm::operator==;
  1014. }
  1015. namespace
  1016. qvm_detail
  1017. {
  1018. template <int R,int C>
  1019. struct eq_mm_defined;
  1020. template <>
  1021. struct
  1022. eq_mm_defined<2,2>
  1023. {
  1024. static bool const value=true;
  1025. };
  1026. }
  1027. template <class A,class B>
  1028. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1029. typename enable_if_c<
  1030. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  1031. mat_traits<A>::cols==1 && mat_traits<B>::cols==1,
  1032. bool>::type
  1033. operator==( A const & a, B const & b )
  1034. {
  1035. return
  1036. mat_traits<A>::template read_element<0,0>(a)==mat_traits<B>::template read_element<0,0>(b) &&
  1037. mat_traits<A>::template read_element<1,0>(a)==mat_traits<B>::template read_element<1,0>(b);
  1038. }
  1039. namespace
  1040. sfinae
  1041. {
  1042. using ::boost::qvm::operator==;
  1043. }
  1044. namespace
  1045. qvm_detail
  1046. {
  1047. template <int R,int C>
  1048. struct eq_mm_defined;
  1049. template <>
  1050. struct
  1051. eq_mm_defined<2,1>
  1052. {
  1053. static bool const value=true;
  1054. };
  1055. }
  1056. template <class A,class B>
  1057. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1058. typename enable_if_c<
  1059. mat_traits<A>::rows==1 && mat_traits<B>::rows==1 &&
  1060. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  1061. bool>::type
  1062. operator==( A const & a, B const & b )
  1063. {
  1064. return
  1065. mat_traits<A>::template read_element<0,0>(a)==mat_traits<B>::template read_element<0,0>(b) &&
  1066. mat_traits<A>::template read_element<0,1>(a)==mat_traits<B>::template read_element<0,1>(b);
  1067. }
  1068. namespace
  1069. sfinae
  1070. {
  1071. using ::boost::qvm::operator==;
  1072. }
  1073. namespace
  1074. qvm_detail
  1075. {
  1076. template <int R,int C>
  1077. struct eq_mm_defined;
  1078. template <>
  1079. struct
  1080. eq_mm_defined<1,2>
  1081. {
  1082. static bool const value=true;
  1083. };
  1084. }
  1085. template <class A,class B>
  1086. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1087. typename enable_if_c<
  1088. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  1089. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  1090. bool>::type
  1091. operator!=( A const & a, B const & b )
  1092. {
  1093. return
  1094. !(mat_traits<A>::template read_element<0,0>(a)==mat_traits<B>::template read_element<0,0>(b)) ||
  1095. !(mat_traits<A>::template read_element<0,1>(a)==mat_traits<B>::template read_element<0,1>(b)) ||
  1096. !(mat_traits<A>::template read_element<1,0>(a)==mat_traits<B>::template read_element<1,0>(b)) ||
  1097. !(mat_traits<A>::template read_element<1,1>(a)==mat_traits<B>::template read_element<1,1>(b));
  1098. }
  1099. namespace
  1100. sfinae
  1101. {
  1102. using ::boost::qvm::operator!=;
  1103. }
  1104. namespace
  1105. qvm_detail
  1106. {
  1107. template <int R,int C>
  1108. struct neq_mm_defined;
  1109. template <>
  1110. struct
  1111. neq_mm_defined<2,2>
  1112. {
  1113. static bool const value=true;
  1114. };
  1115. }
  1116. template <class A,class B>
  1117. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1118. typename enable_if_c<
  1119. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  1120. mat_traits<A>::cols==1 && mat_traits<B>::cols==1,
  1121. bool>::type
  1122. operator!=( A const & a, B const & b )
  1123. {
  1124. return
  1125. !(mat_traits<A>::template read_element<0,0>(a)==mat_traits<B>::template read_element<0,0>(b)) ||
  1126. !(mat_traits<A>::template read_element<1,0>(a)==mat_traits<B>::template read_element<1,0>(b));
  1127. }
  1128. namespace
  1129. sfinae
  1130. {
  1131. using ::boost::qvm::operator!=;
  1132. }
  1133. namespace
  1134. qvm_detail
  1135. {
  1136. template <int R,int C>
  1137. struct neq_mm_defined;
  1138. template <>
  1139. struct
  1140. neq_mm_defined<2,1>
  1141. {
  1142. static bool const value=true;
  1143. };
  1144. }
  1145. template <class A,class B>
  1146. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1147. typename enable_if_c<
  1148. mat_traits<A>::rows==1 && mat_traits<B>::rows==1 &&
  1149. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  1150. bool>::type
  1151. operator!=( A const & a, B const & b )
  1152. {
  1153. return
  1154. !(mat_traits<A>::template read_element<0,0>(a)==mat_traits<B>::template read_element<0,0>(b)) ||
  1155. !(mat_traits<A>::template read_element<0,1>(a)==mat_traits<B>::template read_element<0,1>(b));
  1156. }
  1157. namespace
  1158. sfinae
  1159. {
  1160. using ::boost::qvm::operator!=;
  1161. }
  1162. namespace
  1163. qvm_detail
  1164. {
  1165. template <int R,int C>
  1166. struct neq_mm_defined;
  1167. template <>
  1168. struct
  1169. neq_mm_defined<1,2>
  1170. {
  1171. static bool const value=true;
  1172. };
  1173. }
  1174. template <class A>
  1175. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1176. typename lazy_enable_if_c<
  1177. mat_traits<A>::rows==2 && mat_traits<A>::cols==2,
  1178. deduce_mat<A> >::type
  1179. operator-( A const & a )
  1180. {
  1181. typedef typename deduce_mat<A>::type R;
  1182. R r;
  1183. write_mat_element<0,0>(r,-mat_traits<A>::template read_element<0,0>(a));
  1184. write_mat_element<0,1>(r,-mat_traits<A>::template read_element<0,1>(a));
  1185. write_mat_element<1,0>(r,-mat_traits<A>::template read_element<1,0>(a));
  1186. write_mat_element<1,1>(r,-mat_traits<A>::template read_element<1,1>(a));
  1187. return r;
  1188. }
  1189. namespace
  1190. sfinae
  1191. {
  1192. using ::boost::qvm::operator-;
  1193. }
  1194. namespace
  1195. qvm_detail
  1196. {
  1197. template <int R,int C>
  1198. struct minus_m_defined;
  1199. template <>
  1200. struct
  1201. minus_m_defined<2,2>
  1202. {
  1203. static bool const value=true;
  1204. };
  1205. }
  1206. template <class A>
  1207. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1208. typename lazy_enable_if_c<
  1209. mat_traits<A>::rows==2 && mat_traits<A>::cols==1,
  1210. deduce_mat<A> >::type
  1211. operator-( A const & a )
  1212. {
  1213. typedef typename deduce_mat<A>::type R;
  1214. R r;
  1215. write_mat_element<0,0>(r,-mat_traits<A>::template read_element<0,0>(a));
  1216. write_mat_element<1,0>(r,-mat_traits<A>::template read_element<1,0>(a));
  1217. return r;
  1218. }
  1219. namespace
  1220. sfinae
  1221. {
  1222. using ::boost::qvm::operator-;
  1223. }
  1224. namespace
  1225. qvm_detail
  1226. {
  1227. template <int R,int C>
  1228. struct minus_m_defined;
  1229. template <>
  1230. struct
  1231. minus_m_defined<2,1>
  1232. {
  1233. static bool const value=true;
  1234. };
  1235. }
  1236. template <class A>
  1237. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1238. typename lazy_enable_if_c<
  1239. mat_traits<A>::rows==1 && mat_traits<A>::cols==2,
  1240. deduce_mat<A> >::type
  1241. operator-( A const & a )
  1242. {
  1243. typedef typename deduce_mat<A>::type R;
  1244. R r;
  1245. write_mat_element<0,0>(r,-mat_traits<A>::template read_element<0,0>(a));
  1246. write_mat_element<0,1>(r,-mat_traits<A>::template read_element<0,1>(a));
  1247. return r;
  1248. }
  1249. namespace
  1250. sfinae
  1251. {
  1252. using ::boost::qvm::operator-;
  1253. }
  1254. namespace
  1255. qvm_detail
  1256. {
  1257. template <int R,int C>
  1258. struct minus_m_defined;
  1259. template <>
  1260. struct
  1261. minus_m_defined<1,2>
  1262. {
  1263. static bool const value=true;
  1264. };
  1265. }
  1266. template <class A>
  1267. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1268. typename enable_if_c<
  1269. mat_traits<A>::rows==2 && mat_traits<A>::cols==2,
  1270. typename mat_traits<A>::scalar_type>::type
  1271. determinant( A const & a )
  1272. {
  1273. typedef typename mat_traits<A>::scalar_type T;
  1274. T const a00=mat_traits<A>::template read_element<0,0>(a);
  1275. T const a01=mat_traits<A>::template read_element<0,1>(a);
  1276. T const a10=mat_traits<A>::template read_element<1,0>(a);
  1277. T const a11=mat_traits<A>::template read_element<1,1>(a);
  1278. T det=(a00*a11-a01*a10);
  1279. return det;
  1280. }
  1281. namespace
  1282. sfinae
  1283. {
  1284. using ::boost::qvm::determinant;
  1285. }
  1286. namespace
  1287. qvm_detail
  1288. {
  1289. template <int D>
  1290. struct determinant_defined;
  1291. template <>
  1292. struct
  1293. determinant_defined<2>
  1294. {
  1295. static bool const value=true;
  1296. };
  1297. }
  1298. template <class A,class B>
  1299. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1300. typename lazy_enable_if_c<
  1301. mat_traits<A>::rows==2 && mat_traits<A>::cols==2 && is_scalar<B>::value,
  1302. deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols> >::type
  1303. inverse( A const & a, B det )
  1304. {
  1305. typedef typename mat_traits<A>::scalar_type T;
  1306. BOOST_QVM_ASSERT(det!=scalar_traits<B>::value(0));
  1307. T const a00=mat_traits<A>::template read_element<0,0>(a);
  1308. T const a01=mat_traits<A>::template read_element<0,1>(a);
  1309. T const a10=mat_traits<A>::template read_element<1,0>(a);
  1310. T const a11=mat_traits<A>::template read_element<1,1>(a);
  1311. T const f=scalar_traits<T>::value(1)/det;
  1312. typedef typename deduce_mat2<A,B,mat_traits<A>::rows,mat_traits<A>::cols>::type R;
  1313. R r;
  1314. write_mat_element<0,0>(r, f*a11);
  1315. write_mat_element<0,1>(r,-f*a01);
  1316. write_mat_element<1,0>(r,-f*a10);
  1317. write_mat_element<1,1>(r, f*a00);
  1318. return r;
  1319. }
  1320. template <class A>
  1321. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1322. typename lazy_enable_if_c<
  1323. mat_traits<A>::rows==2 && mat_traits<A>::cols==2,
  1324. deduce_mat<A> >::type
  1325. inverse( A const & a )
  1326. {
  1327. typedef typename mat_traits<A>::scalar_type T;
  1328. T det=determinant(a);
  1329. if( det==scalar_traits<T>::value(0) )
  1330. BOOST_QVM_THROW_EXCEPTION(zero_determinant_error());
  1331. return inverse(a,det);
  1332. }
  1333. namespace
  1334. sfinae
  1335. {
  1336. using ::boost::qvm::inverse;
  1337. }
  1338. namespace
  1339. qvm_detail
  1340. {
  1341. template <int D>
  1342. struct inverse_m_defined;
  1343. template <>
  1344. struct
  1345. inverse_m_defined<2>
  1346. {
  1347. static bool const value=true;
  1348. };
  1349. }
  1350. template <class A,class B>
  1351. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1352. typename lazy_enable_if_c<
  1353. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  1354. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  1355. deduce_mat2<A,B,2,2> >::type
  1356. operator*( A const & a, B const & b )
  1357. {
  1358. typedef typename mat_traits<A>::scalar_type Ta;
  1359. typedef typename mat_traits<B>::scalar_type Tb;
  1360. Ta const a00 = mat_traits<A>::template read_element<0,0>(a);
  1361. Ta const a01 = mat_traits<A>::template read_element<0,1>(a);
  1362. Ta const a10 = mat_traits<A>::template read_element<1,0>(a);
  1363. Ta const a11 = mat_traits<A>::template read_element<1,1>(a);
  1364. Tb const b00 = mat_traits<B>::template read_element<0,0>(b);
  1365. Tb const b01 = mat_traits<B>::template read_element<0,1>(b);
  1366. Tb const b10 = mat_traits<B>::template read_element<1,0>(b);
  1367. Tb const b11 = mat_traits<B>::template read_element<1,1>(b);
  1368. typedef typename deduce_mat2<A,B,2,2>::type R;
  1369. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==2);
  1370. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==2);
  1371. R r;
  1372. write_mat_element<0,0>(r,a00*b00+a01*b10);
  1373. write_mat_element<0,1>(r,a00*b01+a01*b11);
  1374. write_mat_element<1,0>(r,a10*b00+a11*b10);
  1375. write_mat_element<1,1>(r,a10*b01+a11*b11);
  1376. return r;
  1377. }
  1378. namespace
  1379. sfinae
  1380. {
  1381. using ::boost::qvm::operator*;
  1382. }
  1383. namespace
  1384. qvm_detail
  1385. {
  1386. template <int R,int /*CR*/,int C>
  1387. struct mul_mm_defined;
  1388. template <>
  1389. struct
  1390. mul_mm_defined<2,2,2>
  1391. {
  1392. static bool const value=true;
  1393. };
  1394. }
  1395. template <class A,class B>
  1396. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1397. typename enable_if_c<
  1398. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  1399. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  1400. A &>::type
  1401. operator*=( A & a, B const & b )
  1402. {
  1403. typedef typename mat_traits<A>::scalar_type Ta;
  1404. typedef typename mat_traits<B>::scalar_type Tb;
  1405. Ta const a00 = mat_traits<A>::template read_element<0,0>(a);
  1406. Ta const a01 = mat_traits<A>::template read_element<0,1>(a);
  1407. Ta const a10 = mat_traits<A>::template read_element<1,0>(a);
  1408. Ta const a11 = mat_traits<A>::template read_element<1,1>(a);
  1409. Tb const b00 = mat_traits<B>::template read_element<0,0>(b);
  1410. Tb const b01 = mat_traits<B>::template read_element<0,1>(b);
  1411. Tb const b10 = mat_traits<B>::template read_element<1,0>(b);
  1412. Tb const b11 = mat_traits<B>::template read_element<1,1>(b);
  1413. write_mat_element<0,0>(a,a00*b00+a01*b10);
  1414. write_mat_element<0,1>(a,a00*b01+a01*b11);
  1415. write_mat_element<1,0>(a,a10*b00+a11*b10);
  1416. write_mat_element<1,1>(a,a10*b01+a11*b11);
  1417. return a;
  1418. }
  1419. namespace
  1420. sfinae
  1421. {
  1422. using ::boost::qvm::operator*=;
  1423. }
  1424. namespace
  1425. qvm_detail
  1426. {
  1427. template <int D>
  1428. struct mul_eq_mm_defined;
  1429. template <>
  1430. struct
  1431. mul_eq_mm_defined<2>
  1432. {
  1433. static bool const value=true;
  1434. };
  1435. }
  1436. template <class A,class B>
  1437. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1438. typename lazy_enable_if_c<
  1439. mat_traits<A>::rows==2 && mat_traits<B>::rows==2 &&
  1440. mat_traits<A>::cols==2 && mat_traits<B>::cols==1,
  1441. deduce_mat2<A,B,2,1> >::type
  1442. operator*( A const & a, B const & b )
  1443. {
  1444. typedef typename mat_traits<A>::scalar_type Ta;
  1445. typedef typename mat_traits<B>::scalar_type Tb;
  1446. Ta const a00 = mat_traits<A>::template read_element<0,0>(a);
  1447. Ta const a01 = mat_traits<A>::template read_element<0,1>(a);
  1448. Ta const a10 = mat_traits<A>::template read_element<1,0>(a);
  1449. Ta const a11 = mat_traits<A>::template read_element<1,1>(a);
  1450. Tb const b00 = mat_traits<B>::template read_element<0,0>(b);
  1451. Tb const b10 = mat_traits<B>::template read_element<1,0>(b);
  1452. typedef typename deduce_mat2<A,B,2,1>::type R;
  1453. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==2);
  1454. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==1);
  1455. R r;
  1456. write_mat_element<0,0>(r,a00*b00+a01*b10);
  1457. write_mat_element<1,0>(r,a10*b00+a11*b10);
  1458. return r;
  1459. }
  1460. namespace
  1461. sfinae
  1462. {
  1463. using ::boost::qvm::operator*;
  1464. }
  1465. namespace
  1466. qvm_detail
  1467. {
  1468. template <int R,int /*CR*/,int C>
  1469. struct mul_mm_defined;
  1470. template <>
  1471. struct
  1472. mul_mm_defined<2,2,1>
  1473. {
  1474. static bool const value=true;
  1475. };
  1476. }
  1477. template <class A,class B>
  1478. BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
  1479. typename lazy_enable_if_c<
  1480. mat_traits<A>::rows==1 && mat_traits<B>::rows==2 &&
  1481. mat_traits<A>::cols==2 && mat_traits<B>::cols==2,
  1482. deduce_mat2<A,B,1,2> >::type
  1483. operator*( A const & a, B const & b )
  1484. {
  1485. typedef typename mat_traits<A>::scalar_type Ta;
  1486. typedef typename mat_traits<B>::scalar_type Tb;
  1487. Ta const a00 = mat_traits<A>::template read_element<0,0>(a);
  1488. Ta const a01 = mat_traits<A>::template read_element<0,1>(a);
  1489. Tb const b00 = mat_traits<B>::template read_element<0,0>(b);
  1490. Tb const b01 = mat_traits<B>::template read_element<0,1>(b);
  1491. Tb const b10 = mat_traits<B>::template read_element<1,0>(b);
  1492. Tb const b11 = mat_traits<B>::template read_element<1,1>(b);
  1493. typedef typename deduce_mat2<A,B,1,2>::type R;
  1494. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==1);
  1495. BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==2);
  1496. R r;
  1497. write_mat_element<0,0>(r,a00*b00+a01*b10);
  1498. write_mat_element<0,1>(r,a00*b01+a01*b11);
  1499. return r;
  1500. }
  1501. namespace
  1502. sfinae
  1503. {
  1504. using ::boost::qvm::operator*;
  1505. }
  1506. namespace
  1507. qvm_detail
  1508. {
  1509. template <int R,int /*CR*/,int C>
  1510. struct mul_mm_defined;
  1511. template <>
  1512. struct
  1513. mul_mm_defined<1,2,2>
  1514. {
  1515. static bool const value=true;
  1516. };
  1517. }
  1518. } }
  1519. #endif