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
0019
0020 #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_MKL_MKL_OPERATIONS_HPP_INCLUDED
0021 #define BOOST_NUMERIC_ODEINT_EXTERNAL_MKL_MKL_OPERATIONS_HPP_INCLUDED
0022
0023 #include <iostream>
0024
0025 #include <mkl_cblas.h>
0026 #include <boost/numeric/odeint/algebra/default_operations.hpp>
0027
0028
0029
0030
0031
0032
0033
0034 namespace boost {
0035 namespace numeric {
0036 namespace odeint {
0037
0038
0039 struct mkl_operations
0040 {
0041
0042
0043 template< class F1 = double , class F2 = F1 >
0044 struct scale_sum2
0045 {
0046 typedef double Fac1;
0047 typedef double Fac2;
0048 const Fac1 m_alpha1;
0049 const Fac2 m_alpha2;
0050
0051 scale_sum2( const Fac1 alpha1 , const Fac2 alpha2 ) : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) { }
0052
0053 template< class T1 , class T2 , class T3 >
0054 void operator()( T1 &t1 , const T2 &t2 , const T3 &t3) const
0055 {
0056
0057
0058 const int n = t1.size();
0059
0060 if( &(t2[0]) != &(t1[0]) )
0061 {
0062 cblas_dcopy( n , &(t2[0]) , 1 , &(t1[0]) , 1 );
0063 }
0064 cblas_dscal( n , m_alpha1 , &(t1[0]) , 1 );
0065 cblas_daxpy( n , m_alpha2 , &(t3[0]) , 1 , &(t1[0]) , 1 );
0066
0067 }
0068 };
0069
0070 template< class F1 = double , class F2 = F1 , class F3 = F2 >
0071 struct scale_sum3
0072 {
0073 typedef double Fac1;
0074 typedef double Fac2;
0075 typedef double Fac3;
0076 const Fac1 m_alpha1;
0077 const Fac2 m_alpha2;
0078 const Fac3 m_alpha3;
0079
0080 scale_sum3( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 )
0081 : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) { }
0082
0083 template< class T1 , class T2 , class T3 , class T4 >
0084 void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 ) const
0085 {
0086
0087
0088 const int n = t1.size();
0089
0090 if( &(t2[0]) != &(t1[0]) )
0091 {
0092 cblas_dcopy( n , &(t2[0]) , 1 , &(t1[0]) , 1 );
0093 }
0094 cblas_dscal( n , m_alpha1 , &(t1[0]) , 1 );
0095 cblas_daxpy( n , m_alpha2 , &(t3[0]) , 1 , &(t1[0]) , 1 );
0096
0097 cblas_daxpy( n , m_alpha3 , &(t4[0]) , 1 , &(t1[0]) , 1 );
0098 }
0099 };
0100
0101 template< class F1 = double , class F2 = F1 , class F3 = F2 , class F4 = F3 >
0102 struct scale_sum4
0103 {
0104 typedef double Fac1;
0105 typedef double Fac2;
0106 typedef double Fac3;
0107 typedef double Fac4;
0108 const Fac1 m_alpha1;
0109 const Fac2 m_alpha2;
0110 const Fac3 m_alpha3;
0111 const Fac4 m_alpha4;
0112
0113 scale_sum4( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 , const Fac4 alpha4 )
0114 : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) { }
0115
0116 template< class T1 , class T2 , class T3 , class T4 , class T5 >
0117 void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 ) const
0118 {
0119
0120
0121 const int n = t1.size();
0122
0123 if( &(t2[0]) != &(t1[0]) )
0124 {
0125 cblas_dcopy( n , &(t2[0]) , 1 , &(t1[0]) , 1 );
0126 }
0127
0128 cblas_dscal( n , m_alpha1 , &(t1[0]) , 1 );
0129 cblas_daxpy( n , m_alpha2 , &(t3[0]) , 1 , &(t1[0]) , 1 );
0130
0131 cblas_daxpy( n , m_alpha3 , &(t4[0]) , 1 , &(t1[0]) , 1 );
0132 cblas_daxpy( n , m_alpha4 , &(t5[0]) , 1 , &(t1[0]) , 1 );
0133 }
0134 };
0135
0136
0137 template< class F1 = double , class F2 = F1 , class F3 = F2 , class F4 = F3 , class F5 = F4 >
0138 struct scale_sum5
0139 {
0140 typedef double Fac1;
0141 typedef double Fac2;
0142 typedef double Fac3;
0143 typedef double Fac4;
0144 typedef double Fac5;
0145 const Fac1 m_alpha1;
0146 const Fac2 m_alpha2;
0147 const Fac3 m_alpha3;
0148 const Fac4 m_alpha4;
0149 const Fac5 m_alpha5;
0150
0151 scale_sum5( const Fac1 alpha1 , const Fac2 alpha2 , const Fac3 alpha3 , const Fac4 alpha4 , const Fac5 alpha5 )
0152 : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) { }
0153
0154 template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 >
0155 void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 ) const
0156 {
0157
0158
0159 const int n = t1.size();
0160
0161 if( &(t2[0]) != &(t1[0]) )
0162 {
0163 cblas_dcopy( n , &(t2[0]) , 1 , &(t1[0]) , 1 );
0164 }
0165
0166 cblas_dscal( n , m_alpha1 , &(t1[0]) , 1 );
0167 cblas_daxpy( n , m_alpha2 , &(t3[0]) , 1 , &(t1[0]) , 1 );
0168
0169 cblas_daxpy( n , m_alpha3 , &(t4[0]) , 1 , &(t1[0]) , 1 );
0170 cblas_daxpy( n , m_alpha4 , &(t5[0]) , 1 , &(t1[0]) , 1 );
0171 cblas_daxpy( n , m_alpha5 , &(t6[0]) , 1 , &(t1[0]) , 1 );
0172 }
0173 };
0174
0175 };
0176
0177 }
0178 }
0179 }
0180
0181 #endif