mat_operations2.hpp 43 KB

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