-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathcompv_math_exp.cxx
executable file
·461 lines (410 loc) · 65.3 KB
/
compv_math_exp.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
/* Copyright (C) 2011-2020 Doubango Telecom <https://www.doubango.org>
* File author: Mamadou DIOP (Doubango Telecom, France).
* License: GPLv3. For commercial license please contact us.
* Source code: https://github.com/DoubangoTelecom/compv
* WebSite: http://compv.org
*/
#include "compv/base/math/compv_math_exp.h"
#include "compv/base/math/compv_math.h"
#include "compv/base/compv_generic_invoke.h"
#include "compv/base/parallel/compv_parallel.h"
#include "compv/base/compv_cpu.h"
#include "compv/base/math/intrin/x86/compv_math_exp_intrin_sse2.h"
#include "compv/base/math/intrin/x86/compv_math_exp_intrin_avx2.h"
#include "compv/base/math/intrin/arm/compv_math_exp_intrin_neon.h"
#define COMPV_THIS_CLASSNAME "CompVMathExp"
// Part of the code is based on https://github.com/herumi/fmath
COMPV_NAMESPACE_BEGIN()
#if COMPV_ASM && COMPV_ARCH_X64
COMPV_EXTERNC void CompVMathExpExp_minpack1_64f64f_Asm_X64_AVX2(const compv_float64_t* ptrIn, compv_float64_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, const compv_uscalar_t stride, const uint64_t* lut64u, const uint64_t* var64u, const compv_float64_t* var64f);
COMPV_EXTERNC void CompVMathExpExp_minpack1_64f64f_Asm_X64_FMA3_AVX2(const compv_float64_t* ptrIn, compv_float64_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, const compv_uscalar_t stride, const uint64_t* lut64u, const uint64_t* var64u, const compv_float64_t* var64f);
COMPV_EXTERNC void CompVMathExpExp_minpack1_32f32f_Asm_X64_AVX2(COMPV_ALIGNED(AVX) const compv_float32_t* ptrIn, COMPV_ALIGNED(AVX) compv_float32_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, COMPV_ALIGNED(AVX) const compv_uscalar_t stride, COMPV_ALIGNED(AVX) const uint32_t* lut32u, COMPV_ALIGNED(AVX) const compv_float32_t* var32f);
COMPV_EXTERNC void CompVMathExpExp_minpack1_32f32f_Asm_X64_FMA3_AVX2(COMPV_ALIGNED(AVX) const compv_float32_t* ptrIn, COMPV_ALIGNED(AVX) compv_float32_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, COMPV_ALIGNED(AVX) const compv_uscalar_t stride, COMPV_ALIGNED(AVX) const uint32_t* lut32u, COMPV_ALIGNED(AVX) const compv_float32_t* var32f);
#endif /* #if COMPV_ASM && COMPV_ARCH_X64 */
#if COMPV_ASM && COMPV_ARCH_ARM32
COMPV_EXTERNC void CompVMathExpExp_minpack1_64f64f_Asm_NEON32(const compv_float64_t* ptrIn, compv_float64_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, const compv_uscalar_t stride, const uint64_t* lut64u, const uint64_t* var64u, const compv_float64_t* var64f);
COMPV_EXTERNC void CompVMathExpExp_minpack1_64f64f_Asm_FMA_NEON32(const compv_float64_t* ptrIn, compv_float64_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, const compv_uscalar_t stride, const uint64_t* lut64u, const uint64_t* var64u, const compv_float64_t* var64f);
COMPV_EXTERNC void CompVMathExpExp_minpack1_32f32f_Asm_NEON32(COMPV_ALIGNED(NEON) const compv_float32_t* ptrIn, COMPV_ALIGNED(NEON) compv_float32_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, COMPV_ALIGNED(NEON) const compv_uscalar_t stride, COMPV_ALIGNED(NEON) const uint32_t* lut32u, COMPV_ALIGNED(NEON) const compv_float32_t* var32f);
COMPV_EXTERNC void CompVMathExpExp_minpack1_32f32f_Asm_FMA_NEON32(COMPV_ALIGNED(NEON) const compv_float32_t* ptrIn, COMPV_ALIGNED(NEON) compv_float32_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, COMPV_ALIGNED(NEON) const compv_uscalar_t stride, COMPV_ALIGNED(NEON) const uint32_t* lut32u, COMPV_ALIGNED(NEON) const compv_float32_t* var32f);
#endif /* COMPV_ASM && COMPV_ARCH_ARM32 */
#if COMPV_ASM && COMPV_ARCH_ARM64
COMPV_EXTERNC void CompVMathExpExp_minpack1_64f64f_Asm_NEON64(const compv_float64_t* ptrIn, compv_float64_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, const compv_uscalar_t stride, const uint64_t* lut64u, const uint64_t* var64u, const compv_float64_t* var64f);
COMPV_EXTERNC void CompVMathExpExp_minpack1_64f64f_Asm_FMA_NEON64(const compv_float64_t* ptrIn, compv_float64_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, const compv_uscalar_t stride, const uint64_t* lut64u, const uint64_t* var64u, const compv_float64_t* var64f);
COMPV_EXTERNC void CompVMathExpExp_minpack1_32f32f_Asm_NEON64(COMPV_ALIGNED(NEON) const compv_float32_t* ptrIn, COMPV_ALIGNED(NEON) compv_float32_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, COMPV_ALIGNED(NEON) const compv_uscalar_t stride, COMPV_ALIGNED(NEON) const uint32_t* lut32u, COMPV_ALIGNED(NEON) const compv_float32_t* var32f);
COMPV_EXTERNC void CompVMathExpExp_minpack1_32f32f_Asm_FMA_NEON64(COMPV_ALIGNED(NEON) const compv_float32_t* ptrIn, COMPV_ALIGNED(NEON) compv_float32_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, COMPV_ALIGNED(NEON) const compv_uscalar_t stride, COMPV_ALIGNED(NEON) const uint32_t* lut32u, COMPV_ALIGNED(NEON) const compv_float32_t* var32f);
#endif /* COMPV_ASM && COMPV_ARCH_ARM64 */
bool CompVMathExp::s_bInitialized = false;
COMPV_ALIGN_DEFAULT() const uint64_t CompVMathExp::s_arrayVars64u[2] = { //!\\ MUST NOT CHANGE THE INDEXES (add at the bottom but never remove or swap)
2047ULL, /* [0]: mask(c.sbit = 11) */
2095104ULL /* [1]: c.adj = (1UL << (sbit + 10)) - (1UL << sbit) */
};
COMPV_ALIGN_DEFAULT() const compv_float64_t CompVMathExp::s_arrayVars64f[8] = { //!\\ MUST NOT CHANGE THE INDEXES (add at the bottom but never remove or swap)
6755399441055744.0, /* [0]: 3ULL << 51 */
2954.6394437405970, /* [1]: c.a */
0.00033845077175778578, /* [2]: c.ra */
1.0000000000000000, /* [3]: c.C1[0] */
0.16666666685227835, /* [4]: c.C2[0] */
3.0000000027955394, /* [5]: c.C3[0] */
-708.39641853226408, /* [6]: ExpMin */
709.78271289338397 /* [7]: ExpMax */
};
COMPV_ALIGN_DEFAULT() const compv_float32_t CompVMathExp::s_arrayVars32f[5] = { //!\\ MUST NOT CHANGE THE INDEXES (add at the bottom but never remove or swap)
12582912.0f, /* [0]: (1 << 23) + (1 << 22) */
1477.31970f, /* [1]: expVar.a[0] */
0.000676901545f, /* [2]: expVar.b[0] */
88.000000f, /* [3]: expVar.maxX[0] */
-88.0000000f /* [4]: expVar.minX[0] */
};
COMPV_ALIGN_DEFAULT() const uint64_t CompVMathExp::s_arrayLut64u[2048 /* 1UL << sbit[11] */] = { 0, 1524504739922, 3049525536975, 4575062565848, 6101116001290, 7627686018109, 9154772791171, 10682376495403, 12210497305791, 13739135397378, 15268290945269, 16797964124627, 18328155110673, 19858864078691, 21390091204021, 22921836662063, 24454100628277, 25986883278183, 27520184787359, 29054005331443, 30588345086132, 32123204227184, 33658582930415, 35194481371701, 36730899726977, 38267838172239, 39805296883541, 41343276036997, 42881775808782, 44420796375129, 45960337912330, 47500400596739, 49040984604769, 50582090112891, 52123717297638, 53665866335601, 55208537403431, 56751730677841, 58295446335601, 59839684553543, 61384445508556, 62929729377592, 64475536337662, 66021866565835, 67568720239242, 69116097535075, 70663998630582, 72212423703076, 73761372929925, 75310846488560, 76860844556473, 78411367311213, 79962414930392, 81513987591680, 83066085472808, 84618708751567, 86171857605809, 87725532213445, 89279732752447, 90834459400847, 92389712336738, 93945491738271, 95501797783659, 97058630651177, 98615990519156, 100173877565992, 101732291970139, 103291233910110, 104850703564482, 106410701111890, 107971226731030, 109532280600659, 111093862899593, 112655973806710, 114218613500948, 115781782161306, 117345479966844, 118909707096680, 120474463729997, 122039750046034, 123605566224094, 125171912443539, 126738788883793, 128306195724339, 129874133144723, 131442601324549, 133011600443485, 134581130681257, 136151192217654, 137721785232524, 139292909905777, 140864566417384, 142436754947376, 144009475675845, 145582728782946, 147156514448892, 148730832853960, 150305684178485, 151881068602866, 153456986307560, 155033437473087, 156610422280029, 158187940909026, 159765993540783, 161344580356064, 162923701535693, 164503357260557, 166083547711605, 167664273069846, 169245533516349, 170827329232247, 172409660398732, 173992527197059, 175575929808544, 177159868414563, 178744343196556, 180329354336021, 181914902014521, 183500986413678, 185087607715176, 186674766100761, 188262461752241, 189850694851484, 191439465580420, 193028774121042, 194618620655404, 196209005365620, 197799928433867, 199391390042383, 200983390373470, 202575929609489, 204169007932863, 205762625526079, 207356782571682, 208951479252283, 210546715750552, 212142492249221, 213738808931086, 215335665979002, 216933063575887, 218531001904723, 220129481148550, 221728501490474, 223328063113659, 224928166201335, 226528810936791, 228129997503380, 229731726084515, 231333996863674, 232936810024393, 234540165750274, 236144064224980, 237748505632236, 239353490155827, 240959017979605, 242565089287479, 244171704263424, 245778863091477, 247386565955734, 248994813040358, 250603604529570, 252212940607656, 253822821458965, 255433247267905, 257044218218950, 258655734496635, 260267796285556, 261880403770375, 263493557135813, 265107256566655, 266721502247749, 268336294364006, 269951633100397, 271567518641958, 273183951173787, 274800930881045, 276418457948955, 278036532562803, 279655154907937, 281274325169769, 282894043533774, 284514310185488, 286135125310511, 287756489094506, 289378401723198, 291000863382376, 292623874257890, 294247434535656, 295871544401649, 297496204041911, 299121413642543, 300747173389713, 302373483469649, 304000344068643, 305627755373050, 307255717569289, 308884230843841, 310513295383250, 312142911374124, 313773079003134, 315403798457014, 317035069922560, 318666893586633, 320299269636158, 321932198258120, 323565679639570, 325199713967621, 326834301429451, 328469442212300, 330105136503471, 331741384490331, 333378186360311, 335015542300905, 336653452499669, 338291917144226, 339930936422258, 341570510521515, 343210639629807, 344851323935010, 346492563625062, 348134358887966, 349776709911787, 351419616884655, 353063079994763, 354707099430368, 356351675379790, 357996808031415, 359642497573690, 361288744195128, 362935548084303, 364582909429857, 366230828420491, 367879305244974, 369528340092136, 371177933150874, 372828084610145, 374478794658974, 376130063486447, 377781891281715, 379434278233993, 381087224532561, 382740730366762, 384394795926002, 386049421399754, 387704606977554, 389360352849000, 391016659203756, 392673526231552, 394330954122178, 395988943065492, 397647493251415, 399306604869932, 400966278111091, 402626513165008, 404287310221860, 405948669471889, 407610591105403, 409273075312773, 410936122284434, 412599732210887, 414263905282697, 415928641690493, 417593941624968, 419259805276882, 420926232837056, 422593224496379, 424260780445802, 425928900876342, 427597585979081, 429266835945164, 430936650965803, 432607031232273, 434277976935914, 435949488268131, 437621565420395, 439294208584239, 440967417951263, 442641193713132, 444315536061575, 445990445188386, 447665921285423, 449341964544612, 451018575157940, 452695753317463, 454373499215298, 456051813043629, 457730694994707, 459410145260845, 461090164034421, 462770751507881, 464451907873735, 466133633324556, 467815928052984, 469498792251725, 471182226113549, 472866229831291, 474550803597852, 476235947606199, 477921662049363, 479607947120440, 481294803012592, 482982229919048, 484670228033100, 486358797548107, 488047938657492, 489737651554744, 491427936433419, 493118793487137, 494810222909583, 496502224894510, 498194799635733, 499887947327136, 501581668162667, 503275962336340, 504970830042234, 506666271474495, 508362286827334, 510058876295027, 511756040071917, 513453778352412, 515152091330986, 516850979202180, 518550442160599, 520250480400914, 521951094117864, 523652283506251, 525354048760945, 527056390076882, 528759307649063, 530462801672555, 532166872342491, 533871519854072, 535576744402562, 537282546183294, 538988925391664, 540695882223138, 542403416873245, 544111529537581, 545820220411808, 547529489691657, 549239337572920, 550949764251461, 552660769923205, 554372354784148, 556084519030349, 557797262857934, 559510586463098, 561224490042099, 562938973791262, 564654037906981, 566369682585714, 568085908023987, 569802714418390, 571520101965583, 573238070862290, 574956621305303, 576675753491480, 578395467617745, 580115763881091, 581836642478575, 583558103607321, 585280147464522, 587002774247436, 588725984153388, 590449777379769, 592174154124039, 593899114583722, 595624658956411, 597350787439766, 599077500231513, 600804797529444, 602532679531420, 604261146435367, 605990198439281, 607719835741221, 609450058539316, 611180867031761, 612912261416819, 614644241892818, 616376808658156, 618109961911295, 619843701850767, 621578028675170, 623312942583169, 625048443773496, 626784532444952, 628521208796404, 630258473026785, 631996325335098, 633734765920411, 635473794981862, 637213412718654, 638953619330058, 640694415015414, 642435799974127, 644177774405672, 645920338509589, 647663492485488, 649407236533045, 651151570852003, 652896495642175, 654642011103440, 656388117435745, 658134814839104, 659882103513599, 661629983659382, 663378455476668, 665127519165745, 666877174926965, 668627422960750, 670378263467589, 672129696648037, 673881722702722, 675634341832334, 677387554237635, 679141360119453, 680895759678685, 682650753116296, 684406340633317, 686162522430850, 687919298710064, 689676669672195, 691434635518548, 693193196450496, 694952352669481, 696712104377013, 698472451774667, 700233395064092, 701994934447000, 703757070125175, 705519802300466, 707283131174794, 709047056950145, 710811579828575, 712576700012209, 714342417703239, 716108733103926, 717875646416599, 719643157843658, 721411267587568, 723179975850864, 724949282836150, 726719188746098, 728489693783450, 730260798151013, 732032502051668, 733804805688359, 735577709264104, 737351212981985, 739125317045157, 740900021656840, 742675327020325, 744451233338972, 746227740816208, 748004849655532, 749782560060507, 751560872234771, 753339786382025, 755119302706043, 756899421410667, 758680142699807, 760461466777443, 762243393847624, 764025924114467, 765809057782160, 767592795054958, 769377136137187, 771162081233241, 772947630547584, 774733784284748, 776520542649335, 778307905846018, 780095874079535, 781884447554697, 783673626476383, 785463411049542, 787253801479192, 789044797970419, 790836400728381, 792628609958304, 794421425865483, 796214848655284, 798008878533141, 799803515704559, 801598760375110, 803394612750439, 805191073036259, 806988141438351, 808785818162569, 810584103414835, 812382997401139, 814182500327543, 815982612400179, 817783333825247, 819584664809019, 821386605557833, 823189156278102, 824992317176305, 826796088458992, 828600470332784, 830405463004370, 832211066680510, 834017281568035, 835824107873844, 837631545804907, 839439595568265, 841248257371027, 843057531420374, 844867417923556, 846677917087894, 848489029120779, 850300754229671, 852113092622101, 853926044505672, 855739610088054, 857553789576990, 859368583180292, 861183991105843, 863000013561595, 864816650755573, 866633902895869, 868451770190649, 870270252848147, 872089351076668, 873909065084588, 875729395080353, 877550341272480, 879371903869557, 881194083080241, 883016879113262, 884840292177418, 886664322481580, 888488970234688, 890314235645754, 892140118923860, 893966620278158, 895793739917874, 897621478052300, 899449834890803, 901278810642820, 903108405517856, 904938619725491, 906769453475373, 908600906977223, 910432980440831, 912265674076060, 914098988092842, 915932922701183, 917767478111156, 919602654532908, 921438452176658, 923274871252693, 925111911971373, 926949574543129, 928787859178465, 930626766087952, 932466295482237, 934306447572034, 936147222568132, 937988620681390, 939830642122737, 941673287103175, 943516555833777, 945360448525688, 947204965390123, 949050106638370, 950895872481788, 952742263131808, 954589278799931, 956436919697731, 958285186036853, 960134078029015, 961983595886004, 963833739819682, 965684510041980, 967535906764901, 969387930200523, 971240580560991, 973093858058524, 974947762905415, 976802295314025, 978657455496789, 980513243666214, 982369660034879, 984226704815434, 986084378220601, 987942680463174, 989801611756022, 991661172312081, 993521362344363, 995382182065951, 997243631689998, 999105711429734, 1000968421498455, 1002831762109535, 1004695733476417, 1006560335812616, 1008425569331721, 1010291434247393, 1012157930773364, 1014025059123439, 1015892819511496, 1017761212151484, 1019630237257427, 1021499895043419, 1023370185723628, 1025241109512292, 1027112666623725, 1028984857272311, 1030857681672508, 1032731140038845, 1034605232585926, 1036479959528426, 1038355321081092, 1040231317458745, 1042107948876279, 1043985215548660, 1045863117690927, 1047741655518191, 1049620829245636, 1051500639088521, 1053381085262175, 1055262167982001, 1057143887463476, 1059026243922149, 1060909237573640, 1062792868633646, 1064677137317934, 1066562043842344, 1068447588422792, 1070333771275264, 1072220592615821, 1074108052660595, 1075996151625794, 1077884889727696, 1079774267182656, 1081664284207098, 1083554941017523, 1085446237830503, 1087338174862684, 1089230752330786, 1091123970451601, 1093017829441996, 1094912329518909, 1096807470899355, 1098703253800418, 1100599678439260, 1102496745033113, 1104394453799285, 1106292804955156, 1108191798718179, 1110091435305884, 1111991714935871, 1113892637825814, 1115794204193464, 1117696414256642, 1119599268233244, 1121502766341240, 1123406908798674, 1125311695823663, 1127217127634399, 1129123204449147, 1131029926486245, 1132937293964107, 1134845307101220, 1136753966116145, 1138663271227516, 1140573222654042, 1142483820614506, 1144395065327765, 1146306957012750, 1148219495888467, 1150132682173994, 1152046516088485, 1153960997851167, 1155876127681343, 1157791905798389, 1159708332421754, 1161625407770963, 1163543132065616, 1165461505525386, 1167380528370019, 1169300200819339, 1171220523093241, 1173141495411697, 1175063117994752, 1176985391062525, 1178908314835211, 1180831889533079, 1182756115376472, 1184680992585808, 1186606521381580, 1188532701984355, 1190459534614775, 1192387019493556, 1194315156841491, 1196243946879444, 1198173389828357, 1200103485909246, 1202034235343200, 1203965638351386, 1205897695155042, 1207830405975485, 1209763771034105, 1211697790552365, 1213632464751806, 1215567793854043, 1217503778080766, 1219440417653740, 1221377712794804, 1223315663725874, 1225254270668939, 1227193533846066, 1229133453479394, 1231074029791140, 1233015263003595, 1234957153339124, 1236899701020169, 1238842906269246, 1240786769308949, 1242731290361943, 1244676469650973, 1246622307398856, 1248568803828486, 1250515959162832, 1252463773624938, 1254412247437925, 1256361380824988, 1258311174009399, 1260261627214503, 1262212740663723, 1264164514580558, 1266116949188581, 1268070044711441, 1270023801372863, 1271978219396648, 1273933299006672, 1275889040426888, 1277845443881324, 1279802509594083, 1281760237789345, 1283718628691367, 1285677682524479, 1287637399513090, 1289597779881682, 1291558823854815, 1293520531657125, 1295482903513323, 1297445939648196, 1299409640286609, 1301374005653501, 1303339035973888, 1305304731472862, 1307271092375592, 1309238118907322, 1311205811293373, 1313174169759142, 1315143194530101, 1317112885831802, 1319083243889870, 1321054268930007, 1323025961177992, 1324998320859680, 1326971348201004, 1328945043427971, 1330919406766665, 1332894438443249, 1334870138683959, 1336846507715111, 1338823545763095, 1340801253054378, 1342779629815506, 1344758676273098, 1346738392653853, 1348718779184545, 1350699836092024, 1352681563603220, 1354663961945137, 1356647031344856, 1358630772029536, 1360615184226411, 1362600268162796, 1364586024066078, 1366572452163724, 1368559552683277, 1370547325852358, 1372535771898663, 1374524891049967, 1376514683534122, 1378505149579056, 1380496289412774, 1382488103263361, 1384480591358975, 1386473753927854, 1388467591198313, 1390462103398744, 1392457290757616, 1394453153503476, 1396449691864947, 1398446906070731, 1400444796349607, 1402443362930430, 1404442606042135, 1406442525913732, 1408443122774311, 1410444396853037, 1412446348379154, 1414448977581984, 1416452284690926, 1418456269935456, 1420460933545129, 1422466275749577, 1424472296778509, 1426478996861713, 1428486376229055, 1430494435110478, 1432503173736002, 1434512592335726, 1436522691139828, 1438533470378562, 1440544930282260, 1442557071081333, 1444569893006270, 1446583396287637, 1448597581156079, 1450612447842318, 1452627996577156, 1454644227591471, 1456661141116221, 1458678737382440, 1460697016621242, 1462715979063820, 1464735624941442, 1466755954485457, 1468776967927292, 1470798665498452, 1472821047430520, 1474844113955157, 1476867865304104, 1478892301709179, 1480917423402279, 1482943230615380, 1484969723580536, 1486996902529880, 1489024767695622, 1491053319310052, 1493082557605539, 1495112482814530, 1497143095169551, 1499174394903205, 1501206382248177, 1503239057437228, 1505272420703199, 1507306472279010, 1509341212397659, 1511376641292222, 1513412759195858, 1515449566341800, 1517487062963362, 1519525249293939, 1521564125567001, 1523603692016100, 1525643948874866, 1527684896377008, 1529726534756314, 1531768864246653, 1533811885081971, 1535855597496293, 1537900001723724, 1539945097998450, 1541990886554733, 1544037367626917, 1546084541449423, 1548132408256753, 1550180968283488, 1552230221764289, 1554280168933895, 1556330810027126, 1558382145278879, 1560434174924135, 1562486899197949, 1564540318335460, 1566594432571885, 1568649242142520, 1570704747282741, 1572760948228005, 1574817845213846, 1576875438475881, 1578933728249804, 1580992714771390, 1583052398276494, 1585112779001051, 1587173857181074, 1589235633052659, 1591298106851979, 1593361278815288, 1595425149178921, 1597489718179292, 1599554986052895, 1601620953036304, 1603687619366174, 1605754985279238, 1607823051012312, 1609891816802290, 1611961282886147, 1614031449500938, 1616102316883798, 1618173885271944, 1620246154902671, 1622319126013355, 1624392798841453, 1626467173624502, 1628542250600119, 1630618030006003, 1632694512079930, 1634771697059762, 1636849585183436, 1638928176688972, 1641007471814471, 1643087470798114, 1645168173878163, 1647249581292959, 1649331693280926, 1651414510080568, 1653498031930469, 1655582259069293, 1657667191735788, 1659752830168780, 1661839174607176, 1663926225289966, 1666013982456218, 1668102446345083, 1670191617195791, 1672281495247657, 1674372080740072, 1676463373912510, 1678555375004529, 1680648084255763, 1682741501905931, 1684835628194831, 1686930463362342, 1689026007648428, 1691122261293129, 1693219224536569, 1695316897618953, 1697415280780567, 1699514374261779, 1701614178303038, 1703714693144874, 1705815919027899, 1707917856192805, 1710020504880369, 1712123865331444, 1714227937786971, 1716332722487967, 1718438219675533, 1720544429590852, 1722651352475188, 1724758988569887, 1726867338116376, 1728976401356165, 1731086178530843, 1733196669882085, 1735307875651644, 1737419796081357, 1739532431413143, 1741645781889000, 1743759847751012, 1745874629241341, 1747990126602235, 1750106340076021, 1752223269905109, 1754340916331992, 1756459279599242, 1758578359949517, 1760698157625555, 1762818672870176, 1764939905926283, 1767061857036861, 1769184526444978, 1771307914393783, 1773432021126507, 1775556846886465, 1777682391917053, 1779808656461751, 1781935640764119, 1784063345067801, 1786191769616524, 1788320914654096, 1790450780424408, 1792581367171435, 1794712675139233, 1796844704571941, 1798977455713780, 1801110928809055, 1803245124102153, 1805380041837543, 1807515682259779, 1809652045613496, 1811789132143411, 1813926942094326, 1816065475711124, 1818204733238773, 1820344714922321, 1822485421006902, 1824626851737731, 1826769007360106, 1828911888119410, 1831055494261107, 1833199826030745, 1835344883673954, 1837490667436449, 1839637177564026, 1841784414302568, 1843932377898036, 1846081068596478, 1848230486644024, 1850380632286888, 1852531505771367, 1854683107343840, 1856835437250772, 1858988495738709, 1861142283054282, 1863296799444206, 1865452045155277, 1867608020434376, 1869764725528469, 1871922160684604, 1874080326149912, 1876239222171609, 1878398848996995, 1880559206873452, 1882720296048446, 1884882116769529, 1887044669284334, 1889207953840580, 1891371970686069, 1893536720068686, 1895702202236400, 1897868417437267, 1900035365919423, 1902203047931090, 1904371463720573, 1906540613536263, 1908710497626633, 1910881116240241, 1913052469625729, 1915224558031823, 1917397381707333, 1919570940901155, 1921745235862267, 1923920266839733, 1926096034082698, 1928272537840397, 1930449778362144, 1932627755897340, 1934806470695471, 1936985923006105, 1939166113078897, 1941347041163585, 1943528707509992, 1945711112368025, 1947894255987677, 1950078138619024, 1952262760512229, 1954448121917536, 1956634223085277, 1958821064265867, 1961008645709807, 1963196967667681, 1965386030390160, 1967575834127998, 1969766379132036, 1971957665653197, 1974149693942491, 1976342464251013, 1978535976829942, 1980730231930542, 1982925229804164, 1985120970702242, 1987317454876295, 1989514682577929, 1991712654058833, 1993911369570783, 1996110829365640, 1998311033695348, 2000511982811940, 2002713676967531, 2004916116414324, 2007119301404605, 2009323232190746, 2011527909025206, 2013733332160529, 2015939501849342, 2018146418344360, 2020354081898384, 2022562492764298, 2024771651195074, 2026981557443768, 2029192211763523, 2031403614407567, 2033615765629214, 2035828665681863, 2038042314819000, 2040256713294196, 2042471861361107, 2044687759273477, 2046904407285134, 2049121805649993, 2051339954622054, 2053558854455405, 2055778505404217, 2057998907722749, 2060220061665347, 2062441967486440, 2064664625440546, 2066888035782268, 2069112198766295, 2071337114647403, 2073562783680453, 2075789206120393, 2078016382222258, 2080244312241167, 2082472996432330, 2084702435051037, 2086932628352671, 2089163576592695, 2091395280026665, 2093627738910217, 2095860953499080, 2098094924049063, 2100329650816068, 2102565134056079, 2104801374025168, 2107038370979494, 2109276125175303, 2111514636868927, 2113753906316786, 2115993933775385, 2118234719501317, 2120476263751261, 2122718566781985, 2124961628850341, 2127205450213269, 2129450031127798, 2131695371851042, 2133941472640201, 2136188333752564, 2138435955445507, 2140684337976493, 2142933481603071, 2145183386582878, 2147434053173639, 2149685481633164, 2151937672219353, 2154190625190192, 2156444340803754, 2158698819318199, 2160954060991776, 2163210066082820, 2165466834849755, 2167724367551090, 2169982664445423, 2172241725791441, 2174501551847916, 2176762142873709, 2179023499127767, 2181285620869128, 2183548508356914, 2185812161850338, 2188076581608697, 2190341767891379, 2192607720957859, 2194874441067698, 2197141928480548, 2199410183456147, 2201679206254320, 2203948997134983, 2206219556358136, 2208490884183870, 2210762980872364, 2213035846683883, 2215309481878782, 2217583886717504, 2219859061460578, 2222135006368624, 2224411721702349, 2226689207722548, 2228967464690105, 2231246492865992, 2233526292511268, 2235806863887083, 2238088207254673, 2240370322875364, 2242653211010570, 2244936871921793, 2247221305870623, 2249506513118742, 2251792493927916, 2254079248560002, 2256366777276946, 2258655080340781, 2260944158013630, 2263234010557705, 2265524638235305, 2267816041308820, 2270108220040727, 2272401174693593, 2274694905530073, 2276989412812913, 2279284696804944, 2281580757769090, 2283877595968362, 2286175211665860, 2288473605124774, 2290772776608381, 2293072726380051, 2295373454703238, 2297674961841491, 2299977248058442, 2302280313617818, 2304584158783432, 2306888783819186, 2309194188989073, 2311500374557175, 2313807340787663, 2316115087944797, 2318423616292928, 2320732926096493, 2323043017620024, 2325353891128138, 2327665546885543, 2329977985157037, 2332291206207507, 2334605210301930, 2336919997705374, 2339235568682993, 2341551923500035, 2343869062421836, 2346186985713820, 2348505693641505, 2350825186470495, 2353145464466485, 2355466527895262, 2357788377022700, 2360111012114765, 2362434433437512, 2364758641257087, 2367083635839725, 2369409417451751, 2371735986359581, 2374063342829723, 2376391487128770, 2378720419523411, 2381050140280422, 2383380649666669, 2385711947949110, 2388044035394793, 2390376912270856, 2392710578844528, 2395045035383127, 2397380282154063, 2399716319424836, 2402053147463036, 2404390766536345, 2406729176912535, 2409068378859467, 2411408372645096, 2413749158537463, 2416090736804705, 2418433107715047, 2420776271536804, 2423120228538383, 2425464978988283, 2427810523155092, 2430156861307488, 2432503993714244, 2434851920644220, 2437200642366369, 2439550159149735, 2441900471263451, 2444251578976745, 2446603482558932, 2448956182279421, 2451309678407710, 2453663971213391, 2456019060966146, 2458374947935746, 2460731632392056, 2463089114605033, 2465447394844723, 2467806473381265, 2470166350484888, 2472527026425914, 2474888501474756, 2477250775901918, 2479613849977996, 2481977723973678, 2484342398159743, 2486707872807062, 2489074148186598, 2491441224569405, 2493809102226628, 2496177781429506, 2498547262449369, 2500917545557637, 2503288631025825, 2505660519125537, 2508033210128471, 2510406704306416, 2512781001931254, 2515156103274957, 2517532008609590, 2519908718207312, 2522286232340371, 2524664551281110, 2527043675301963, 2529423604675454, 2531804339674204, 2534185880570921, 2536568227638410, 2538951381149566, 2541335341377376, 2543720108594920, 2546105683075372, 2548492065091995, 2550879254918147, 2553267252827279, 2555656059092934, 2558045673988745, 2560436097788441, 2562827330765843, 2565219373194864, 2567612225349509, 2570005887503877, 2572400359932160, 2574795642908642, 2577191736707700, 2579588641603804, 2581986357871516, 2584384885785494, 2586784225620484, 2589184377651331, 2591585342152967, 2593987119400421, 2596389709668814, 2598793113233361, 2601197330369367, 2603602361352235, 2606008206457457, 2608414865960621, 2610822340137407, 2613230629263589, 2615639733615033, 2618049653467699, 2620460389097642, 2622871940781009, 2625284308794039, 2627697493413069, 2630111494914524, 2632526313574927, 2634941949670892, 2637358403479128, 2639775675276437, 2642193765339715, 2644612673945952, 2647032401372230, 2649452947895727, 2651874313793715, 2654296499343558, 2656719504822714, 2659143330508736, 2661567976679272, 2663993443612061, 2666419731584939, 2668846840875833, 2671274771762768, 2673703524523858, 2676133099437317, 2678563496781448, 2680994716834651, 2683426759875421, 2685859626182344, 2688293316034103, 2690727829709474, 2693163167487329, 2695599329646633, 2698036316466445, 2700474128225921, 2702912765204307, 2705352227680949, 2707792515935283, 2710233630246842, 2712675570895253, 2715118338160237, 2717561932321612, 2720006353659288, 2722451602453270, 2724897678983661, 2727344583530654, 2729792316374541, 2732240877795706, 2734690268074629, 2737140487491886, 2739591536328147, 2742043414864177, 2744496123380835, 2746949662159076, 2749404031479952, 2751859231624607, 2754315262874282, 2756772125510313, 2759229819814130, 2761688346067261, 2764147704551325, 2766607895548041, 2769068919339221, 2771530776206771, 2773993466432696, 2776456990299094, 2778921348088158, 2781386540082179, 2783852566563541, 2786319427814725, 2788787124118307, 2791255655756960, 2793725023013451, 2796195226170643, 2798666265511495, 2801138141319063, 2803610853876497, 2806084403467044, 2808558790374046, 2811034014880941, 2813510077271264, 2815986977828645, 2818464716836811, 2820943294579583, 2823422711340880, 2825902967404717, 2828384063055205, 2830865998576549, 2833348774253054, 2835832390369118, 2838316847209237, 2840802145058004, 2843288284200105, 2845775264920326, 2848263087503547, 2850751752234747, 2853241259398999, 2855731609281473, 2858222802167436, 2860714838342252, 2863207718091380, 2865701441700378, 2868196009454899, 2870691421640693, 2873187678543606, 2875684780449583, 2878182727644663, 2880681520414984, 2883181159046780, 2885681643826381, 2888182975040216, 2890685152974809, 2893188177916782, 2895692050152854, 2898196769969841, 2900702337654655, 2903208753494308, 2905716017775905, 2908224130786653, 2910733092813851, 2913242904144899, 2915753565067294, 2918265075868628, 2920777436836593, 2923290648258977, 2925804710423666, 2928319623618642, 2930835388131987, 2933352004251878, 2935869472266591, 2938387792464499, 2940906965134074, 2943426990563883, 2945947869042593, 2948469600858968, 2950992186301870, 2953515625660258, 2956039919223189, 2958565067279818, 2961091070119399, 2963617928031282, 2966145641304916, 2968674210229849, 2971203635095724, 2973733916192285, 2976265053809372, 2978797048236926, 2981329899764982, 2983863608683677, 2986398175283244, 2988933599854015, 2991469882686421, 2994007024070989, 2996545024298346, 2999083883659218, 3001623602444428, 3004164180944899, 3006705619451651, 3009247918255802, 3011791077648571, 3014335097921274, 3016879979365325, 3019425722272238, 3021972326933626, 3024519793641198, 3027068122686764, 3029617314362234, 3032167368959613, 3034718286771008, 3037270068088625, 3039822713204766, 3042376222411834, 3044930596002332, 3047485834268859, 3050041937504116, 3052598906000902, 3055156740052115, 3057715439950751, 3060275005989907, 3062835438462779, 3065396737662662, 3067958903882949, 3070521937417133, 3073085838558809, 3075650607601667, 3078216244839499, 3080782750566197, 3083350125075750, 3085918368662249, 3088487481619884, 3091057464242943, 3093628316825815, 3096200039662988, 3098772633049051, 3101346097278692, 3103920432646698, 3106495639447956, 3109071717977453, 3111648668530278, 3114226491401615, 3116805186886753, 3119384755281078, 3121965196880077, 3124546511979337, 3127128700874545, 3129711763861487, 3132295701236050, 3134880513294223, 3137466200332092, 3140052762645845, 3142640200531770, 3145228514286255, 3147817704205789, 3150407770586960, 3152998713726459, 3155590533921074, 3158183231467697, 3160776806663317, 3163371259805026, 3165966591190015, 3168562801115578, 3171159889879108, 3173757857778097, 3176356705110141, 3178956432172934, 3181557039264272, 3184158526682054, 3186760894724274, 3189364143689034, 3191968273874531, 3194573285579066, 3197179179101040, 3199785954738956, 3202393612791417, 3205002153557127, 3207611577334892, 3210221884423619, 3212833075122315, 3215445149730090, 3218058108546154, 3220671951869819, 3223286680000497, 3225902293237702, 3228518791881052, 3231136176230262, 3233754446585151, 3236373603245639, 3238993646511748, 3241614576683601, 3244236394061423, 3246859098945540, 3249482691636379, 3252107172434472, 3254732541640449, 3257358799555044, 3259985946479091, 3262613982713527, 3265242908559391, 3267872724317824, 3270503430290069, 3273135026777469, 3275767514081472, 3278400892503626, 3281035162345581, 3283670323909091, 3286306377496010, 3288943323408295, 3291581161948007, 3294219893417306, 3296859518118456, 3299500036353823, 3302141448425876, 3304783754637186, 3307426955290427, 3310071050688373, 3312716041133904, 3315361926929999, 3318008708379744, 3320656385786322, 3323304959453024, 3325954429683240, 3328604796780464, 3331256061048293, 3333908222790427, 3336561282310667, 3339215239912919, 3341870095901191, 3344525850579594, 3347182504252341, 3349840057223750, 3352498509798240, 3355157862280334, 3357818114974658, 3360479268185942, 3363141322219017, 3365804277378818, 3368468133970386, 3371132892298860, 3373798552669488, 3376465115387616, 3379132580758698, 3381800949088288, 3384470220682045, 3387140395845731, 3389811474885212, 3392483458106458, 3395156345815540, 3397830138318636, 3400504835922026, 3403180438932093, 3405856947655324, 3408534362398311, 3411212683467750, 3413891911170437, 3416572045813278, 3419253087703277, 3421935037147545, 3424617894453297, 3427301659927852, 3429986333878631, 3432671916613161, 3435358408439073, 3438045809664101, 3440734120596085, 3443423341542968, 3446113472812796, 3448804514713722, 3451496467554002, 3454189331641996, 3456883107286168, 3459577794795088, 3462273394477429, 3464969906641969, 3467667331597591, 3470365669653282, 3473064921118134, 3475765086301343, 3478466165512210, 3481168159060141, 3483871067254646, 3486574890405341, 3489279628821945, 3491985282814283, 3494691852692286, 3497399338765988, 3500107741345528, 3502817060741151, 3505527297263207, 3508238451222150, 3510950522928540, 3513663512693043, 3516377420826427, 3519092247639569, 3521807993443449, 3524524658549153, 3527242243267871, 3529960747910900, 3532680172789643, 3535400518215605, 3538121784500400, 3540843971955746, 3543567080893467, 3546291111625491, 3549016064463854, 3551741939720696, 3554468737708263, 3557196458738907, 3559925103125085, 3562654671179361, 3565385163214403, 3568116579542987, 3570848920477994, 3573582186332409, 3576316377419327, 3579051494051945, 3581787536543568, 3584524505207607, 3587262400357579, 3590001222307107, 3592740971369919, 3595481647859851, 3598223252090845, 3600965784376949, 3603709245032316, 3606453634371207, 3609198952707989, 3611945200357135, 3614692377633225, 3617440484850946, 3620189522325089, 3622939490370554, 3625690389302347, 3628442219435581, 3631194981085474, 3633948674567353, 3636703300196650, 3639458858288905, 3642215349159764, 3644972773124980, 3647731130500412, 3650490421602028, 3653250646745902, 3656011806248215, 3658773900425253, 3661536929593413, 3664300894069196, 3667065794169212, 3669831630210176, 3672598402508912, 3675366111382351, 3678134757147532, 3680904340121599, 3683674860621806, 3686446318965511, 3689218715470184, 3691992050453399, 3694766324232839, 3697541537126293, 3700317689451660, 3703094781526944, 3705872813670258, 3708651786199824, 3711431699433970, 3714212553691130, 3716994349289850, 3719777086548782, 3722560765786684, 3725345387322424, 3728130951474977, 3730917458563428, 3733704908906966, 3736493302824893, 3739282640636615, 3742072922661647, 3744864149219615, 3747656320630249, 3750449437213390, 3753243499288986, 3756038507177095, 3758834461197881, 3761631361671619, 3764429208918689, 3767228003259582, 3770027745014898, 3772828434505343, 3775630072051734, 3778432657974995, 3781236192596159, 3784040676236369, 3786846109216874, 3789652491859035, 3792459824484319, 3795268107414303, 3798077340970673, 3800887525475224, 3803698661249859, 3806510748616591, 3809323787897541, 3812137779414941, 3814952723491129, 3817768620448555, 3820585470609777, 3823403274297461, 3826222031834385, 3829041743543433, 3831862409747602, 3834684030769994, 3837506606933824, 3840330138562414, 3843154625979198, 3845980069507717, 3848806469471623, 3851633826194677, 3854462140000750, 3857291411213821, 3860121640157981, 3862952827157430, 3865784972536477, 3868618076619541, 3871452139731151, 3874287162195946, 3877123144338675, 3879960086484196, 3882797988957479, 3885636852083602, 3888476676187753, 3891317461595232, 3894159208631448, 3897001917621918, 3899845588892274, 3902690222768253, 3905535819575707, 3908382379640594, 3911229903288986, 3914078390847064, 3916927842641117, 3919778258997549, 3922629640242870, 3925481986703705, 3928335298706785, 3931189576578956, 3934044820647171, 3936901031238495, 3939758208680104, 3942616353299286, 3945475465423436, 3948335545380065, 3951196593496790, 3954058610101341, 3956921595521560, 3959785550085399, 3962650474120920, 3965516367956297, 3968383231919816, 3971251066339872, 3974119871544973, 3976989647863738, 3979860395624896, 3982732115157289, 3985604806789868, 3988478470851697, 3991353107671953, 3994228717579920, 3997105300904998, 3999982857976696, 4002861389124634, 4005740894678546, 4008621374968275, 4011502830323778, 4014385261075123, 4017268667552488, 4020153050086165, 4023038409006556, 4025924744644177, 4028812057329654, 4031700347393726, 4034589615167243, 4037479860981167, 4040371085166574, 4043263288054650, 4046156469976693, 4049050631264115, 4051945772248438, 4054841893261298, 4057738994634442, 4060637076699731, 4063536139789136, 4066436184234743, 4069337210368747, 4072239218523458, 4075142209031299, 4078046182224804, 4080951138436619, 4083857077999505, 4086764001246334, 4089671908510090, 4092580800123871, 4095490676420888, 4098401537734464, 4101313384398034, 4104226216745149, 4107140035109469, 4110054839824769, 4112970631224938, 4115887409643975, 4118805175415996, 4121723928875226, 4124643670356005, 4127564400192788, 4130486118720140, 4133408826272741, 4136332523185385, 4139257209792977, 4142182886430537, 4145109553433198, 4148037211136208, 4150965859874925, 4153895499984824, 4156826131801492, 4159757755660629, 4162690371898050, 4165623980849682, 4168558582851569, 4171494178239864, 4174430767350837, 4177368350520872, 4180306928086466, 4183246500384229, 4186187067750886, 4189128630523276, 4192071189038352, 4195014743633181, 4197959294644944, 4200904842410936, 4203851387268566, 4206798929555358, 4209747469608950, 4212697007767094, 4215647544367655, 4218599079748616, 4221551614248071, 4224505148204230, 4227459681955417, 4230415215840071, 4233371750196745, 4236329285364106, 4239287821680938, 4242247359486137, 4245207899118715, 4248169440917799, 4251131985222631, 4254095532372566, 4257060082707076, 4260025636565747, 4262992194288279, 4265959756214490, 4268928322684309, 4271897894037783, 4274868470615074, 4277840052756456, 4280812640802323, 4283786235093181, 4286760835969652, 4289736443772473, 4292713058842497, 4295690681520691, 4298669312148140, 4301648951066043, 4304629598615713, 4307611255138581, 4310593920976192, 4313577596470208, 4316562281962405, 4319547977794676, 4322534684309029, 4325522401847589, 4328511130752594, 4331500871366401, 4334491624031480, 4337483389090421, 4340476166885926, 4343469957760815, 4346464762058022, 4349460580120601, 4352457412291718, 4355455258914657, 4358454120332820, 4361453996889721, 4364454888928993, 4367456796794386, 4370459720829765, 4373463661379112, 4376468618786524, 4379474593396217, 4382481585552521, 4385489595599884, 4388498623882871, 4391508670746163, 4394519736534557, 4397531821592967, 4400544926266425, 4403559050900078, 4406574195839192, 4409590361429148, 4412607548015444, 4415625755943696, 4418644985559636, 4421665237209114, 4424686511238097, 4427708807992668, 4430732127819028, 4433756471063495, 4436781838072504, 4439808229192608, 4442835644770477, 4445864085152898, 4448893550686775, 4451924041719131, 4454955558597105, 4457988101667954, 4461021671279052, 4464056267777893, 4467091891512084, 4470128542829355, 4473166222077550, 4476204929604632, 4479244665758681, 4482285430887897, 4485327225340595, 4488370049465210, 4491413903610294, 4494458788124517, 4497504703356668, 4500551649655653 };
COMPV_ALIGN_DEFAULT() const uint32_t CompVMathExp::s_arrayLut32u[1024 /* tbl */] = { 0, 5680, 11364, 17052, 22744, 28439, 34139, 39842, 45549, 51260, 56975, 62694, 68417, 74143, 79874, 85608, 91346, 97088, 102834, 108584, 114337, 120095, 125857, 131622, 137391, 143164, 148942, 154723, 160508, 166296, 172089, 177886, 183687, 189491, 195300, 201112, 206928, 212749, 218573, 224401, 230233, 236069, 241909, 247753, 253601, 259453, 265309, 271169, 277033, 282901, 288772, 294648, 300528, 306411, 312299, 318191, 324086, 329986, 335890, 341797, 347709, 353624, 359544, 365468, 371395, 377327, 383263, 389202, 395146, 401094, 407046, 413002, 418961, 424925, 430893, 436865, 442841, 448821, 454805, 460793, 466786, 472782, 478782, 484787, 490795, 496808, 502824, 508845, 514869, 520898, 526931, 532968, 539009, 545054, 551104, 557157, 563215, 569276, 575342, 581411, 587485, 593563, 599645, 605732, 611822, 617916, 624015, 630118, 636225, 642336, 648451, 654570, 660693, 666821, 672953, 679089, 685229, 691373, 697521, 703674, 709830, 715991, 722156, 728325, 734499, 740676, 746858, 753044, 759234, 765428, 771627, 777829, 784036, 790247, 796463, 802682, 808906, 815134, 821366, 827602, 833843, 840088, 846337, 852590, 858847, 865109, 871375, 877645, 883920, 890198, 896481, 902769, 909060, 915356, 921656, 927960, 934269, 940581, 946899, 953220, 959546, 965875, 972210, 978548, 984891, 991238, 997589, 1003945, 1010305, 1016669, 1023038, 1029411, 1035788, 1042170, 1048556, 1054946, 1061340, 1067739, 1074142, 1080550, 1086962, 1093378, 1099798, 1106223, 1112653, 1119086, 1125524, 1131966, 1138413, 1144864, 1151320, 1157779, 1164243, 1170712, 1177185, 1183662, 1190144, 1196630, 1203120, 1209615, 1216114, 1222618, 1229126, 1235639, 1242156, 1248677, 1255203, 1261733, 1268267, 1274806, 1281350, 1287897, 1294450, 1301006, 1307567, 1314133, 1320703, 1327278, 1333856, 1340440, 1347028, 1353620, 1360217, 1366818, 1373424, 1380034, 1386648, 1393268, 1399891, 1406519, 1413152, 1419789, 1426431, 1433077, 1439727, 1446382, 1453042, 1459706, 1466374, 1473048, 1479725, 1486407, 1493094, 1499785, 1506481, 1513181, 1519886, 1526595, 1533309, 1540028, 1546751, 1553478, 1560210, 1566947, 1573688, 1580434, 1587184, 1593939, 1600699, 1607463, 1614231, 1621005, 1627782, 1634565, 1641352, 1648143, 1654940, 1661740, 1668546, 1675356, 1682170, 1688990, 1695814, 1702642, 1709475, 1716313, 1723155, 1730002, 1736854, 1743710, 1750571, 1757437, 1764307, 1771182, 1778061, 1784945, 1791834, 1798728, 1805626, 1812529, 1819436, 1826348, 1833265, 1840187, 1847113, 1854044, 1860979, 1867920, 1874865, 1881814, 1888769, 1895728, 1902692, 1909660, 1916634, 1923612, 1930594, 1937582, 1944574, 1951571, 1958573, 1965579, 1972590, 1979606, 1986627, 1993652, 2000682, 2007717, 2014757, 2021801, 2028850, 2035904, 2042963, 2050027, 2057095, 2064168, 2071246, 2078329, 2085416, 2092508, 2099606, 2106707, 2113814, 2120926, 2128042, 2135163, 2142289, 2149420, 2156555, 2163696, 2170841, 2177991, 2185146, 2192306, 2199471, 2206640, 2213815, 2220994, 2228178, 2235367, 2242561, 2249759, 2256963, 2264171, 2271385, 2278603, 2285826, 2293054, 2300287, 2307525, 2314767, 2322015, 2329267, 2336525, 2343787, 2351054, 2358327, 2365604, 2372886, 2380173, 2387464, 2394761, 2402063, 2409370, 2416681, 2423998, 2431320, 2438646, 2445977, 2453314, 2460655, 2468002, 2475353, 2482709, 2490071, 2497437, 2504808, 2512184, 2519566, 2526952, 2534343, 2541740, 2549141, 2556547, 2563958, 2571375, 2578796, 2586222, 2593654, 2601090, 2608532, 2615978, 2623430, 2630886, 2638348, 2645815, 2653286, 2660763, 2668245, 2675732, 2683224, 2690721, 2698223, 2705730, 2713243, 2720760, 2728283, 2735810, 2743343, 2750881, 2758424, 2765972, 2773525, 2781083, 2788646, 2796215, 2803788, 2811367, 2818951, 2826540, 2834134, 2841733, 2849338, 2856947, 2864562, 2872182, 2879807, 2887437, 2895072, 2902713, 2910359, 2918010, 2925666, 2933327, 2940993, 2948665, 2956342, 2964024, 2971711, 2979403, 2987101, 2994804, 3002512, 3010225, 3017944, 3025667, 3033396, 3041131, 3048870, 3056615, 3064365, 3072120, 3079880, 3087646, 3095417, 3103193, 3110974, 3118761, 3126553, 3134350, 3142153, 3149961, 3157774, 3165592, 3173416, 3181245, 3189079, 3196919, 3204764, 3212614, 3220470, 3228330, 3236197, 3244068, 3251945, 3259827, 3267715, 3275607, 3283506, 3291409, 3299318, 3307232, 3315152, 3323077, 3331007, 3338943, 3346884, 3354831, 3362782, 3370740, 3378702, 3386670, 3394644, 3402622, 3410607, 3418596, 3426591, 3434592, 3442598, 3450609, 3458626, 3466648, 3474675, 3482708, 3490747, 3498791, 3506840, 3514895, 3522955, 3531021, 3539092, 3547168, 3555250, 3563338, 3571431, 3579529, 3587633, 3595743, 3603858, 3611978, 3620104, 3628236, 3636373, 3644515, 3652663, 3660817, 3668976, 3677140, 3685310, 3693486, 3701667, 3709854, 3718046, 3726244, 3734447, 3742656, 3750871, 3759091, 3767316, 3775547, 3783784, 3792026, 3800274, 3808528, 3816787, 3825051, 3833322, 3841598, 3849879, 3858166, 3866459, 3874757, 3883061, 3891370, 3899686, 3908006, 3916333, 3924665, 3933002, 3941346, 3949695, 3958049, 3966410, 3974776, 3983147, 3991525, 3999908, 4008296, 4016691, 4025091, 4033496, 4041908, 4050325, 4058748, 4067176, 4075610, 4084050, 4092496, 4100947, 4109404, 4117867, 4126335, 4134810, 4143290, 4151775, 4160267, 4168764, 4177267, 4185776, 4194290, 4202811, 4211337, 4219868, 4228406, 4236949, 4245499, 4254054, 4262614, 4271181, 4279753, 4288331, 4296915, 4305505, 4314101, 4322702, 4331309, 4339922, 4348541, 4357166, 4365796, 4374433, 4383075, 4391723, 4400377, 4409037, 4417703, 4426374, 4435051, 4443735, 4452424, 4461119, 4469820, 4478527, 4487240, 4495958, 4504683, 4513413, 4522149, 4530892, 4539640, 4548394, 4557154, 4565920, 4574692, 4583470, 4592254, 4601043, 4609839, 4618641, 4627448, 4636262, 4645081, 4653907, 4662738, 4671576, 4680419, 4689269, 4698124, 4706986, 4715853, 4724727, 4733606, 4742491, 4751383, 4760280, 4769184, 4778093, 4787009, 4795931, 4804858, 4813792, 4822732, 4831678, 4840629, 4849587, 4858551, 4867521, 4876497, 4885480, 4894468, 4903462, 4912463, 4921469, 4930482, 4939501, 4948526, 4957557, 4966594, 4975637, 4984686, 4993742, 5002803, 5011871, 5020945, 5030025, 5039111, 5048204, 5057302, 5066407, 5075517, 5084634, 5093758, 5102887, 5112022, 5121164, 5130312, 5139466, 5148626, 5157793, 5166965, 5176144, 5185329, 5194521, 5203718, 5212922, 5222132, 5231348, 5240571, 5249800, 5259035, 5268276, 5277523, 5286777, 5296037, 5305303, 5314576, 5323855, 5333140, 5342431, 5351729, 5361033, 5370343, 5379660, 5388983, 5398312, 5407648, 5416990, 5426338, 5435692, 5445053, 5454420, 5463794, 5473174, 5482560, 5491953, 5501352, 5510757, 5520169, 5529587, 5539011, 5548442, 5557879, 5567323, 5576773, 5586229, 5595692, 5605161, 5614637, 5624119, 5633607, 5643102, 5652603, 5662111, 5671625, 5681146, 5690673, 5700206, 5709746, 5719293, 5728846, 5738405, 5747971, 5757543, 5767122, 5776707, 5786299, 5795897, 5805502, 5815113, 5824731, 5834355, 5843986, 5853624, 5863267, 5872918, 5882575, 5892238, 5901908, 5911585, 5921268, 5930957, 5940654, 5950356, 5960066, 5969782, 5979504, 5989233, 5998969, 6008711, 6018460, 6028216, 6037978, 6047746, 6057522, 6067304, 6077092, 6086887, 6096689, 6106498, 6116313, 6126134, 6135963, 6145798, 6155639, 6165488, 6175343, 6185205, 6195073, 6204948, 6214830, 6224718, 6234613, 6244515, 6254424, 6264339, 6274261, 6284190, 6294125, 6304067, 6314016, 6323971, 6333934, 6343903, 6353879, 6363861, 6373851, 6383847, 6393850, 6403859, 6413876, 6423899, 6433929, 6443966, 6454009, 6464060, 6474117, 6484181, 6494252, 6504329, 6514414, 6524505, 6534603, 6544708, 6554820, 6564939, 6575064, 6585197, 6595336, 6605482, 6615635, 6625795, 6635961, 6646135, 6656316, 6666503, 6676697, 6686898, 6697106, 6707321, 6717543, 6727772, 6738008, 6748251, 6758500, 6768757, 6779020, 6789291, 6799568, 6809853, 6820144, 6830442, 6840748, 6851060, 6861379, 6871705, 6882039, 6892379, 6902726, 6913080, 6923441, 6933810, 6944185, 6954567, 6964957, 6975353, 6985756, 6996167, 7006584, 7017009, 7027441, 7037879, 7048325, 7058778, 7069238, 7079705, 7090179, 7100660, 7111148, 7121644, 7132146, 7142656, 7153172, 7163696, 7174227, 7184765, 7195310, 7205863, 7216422, 7226989, 7237563, 7248144, 7258732, 7269327, 7279929, 7290539, 7301156, 7311780, 7322411, 7333050, 7343695, 7354348, 7365008, 7375675, 7386350, 7397032, 7407720, 7418417, 7429120, 7439831, 7450549, 7461274, 7472006, 7482746, 7493493, 7504247, 7515009, 7525778, 7536554, 7547337, 7558128, 7568926, 7579731, 7590544, 7601364, 7612191, 7623026, 7633868, 7644717, 7655574, 7666438, 7677309, 7688188, 7699074, 7709967, 7720868, 7731776, 7742692, 7753615, 7764545, 7775483, 7786428, 7797381, 7808341, 7819309, 7830283, 7841266, 7852255, 7863253, 7874257, 7885269, 7896289, 7907316, 7918350, 7929392, 7940442, 7951499, 7962563, 7973635, 7984714, 7995801, 8006896, 8017997, 8029107, 8040224, 8051348, 8062480, 8073620, 8084767, 8095922, 8107084, 8118253, 8129431, 8140616, 8151808, 8163008, 8174216, 8185431, 8196654, 8207884, 8219122, 8230368, 8241621, 8252882, 8264150, 8275426, 8286710, 8298001, 8309300, 8320607, 8331921, 8343243, 8354573, 8365910, 8377255 };
template<typename T>
static void CompVMathExpExp_C(const T* ptrIn, T* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, const compv_uscalar_t stride)
{
COMPV_DEBUG_INFO_CODE_NOT_OPTIMIZED("No SIMD implementation could be found. On ARM, the NEON code is almost #10 faster.");
for (compv_uscalar_t j = 0; j < height; ++j) {
for (compv_uscalar_t i = 0; i < width; ++i) {
ptrOut[i] = std::exp(ptrIn[i]);
}
ptrIn += stride;
ptrOut += stride;
}
}
// Source code based on https://github.com/herumi/fmath
static void CompVMathExpExp_minpack1_64f64f_C(const compv_float64_t* ptrIn, compv_float64_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, const compv_uscalar_t stride, const uint64_t* lut64u, const uint64_t* var64u, const compv_float64_t* var64f)
{
#if COMPV_ARCH_X86
if (width > 3) {
#elif COMPV_ARCH_ARM
if (width > 1) {
#endif
COMPV_DEBUG_INFO_CODE_NOT_OPTIMIZED("No SIMD implementation could be found [ASM code more than #10 times faster on ARM CPUs]");
}
static const uint64_t& mask = var64u[0]; /* mask(c.sbit = 11) */
static const uint64_t& cadj = var64u[1]; /* c.adj = (1UL << (sbit + 10)) - (1UL << sbit) */
static const compv_float64_t& b = var64f[0]; /* 3ULL << 51 */
static const compv_float64_t& ca = var64f[1]; /* c.a */
static const compv_float64_t& cra = var64f[2]; /* c.ra */
static const compv_float64_t& C10 = var64f[3]; /* c.C1[0] */
static const compv_float64_t& C20 = var64f[4]; /* c.C2[0] */
static const compv_float64_t& C30 = var64f[5]; /* c.C3[0] */
static const compv_float64_t& ExpMin = var64f[6]; /* ExpMin */
static const compv_float64_t& ExpMax = var64f[7]; /* ExpMax */
union di {
compv_float64_t d;
uint64_t i;
};
for (compv_uscalar_t j = 0; j < height; ++j) {
for (compv_uscalar_t i = 0; i < width; ++i) {
compv_float64_t x = ptrIn[i];
x = COMPV_MATH_CLIP3(ExpMin, ExpMax, x);
di di;
di.d = x * ca + b;
const double t = (di.d - b) * cra - x;
const uint64_t u = ((di.i + cadj) >> 11) << 52; // 2095104 is c.adj
const double y = (C30 - t) * (t * t) * C20 - t + C10;
di.i = u | lut64u[di.i & mask];
ptrOut[i] = y * di.d;
}
ptrIn += stride;
ptrOut += stride;
}
}
// Source code based on https://github.com/herumi/fmath
static void CompVMathExpExp_minpack1_32f32f_C(const compv_float32_t* ptrIn, compv_float32_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, const compv_uscalar_t stride, const uint32_t* lut32u, const compv_float32_t* var32f)
{
COMPV_DEBUG_INFO_CODE_NOT_OPTIMIZED("No SIMD implementation could be found [ASM code more than #10 times faster on ARM CPUs]");
static const compv_float32_t& magic = var32f[0]; // [0]: (1 << 23) + (1 << 22)
static const compv_float32_t& a0 = var32f[1]; // [1]: expVar.a[0]
static const compv_float32_t& b0 = var32f[2]; // [2]: expVar.b[0]
static const compv_float32_t& maxX = var32f[3]; // [3]: expVar.maxX[0]
static const compv_float32_t& minX = var32f[4]; // [4]: expVar.minX[0]
union fi {
compv_float32_t f;
uint32_t i;
};
for (compv_uscalar_t j = 0; j < height; ++j) {
for (compv_uscalar_t i = 0; i < width; ++i) {
compv_float32_t x = ptrIn[i];
x = COMPV_MATH_CLIP3(minX, maxX, x); // max(min(x, maxX), minX)
compv_float32_t t = (x * a0) + magic; // Fused Multiply Add
fi fi;
fi.f = t;
t = x - (t - magic) * b0; // Fused Multiply Add
const uint32_t u = ((fi.i + 130048) >> 10) << 23;
const uint32_t v = fi.i & 1023;
fi.i = u | lut32u[v];
ptrOut[i] = fi.f + (t * fi.f) ; // Fused Multiply Add
}
ptrIn += stride;
ptrOut += stride;
}
}
template<typename T>
static COMPV_ERROR_CODE CompVMathExpExp(const CompVMatPtr &in, CompVMatPtrPtr out)
{
COMPV_CHECK_EXP_RETURN(!in || !in->isRawTypeMatch<T>(), COMPV_ERROR_CODE_E_INVALID_PARAMETER);
const size_t rows = in->rows();
const size_t cols = in->cols();
const size_t stride = in->stride();
CompVMatPtr out_ = *out;
if (out_ != in) { // This function allows "in == out"
COMPV_CHECK_CODE_RETURN(CompVMat::newObj(&out_, in));
}
auto funcPtr = [&](const size_t start, const size_t end) -> COMPV_ERROR_CODE {
const T* ptrIn = in->ptr<const T>(start);
T* ptrOut = out_->ptr<T>(start);
if (std::is_same<T, compv_float64_t>::value) {
int minpack;
void(*CompVMathExpExp_64f64f)(const compv_float64_t* ptrIn, compv_float64_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, const compv_uscalar_t stride, const uint64_t* lut64u, const uint64_t* var64u, const compv_float64_t* var64f)
= nullptr;
COMPV_CHECK_CODE_RETURN(CompVMathExp::hookExp_64f(&CompVMathExpExp_64f64f, &minpack));
CompVMathExpExp_64f64f(
reinterpret_cast<const compv_float64_t*>(ptrIn), reinterpret_cast<compv_float64_t*>(ptrOut),
cols, (end - start), stride,
CompVMathExp::lut64u(), CompVMathExp::vars64u(), CompVMathExp::vars64f()
);
const size_t colsp = cols & -minpack;
const size_t remain = (cols - colsp);
if (remain) {
CompVMathExpExp_minpack1_64f64f_C(
reinterpret_cast<const compv_float64_t*>(&ptrIn[colsp]), reinterpret_cast<compv_float64_t*>(&ptrOut[colsp]),
remain, (end - start), stride,
CompVMathExp::lut64u(), CompVMathExp::vars64u(), CompVMathExp::vars64f()
);
}
}
else if (std::is_same<T, compv_float32_t>::value) {
void(*CompVMathExpExp_32f32f)(const compv_float32_t* ptrIn, compv_float32_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, const compv_uscalar_t stride, const uint32_t* lut32u, const compv_float32_t* var32f)
= CompVMathExpExp_minpack1_32f32f_C;
#if COMPV_ARCH_X86
if (CompVCpu::isEnabled(kCpuFlagSSE2) && COMPV_IS_ALIGNED_SSE(ptrIn) && COMPV_IS_ALIGNED_SSE(ptrOut) && COMPV_IS_ALIGNED_SSE(stride * sizeof(compv_float32_t))) {
COMPV_EXEC_IFDEF_INTRIN_X86(CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Intrin_SSE2);
}
if (CompVCpu::isEnabled(kCpuFlagAVX2) && COMPV_IS_ALIGNED_AVX(ptrIn) && COMPV_IS_ALIGNED_AVX(ptrOut) && COMPV_IS_ALIGNED_AVX(stride * sizeof(compv_float32_t))) {
COMPV_EXEC_IFDEF_INTRIN_X86(CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Intrin_AVX2);
COMPV_EXEC_IFDEF_ASM_X64(CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Asm_X64_AVX2);
if (CompVCpu::isEnabled(kCpuFlagFMA3)) {
COMPV_EXEC_IFDEF_ASM_X64(CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Asm_X64_FMA3_AVX2);
}
}
#elif COMPV_ARCH_ARM
if (CompVCpu::isEnabled(kCpuFlagARM_NEON) && COMPV_IS_ALIGNED_NEON(ptrIn) && COMPV_IS_ALIGNED_NEON(ptrOut) && COMPV_IS_ALIGNED_NEON(stride * sizeof(compv_float32_t))) {
COMPV_EXEC_IFDEF_INTRIN_ARM(CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Intrin_NEON);
COMPV_EXEC_IFDEF_ASM_ARM32(CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Asm_NEON32);
COMPV_EXEC_IFDEF_ASM_ARM64(CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Asm_NEON64);
if (CompVCpu::isEnabled(kCpuFlagARM_NEON_FMA)) {
COMPV_EXEC_IFDEF_ASM_ARM32(CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Asm_FMA_NEON32);
COMPV_EXEC_IFDEF_ASM_ARM64(CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Asm_FMA_NEON64);
}
}
#endif
CompVMathExpExp_32f32f(
reinterpret_cast<const compv_float32_t*>(ptrIn), reinterpret_cast<compv_float32_t*>(ptrOut),
cols, (end - start), stride,
CompVMathExp::lut32u(), CompVMathExp::vars32f()
);
}
else {
CompVMathExpExp_C(
ptrIn, ptrOut,
cols, (end - start), stride
);
}
return COMPV_ERROR_CODE_S_OK;
};
COMPV_CHECK_CODE_RETURN(CompVThreadDispatcher::dispatchDividingAcrossY(
funcPtr,
cols,
rows,
1
));
*out = out_;
return COMPV_ERROR_CODE_S_OK;
}
// out[i] = std::exp(in[i])
COMPV_ERROR_CODE CompVMathExp::exp(const CompVMatPtr &in, CompVMatPtrPtr out)
{
COMPV_CHECK_EXP_RETURN(!in || !out || in->planeCount() != 1
, COMPV_ERROR_CODE_E_INVALID_PARAMETER);
COMPV_CHECK_CODE_RETURN(CompVMathExp::init()); // Init LUT tables (nop if already done)
CompVGenericFloatInvokeCodeRawType(in->subType(), CompVMathExpExp, in, out);
return COMPV_ERROR_CODE_S_OK;
}
COMPV_ERROR_CODE CompVMathExp::hookExp_64f(
void(**CompVMathExpExp_64f64f)(const compv_float64_t* ptrIn, compv_float64_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, const compv_uscalar_t stride, const uint64_t* lut64u, const uint64_t* var64u, const compv_float64_t* var64f)
, int* minpack COMPV_DEFAULT(nullptr)
)
{
COMPV_CHECK_EXP_RETURN(!CompVMathExpExp_64f64f, COMPV_ERROR_CODE_E_INVALID_PARAMETER);
int minpack_ = 1;
*CompVMathExpExp_64f64f = CompVMathExpExp_minpack1_64f64f_C, minpack_ = 1;
#if COMPV_ARCH_X86
if (CompVCpu::isEnabled(kCpuFlagSSE2)) {
COMPV_EXEC_IFDEF_INTRIN_X86((*CompVMathExpExp_64f64f = CompVMathExpExp_minpack2_64f64f_Intrin_SSE2, minpack_ = 2));
}
if (CompVCpu::isEnabled(kCpuFlagAVX2)) {
COMPV_EXEC_IFDEF_INTRIN_X86((*CompVMathExpExp_64f64f = CompVMathExpExp_minpack4_64f64f_Intrin_AVX2, minpack_ = 4));
COMPV_EXEC_IFDEF_ASM_X64((*CompVMathExpExp_64f64f = CompVMathExpExp_minpack1_64f64f_Asm_X64_AVX2, minpack_ = 1));
if (CompVCpu::isEnabled(kCpuFlagFMA3)) {
COMPV_EXEC_IFDEF_ASM_X64((*CompVMathExpExp_64f64f = CompVMathExpExp_minpack1_64f64f_Asm_X64_FMA3_AVX2, minpack_ = 1));
}
}
#elif COMPV_ARCH_ARM
if (CompVCpu::isEnabled(kCpuFlagARM_NEON)) {
COMPV_EXEC_IFDEF_INTRIN_ARM64((*CompVMathExpExp_64f64f = CompVMathExpExp_minpack2_64f64f_Intrin_NEON64, minpack_ = 2));
COMPV_EXEC_IFDEF_ASM_ARM32((*CompVMathExpExp_64f64f = CompVMathExpExp_minpack1_64f64f_Asm_NEON32, minpack_ = 1));
COMPV_EXEC_IFDEF_ASM_ARM64((*CompVMathExpExp_64f64f = CompVMathExpExp_minpack1_64f64f_Asm_NEON64, minpack_ = 1));
if (CompVCpu::isEnabled(kCpuFlagARM_NEON_FMA)) {
COMPV_EXEC_IFDEF_ASM_ARM32((*CompVMathExpExp_64f64f = CompVMathExpExp_minpack1_64f64f_Asm_FMA_NEON32, minpack_ = 1));
COMPV_EXEC_IFDEF_ASM_ARM64((*CompVMathExpExp_64f64f = CompVMathExpExp_minpack1_64f64f_Asm_FMA_NEON64, minpack_ = 1));
}
}
#endif
if (minpack) {
*minpack = minpack_;
}
return COMPV_ERROR_CODE_S_OK;
}
COMPV_ERROR_CODE CompVMathExp::hookExp_32f(
void(**CompVMathExpExp_32f32f)(const compv_float32_t* ptrIn, compv_float32_t* ptrOut, const compv_uscalar_t width, const compv_uscalar_t height, const compv_uscalar_t stride, const uint32_t* lut32u, const compv_float32_t* var32f)
)
{
COMPV_CHECK_EXP_RETURN(!CompVMathExpExp_32f32f, COMPV_ERROR_CODE_E_INVALID_PARAMETER);
*CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_C;
#if COMPV_ARCH_X86
if (CompVCpu::isEnabled(kCpuFlagSSE2)) {
COMPV_EXEC_IFDEF_INTRIN_X86((*CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Intrin_SSE2));
}
if (CompVCpu::isEnabled(kCpuFlagAVX2)) {
COMPV_EXEC_IFDEF_INTRIN_X86((*CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Intrin_AVX2));
COMPV_EXEC_IFDEF_ASM_X64((*CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Asm_X64_AVX2));
if (CompVCpu::isEnabled(kCpuFlagFMA3)) {
COMPV_EXEC_IFDEF_ASM_X64((*CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Asm_X64_FMA3_AVX2));
}
}
#elif COMPV_ARCH_ARM
if (CompVCpu::isEnabled(kCpuFlagARM_NEON)) {
COMPV_EXEC_IFDEF_INTRIN_ARM((*CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Intrin_NEON));
COMPV_EXEC_IFDEF_ASM_ARM32((*CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Asm_NEON32));
COMPV_EXEC_IFDEF_ASM_ARM64((*CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Asm_NEON64));
if (CompVCpu::isEnabled(kCpuFlagARM_NEON_FMA)) {
COMPV_EXEC_IFDEF_ASM_ARM32((*CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Asm_FMA_NEON32));
COMPV_EXEC_IFDEF_ASM_ARM64((*CompVMathExpExp_32f32f = CompVMathExpExp_minpack1_32f32f_Asm_FMA_NEON64));
}
}
#endif
return COMPV_ERROR_CODE_S_OK;
}
COMPV_ERROR_CODE CompVMathExp::init()
{
if (isInitialized()) {
return COMPV_ERROR_CODE_S_OK;
}
COMPV_DEBUG_INFO_EX(COMPV_THIS_CLASSNAME, "Init");
// 64u LUT
#if 0 // LUT is hard-coded to make sure exp will return same MD5 on all platforms (std::pow implementation is different)
{
COMPV_ASSERT(false); // Code used to show how the LUT is generated
COMPV_DEBUG_INFO_CODE_FOR_TESTING("Code used to show how the LUT is generated");
const int s = static_cast<int>(sizeof(s_arrayLut64u) / sizeof(s_arrayLut64u[0]));
const uint64_t mask = (1ULL << 52) - 1; // mask64(52)
union di {
compv_float64_t d;
uint64_t i;
};
const compv_float64_t scale = (1.0 / s);
std::string data;
for (int i = 0; i < s; i++) {
di di;
di.d = std::pow(2.0, i * scale);
data += CompVBase::to_string(di.i & mask) + std::string(", ");
}
printf("%s", data.c_str());
FILE* file = fopen("./lut64.txt", "w+");
fwrite(data.c_str(), 1, data.length(), file);
fclose(file);
}
#endif
s_bInitialized = true;
return COMPV_ERROR_CODE_S_OK;
}
COMPV_ERROR_CODE CompVMathExp::deInit()
{
// Nothing to do
COMPV_DEBUG_INFO_EX(COMPV_THIS_CLASSNAME, "DeInit");
return COMPV_ERROR_CODE_S_OK;
}
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Based on:
e ^ x = (1+m) * (2^n)
x = log(1+m) + n * log(2)
n = (int) (x * 1.0 / log(2))
(1+m) = e ^ (x - n * log(2))
(1+m) = Poly(x - n * log(2))
where Poly(x) is the Minimax approximation of e ^ x over the
range [-Log(2), Log(2)]
Test func : expf(x)
Test Range: 0 < x < 50
Peak Error: ~0.00024%
RMS Error: ~0.00007%
*/
const float __expf_rng[2] = {
1.442695041f,
0.693147180f
};
const float __expf_lut[8] = {
0.9999999916728642f, //p0
0.04165989275009526f, //p4
0.5000006143673624f, //p2
0.0014122663401803872f, //p6
1.000000059694879f, //p1
0.008336936973260111f, //p5
0.16666570253074878f, //p3
0.00019578093328483123f //p7
};
float ___expf_c(float x)
{
float a, b, c, d, xx;
int m;
union {
float f;
int i;
} r;
//Range Reduction:
m = (int)(x * __expf_rng[0]);
x = x - ((float)m) * __expf_rng[1];
//Taylor Polynomial (Estrins)
a = (__expf_lut[4] * x) + (__expf_lut[0]);
b = (__expf_lut[6] * x) + (__expf_lut[2]);
c = (__expf_lut[5] * x) + (__expf_lut[1]);
d = (__expf_lut[7] * x) + (__expf_lut[3]);
xx = x * x;
a = a + b * xx;
c = c + d * xx;
xx = xx * xx;
r.f = a + c * xx;
//multiply by 2 ^ m
m = m << 23;
r.i = r.i + m;
return r.f;
}
COMPV_NAMESPACE_END()