File indexing completed on 2025-01-18 09:51:02
0001 #ifndef BOOST_QVM_GEN_VEC_MAT_OPERATIONS3_HPP_INCLUDED
0002 #define BOOST_QVM_GEN_VEC_MAT_OPERATIONS3_HPP_INCLUDED
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <boost/qvm/config.hpp>
0012 #include <boost/qvm/deduce_vec.hpp>
0013 #include <boost/qvm/enable_if.hpp>
0014 #include <boost/qvm/mat_traits.hpp>
0015 #include <boost/qvm/vec_traits.hpp>
0016
0017 namespace boost { namespace qvm {
0018
0019 template <class A,class B>
0020 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
0021 typename lazy_enable_if_c<
0022 mat_traits<A>::rows==3 && mat_traits<A>::cols==3 &&
0023 vec_traits<B>::dim==3,
0024 deduce_vec2<A,B,3> >::type
0025 operator*( A const & a, B const & b )
0026 {
0027 typedef typename mat_traits<A>::scalar_type Ta;
0028 typedef typename vec_traits<B>::scalar_type Tb;
0029 Ta const a00 = mat_traits<A>::template read_element<0,0>(a);
0030 Ta const a01 = mat_traits<A>::template read_element<0,1>(a);
0031 Ta const a02 = mat_traits<A>::template read_element<0,2>(a);
0032 Ta const a10 = mat_traits<A>::template read_element<1,0>(a);
0033 Ta const a11 = mat_traits<A>::template read_element<1,1>(a);
0034 Ta const a12 = mat_traits<A>::template read_element<1,2>(a);
0035 Ta const a20 = mat_traits<A>::template read_element<2,0>(a);
0036 Ta const a21 = mat_traits<A>::template read_element<2,1>(a);
0037 Ta const a22 = mat_traits<A>::template read_element<2,2>(a);
0038 Tb const b0 = vec_traits<B>::template read_element<0>(b);
0039 Tb const b1 = vec_traits<B>::template read_element<1>(b);
0040 Tb const b2 = vec_traits<B>::template read_element<2>(b);
0041 typedef typename deduce_vec2<A,B,3>::type R;
0042 BOOST_QVM_STATIC_ASSERT(vec_traits<R>::dim==3);
0043 R r;
0044 write_vec_element<0>(r,a00*b0+a01*b1+a02*b2);
0045 write_vec_element<1>(r,a10*b0+a11*b1+a12*b2);
0046 write_vec_element<2>(r,a20*b0+a21*b1+a22*b2);
0047 return r;
0048 }
0049
0050 namespace
0051 sfinae
0052 {
0053 using ::boost::qvm::operator*;
0054 }
0055
0056 namespace
0057 qvm_detail
0058 {
0059 template <int R,int C>
0060 struct mul_mv_defined;
0061
0062 template <>
0063 struct
0064 mul_mv_defined<3,3>
0065 {
0066 static bool const value=true;
0067 };
0068 }
0069
0070 template <class A,class B>
0071 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
0072 typename lazy_enable_if_c<
0073 mat_traits<B>::rows==3 && mat_traits<B>::cols==3 &&
0074 vec_traits<A>::dim==3,
0075 deduce_vec2<A,B,3> >::type
0076 operator*( A const & a, B const & b )
0077 {
0078 typedef typename vec_traits<A>::scalar_type Ta;
0079 typedef typename mat_traits<B>::scalar_type Tb;
0080 Ta const a0 = vec_traits<A>::template read_element<0>(a);
0081 Ta const a1 = vec_traits<A>::template read_element<1>(a);
0082 Ta const a2 = vec_traits<A>::template read_element<2>(a);
0083 Tb const b00 = mat_traits<B>::template read_element<0,0>(b);
0084 Tb const b01 = mat_traits<B>::template read_element<0,1>(b);
0085 Tb const b02 = mat_traits<B>::template read_element<0,2>(b);
0086 Tb const b10 = mat_traits<B>::template read_element<1,0>(b);
0087 Tb const b11 = mat_traits<B>::template read_element<1,1>(b);
0088 Tb const b12 = mat_traits<B>::template read_element<1,2>(b);
0089 Tb const b20 = mat_traits<B>::template read_element<2,0>(b);
0090 Tb const b21 = mat_traits<B>::template read_element<2,1>(b);
0091 Tb const b22 = mat_traits<B>::template read_element<2,2>(b);
0092 typedef typename deduce_vec2<A,B,3>::type R;
0093 BOOST_QVM_STATIC_ASSERT(vec_traits<R>::dim==3);
0094 R r;
0095 write_vec_element<0>(r,a0*b00+a1*b10+a2*b20);
0096 write_vec_element<1>(r,a0*b01+a1*b11+a2*b21);
0097 write_vec_element<2>(r,a0*b02+a1*b12+a2*b22);
0098 return r;
0099 }
0100
0101 namespace
0102 sfinae
0103 {
0104 using ::boost::qvm::operator*;
0105 }
0106
0107 namespace
0108 qvm_detail
0109 {
0110 template <int R,int C>
0111 struct mul_vm_defined;
0112
0113 template <>
0114 struct
0115 mul_vm_defined<3,3>
0116 {
0117 static bool const value=true;
0118 };
0119 }
0120
0121 } }
0122
0123 #endif