File indexing completed on 2025-09-15 08:51:33
0001 #ifndef BOOST_QVM_GEN_VEC_MAT_OPERATIONS2_HPP_INCLUDED
0002 #define BOOST_QVM_GEN_VEC_MAT_OPERATIONS2_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==2 && mat_traits<A>::cols==2 &&
0021 vec_traits<B>::dim==2,
0022 deduce_vec2<A,B,2> >::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 a10 = mat_traits<A>::template read_element<1,0>(a);
0030 Ta const a11 = mat_traits<A>::template read_element<1,1>(a);
0031 Tb const b0 = vec_traits<B>::template read_element<0>(b);
0032 Tb const b1 = vec_traits<B>::template read_element<1>(b);
0033 typedef typename deduce_vec2<A,B,2>::type R;
0034 BOOST_QVM_STATIC_ASSERT(vec_traits<R>::dim==2);
0035 R r;
0036 write_vec_element<0>(r,a00*b0+a01*b1);
0037 write_vec_element<1>(r,a10*b0+a11*b1);
0038 return r;
0039 }
0040
0041 namespace
0042 sfinae
0043 {
0044 using ::boost::qvm::operator*;
0045 }
0046
0047 namespace
0048 qvm_detail
0049 {
0050 template <int R,int C>
0051 struct mul_mv_defined;
0052
0053 template <>
0054 struct
0055 mul_mv_defined<2,2>
0056 {
0057 static bool const value=true;
0058 };
0059 }
0060
0061 template <class A,class B>
0062 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_OPERATIONS
0063 typename lazy_enable_if_c<
0064 mat_traits<B>::rows==2 && mat_traits<B>::cols==2 &&
0065 vec_traits<A>::dim==2,
0066 deduce_vec2<A,B,2> >::type
0067 operator*( A const & a, B const & b )
0068 {
0069 typedef typename vec_traits<A>::scalar_type Ta;
0070 typedef typename mat_traits<B>::scalar_type Tb;
0071 Ta const a0 = vec_traits<A>::template read_element<0>(a);
0072 Ta const a1 = vec_traits<A>::template read_element<1>(a);
0073 Tb const b00 = mat_traits<B>::template read_element<0,0>(b);
0074 Tb const b01 = mat_traits<B>::template read_element<0,1>(b);
0075 Tb const b10 = mat_traits<B>::template read_element<1,0>(b);
0076 Tb const b11 = mat_traits<B>::template read_element<1,1>(b);
0077 typedef typename deduce_vec2<A,B,2>::type R;
0078 BOOST_QVM_STATIC_ASSERT(vec_traits<R>::dim==2);
0079 R r;
0080 write_vec_element<0>(r,a0*b00+a1*b10);
0081 write_vec_element<1>(r,a0*b01+a1*b11);
0082 return r;
0083 }
0084
0085 namespace
0086 sfinae
0087 {
0088 using ::boost::qvm::operator*;
0089 }
0090
0091 namespace
0092 qvm_detail
0093 {
0094 template <int R,int C>
0095 struct mul_vm_defined;
0096
0097 template <>
0098 struct
0099 mul_vm_defined<2,2>
0100 {
0101 static bool const value=true;
0102 };
0103 }
0104
0105 } }
0106
0107 #endif