Skip to content

Commit

Permalink
Add selector
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Sep 11, 2024
1 parent 7500e83 commit 91cceeb
Showing 1 changed file with 58 additions and 34 deletions.
92 changes: 58 additions & 34 deletions include/boost/math/quadrature/detail/tanh_sinh_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@ void tanh_sinh_detail<Real, Policy>::prune_to_min_complement(const Real& m)
#include <boost/math/tools/cstdint.hpp>
#include <boost/math/tools/type_traits.hpp>
#include <boost/math/tools/numeric_limits.hpp>
#include <boost/math/tools/precision.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/math/special_functions/fpclassify.hpp>

Expand All @@ -895,30 +896,30 @@ namespace math {
namespace quadrature {
namespace detail {

__constant__ m_abscissas_float_1[5] =
__constant__ float m_abscissas_float_1[5] =
{ 0.0f, -0.04863203593f, -2.252280754e-05f, -4.294161056e-14f, -1.167648898e-37f, };

__constant__ m_abscissas_float_2[4] =
__constant__ float m_abscissas_float_2[4] =
{ -0.3257285078f, -0.002485143543f, -1.112433512e-08f, -5.378491591e-23f, };

__constant__ m_abscissas_float_3[8] =
__constant__ float m_abscissas_float_3[8] =
{ 0.3772097382f, -0.1404309413f, -0.01295943949f, -0.0003117359716f, -7.952628853e-07f, -4.714355182e-11f,
-5.415222824e-18f, -2.040300394e-29f, };

__constant__ m_abscissas_float_4[16] =
__constant__ float m_abscissas_float_4[16] =
{ 0.1943570033f, -0.4608532946f, -0.219392561f, -0.08512073674f, -0.0260331318f, -0.005944493369f,
-0.0009348035442f, -9.061530486e-05f, -4.683958779e-06f, -1.072183876e-07f, -8.572949078e-10f,
-1.767834693e-12f, -6.374878495e-16f, -2.442937279e-20f, -5.251546473e-26f, -2.789467162e-33f, };

__constant__ m_abscissas_float_5[32] =
__constant__ float m_abscissas_float_5[32] =
{ 0.09792388529f, 0.2878799327f, 0.4612535439f, -0.3897263425f, -0.2689819652f, -0.1766829945f, -0.1101085972f,
-0.06483914248f, -0.03588783578f, -0.01854517332f, -0.008873007558f, -0.003891334562f, -0.001545791232f,
-0.0005485655647f, -0.0001711779271f, -4.612899437e-05f, -1.051798518e-05f, -1.982859405e-06f, -3.011058474e-07f,
-3.576091908e-08f, -3.212800902e-09f, -2.102671378e-10f, -9.606066479e-12f, -2.919026641e-13f, -5.586116639e-15f,
-6.328207135e-17f, -3.956461339e-19f, -1.260975845e-21f, -1.872492175e-24f, -1.170030294e-27f, -2.740986178e-31f,
-2.112282721e-35f, };

__constant__ m_abscissas_float_6[64] =
__constant__ float m_abscissas_float_6[64] =
{ 0.04905596731f, 0.1464179843f, 0.2415663195f, 0.3331422646f, 0.4199521113f, -0.4989866106f, -0.4244155094f,
-0.356823241f, -0.2964499949f, -0.2433060914f, -0.1972012587f, -0.1577807536f, -0.1245646024f, -0.09698671849f,
-0.07443136593f, -0.05626521395f, -0.04186397729f, -0.0306332671f, -0.02202376481f, -0.01554116883f,
Expand All @@ -931,7 +932,7 @@ __constant__ m_abscissas_float_6[64] =
-1.030178138e-23f, -3.224484876e-25f, -8.0747829e-27f, -1.594654602e-28f, -2.445723975e-30f, -2.865919772e-32f,
-2.521682525e-34f, -1.63551444e-36f, };

__constant__ m_abscissas_float_7[128] =
__constant__ float m_abscissas_float_7[128] =
{ 0.02453976357f, 0.07352512299f, 0.1222291222f, 0.1704679724f, 0.2180634735f, 0.2648450766f, 0.3106517806f,
0.3553338252f, 0.3987541505f, 0.440789599f, 0.4813318461f, -0.4797119493f, -0.4424187717f, -0.4068496464f,
-0.3730497919f, -0.3410490083f, -0.3108622749f, -0.2824905325f, -0.2559216165f, -0.2311313132f, -0.2080845076f,
Expand All @@ -954,7 +955,7 @@ __constant__ m_abscissas_float_7[128] =
-4.353200528e-28f, -5.749955668e-29f, -7.122715927e-30f, -8.25783542e-31f, -8.941541007e-32f, -9.02279665e-33f,
-8.46603012e-34f, -7.369272807e-35f, -5.936632356e-36f, -4.415277839e-37f, };

__constant__ m_abscissas_float_8[256] =
__constant__ float m_abscissas_float_8[256] =
{ 0.01227135512f, 0.03680228095f, 0.06129788941f, 0.08573475488f, 0.1100896299f, 0.1343395153f, 0.1584617283f,
0.1824339697f, 0.2062343883f, 0.2298416433f, 0.2532349634f, 0.2763942036f, 0.2992998981f, 0.3219333097f,
0.3442764756f, 0.3663122492f, 0.3880243378f, 0.4093973357f, 0.4304167537f, 0.4510690435f, 0.4713416183f,
Expand Down Expand Up @@ -1009,29 +1010,29 @@ __constant__ float* m_abscissas_float[8] = {
m_abscissas_float_8,
};

__constant__ m_weights_float_1[5] =
__constant__ float m_weights_float_1[5] =
{ 1.570796327f, 0.2300223945f, 0.0002662005138f, 1.358178427e-12f, 1.001741678e-35f, };

__constant__ m_weights_float_2[4] =
__constant__ float m_weights_float_2[4] =
{ 0.9659765794f, 0.01834316699f, 2.143120456e-07f, 2.800315102e-21f, };

__constant__ m_weights_float_3[8] =
__constant__ float m_weights_float_3[8] =
{ 1.389614759f, 0.5310782754f, 0.07638574357f, 0.002902517748f, 1.198370136e-05f, 1.163116581e-09f,
2.197079236e-16f, 1.363510331e-27f, };

__constant__ m_weights_float_4[16] =
__constant__ float m_weights_float_4[16] =
{ 1.523283719f, 1.193463026f, 0.7374378484f, 0.3604614185f, 0.1374221077f, 0.03917500549f, 0.007742601026f,
0.0009499468043f, 6.248255924e-05f, 1.826332059e-06f, 1.868728227e-08f, 4.937853878e-11f, 2.28349267e-14f,
1.122753143e-18f, 3.09765397e-24f, 2.112123344e-31f, };

__constant__ m_weights_float_5[32] =
__constant__ float m_weights_float_5[32] =
{ 1.558773356f, 1.466014427f, 1.29747575f, 1.081634985f, 0.8501728565f, 0.6304051352f, 0.4408332363f, 0.2902406793f,
0.1793244121f, 0.1034321542f, 0.05528968374f, 0.02713351001f, 0.0120835436f, 0.004816298144f, 0.001690873998f,
0.0005133938241f, 0.0001320523413f, 2.811016433e-05f, 4.823718203e-06f, 6.477756604e-07f, 6.583518513e-08f,
4.876006097e-09f, 2.521634792e-10f, 8.675931415e-12f, 1.880207173e-13f, 2.412423038e-15f, 1.708453277e-17f,
6.168256849e-20f, 1.037679724e-22f, 7.345984103e-26f, 1.949783362e-29f, 1.702438776e-33f, };

__constant__ m_weights_float_6[64] =
__constant__ float m_weights_float_6[64] =
{ 1.567781431f, 1.543881116f, 1.497226223f, 1.430008355f, 1.345278885f, 1.246701207f, 1.138272243f, 1.024044933f,
0.9078793792f, 0.7932427008f, 0.6830685163f, 0.5796781031f, 0.4847580912f, 0.3993847415f, 0.3240825396f,
0.2589046395f, 0.2035239989f, 0.1573262035f, 0.1194974113f, 0.08910313924f, 0.06515553343f, 0.04666820805f,
Expand All @@ -1043,7 +1044,7 @@ __constant__ m_weights_float_6[64] =
1.346994157e-20f, 5.533583499e-22f, 1.843546975e-23f, 4.913936871e-25f, 1.032939131e-26f, 1.686277004e-28f, 2.103305749e-30f,
1.96992098e-32f, 1.359989462e-34f, };

__constant__ m_weights_float_7[128] =
__constant__ float m_weights_float_7[128] =
{ 1.570042029f, 1.564021404f, 1.55205317f, 1.534281738f, 1.510919723f, 1.482243298f, 1.448586255f, 1.410332971f,
1.367910512f, 1.321780117f, 1.272428346f, 1.22035811f, 1.16607987f, 1.110103194f, 1.05292888f, 0.995041804f,
0.9369046127f, 0.8789523456f, 0.8215880353f, 0.7651792989f, 0.7100559012f, 0.6565082461f, 0.6047867306f, 0.555101878f,
Expand All @@ -1063,7 +1064,7 @@ __constant__ m_weights_float_7[128] =
1.91431069e-25f, 2.776125103e-26f, 3.783124073e-27f, 4.834910155e-28f, 5.783178697e-29f, 6.460575703e-30f, 6.72603739e-31f,
6.511153451e-32f, 5.847409075e-33f, 4.860046055e-34f, 3.72923953e-35f, };

__constant__ m_weights_float_8[256] =
__constant__ float m_weights_float_8[256] =
{ 1.570607717f, 1.569099695f, 1.566088239f, 1.561582493f, 1.555596115f, 1.548147191f, 1.539258145f, 1.528955608f,
1.517270275f, 1.504236738f, 1.489893298f, 1.474281762f, 1.457447221f, 1.439437815f, 1.420304486f, 1.400100716f,
1.378882264f, 1.35670689f, 1.333634075f, 1.309724744f, 1.285040985f, 1.259645765f, 1.233602657f, 1.206975567f,
Expand Down Expand Up @@ -1112,28 +1113,28 @@ __constant__ float* m_weights_float[8] = {
m_weights_float_8
};

__constant__ m_abscissas_double_1[7] =
__constant__ double m_abscissas_double_1[7] =
{ 0, -0.0486320359272530543, -2.25228075384071351e-05, -4.29416105587824078e-14, -1.16764889750986093e-37,
-1.14795299162938991e-101, -1.22565381365848647e-275, };

__constant__ m_abscissas_double_2[6] =
__constant__ double m_abscissas_double_2[6] =
{ -0.325728507751564174, -0.00248514354277561317, -1.1124335118015332e-08, -5.37849159139368877e-23,
-7.9430213192221161e-62, -2.38712281858192662e-167, };

__constant__ m_abscissas_double_3[12] =
__constant__ double m_abscissas_double_3[12] =
{ 0.377209738164034174, -0.140430941310103365, -0.0129594394926231083, -0.000311735971646790949,
-7.95262885287335534e-07, -4.71435518232225751e-11, -5.41522282380723085e-18, -2.04030039435249433e-29,
-3.05969013536445003e-48, -2.86219841925875116e-79, -2.00703306915332264e-130, -9.24799327395281672e-215, };

__constant__ m_abscissas_double_4[24] =
__constant__ double m_abscissas_double_4[24] =
{ 0.194357003324935432, -0.460853294612032231, -0.219392561016799701, -0.0851207367354253891, -0.0260331318043225514,
-0.00594449336859785671, -0.000934803544214153575, -9.06153048560001614e-05, -4.68395877947156992e-06,
-1.07218387581618094e-07, -8.57294907821677329e-10, -1.76783469283872037e-12, -6.37487849504443965e-16,
-2.44293727908521732e-20, -5.25154647301957486e-26, -2.78946716228941774e-33, -1.2781108980938045e-42,
-1.3082723368531808e-54, -5.27997812261025438e-70, -9.06191040541810149e-90, -3.79031527880246479e-115,
-9.83017699648704421e-148, -1.41780355464723683e-189, -2.67381847626328947e-243, };

__constant__ m_abscissas_double_5[48] =
__constant__ double m_abscissas_double_5[48] =
{ 0.0979238852878323333, 0.287879932742715915, 0.461253543939585704, -0.389726342499361055, -0.268981965207438489,
-0.17668299449359763, -0.110108597215739802, -0.0648391424780153168, -0.0358878357764527081, -0.01854517332266483,
-0.00887300755830119777, -0.00389133456249145746, -0.00154579123230226249, -0.000548565564725394158,
Expand All @@ -1147,7 +1148,7 @@ __constant__ m_abscissas_double_5[48] =
-8.27800009567041668e-139, -3.10160298195808184e-157, -4.09173469287244044e-178, -8.9581681449485487e-202,
-1.3878968774299745e-228, -5.79257421293503894e-259, };

__constant__ m_abscissas_double_6[96] =
__constant__ double m_abscissas_double_6[96] =
{ 0.0490559673050778863, 0.146417984290587941, 0.241566319538883658, 0.333142264577638092, 0.419952111278447158,
-0.498986610620690898, -0.42441550936484834, -0.356823241014795299, -0.296449994852857984, -0.243306091366270051,
-0.197201258656758734, -0.157780753649243136, -0.124564602369591322, -0.0969867184864261294, -0.0744313659313873335,
Expand All @@ -1172,7 +1173,7 @@ __constant__ m_abscissas_double_6[96] =
-9.36020855840271015e-184, -1.40350944280078664e-195, -3.63561076394912477e-208, -1.45274399574122646e-221,
-7.93772358209223086e-236, -5.21635362297544998e-251, -3.59647437525778163e-267, };

__constant__ m_abscissas_double_7[192] =
__constant__ double m_abscissas_double_7[192] =
{ 0.0245397635746491604, 0.0735251229856712945, 0.122229122201557642, 0.170467972382010518, 0.218063473469712005,
0.26484507658344795, 0.310651780552845961, 0.355333825165074533, 0.398754150467237756, 0.440789599033900866,
0.481331846116905044, -0.47971194930876984, -0.442418771739221769, -0.406849646408046841, -0.373049791948957121,
Expand Down Expand Up @@ -1213,7 +1214,7 @@ __constant__ m_abscissas_double_7[192] =
-4.78292200095461437e-225, -3.54255959173241182e-232, -1.55812601911741406e-239, -4.00280716389675087e-247, -5.90460003827621713e-255,
-4.91396180352002352e-263, -2.26567446980557423e-271, };

__constant__ m_abscissas_double_8[384] =
__constant__ double m_abscissas_double_8[384] =
{ 0.012271355118082202, 0.036802280950025085, 0.0612978894136599758, 0.0857347548776510558, 0.110089629932628013,
0.134339515287672237, 0.158461728289299504, 0.18243396969028915, 0.206234388311028769, 0.229841643254360754,
0.253234963356000236, 0.276394203576178614, 0.299299898063960473, 0.321933309653369166, 0.344276475579704919,
Expand Down Expand Up @@ -1303,27 +1304,27 @@ __constant__ double* m_abscissas_double[8] = {
m_abscissas_double_8,
};

__constant__ m_weights_double_1[7] =
__constant__ double m_weights_double_1[7] =
{ 1.57079632679489662, 0.230022394514788685, 0.000266200513752716909, 1.35817842745390908e-12, 1.0017416784066253e-35,
2.6763080920617461e-99, 7.76707068863340629e-273, };

__constant__ m_weights_double_2[6] =
__constant__ double m_weights_double_2[6] =
{ 0.965976579412301148, 0.0183431669899278421, 2.14312045569430394e-07, 2.80031510197758896e-21, 1.12327053454869188e-59,
9.17532687500178413e-165, };

__constant__ m_weights_double_3[12] =
__constant__ double m_weights_double_3[12] =
{ 1.38961475924725632, 0.531078275428053975, 0.0763857435708323042, 0.00290251774790131359, 1.198370136317072e-05,
1.16311658142557828e-09, 2.19707923629797992e-16, 1.36351033076376154e-27, 3.3700568540419265e-46, 5.19697838008985521e-77,
6.00803417057135015e-128, 4.5642040563555991e-212, };

__constant__ m_weights_double_4[24] =
__constant__ double m_weights_double_4[24] =
{ 1.52328371863470521, 1.19346302584915696, 0.737437848361547841, 0.360461418469343674, 0.137422107733167723,
0.0391750054936007791, 0.00774260102606424071, 0.000949946804283468717, 6.24825592407440829e-05, 1.82633205937106597e-06,
1.86872822687364101e-08, 4.9378538776631927e-11, 2.2834926702613954e-14, 1.12275314281815515e-18, 3.09765397011735437e-24,
2.11212334353722559e-31, 1.24241475706160524e-40, 1.63277073317994932e-52, 8.4606887310962138e-68, 1.86444920795886503e-87,
1.00131284686664302e-112, 3.33444354118689902e-145, 6.17515762254877653e-187, 1.49532400222570759e-240, };

__constant__ m_weights_double_5[48] =
__constant__ double m_weights_double_5[48] =
{ 1.55877335553333015, 1.46601442671696578, 1.297475750424978, 1.08163498549007041, 0.850172856456620069, 0.630405135164743691,
0.440833236273858237, 0.290240679312454185, 0.179324412110728293, 0.103432154223332901, 0.0552896837422405838, 0.0271335100137120032,
0.0120835435991579535, 0.00481629814392846302, 0.00169087399814263965, 0.00051339382406790336, 0.000132052341256099749,
Expand All @@ -1335,7 +1336,7 @@ __constant__ m_weights_double_5[48] =
2.63782082635045215e-136, 1.11992914558412798e-154, 1.67415937867108893e-175, 4.15330608101949222e-199, 7.29151266090566043e-226,
3.44840283588682197e-256, };

__constant__ m_weights_double_6[96] =
__constant__ double m_weights_double_6[96] =
{ 1.56778143130722186, 1.54388111617695922, 1.49722622254103629, 1.43000835487229967, 1.34527888476625166, 1.2467012074518577,
1.13827224337630537, 1.02404493311181145, 0.907879379154895317, 0.793242700820516718, 0.683068516344263755, 0.579678103087787647,
0.484758091214755393, 0.399384741525717135, 0.324082539611528904, 0.258904639514053516, 0.203523998858601745, 0.15732620348436615,
Expand All @@ -1356,7 +1357,7 @@ __constant__ m_weights_double_6[96] =
6.3069398037899023e-193, 1.73909581157725484e-205, 7.39738244904451982e-219, 4.3025693007354699e-233, 3.00982956958324877e-248,
2.20899573159075297e-264, };

__constant__ m_weights_double_7[192] =
__constant__ double m_weights_double_7[192] =
{ 1.57004202927959315, 1.5640214037732321, 1.55205316984541212, 1.53428173815430343, 1.51091972307416971, 1.48224329788553807,
1.44858625496132259, 1.41033297144625901, 1.36791051168089649, 1.32178011744377286, 1.27242834553786271, 1.22035810957935822,
1.16607986993243458, 1.11010319396534038, 1.05292887995526666, 0.995041804046132715, 0.936904612745667934, 0.87895234555278212,
Expand Down Expand Up @@ -1395,7 +1396,7 @@ __constant__ m_weights_double_7[192] =
2.47381948587608999e-222, 1.89044188887636326e-229, 8.57867513484860174e-237, 2.27380804498007095e-244, 3.46059771526558578e-252,
2.97141917521293704e-260, 1.41351747260411324e-268, };

__constant__ m_weights_double_8[384] =
__constant__ double m_weights_double_8[384] =
{ 1.57060771653827522, 1.56909969535166913, 1.56608823891746137, 1.56158249349181062, 1.55559611463166042, 1.54814719123555733,
1.53925814531188183, 1.52895560835458072, 1.51727027540505468, 1.50423673806367721, 1.48989329788329712, 1.47428176172807973,
1.45744722081254867, 1.43943781524640698, 1.42030448599969118, 1.40010071626944465, 1.37888226427313752, 1.35670688951560547,
Expand Down Expand Up @@ -1477,6 +1478,28 @@ __constant__ boost::math::size_t double_coefficients_size[8] = {7, 6, 12, 24, 48

__constant__ boost::math::size_t m_first_complements[8] = {1, 0, 1, 1, 3, 5, 11, 22};

template<typename T>
struct coefficients_selector;

template<>
struct coefficients_selector<float>
{
__device__ static const auto abscissas() { return m_abscissas_float; }
__device__ static const auto weights() { return m_weights_float; }
__device__ static const auto size() { return float_coefficients_size; }
__device__ static constexpr boost::math::size_t initial_row_length() { return 4; }
};

template<>
struct coefficients_selector<double>
{
__device__ static const auto abscissas() { return m_abscissas_double; }
__device__ static const auto weights() { return m_weights_double; }
__device__ static const auto size() { return double_coefficients_size; }
__device__ static constexpr boost::math::size_t initial_row_length() { return 6; };
};


template<class F, class Real, class Policy = policies::policy<> >
__device__ auto tanh_sinh_integrate_impl(const F f, Real* error, Real* L1, const char* function, Real left_min_complement, Real right_min_complement, Real tolerance, boost::math::size_t* levels)
{
Expand All @@ -1486,13 +1509,14 @@ __device__ auto tanh_sinh_integrate_impl(const F f, Real* error, Real* L1, const

//
// The type of the result:
using result_type = decltype(f(static_cast<Real>(0)));
using result_type = decltype(f(static_cast<Real>(0), static_cast<Real>(0)));

const auto m_abscissas = coefficients_selector<Real>::abscissas();
const auto m_weights = coefficients_selector<Real>::weights();
const auto m_size = coefficients_selector<Real>::size();
const auto m_initial_row_length = coefficients_selector<Real>::initial_row_length();

Real h = m_t_max / m_inital_row_length;
Real h = 1;
result_type I0 = half_pi<Real>() * f(0, 1);
Real L1_I0 = abs(I0);
//
Expand Down

0 comments on commit 91cceeb

Please sign in to comment.