mat_operations2.hpp 43 KB

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