| 1 | #ifndef BOOST_QVM_GEN_VEC_OPERATIONS3_HPP_INCLUDED |
| 2 | #define BOOST_QVM_GEN_VEC_OPERATIONS3_HPP_INCLUDED |
| 3 | |
| 4 | // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc. |
| 5 | |
| 6 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 7 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 8 | |
| 9 | // This file was generated by a program. Do not edit manually. |
| 10 | |
| 11 | #include <boost/qvm/deduce_scalar.hpp> |
| 12 | #include <boost/qvm/deduce_vec.hpp> |
| 13 | #include <boost/qvm/error.hpp> |
| 14 | #include <boost/qvm/gen/vec_assign3.hpp> |
| 15 | #include <boost/qvm/math.hpp> |
| 16 | #include <boost/qvm/static_assert.hpp> |
| 17 | #include <boost/qvm/throw_exception.hpp> |
| 18 | |
| 19 | namespace boost { namespace qvm { |
| 20 | |
| 21 | template <class A,class B> |
| 22 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 23 | typename lazy_enable_if_c< |
| 24 | vec_traits<A>::dim==3 && vec_traits<B>::dim==3, |
| 25 | deduce_vec2<A,B,3> >::type |
| 26 | operator+( A const & a, B const & b ) |
| 27 | { |
| 28 | typedef typename deduce_vec2<A,B,3>::type R; |
| 29 | BOOST_QVM_STATIC_ASSERT(vec_traits<R>::dim==3); |
| 30 | R r; |
| 31 | write_vec_element<0>(r,vec_traits<A>::template read_element<0>(a)+vec_traits<B>::template read_element<0>(b)); |
| 32 | write_vec_element<1>(r,vec_traits<A>::template read_element<1>(a)+vec_traits<B>::template read_element<1>(b)); |
| 33 | write_vec_element<2>(r,vec_traits<A>::template read_element<2>(a)+vec_traits<B>::template read_element<2>(b)); |
| 34 | return r; |
| 35 | } |
| 36 | |
| 37 | namespace |
| 38 | sfinae |
| 39 | { |
| 40 | using ::boost::qvm::operator+; |
| 41 | } |
| 42 | |
| 43 | namespace |
| 44 | qvm_detail |
| 45 | { |
| 46 | template <int D> |
| 47 | struct plus_vv_defined; |
| 48 | |
| 49 | template <> |
| 50 | struct |
| 51 | plus_vv_defined<3> |
| 52 | { |
| 53 | static bool const value=true; |
| 54 | }; |
| 55 | } |
| 56 | |
| 57 | template <class A,class B> |
| 58 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 59 | typename lazy_enable_if_c< |
| 60 | vec_traits<A>::dim==3 && vec_traits<B>::dim==3, |
| 61 | deduce_vec2<A,B,3> >::type |
| 62 | operator-( A const & a, B const & b ) |
| 63 | { |
| 64 | typedef typename deduce_vec2<A,B,3>::type R; |
| 65 | BOOST_QVM_STATIC_ASSERT(vec_traits<R>::dim==3); |
| 66 | R r; |
| 67 | write_vec_element<0>(r,vec_traits<A>::template read_element<0>(a)-vec_traits<B>::template read_element<0>(b)); |
| 68 | write_vec_element<1>(r,vec_traits<A>::template read_element<1>(a)-vec_traits<B>::template read_element<1>(b)); |
| 69 | write_vec_element<2>(r,vec_traits<A>::template read_element<2>(a)-vec_traits<B>::template read_element<2>(b)); |
| 70 | return r; |
| 71 | } |
| 72 | |
| 73 | namespace |
| 74 | sfinae |
| 75 | { |
| 76 | using ::boost::qvm::operator-; |
| 77 | } |
| 78 | |
| 79 | namespace |
| 80 | qvm_detail |
| 81 | { |
| 82 | template <int D> |
| 83 | struct minus_vv_defined; |
| 84 | |
| 85 | template <> |
| 86 | struct |
| 87 | minus_vv_defined<3> |
| 88 | { |
| 89 | static bool const value=true; |
| 90 | }; |
| 91 | } |
| 92 | |
| 93 | template <class A,class B> |
| 94 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 95 | typename enable_if_c< |
| 96 | vec_traits<A>::dim==3 && vec_traits<B>::dim==3, |
| 97 | A &>::type |
| 98 | operator+=( A & a, B const & b ) |
| 99 | { |
| 100 | write_vec_element<0>(a,vec_traits<A>::template read_element<0>(a)+vec_traits<B>::template read_element<0>(b)); |
| 101 | write_vec_element<1>(a,vec_traits<A>::template read_element<1>(a)+vec_traits<B>::template read_element<1>(b)); |
| 102 | write_vec_element<2>(a,vec_traits<A>::template read_element<2>(a)+vec_traits<B>::template read_element<2>(b)); |
| 103 | return a; |
| 104 | } |
| 105 | |
| 106 | namespace |
| 107 | sfinae |
| 108 | { |
| 109 | using ::boost::qvm::operator+=; |
| 110 | } |
| 111 | |
| 112 | namespace |
| 113 | qvm_detail |
| 114 | { |
| 115 | template <int D> |
| 116 | struct plus_eq_vv_defined; |
| 117 | |
| 118 | template <> |
| 119 | struct |
| 120 | plus_eq_vv_defined<3> |
| 121 | { |
| 122 | static bool const value=true; |
| 123 | }; |
| 124 | } |
| 125 | |
| 126 | template <class A,class B> |
| 127 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 128 | typename enable_if_c< |
| 129 | vec_traits<A>::dim==3 && vec_traits<B>::dim==3, |
| 130 | A &>::type |
| 131 | operator-=( A & a, B const & b ) |
| 132 | { |
| 133 | write_vec_element<0>(a,vec_traits<A>::template read_element<0>(a)-vec_traits<B>::template read_element<0>(b)); |
| 134 | write_vec_element<1>(a,vec_traits<A>::template read_element<1>(a)-vec_traits<B>::template read_element<1>(b)); |
| 135 | write_vec_element<2>(a,vec_traits<A>::template read_element<2>(a)-vec_traits<B>::template read_element<2>(b)); |
| 136 | return a; |
| 137 | } |
| 138 | |
| 139 | namespace |
| 140 | sfinae |
| 141 | { |
| 142 | using ::boost::qvm::operator-=; |
| 143 | } |
| 144 | |
| 145 | namespace |
| 146 | qvm_detail |
| 147 | { |
| 148 | template <int D> |
| 149 | struct minus_eq_vv_defined; |
| 150 | |
| 151 | template <> |
| 152 | struct |
| 153 | minus_eq_vv_defined<3> |
| 154 | { |
| 155 | static bool const value=true; |
| 156 | }; |
| 157 | } |
| 158 | |
| 159 | template <class A,class B> |
| 160 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 161 | typename lazy_enable_if_c< |
| 162 | vec_traits<A>::dim==3 && is_scalar<B>::value, |
| 163 | deduce_vec2<A,B,vec_traits<A>::dim> >::type |
| 164 | operator*( A const & a, B b ) |
| 165 | { |
| 166 | typedef typename deduce_vec2<A,B,vec_traits<A>::dim>::type R; |
| 167 | R r; |
| 168 | write_vec_element<0>(r,vec_traits<A>::template read_element<0>(a)*b); |
| 169 | write_vec_element<1>(r,vec_traits<A>::template read_element<1>(a)*b); |
| 170 | write_vec_element<2>(r,vec_traits<A>::template read_element<2>(a)*b); |
| 171 | return r; |
| 172 | } |
| 173 | |
| 174 | namespace |
| 175 | sfinae |
| 176 | { |
| 177 | using ::boost::qvm::operator*; |
| 178 | } |
| 179 | |
| 180 | namespace |
| 181 | qvm_detail |
| 182 | { |
| 183 | template <int D> |
| 184 | struct mul_vs_defined; |
| 185 | |
| 186 | template <> |
| 187 | struct |
| 188 | mul_vs_defined<3> |
| 189 | { |
| 190 | static bool const value=true; |
| 191 | }; |
| 192 | } |
| 193 | |
| 194 | template <class A,class B> |
| 195 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 196 | typename lazy_enable_if_c< |
| 197 | is_scalar<A>::value && vec_traits<B>::dim==3, |
| 198 | deduce_vec2<A,B,vec_traits<B>::dim> >::type |
| 199 | operator*( A a, B const & b ) |
| 200 | { |
| 201 | typedef typename deduce_vec2<A,B,vec_traits<B>::dim>::type R; |
| 202 | R r; |
| 203 | write_vec_element<0>(r,a*vec_traits<B>::template read_element<0>(b)); |
| 204 | write_vec_element<1>(r,a*vec_traits<B>::template read_element<1>(b)); |
| 205 | write_vec_element<2>(r,a*vec_traits<B>::template read_element<2>(b)); |
| 206 | return r; |
| 207 | } |
| 208 | |
| 209 | namespace |
| 210 | sfinae |
| 211 | { |
| 212 | using ::boost::qvm::operator*; |
| 213 | } |
| 214 | |
| 215 | namespace |
| 216 | qvm_detail |
| 217 | { |
| 218 | template <int D> |
| 219 | struct mul_sv_defined; |
| 220 | |
| 221 | template <> |
| 222 | struct |
| 223 | mul_sv_defined<3> |
| 224 | { |
| 225 | static bool const value=true; |
| 226 | }; |
| 227 | } |
| 228 | |
| 229 | template <class A,class B> |
| 230 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 231 | typename enable_if_c< |
| 232 | vec_traits<A>::dim==3 && is_scalar<B>::value, |
| 233 | A &>::type |
| 234 | operator*=( A & a, B b ) |
| 235 | { |
| 236 | write_vec_element<0>(a, vec_traits<A>::template read_element<0>(a)*b); |
| 237 | write_vec_element<1>(a, vec_traits<A>::template read_element<1>(a)*b); |
| 238 | write_vec_element<2>(a, vec_traits<A>::template read_element<2>(a)*b); |
| 239 | return a; |
| 240 | } |
| 241 | |
| 242 | namespace |
| 243 | sfinae |
| 244 | { |
| 245 | using ::boost::qvm::operator*=; |
| 246 | } |
| 247 | |
| 248 | namespace |
| 249 | qvm_detail |
| 250 | { |
| 251 | template <int D> |
| 252 | struct mul_eq_vs_defined; |
| 253 | |
| 254 | template <> |
| 255 | struct |
| 256 | mul_eq_vs_defined<3> |
| 257 | { |
| 258 | static bool const value=true; |
| 259 | }; |
| 260 | } |
| 261 | |
| 262 | template <class A,class B> |
| 263 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 264 | typename lazy_enable_if_c< |
| 265 | vec_traits<A>::dim==3 && is_scalar<B>::value, |
| 266 | deduce_vec2<A,B,vec_traits<A>::dim> >::type |
| 267 | operator/( A const & a, B b ) |
| 268 | { |
| 269 | typedef typename deduce_vec2<A,B,vec_traits<A>::dim>::type R; |
| 270 | R r; |
| 271 | write_vec_element<0>(r,vec_traits<A>::template read_element<0>(a)/b); |
| 272 | write_vec_element<1>(r,vec_traits<A>::template read_element<1>(a)/b); |
| 273 | write_vec_element<2>(r,vec_traits<A>::template read_element<2>(a)/b); |
| 274 | return r; |
| 275 | } |
| 276 | |
| 277 | namespace |
| 278 | sfinae |
| 279 | { |
| 280 | using ::boost::qvm::operator/; |
| 281 | } |
| 282 | |
| 283 | namespace |
| 284 | qvm_detail |
| 285 | { |
| 286 | template <int D> |
| 287 | struct div_vs_defined; |
| 288 | |
| 289 | template <> |
| 290 | struct |
| 291 | div_vs_defined<3> |
| 292 | { |
| 293 | static bool const value=true; |
| 294 | }; |
| 295 | } |
| 296 | |
| 297 | template <class A,class B> |
| 298 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 299 | typename enable_if_c< |
| 300 | vec_traits<A>::dim==3 && is_scalar<B>::value, |
| 301 | A &>::type |
| 302 | operator/=( A & a, B b ) |
| 303 | { |
| 304 | write_vec_element<0>(a, vec_traits<A>::template read_element<0>(a)/b); |
| 305 | write_vec_element<1>(a, vec_traits<A>::template read_element<1>(a)/b); |
| 306 | write_vec_element<2>(a, vec_traits<A>::template read_element<2>(a)/b); |
| 307 | return a; |
| 308 | } |
| 309 | |
| 310 | namespace |
| 311 | sfinae |
| 312 | { |
| 313 | using ::boost::qvm::operator/=; |
| 314 | } |
| 315 | |
| 316 | namespace |
| 317 | qvm_detail |
| 318 | { |
| 319 | template <int D> |
| 320 | struct div_eq_vs_defined; |
| 321 | |
| 322 | template <> |
| 323 | struct |
| 324 | div_eq_vs_defined<3> |
| 325 | { |
| 326 | static bool const value=true; |
| 327 | }; |
| 328 | } |
| 329 | |
| 330 | template <class R,class A> |
| 331 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 332 | typename enable_if_c< |
| 333 | is_vec<A>::value && |
| 334 | vec_traits<R>::dim==3 && vec_traits<A>::dim==3, |
| 335 | R>::type |
| 336 | convert_to( A const & a ) |
| 337 | { |
| 338 | R r; |
| 339 | write_vec_element<0>(r,vec_traits<A>::template read_element<0>(a)); |
| 340 | write_vec_element<1>(r,vec_traits<A>::template read_element<1>(a)); |
| 341 | write_vec_element<2>(r,vec_traits<A>::template read_element<2>(a)); |
| 342 | return r; |
| 343 | } |
| 344 | |
| 345 | namespace |
| 346 | sfinae |
| 347 | { |
| 348 | using ::boost::qvm::convert_to; |
| 349 | } |
| 350 | |
| 351 | namespace |
| 352 | qvm_detail |
| 353 | { |
| 354 | template <int D> |
| 355 | struct convert_to_v_defined; |
| 356 | |
| 357 | template <> |
| 358 | struct |
| 359 | convert_to_v_defined<3> |
| 360 | { |
| 361 | static bool const value=true; |
| 362 | }; |
| 363 | } |
| 364 | |
| 365 | template <class A,class B> |
| 366 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 367 | typename enable_if_c< |
| 368 | vec_traits<A>::dim==3 && vec_traits<B>::dim==3, |
| 369 | bool>::type |
| 370 | operator==( A const & a, B const & b ) |
| 371 | { |
| 372 | return |
| 373 | vec_traits<A>::template read_element<0>(a)==vec_traits<B>::template read_element<0>(b) && |
| 374 | vec_traits<A>::template read_element<1>(a)==vec_traits<B>::template read_element<1>(b) && |
| 375 | vec_traits<A>::template read_element<2>(a)==vec_traits<B>::template read_element<2>(b); |
| 376 | } |
| 377 | |
| 378 | namespace |
| 379 | sfinae |
| 380 | { |
| 381 | using ::boost::qvm::operator==; |
| 382 | } |
| 383 | |
| 384 | namespace |
| 385 | qvm_detail |
| 386 | { |
| 387 | template <int D> |
| 388 | struct eq_vv_defined; |
| 389 | |
| 390 | template <> |
| 391 | struct |
| 392 | eq_vv_defined<3> |
| 393 | { |
| 394 | static bool const value=true; |
| 395 | }; |
| 396 | } |
| 397 | |
| 398 | template <class A,class B> |
| 399 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 400 | typename enable_if_c< |
| 401 | vec_traits<A>::dim==3 && vec_traits<B>::dim==3, |
| 402 | bool>::type |
| 403 | operator!=( A const & a, B const & b ) |
| 404 | { |
| 405 | return |
| 406 | !(vec_traits<A>::template read_element<0>(a)==vec_traits<B>::template read_element<0>(b)) || |
| 407 | !(vec_traits<A>::template read_element<1>(a)==vec_traits<B>::template read_element<1>(b)) || |
| 408 | !(vec_traits<A>::template read_element<2>(a)==vec_traits<B>::template read_element<2>(b)); |
| 409 | } |
| 410 | |
| 411 | namespace |
| 412 | sfinae |
| 413 | { |
| 414 | using ::boost::qvm::operator!=; |
| 415 | } |
| 416 | |
| 417 | namespace |
| 418 | qvm_detail |
| 419 | { |
| 420 | template <int D> |
| 421 | struct neq_vv_defined; |
| 422 | |
| 423 | template <> |
| 424 | struct |
| 425 | neq_vv_defined<3> |
| 426 | { |
| 427 | static bool const value=true; |
| 428 | }; |
| 429 | } |
| 430 | |
| 431 | template <class A> |
| 432 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 433 | typename lazy_enable_if_c< |
| 434 | vec_traits<A>::dim==3, |
| 435 | deduce_vec<A> >::type |
| 436 | operator-( A const & a ) |
| 437 | { |
| 438 | typedef typename deduce_vec<A>::type R; |
| 439 | R r; |
| 440 | write_vec_element<0>(r,-vec_traits<A>::template read_element<0>(a)); |
| 441 | write_vec_element<1>(r,-vec_traits<A>::template read_element<1>(a)); |
| 442 | write_vec_element<2>(r,-vec_traits<A>::template read_element<2>(a)); |
| 443 | return r; |
| 444 | } |
| 445 | |
| 446 | namespace |
| 447 | sfinae |
| 448 | { |
| 449 | using ::boost::qvm::operator-; |
| 450 | } |
| 451 | |
| 452 | namespace |
| 453 | qvm_detail |
| 454 | { |
| 455 | template <int D> |
| 456 | struct minus_v_defined; |
| 457 | |
| 458 | template <> |
| 459 | struct |
| 460 | minus_v_defined<3> |
| 461 | { |
| 462 | static bool const value=true; |
| 463 | }; |
| 464 | } |
| 465 | |
| 466 | template <class A> |
| 467 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 468 | typename enable_if_c< |
| 469 | is_vec<A>::value && vec_traits<A>::dim==3, |
| 470 | typename vec_traits<A>::scalar_type>::type |
| 471 | mag( A const & a ) |
| 472 | { |
| 473 | typedef typename vec_traits<A>::scalar_type T; |
| 474 | T const a0=vec_traits<A>::template read_element<0>(a); |
| 475 | T const a1=vec_traits<A>::template read_element<1>(a); |
| 476 | T const a2=vec_traits<A>::template read_element<2>(a); |
| 477 | T const m2=a0*a0+a1*a1+a2*a2; |
| 478 | T const mag=sqrt(m2); |
| 479 | return mag; |
| 480 | } |
| 481 | |
| 482 | namespace |
| 483 | sfinae |
| 484 | { |
| 485 | using ::boost::qvm::mag; |
| 486 | } |
| 487 | |
| 488 | namespace |
| 489 | qvm_detail |
| 490 | { |
| 491 | template <int D> |
| 492 | struct mag_v_defined; |
| 493 | |
| 494 | template <> |
| 495 | struct |
| 496 | mag_v_defined<3> |
| 497 | { |
| 498 | static bool const value=true; |
| 499 | }; |
| 500 | } |
| 501 | |
| 502 | template <class A> |
| 503 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 504 | typename enable_if_c< |
| 505 | is_vec<A>::value && vec_traits<A>::dim==3, |
| 506 | typename vec_traits<A>::scalar_type>::type |
| 507 | mag_sqr( A const & a ) |
| 508 | { |
| 509 | typedef typename vec_traits<A>::scalar_type T; |
| 510 | T const a0=vec_traits<A>::template read_element<0>(a); |
| 511 | T const a1=vec_traits<A>::template read_element<1>(a); |
| 512 | T const a2=vec_traits<A>::template read_element<2>(a); |
| 513 | T const m2=a0*a0+a1*a1+a2*a2; |
| 514 | return m2; |
| 515 | } |
| 516 | |
| 517 | namespace |
| 518 | sfinae |
| 519 | { |
| 520 | using ::boost::qvm::mag_sqr; |
| 521 | } |
| 522 | |
| 523 | namespace |
| 524 | qvm_detail |
| 525 | { |
| 526 | template <int D> |
| 527 | struct mag_sqr_v_defined; |
| 528 | |
| 529 | template <> |
| 530 | struct |
| 531 | mag_sqr_v_defined<3> |
| 532 | { |
| 533 | static bool const value=true; |
| 534 | }; |
| 535 | } |
| 536 | |
| 537 | template <class A> |
| 538 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 539 | typename lazy_enable_if_c< |
| 540 | vec_traits<A>::dim==3, |
| 541 | deduce_vec<A> >::type |
| 542 | normalized( A const & a ) |
| 543 | { |
| 544 | typedef typename vec_traits<A>::scalar_type T; |
| 545 | T const a0=vec_traits<A>::template read_element<0>(a); |
| 546 | T const a1=vec_traits<A>::template read_element<1>(a); |
| 547 | T const a2=vec_traits<A>::template read_element<2>(a); |
| 548 | T const m2=a0*a0+a1*a1+a2*a2; |
| 549 | if( m2==scalar_traits<typename vec_traits<A>::scalar_type>::value(0) ) |
| 550 | BOOST_QVM_THROW_EXCEPTION(e: zero_magnitude_error()); |
| 551 | T const rm=scalar_traits<T>::value(1)/sqrt(m2); |
| 552 | typedef typename deduce_vec<A>::type R; |
| 553 | R r; |
| 554 | write_vec_element<0>(r,a0*rm); |
| 555 | write_vec_element<1>(r,a1*rm); |
| 556 | write_vec_element<2>(r,a2*rm); |
| 557 | return r; |
| 558 | } |
| 559 | |
| 560 | namespace |
| 561 | sfinae |
| 562 | { |
| 563 | using ::boost::qvm::normalized; |
| 564 | } |
| 565 | |
| 566 | template <class A> |
| 567 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 568 | typename enable_if_c< |
| 569 | vec_traits<A>::dim==3, |
| 570 | void>::type |
| 571 | normalize( A & a ) |
| 572 | { |
| 573 | typedef typename vec_traits<A>::scalar_type T; |
| 574 | T const a0=vec_traits<A>::template read_element<0>(a); |
| 575 | T const a1=vec_traits<A>::template read_element<1>(a); |
| 576 | T const a2=vec_traits<A>::template read_element<2>(a); |
| 577 | T const m2=a0*a0+a1*a1+a2*a2; |
| 578 | if( m2==scalar_traits<typename vec_traits<A>::scalar_type>::value(0) ) |
| 579 | BOOST_QVM_THROW_EXCEPTION(e: zero_magnitude_error()); |
| 580 | T const rm=scalar_traits<T>::value(1)/sqrt(m2); |
| 581 | write_vec_element<0>(a,vec_traits<A>::template read_element<0>(a)*rm); |
| 582 | write_vec_element<1>(a,vec_traits<A>::template read_element<1>(a)*rm); |
| 583 | write_vec_element<2>(a,vec_traits<A>::template read_element<2>(a)*rm); |
| 584 | } |
| 585 | |
| 586 | namespace |
| 587 | sfinae |
| 588 | { |
| 589 | using ::boost::qvm::normalize; |
| 590 | } |
| 591 | |
| 592 | namespace |
| 593 | qvm_detail |
| 594 | { |
| 595 | template <int D> |
| 596 | struct normalize_v_defined; |
| 597 | |
| 598 | template <> |
| 599 | struct |
| 600 | normalize_v_defined<3> |
| 601 | { |
| 602 | static bool const value=true; |
| 603 | }; |
| 604 | } |
| 605 | |
| 606 | template <class A,class B> |
| 607 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS |
| 608 | typename lazy_enable_if_c< |
| 609 | vec_traits<A>::dim==3 && vec_traits<B>::dim==3, |
| 610 | deduce_scalar<typename vec_traits<A>::scalar_type,typename vec_traits<B>::scalar_type> >::type |
| 611 | dot( A const & a, B const & b ) |
| 612 | { |
| 613 | typedef typename vec_traits<A>::scalar_type Ta; |
| 614 | typedef typename vec_traits<B>::scalar_type Tb; |
| 615 | typedef typename deduce_scalar<Ta,Tb>::type Tr; |
| 616 | Ta const a0=vec_traits<A>::template read_element<0>(a); |
| 617 | Ta const a1=vec_traits<A>::template read_element<1>(a); |
| 618 | Ta const a2=vec_traits<A>::template read_element<2>(a); |
| 619 | Tb const b0=vec_traits<B>::template read_element<0>(b); |
| 620 | Tb const b1=vec_traits<B>::template read_element<1>(b); |
| 621 | Tb const b2=vec_traits<B>::template read_element<2>(b); |
| 622 | Tr const dot=a0*b0+a1*b1+a2*b2; |
| 623 | return dot; |
| 624 | } |
| 625 | |
| 626 | namespace |
| 627 | sfinae |
| 628 | { |
| 629 | using ::boost::qvm::dot; |
| 630 | } |
| 631 | |
| 632 | namespace |
| 633 | qvm_detail |
| 634 | { |
| 635 | template <int D> |
| 636 | struct dot_vv_defined; |
| 637 | |
| 638 | template <> |
| 639 | struct |
| 640 | dot_vv_defined<3> |
| 641 | { |
| 642 | static bool const value=true; |
| 643 | }; |
| 644 | } |
| 645 | |
| 646 | } } |
| 647 | |
| 648 | #endif |
| 649 | |