File indexing completed on 2025-01-30 09:59:03
0001 #ifndef BOOST_QVM_DEDUCE_MAT_HPP_INCLUDED
0002 #define BOOST_QVM_DEDUCE_MAT_HPP_INCLUDED
0003
0004
0005
0006
0007
0008
0009 #include <boost/qvm/deduce_scalar.hpp>
0010 #include <boost/qvm/mat_traits.hpp>
0011 #include <boost/qvm/static_assert.hpp>
0012
0013 namespace boost { namespace qvm {
0014
0015 template <class T,int Rows,int Cols>
0016 struct mat;
0017
0018 namespace
0019 qvm_detail
0020 {
0021 template <class M,int R,int C,class S,
0022 int MR=mat_traits<M>::rows,
0023 int MC=mat_traits<M>::cols,
0024 class MS=typename mat_traits<M>::scalar_type>
0025 struct
0026 deduce_m_default
0027 {
0028 BOOST_QVM_STATIC_ASSERT(is_mat<M>::value);
0029 typedef mat<typename mat_traits<M>::scalar_type,R,C> type;
0030 };
0031
0032 template <class M,int R,int C,class S>
0033 struct
0034 deduce_m_default<M,R,C,S,R,C,S>
0035 {
0036 BOOST_QVM_STATIC_ASSERT(is_mat<M>::value);
0037 typedef M type;
0038 };
0039 }
0040
0041 template <class M,int R=mat_traits<M>::rows,int C=mat_traits<M>::cols,class S=typename mat_traits<M>::scalar_type>
0042 struct
0043 deduce_mat
0044 {
0045 BOOST_QVM_STATIC_ASSERT(is_mat<M>::value);
0046 typedef typename qvm_detail::deduce_m_default<M,R,C,S>::type type;
0047 };
0048
0049 namespace
0050 qvm_detail
0051 {
0052 template <class A,class B,int R,int C,class S,
0053 bool IsScalarA=is_scalar<A>::value,
0054 bool IsScalarB=is_scalar<B>::value>
0055 struct
0056 deduce_m2_default
0057 {
0058 typedef mat<S,R,C> type;
0059 };
0060
0061 template <class M,int R,int C,class S>
0062 struct
0063 deduce_m2_default<M,M,R,C,S,false,false>
0064 {
0065 BOOST_QVM_STATIC_ASSERT(is_mat<M>::value);
0066 typedef M type;
0067 };
0068
0069 template <class A,class B,int R,int C,class S>
0070 struct
0071 deduce_m2_default<A,B,R,C,S,false,true>
0072 {
0073 BOOST_QVM_STATIC_ASSERT(is_mat<A>::value);
0074 typedef typename deduce_mat<A,R,C,S>::type type;
0075 };
0076
0077 template <class A,class B,int R,int C,class S>
0078 struct
0079 deduce_m2_default<A,B,R,C,S,true,false>
0080 {
0081 BOOST_QVM_STATIC_ASSERT(is_mat<B>::value);
0082 typedef typename deduce_mat<B,R,C,S>::type type;
0083 };
0084 }
0085
0086 template <class A,class B,int R,int C,class S=typename deduce_scalar<typename scalar<A>::type,typename scalar<B>::type>::type>
0087 struct
0088 deduce_mat2
0089 {
0090 BOOST_QVM_STATIC_ASSERT(is_mat<A>::value || is_mat<B>::value);
0091 typedef typename qvm_detail::deduce_m2_default<A,B,R,C,S>::type type;
0092 };
0093
0094 } }
0095
0096 #endif