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