mat_operations3.hpp 57 KB

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