mat_operations3.hpp 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910
  1. #ifndef BOOST_QVM_GEN_MAT_OPERATIONS3_HPP_INCLUDED
  2. #define BOOST_QVM_GEN_MAT_OPERATIONS3_HPP_INCLUDED
  3. /// Copyright (c) 2008-2021 Emil Dotchevski and Reverge Studios, Inc.
  4. /// Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. /// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /// This file was generated by a program. Do not edit manually.
  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_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. mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)+mat_traits<B>::template read_element<0,0>(b);
  29. mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)+mat_traits<B>::template read_element<0,1>(b);
  30. mat_traits<R>::template write_element<0,2>(r)=mat_traits<A>::template read_element<0,2>(a)+mat_traits<B>::template read_element<0,2>(b);
  31. mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)+mat_traits<B>::template read_element<1,0>(b);
  32. mat_traits<R>::template write_element<1,1>(r)=mat_traits<A>::template read_element<1,1>(a)+mat_traits<B>::template read_element<1,1>(b);
  33. mat_traits<R>::template write_element<1,2>(r)=mat_traits<A>::template read_element<1,2>(a)+mat_traits<B>::template read_element<1,2>(b);
  34. mat_traits<R>::template write_element<2,0>(r)=mat_traits<A>::template read_element<2,0>(a)+mat_traits<B>::template read_element<2,0>(b);
  35. mat_traits<R>::template write_element<2,1>(r)=mat_traits<A>::template read_element<2,1>(a)+mat_traits<B>::template read_element<2,1>(b);
  36. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)+mat_traits<B>::template read_element<0,0>(b);
  69. mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)+mat_traits<B>::template read_element<1,0>(b);
  70. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)+mat_traits<B>::template read_element<0,0>(b);
  103. mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)+mat_traits<B>::template read_element<0,1>(b);
  104. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)-mat_traits<B>::template read_element<0,0>(b);
  137. mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)-mat_traits<B>::template read_element<0,1>(b);
  138. mat_traits<R>::template write_element<0,2>(r)=mat_traits<A>::template read_element<0,2>(a)-mat_traits<B>::template read_element<0,2>(b);
  139. mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)-mat_traits<B>::template read_element<1,0>(b);
  140. mat_traits<R>::template write_element<1,1>(r)=mat_traits<A>::template read_element<1,1>(a)-mat_traits<B>::template read_element<1,1>(b);
  141. mat_traits<R>::template write_element<1,2>(r)=mat_traits<A>::template read_element<1,2>(a)-mat_traits<B>::template read_element<1,2>(b);
  142. mat_traits<R>::template write_element<2,0>(r)=mat_traits<A>::template read_element<2,0>(a)-mat_traits<B>::template read_element<2,0>(b);
  143. mat_traits<R>::template write_element<2,1>(r)=mat_traits<A>::template read_element<2,1>(a)-mat_traits<B>::template read_element<2,1>(b);
  144. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)-mat_traits<B>::template read_element<0,0>(b);
  177. mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)-mat_traits<B>::template read_element<1,0>(b);
  178. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)-mat_traits<B>::template read_element<0,0>(b);
  211. mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)-mat_traits<B>::template read_element<0,1>(b);
  212. mat_traits<R>::template write_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_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. mat_traits<A>::template write_element<0,0>(a)+=mat_traits<B>::template read_element<0,0>(b);
  241. mat_traits<A>::template write_element<0,1>(a)+=mat_traits<B>::template read_element<0,1>(b);
  242. mat_traits<A>::template write_element<0,2>(a)+=mat_traits<B>::template read_element<0,2>(b);
  243. mat_traits<A>::template write_element<1,0>(a)+=mat_traits<B>::template read_element<1,0>(b);
  244. mat_traits<A>::template write_element<1,1>(a)+=mat_traits<B>::template read_element<1,1>(b);
  245. mat_traits<A>::template write_element<1,2>(a)+=mat_traits<B>::template read_element<1,2>(b);
  246. mat_traits<A>::template write_element<2,0>(a)+=mat_traits<B>::template read_element<2,0>(b);
  247. mat_traits<A>::template write_element<2,1>(a)+=mat_traits<B>::template read_element<2,1>(b);
  248. mat_traits<A>::template write_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_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. mat_traits<A>::template write_element<0,0>(a)+=mat_traits<B>::template read_element<0,0>(b);
  277. mat_traits<A>::template write_element<1,0>(a)+=mat_traits<B>::template read_element<1,0>(b);
  278. mat_traits<A>::template write_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_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. mat_traits<A>::template write_element<0,0>(a)+=mat_traits<B>::template read_element<0,0>(b);
  307. mat_traits<A>::template write_element<0,1>(a)+=mat_traits<B>::template read_element<0,1>(b);
  308. mat_traits<A>::template write_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_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. mat_traits<A>::template write_element<0,0>(a)-=mat_traits<B>::template read_element<0,0>(b);
  337. mat_traits<A>::template write_element<0,1>(a)-=mat_traits<B>::template read_element<0,1>(b);
  338. mat_traits<A>::template write_element<0,2>(a)-=mat_traits<B>::template read_element<0,2>(b);
  339. mat_traits<A>::template write_element<1,0>(a)-=mat_traits<B>::template read_element<1,0>(b);
  340. mat_traits<A>::template write_element<1,1>(a)-=mat_traits<B>::template read_element<1,1>(b);
  341. mat_traits<A>::template write_element<1,2>(a)-=mat_traits<B>::template read_element<1,2>(b);
  342. mat_traits<A>::template write_element<2,0>(a)-=mat_traits<B>::template read_element<2,0>(b);
  343. mat_traits<A>::template write_element<2,1>(a)-=mat_traits<B>::template read_element<2,1>(b);
  344. mat_traits<A>::template write_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_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. mat_traits<A>::template write_element<0,0>(a)-=mat_traits<B>::template read_element<0,0>(b);
  373. mat_traits<A>::template write_element<1,0>(a)-=mat_traits<B>::template read_element<1,0>(b);
  374. mat_traits<A>::template write_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_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. mat_traits<A>::template write_element<0,0>(a)-=mat_traits<B>::template read_element<0,0>(b);
  403. mat_traits<A>::template write_element<0,1>(a)-=mat_traits<B>::template read_element<0,1>(b);
  404. mat_traits<A>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)*b;
  434. mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)*b;
  435. mat_traits<R>::template write_element<0,2>(r)=mat_traits<A>::template read_element<0,2>(a)*b;
  436. mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)*b;
  437. mat_traits<R>::template write_element<1,1>(r)=mat_traits<A>::template read_element<1,1>(a)*b;
  438. mat_traits<R>::template write_element<1,2>(r)=mat_traits<A>::template read_element<1,2>(a)*b;
  439. mat_traits<R>::template write_element<2,0>(r)=mat_traits<A>::template read_element<2,0>(a)*b;
  440. mat_traits<R>::template write_element<2,1>(r)=mat_traits<A>::template read_element<2,1>(a)*b;
  441. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=a*mat_traits<B>::template read_element<0,0>(b);
  471. mat_traits<R>::template write_element<0,1>(r)=a*mat_traits<B>::template read_element<0,1>(b);
  472. mat_traits<R>::template write_element<0,2>(r)=a*mat_traits<B>::template read_element<0,2>(b);
  473. mat_traits<R>::template write_element<1,0>(r)=a*mat_traits<B>::template read_element<1,0>(b);
  474. mat_traits<R>::template write_element<1,1>(r)=a*mat_traits<B>::template read_element<1,1>(b);
  475. mat_traits<R>::template write_element<1,2>(r)=a*mat_traits<B>::template read_element<1,2>(b);
  476. mat_traits<R>::template write_element<2,0>(r)=a*mat_traits<B>::template read_element<2,0>(b);
  477. mat_traits<R>::template write_element<2,1>(r)=a*mat_traits<B>::template read_element<2,1>(b);
  478. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)*b;
  508. mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)*b;
  509. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=a*mat_traits<B>::template read_element<0,0>(b);
  539. mat_traits<R>::template write_element<1,0>(r)=a*mat_traits<B>::template read_element<1,0>(b);
  540. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)*b;
  570. mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)*b;
  571. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=a*mat_traits<B>::template read_element<0,0>(b);
  601. mat_traits<R>::template write_element<0,1>(r)=a*mat_traits<B>::template read_element<0,1>(b);
  602. mat_traits<R>::template write_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_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. mat_traits<A>::template write_element<0,0>(a)*=b;
  630. mat_traits<A>::template write_element<0,1>(a)*=b;
  631. mat_traits<A>::template write_element<0,2>(a)*=b;
  632. mat_traits<A>::template write_element<1,0>(a)*=b;
  633. mat_traits<A>::template write_element<1,1>(a)*=b;
  634. mat_traits<A>::template write_element<1,2>(a)*=b;
  635. mat_traits<A>::template write_element<2,0>(a)*=b;
  636. mat_traits<A>::template write_element<2,1>(a)*=b;
  637. mat_traits<A>::template write_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_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. mat_traits<A>::template write_element<0,0>(a)*=b;
  665. mat_traits<A>::template write_element<1,0>(a)*=b;
  666. mat_traits<A>::template write_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_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. mat_traits<A>::template write_element<0,0>(a)*=b;
  694. mat_traits<A>::template write_element<0,1>(a)*=b;
  695. mat_traits<A>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)/b;
  725. mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)/b;
  726. mat_traits<R>::template write_element<0,2>(r)=mat_traits<A>::template read_element<0,2>(a)/b;
  727. mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)/b;
  728. mat_traits<R>::template write_element<1,1>(r)=mat_traits<A>::template read_element<1,1>(a)/b;
  729. mat_traits<R>::template write_element<1,2>(r)=mat_traits<A>::template read_element<1,2>(a)/b;
  730. mat_traits<R>::template write_element<2,0>(r)=mat_traits<A>::template read_element<2,0>(a)/b;
  731. mat_traits<R>::template write_element<2,1>(r)=mat_traits<A>::template read_element<2,1>(a)/b;
  732. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=a/mat_traits<B>::template read_element<0,0>(b);
  762. mat_traits<R>::template write_element<0,1>(r)=a/mat_traits<B>::template read_element<0,1>(b);
  763. mat_traits<R>::template write_element<0,2>(r)=a/mat_traits<B>::template read_element<0,2>(b);
  764. mat_traits<R>::template write_element<1,0>(r)=a/mat_traits<B>::template read_element<1,0>(b);
  765. mat_traits<R>::template write_element<1,1>(r)=a/mat_traits<B>::template read_element<1,1>(b);
  766. mat_traits<R>::template write_element<1,2>(r)=a/mat_traits<B>::template read_element<1,2>(b);
  767. mat_traits<R>::template write_element<2,0>(r)=a/mat_traits<B>::template read_element<2,0>(b);
  768. mat_traits<R>::template write_element<2,1>(r)=a/mat_traits<B>::template read_element<2,1>(b);
  769. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)/b;
  799. mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)/b;
  800. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=a/mat_traits<B>::template read_element<0,0>(b);
  830. mat_traits<R>::template write_element<1,0>(r)=a/mat_traits<B>::template read_element<1,0>(b);
  831. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)/b;
  861. mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)/b;
  862. mat_traits<R>::template write_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_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. mat_traits<A>::template write_element<0,0>(a)/=b;
  890. mat_traits<A>::template write_element<0,1>(a)/=b;
  891. mat_traits<A>::template write_element<0,2>(a)/=b;
  892. mat_traits<A>::template write_element<1,0>(a)/=b;
  893. mat_traits<A>::template write_element<1,1>(a)/=b;
  894. mat_traits<A>::template write_element<1,2>(a)/=b;
  895. mat_traits<A>::template write_element<2,0>(a)/=b;
  896. mat_traits<A>::template write_element<2,1>(a)/=b;
  897. mat_traits<A>::template write_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_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. mat_traits<A>::template write_element<0,0>(a)/=b;
  925. mat_traits<A>::template write_element<1,0>(a)/=b;
  926. mat_traits<A>::template write_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_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. mat_traits<A>::template write_element<0,0>(a)/=b;
  954. mat_traits<A>::template write_element<0,1>(a)/=b;
  955. mat_traits<A>::template write_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_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. mat_traits<R>::template write_element<0,0>(r) = mat_traits<A>::template read_element<0,0>(a);
  985. mat_traits<R>::template write_element<0,1>(r) = mat_traits<A>::template read_element<0,1>(a);
  986. mat_traits<R>::template write_element<0,2>(r) = mat_traits<A>::template read_element<0,2>(a);
  987. mat_traits<R>::template write_element<1,0>(r) = mat_traits<A>::template read_element<1,0>(a);
  988. mat_traits<R>::template write_element<1,1>(r) = mat_traits<A>::template read_element<1,1>(a);
  989. mat_traits<R>::template write_element<1,2>(r) = mat_traits<A>::template read_element<1,2>(a);
  990. mat_traits<R>::template write_element<2,0>(r) = mat_traits<A>::template read_element<2,0>(a);
  991. mat_traits<R>::template write_element<2,1>(r) = mat_traits<A>::template read_element<2,1>(a);
  992. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r) = one - two*(cc+dd);
  1021. mat_traits<R>::template write_element<0,1>(r) = two*(bc-ad);
  1022. mat_traits<R>::template write_element<0,2>(r) = two*(bd+ac);
  1023. mat_traits<R>::template write_element<1,0>(r) = two*(bc+ad);
  1024. mat_traits<R>::template write_element<1,1>(r) = one - two*(bb+dd);
  1025. mat_traits<R>::template write_element<1,2>(r) = two*(cd-ab);
  1026. mat_traits<R>::template write_element<2,0>(r) = two*(bd-ac);
  1027. mat_traits<R>::template write_element<2,1>(r) = two*(cd+ab);
  1028. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r) = mat_traits<A>::template read_element<0,0>(a);
  1058. mat_traits<R>::template write_element<1,0>(r) = mat_traits<A>::template read_element<1,0>(a);
  1059. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r) = mat_traits<A>::template read_element<0,0>(a);
  1089. mat_traits<R>::template write_element<0,1>(r) = mat_traits<A>::template read_element<0,1>(a);
  1090. mat_traits<R>::template write_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_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_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_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_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_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_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_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. mat_traits<R>::template write_element<0,0>(r)=-mat_traits<A>::template read_element<0,0>(a);
  1312. mat_traits<R>::template write_element<0,1>(r)=-mat_traits<A>::template read_element<0,1>(a);
  1313. mat_traits<R>::template write_element<0,2>(r)=-mat_traits<A>::template read_element<0,2>(a);
  1314. mat_traits<R>::template write_element<1,0>(r)=-mat_traits<A>::template read_element<1,0>(a);
  1315. mat_traits<R>::template write_element<1,1>(r)=-mat_traits<A>::template read_element<1,1>(a);
  1316. mat_traits<R>::template write_element<1,2>(r)=-mat_traits<A>::template read_element<1,2>(a);
  1317. mat_traits<R>::template write_element<2,0>(r)=-mat_traits<A>::template read_element<2,0>(a);
  1318. mat_traits<R>::template write_element<2,1>(r)=-mat_traits<A>::template read_element<2,1>(a);
  1319. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=-mat_traits<A>::template read_element<0,0>(a);
  1349. mat_traits<R>::template write_element<1,0>(r)=-mat_traits<A>::template read_element<1,0>(a);
  1350. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=-mat_traits<A>::template read_element<0,0>(a);
  1380. mat_traits<R>::template write_element<0,1>(r)=-mat_traits<A>::template read_element<0,1>(a);
  1381. mat_traits<R>::template write_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_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_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. mat_traits<R>::template write_element<0,0>(r)= f*(a11*a22-a12*a21);
  1460. mat_traits<R>::template write_element<0,1>(r)=-f*(a01*a22-a02*a21);
  1461. mat_traits<R>::template write_element<0,2>(r)= f*(a01*a12-a02*a11);
  1462. mat_traits<R>::template write_element<1,0>(r)=-f*(a10*a22-a12*a20);
  1463. mat_traits<R>::template write_element<1,1>(r)= f*(a00*a22-a02*a20);
  1464. mat_traits<R>::template write_element<1,2>(r)=-f*(a00*a12-a02*a10);
  1465. mat_traits<R>::template write_element<2,0>(r)= f*(a10*a21-a11*a20);
  1466. mat_traits<R>::template write_element<2,1>(r)=-f*(a00*a21-a01*a20);
  1467. mat_traits<R>::template write_element<2,2>(r)= f*(a00*a11-a01*a10);
  1468. return r;
  1469. }
  1470. template <class A>
  1471. 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_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. mat_traits<R>::template write_element<0,0>(r)=a00*b00+a01*b10+a02*b20;
  1533. mat_traits<R>::template write_element<0,1>(r)=a00*b01+a01*b11+a02*b21;
  1534. mat_traits<R>::template write_element<0,2>(r)=a00*b02+a01*b12+a02*b22;
  1535. mat_traits<R>::template write_element<1,0>(r)=a10*b00+a11*b10+a12*b20;
  1536. mat_traits<R>::template write_element<1,1>(r)=a10*b01+a11*b11+a12*b21;
  1537. mat_traits<R>::template write_element<1,2>(r)=a10*b02+a11*b12+a12*b22;
  1538. mat_traits<R>::template write_element<2,0>(r)=a20*b00+a21*b10+a22*b20;
  1539. mat_traits<R>::template write_element<2,1>(r)=a20*b01+a21*b11+a22*b21;
  1540. mat_traits<R>::template write_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_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. mat_traits<A>::template write_element<0,0>(a)=a00*b00+a01*b10+a02*b20;
  1589. mat_traits<A>::template write_element<0,1>(a)=a00*b01+a01*b11+a02*b21;
  1590. mat_traits<A>::template write_element<0,2>(a)=a00*b02+a01*b12+a02*b22;
  1591. mat_traits<A>::template write_element<1,0>(a)=a10*b00+a11*b10+a12*b20;
  1592. mat_traits<A>::template write_element<1,1>(a)=a10*b01+a11*b11+a12*b21;
  1593. mat_traits<A>::template write_element<1,2>(a)=a10*b02+a11*b12+a12*b22;
  1594. mat_traits<A>::template write_element<2,0>(a)=a20*b00+a21*b10+a22*b20;
  1595. mat_traits<A>::template write_element<2,1>(a)=a20*b01+a21*b11+a22*b21;
  1596. mat_traits<A>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=a00*b00+a01*b10+a02*b20;
  1643. mat_traits<R>::template write_element<1,0>(r)=a10*b00+a11*b10+a12*b20;
  1644. mat_traits<R>::template write_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_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. mat_traits<R>::template write_element<0,0>(r)=a00*b00+a01*b10+a02*b20;
  1691. mat_traits<R>::template write_element<0,1>(r)=a00*b01+a01*b11+a02*b21;
  1692. mat_traits<R>::template write_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