File indexing completed on 2025-01-18 09:42:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_VECTOR_SPACE_ALGEBRA_HPP_INCLUDED
0019 #define BOOST_NUMERIC_ODEINT_ALGEBRA_VECTOR_SPACE_ALGEBRA_HPP_INCLUDED
0020
0021 #include <complex>
0022
0023 #include <boost/type_traits/remove_reference.hpp>
0024
0025
0026 namespace boost {
0027 namespace numeric {
0028 namespace odeint {
0029
0030
0031
0032
0033 template< class State, class Enabler = void > struct vector_space_norm_inf;
0034
0035
0036
0037
0038 template<>
0039 struct vector_space_norm_inf< double >
0040 {
0041 typedef double result_type;
0042 double operator()( double x ) const
0043 {
0044 using std::abs;
0045 return abs(x);
0046 }
0047 };
0048
0049 template<>
0050 struct vector_space_norm_inf< float >
0051 {
0052 typedef float result_type;
0053 result_type operator()( float x ) const
0054 {
0055 using std::abs;
0056 return abs(x);
0057 }
0058 };
0059
0060 template< typename T >
0061 struct vector_space_norm_inf< std::complex<T> >
0062 {
0063 typedef T result_type;
0064 result_type operator()( std::complex<T> x ) const
0065 {
0066 using std::abs;
0067 return abs( x );
0068 }
0069 };
0070
0071 struct vector_space_algebra
0072 {
0073 template< class S1 , class Op >
0074 static void for_each1( S1 &s1 , Op op )
0075 {
0076
0077 op( s1 );
0078 }
0079
0080 template< class S1 , class S2 , class Op >
0081 static void for_each2( S1 &s1 , S2 &s2 , Op op )
0082 {
0083 op( s1 , s2 );
0084 }
0085
0086 template< class S1 , class S2 , class S3 , class Op >
0087 static void for_each3( S1 &s1 , S2 &s2 , S3 &s3 , Op op )
0088 {
0089 op( s1 , s2 , s3 );
0090 }
0091
0092 template< class S1 , class S2 , class S3 , class S4 , class Op >
0093 static void for_each4( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , Op op )
0094 {
0095 op( s1 , s2 , s3 , s4 );
0096 }
0097
0098 template< class S1 , class S2 , class S3 , class S4 , class S5 , class Op >
0099 static void for_each5( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , Op op )
0100 {
0101 op( s1 , s2 , s3 , s4 , s5 );
0102 }
0103
0104 template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 , class Op >
0105 static void for_each6( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , Op op )
0106 {
0107 op( s1 , s2 , s3 , s4 , s5 , s6 );
0108 }
0109
0110 template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class Op >
0111 static void for_each7( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , Op op )
0112 {
0113 op( s1 , s2 , s3 , s4 , s5 , s6 , s7 );
0114 }
0115
0116 template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class Op >
0117 static void for_each8( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , Op op )
0118 {
0119 op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 );
0120 }
0121
0122 template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class Op >
0123 static void for_each9( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , Op op )
0124 {
0125 op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 );
0126 }
0127
0128 template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class S10 , class Op >
0129 static void for_each10( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , Op op )
0130 {
0131 op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 );
0132 }
0133
0134 template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class S10 , class S11 , class Op >
0135 static void for_each11( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , Op op )
0136 {
0137 op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 );
0138 }
0139
0140 template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class S10 , class S11 , class S12 , class Op >
0141 static void for_each12( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , S12 &s12 , Op op )
0142 {
0143 op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 );
0144 }
0145
0146 template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class S10 , class S11 , class S12 , class S13 , class Op >
0147 static void for_each13( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , S12 &s12 , S13 &s13 , Op op )
0148 {
0149 op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 , s13 );
0150 }
0151
0152 template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class S10 , class S11 , class S12 , class S13 , class S14 , class Op >
0153 static void for_each14( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , S12 &s12 , S13 &s13 , S14 &s14 , Op op )
0154 {
0155 op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 , s13 , s14 );
0156 }
0157
0158 template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class S10 , class S11 , class S12 , class S13 , class S14 , class S15 , class Op >
0159 static void for_each15( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , S12 &s12 , S13 &s13 , S14 &s14 , S15 &s15 , Op op )
0160 {
0161 op( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 , s13 , s14 , s15 );
0162 }
0163
0164 template< class S >
0165 static typename boost::numeric::odeint::vector_space_norm_inf< S >::result_type norm_inf( const S &s )
0166 {
0167 boost::numeric::odeint::vector_space_norm_inf< S > n;
0168 return n( s );
0169 }
0170 };
0171
0172
0173 }
0174 }
0175 }
0176
0177
0178 #endif