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