File indexing completed on 2025-01-18 09:51:02
0001 #ifndef BOOST_QVM_GEN_VEC_MAT_OPERATIONS4_HPP_INCLUDED
0002 #define BOOST_QVM_GEN_VEC_MAT_OPERATIONS4_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==4 && mat_traits<A>::cols==4 &&
0023 vec_traits<B>::dim==4,
0024 deduce_vec2<A,B,4> >::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 a03 = mat_traits<A>::template read_element<0,3>(a);
0033 Ta const a10 = mat_traits<A>::template read_element<1,0>(a);
0034 Ta const a11 = mat_traits<A>::template read_element<1,1>(a);
0035 Ta const a12 = mat_traits<A>::template read_element<1,2>(a);
0036 Ta const a13 = mat_traits<A>::template read_element<1,3>(a);
0037 Ta const a20 = mat_traits<A>::template read_element<2,0>(a);
0038 Ta const a21 = mat_traits<A>::template read_element<2,1>(a);
0039 Ta const a22 = mat_traits<A>::template read_element<2,2>(a);
0040 Ta const a23 = mat_traits<A>::template read_element<2,3>(a);
0041 Ta const a30 = mat_traits<A>::template read_element<3,0>(a);
0042 Ta const a31 = mat_traits<A>::template read_element<3,1>(a);
0043 Ta const a32 = mat_traits<A>::template read_element<3,2>(a);
0044 Ta const a33 = mat_traits<A>::template read_element<3,3>(a);
0045 Tb const b0 = vec_traits<B>::template read_element<0>(b);
0046 Tb const b1 = vec_traits<B>::template read_element<1>(b);
0047 Tb const b2 = vec_traits<B>::template read_element<2>(b);
0048 Tb const b3 = vec_traits<B>::template read_element<3>(b);
0049 typedef typename deduce_vec2<A,B,4>::type R;
0050 BOOST_QVM_STATIC_ASSERT(vec_traits<R>::dim==4);
0051 R r;
0052 write_vec_element<0>(r,a00*b0+a01*b1+a02*b2+a03*b3);
0053 write_vec_element<1>(r,a10*b0+a11*b1+a12*b2+a13*b3);
0054 write_vec_element<2>(r,a20*b0+a21*b1+a22*b2+a23*b3);
0055 write_vec_element<3>(r,a30*b0+a31*b1+a32*b2+a33*b3);
0056 return r;
0057 }
0058
0059 namespace
0060 sfinae
0061 {
0062 using ::boost::qvm::operator*;
0063 }
0064
0065 namespace
0066 qvm_detail
0067 {
0068 template <int R,int C>
0069 struct mul_mv_defined;
0070
0071 template <>
0072 struct
0073 mul_mv_defined<4,4>
0074 {
0075 static bool const value=true;
0076 };
0077 }
0078
0079 template <class A,class B>
0080 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
0081 typename lazy_enable_if_c<
0082 mat_traits<B>::rows==4 && mat_traits<B>::cols==4 &&
0083 vec_traits<A>::dim==4,
0084 deduce_vec2<A,B,4> >::type
0085 operator*( A const & a, B const & b )
0086 {
0087 typedef typename vec_traits<A>::scalar_type Ta;
0088 typedef typename mat_traits<B>::scalar_type Tb;
0089 Ta const a0 = vec_traits<A>::template read_element<0>(a);
0090 Ta const a1 = vec_traits<A>::template read_element<1>(a);
0091 Ta const a2 = vec_traits<A>::template read_element<2>(a);
0092 Ta const a3 = vec_traits<A>::template read_element<3>(a);
0093 Tb const b00 = mat_traits<B>::template read_element<0,0>(b);
0094 Tb const b01 = mat_traits<B>::template read_element<0,1>(b);
0095 Tb const b02 = mat_traits<B>::template read_element<0,2>(b);
0096 Tb const b03 = mat_traits<B>::template read_element<0,3>(b);
0097 Tb const b10 = mat_traits<B>::template read_element<1,0>(b);
0098 Tb const b11 = mat_traits<B>::template read_element<1,1>(b);
0099 Tb const b12 = mat_traits<B>::template read_element<1,2>(b);
0100 Tb const b13 = mat_traits<B>::template read_element<1,3>(b);
0101 Tb const b20 = mat_traits<B>::template read_element<2,0>(b);
0102 Tb const b21 = mat_traits<B>::template read_element<2,1>(b);
0103 Tb const b22 = mat_traits<B>::template read_element<2,2>(b);
0104 Tb const b23 = mat_traits<B>::template read_element<2,3>(b);
0105 Tb const b30 = mat_traits<B>::template read_element<3,0>(b);
0106 Tb const b31 = mat_traits<B>::template read_element<3,1>(b);
0107 Tb const b32 = mat_traits<B>::template read_element<3,2>(b);
0108 Tb const b33 = mat_traits<B>::template read_element<3,3>(b);
0109 typedef typename deduce_vec2<A,B,4>::type R;
0110 BOOST_QVM_STATIC_ASSERT(vec_traits<R>::dim==4);
0111 R r;
0112 write_vec_element<0>(r,a0*b00+a1*b10+a2*b20+a3*b30);
0113 write_vec_element<1>(r,a0*b01+a1*b11+a2*b21+a3*b31);
0114 write_vec_element<2>(r,a0*b02+a1*b12+a2*b22+a3*b32);
0115 write_vec_element<3>(r,a0*b03+a1*b13+a2*b23+a3*b33);
0116 return r;
0117 }
0118
0119 namespace
0120 sfinae
0121 {
0122 using ::boost::qvm::operator*;
0123 }
0124
0125 namespace
0126 qvm_detail
0127 {
0128 template <int R,int C>
0129 struct mul_vm_defined;
0130
0131 template <>
0132 struct
0133 mul_vm_defined<4,4>
0134 {
0135 static bool const value=true;
0136 };
0137 }
0138
0139 } }
0140
0141 #endif