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