numo-narray-alt 0.9.6 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +31 -10
  3. data/ext/numo/narray/SFMT-params19937.h +8 -16
  4. data/ext/numo/narray/numo/narray.h +2 -2
  5. data/ext/numo/narray/numo/types/complex.h +2 -2
  6. data/ext/numo/narray/src/mh/math/acos.h +9 -0
  7. data/ext/numo/narray/src/mh/math/acosh.h +9 -0
  8. data/ext/numo/narray/src/mh/math/asin.h +9 -0
  9. data/ext/numo/narray/src/mh/math/asinh.h +9 -0
  10. data/ext/numo/narray/src/mh/math/atan.h +9 -0
  11. data/ext/numo/narray/src/mh/math/atan2.h +29 -0
  12. data/ext/numo/narray/src/mh/math/atanh.h +9 -0
  13. data/ext/numo/narray/src/mh/math/cbrt.h +9 -0
  14. data/ext/numo/narray/src/mh/math/cos.h +9 -0
  15. data/ext/numo/narray/src/mh/math/cosh.h +9 -0
  16. data/ext/numo/narray/src/mh/math/erf.h +9 -0
  17. data/ext/numo/narray/src/mh/math/erfc.h +9 -0
  18. data/ext/numo/narray/src/mh/math/exp.h +9 -0
  19. data/ext/numo/narray/src/mh/math/exp10.h +9 -0
  20. data/ext/numo/narray/src/mh/math/exp2.h +9 -0
  21. data/ext/numo/narray/src/mh/math/expm1.h +9 -0
  22. data/ext/numo/narray/src/mh/math/frexp.h +30 -0
  23. data/ext/numo/narray/src/mh/math/hypot.h +29 -0
  24. data/ext/numo/narray/src/mh/math/ldexp.h +29 -0
  25. data/ext/numo/narray/src/mh/math/log.h +9 -0
  26. data/ext/numo/narray/src/mh/math/log10.h +9 -0
  27. data/ext/numo/narray/src/mh/math/log1p.h +9 -0
  28. data/ext/numo/narray/src/mh/math/log2.h +9 -0
  29. data/ext/numo/narray/src/mh/math/sin.h +9 -0
  30. data/ext/numo/narray/src/mh/math/sinc.h +9 -0
  31. data/ext/numo/narray/src/mh/math/sinh.h +9 -0
  32. data/ext/numo/narray/src/mh/math/sqrt.h +203 -0
  33. data/ext/numo/narray/src/mh/math/tan.h +9 -0
  34. data/ext/numo/narray/src/mh/math/tanh.h +9 -0
  35. data/ext/numo/narray/src/mh/math/unary_func.h +70 -0
  36. data/ext/numo/narray/src/mh/mean.h +1 -8
  37. data/ext/numo/narray/src/mh/rms.h +1 -8
  38. data/ext/numo/narray/src/mh/stddev.h +1 -8
  39. data/ext/numo/narray/src/mh/var.h +1 -8
  40. data/ext/numo/narray/src/t_dcomplex.c +236 -1707
  41. data/ext/numo/narray/src/t_dfloat.c +66 -1952
  42. data/ext/numo/narray/src/t_robject.c +4 -4
  43. data/ext/numo/narray/src/t_scomplex.c +236 -1707
  44. data/ext/numo/narray/src/t_sfloat.c +66 -1952
  45. data/lib/numo/narray/extra.rb +77 -0
  46. metadata +33 -3
@@ -46,13 +46,75 @@ extern VALUE cRT;
46
46
  #include "mh/var.h"
47
47
  #include "mh/stddev.h"
48
48
  #include "mh/rms.h"
49
+ #include "mh/math/sqrt.h"
50
+ #include "mh/math/cbrt.h"
51
+ #include "mh/math/log.h"
52
+ #include "mh/math/log2.h"
53
+ #include "mh/math/log10.h"
54
+ #include "mh/math/exp.h"
55
+ #include "mh/math/exp2.h"
56
+ #include "mh/math/exp10.h"
57
+ #include "mh/math/sin.h"
58
+ #include "mh/math/cos.h"
59
+ #include "mh/math/tan.h"
60
+ #include "mh/math/asin.h"
61
+ #include "mh/math/acos.h"
62
+ #include "mh/math/atan.h"
63
+ #include "mh/math/sinh.h"
64
+ #include "mh/math/cosh.h"
65
+ #include "mh/math/tanh.h"
66
+ #include "mh/math/asinh.h"
67
+ #include "mh/math/acosh.h"
68
+ #include "mh/math/atanh.h"
69
+ #include "mh/math/sinc.h"
70
+ #include "mh/math/atan2.h"
71
+ #include "mh/math/hypot.h"
72
+ #include "mh/math/erf.h"
73
+ #include "mh/math/erfc.h"
74
+ #include "mh/math/log1p.h"
75
+ #include "mh/math/expm1.h"
76
+ #include "mh/math/ldexp.h"
77
+ #include "mh/math/frexp.h"
49
78
 
50
79
  typedef double dfloat; // Type aliases for shorter notation
51
80
  // following the codebase naming convention.
52
- DEF_NARRAY_FLT_MEAN_METHOD_FUNC(dfloat, double, numo_cDFloat, numo_cDFloat)
53
- DEF_NARRAY_FLT_VAR_METHOD_FUNC(dfloat, double, numo_cDFloat, numo_cDFloat)
54
- DEF_NARRAY_FLT_STDDEV_METHOD_FUNC(dfloat, double, numo_cDFloat, numo_cDFloat)
55
- DEF_NARRAY_FLT_RMS_METHOD_FUNC(dfloat, double, numo_cDFloat, numo_cDFloat)
81
+ DEF_NARRAY_FLT_MEAN_METHOD_FUNC(dfloat, numo_cDFloat, double, numo_cDFloat)
82
+ DEF_NARRAY_FLT_VAR_METHOD_FUNC(dfloat, numo_cDFloat, double, numo_cDFloat)
83
+ DEF_NARRAY_FLT_STDDEV_METHOD_FUNC(dfloat, numo_cDFloat, double, numo_cDFloat)
84
+ DEF_NARRAY_FLT_RMS_METHOD_FUNC(dfloat, numo_cDFloat, double, numo_cDFloat)
85
+ #ifdef __SSE2__
86
+ DEF_NARRAY_FLT_SQRT_SSE2_DBL_METHOD_FUNC(dfloat, numo_cDFloat)
87
+ #else
88
+ DEF_NARRAY_FLT_SQRT_METHOD_FUNC(dfloat, numo_cDFloat)
89
+ #endif
90
+ DEF_NARRAY_FLT_CBRT_METHOD_FUNC(dfloat, numo_cDFloat)
91
+ DEF_NARRAY_FLT_LOG_METHOD_FUNC(dfloat, numo_cDFloat)
92
+ DEF_NARRAY_FLT_LOG2_METHOD_FUNC(dfloat, numo_cDFloat)
93
+ DEF_NARRAY_FLT_LOG10_METHOD_FUNC(dfloat, numo_cDFloat)
94
+ DEF_NARRAY_FLT_EXP_METHOD_FUNC(dfloat, numo_cDFloat)
95
+ DEF_NARRAY_FLT_EXP2_METHOD_FUNC(dfloat, numo_cDFloat)
96
+ DEF_NARRAY_FLT_EXP10_METHOD_FUNC(dfloat, numo_cDFloat)
97
+ DEF_NARRAY_FLT_SIN_METHOD_FUNC(dfloat, numo_cDFloat)
98
+ DEF_NARRAY_FLT_COS_METHOD_FUNC(dfloat, numo_cDFloat)
99
+ DEF_NARRAY_FLT_TAN_METHOD_FUNC(dfloat, numo_cDFloat)
100
+ DEF_NARRAY_FLT_ASIN_METHOD_FUNC(dfloat, numo_cDFloat)
101
+ DEF_NARRAY_FLT_ACOS_METHOD_FUNC(dfloat, numo_cDFloat)
102
+ DEF_NARRAY_FLT_ATAN_METHOD_FUNC(dfloat, numo_cDFloat)
103
+ DEF_NARRAY_FLT_SINH_METHOD_FUNC(dfloat, numo_cDFloat)
104
+ DEF_NARRAY_FLT_COSH_METHOD_FUNC(dfloat, numo_cDFloat)
105
+ DEF_NARRAY_FLT_TANH_METHOD_FUNC(dfloat, numo_cDFloat)
106
+ DEF_NARRAY_FLT_ASINH_METHOD_FUNC(dfloat, numo_cDFloat)
107
+ DEF_NARRAY_FLT_ACOSH_METHOD_FUNC(dfloat, numo_cDFloat)
108
+ DEF_NARRAY_FLT_ATANH_METHOD_FUNC(dfloat, numo_cDFloat)
109
+ DEF_NARRAY_FLT_SINC_METHOD_FUNC(dfloat, numo_cDFloat)
110
+ DEF_NARRAY_FLT_ATAN2_METHOD_FUNC(dfloat, numo_cDFloat)
111
+ DEF_NARRAY_FLT_HYPOT_METHOD_FUNC(dfloat, numo_cDFloat)
112
+ DEF_NARRAY_FLT_ERF_METHOD_FUNC(dfloat, numo_cDFloat)
113
+ DEF_NARRAY_FLT_ERFC_METHOD_FUNC(dfloat, numo_cDFloat)
114
+ DEF_NARRAY_FLT_LOG1P_METHOD_FUNC(dfloat, numo_cDFloat)
115
+ DEF_NARRAY_FLT_EXPM1_METHOD_FUNC(dfloat, numo_cDFloat)
116
+ DEF_NARRAY_FLT_LDEXP_METHOD_FUNC(dfloat, numo_cDFloat)
117
+ DEF_NARRAY_FLT_FREXP_METHOD_FUNC(dfloat, numo_cDFloat)
56
118
 
57
119
  static VALUE dfloat_store(VALUE, VALUE);
58
120
 
@@ -6328,1954 +6390,6 @@ static VALUE dfloat_median(int argc, VALUE* argv, VALUE self) {
6328
6390
 
6329
6391
  VALUE mTM;
6330
6392
 
6331
- static void iter_dfloat_math_s_sqrt(na_loop_t* const lp) {
6332
- size_t i = 0, n;
6333
- char *p1, *p2;
6334
- ssize_t s1, s2;
6335
- size_t *idx1, *idx2;
6336
- dtype x;
6337
-
6338
- #ifdef __SSE2__
6339
- size_t cnt;
6340
- size_t cnt_simd_loop = -1;
6341
-
6342
- __m128d a;
6343
-
6344
- size_t num_pack; // Number of elements packed for SIMD.
6345
- num_pack = SIMD_ALIGNMENT_SIZE / sizeof(dtype);
6346
- #endif
6347
- INIT_COUNTER(lp, n);
6348
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
6349
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
6350
-
6351
- if (idx1) {
6352
- if (idx2) {
6353
- for (i = 0; i < n; i++) {
6354
- GET_DATA_INDEX(p1, idx1, dtype, x);
6355
- x = m_sqrt(x);
6356
- SET_DATA_INDEX(p2, idx2, dtype, x);
6357
- }
6358
- } else {
6359
- for (i = 0; i < n; i++) {
6360
- GET_DATA_INDEX(p1, idx1, dtype, x);
6361
- x = m_sqrt(x);
6362
- SET_DATA_STRIDE(p2, s2, dtype, x);
6363
- }
6364
- }
6365
- } else {
6366
- if (idx2) {
6367
- for (i = 0; i < n; i++) {
6368
- GET_DATA_STRIDE(p1, s1, dtype, x);
6369
- x = m_sqrt(x);
6370
- SET_DATA_INDEX(p2, idx2, dtype, x);
6371
- }
6372
- } else {
6373
- //
6374
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
6375
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
6376
- #ifdef __SSE2__
6377
- //
6378
- // Check number of elements. & Check same alignment.
6379
- if ((n >= num_pack) &&
6380
- is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p2)[i], SIMD_ALIGNMENT_SIZE)) {
6381
- // Calculate up to the position just before the start of SIMD computation.
6382
- cnt = get_count_of_elements_not_aligned_to_simd_size(
6383
- &((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
6384
- );
6385
- #endif
6386
- #ifdef __SSE2__
6387
- for (i = 0; i < cnt; i++) {
6388
- #else
6389
- for (i = 0; i < n; i++) {
6390
- #endif
6391
- ((dtype*)p2)[i] = m_sqrt(((dtype*)p1)[i]);
6392
- }
6393
-
6394
- #ifdef __SSE2__
6395
- // Get the count of SIMD computation loops.
6396
- cnt_simd_loop = (n - i) % num_pack;
6397
-
6398
- // SIMD computation.
6399
- if (p1 == p2) { // inplace case
6400
- for (; i < n - cnt_simd_loop; i += num_pack) {
6401
- a = _mm_load_pd(&((dtype*)p1)[i]);
6402
- a = _mm_sqrt_pd(a);
6403
- _mm_store_pd(&((dtype*)p1)[i], a);
6404
- }
6405
- } else {
6406
- for (; i < n - cnt_simd_loop; i += num_pack) {
6407
- a = _mm_load_pd(&((dtype*)p1)[i]);
6408
- a = _mm_sqrt_pd(a);
6409
- _mm_stream_pd(&((dtype*)p2)[i], a);
6410
- }
6411
- }
6412
- }
6413
- // Compute the remainder of the SIMD operation.
6414
- if (cnt_simd_loop != 0) {
6415
- //
6416
- for (; i < n; i++) {
6417
- ((dtype*)p2)[i] = m_sqrt(((dtype*)p1)[i]);
6418
- }
6419
- //
6420
- }
6421
- //
6422
- #endif
6423
- return;
6424
- }
6425
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
6426
- //
6427
- for (i = 0; i < n; i++) {
6428
- *(dtype*)p2 = m_sqrt(*(dtype*)p1);
6429
- p1 += s1;
6430
- p2 += s2;
6431
- }
6432
- return;
6433
- //
6434
- }
6435
- }
6436
- for (i = 0; i < n; i++) {
6437
- GET_DATA_STRIDE(p1, s1, dtype, x);
6438
- x = m_sqrt(x);
6439
- SET_DATA_STRIDE(p2, s2, dtype, x);
6440
- }
6441
- //
6442
- }
6443
- }
6444
- }
6445
-
6446
- static VALUE dfloat_math_s_sqrt(VALUE mod, VALUE a1) {
6447
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6448
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6449
- ndfunc_t ndf = { iter_dfloat_math_s_sqrt, FULL_LOOP, 1, 1, ain, aout };
6450
-
6451
- return na_ndloop(&ndf, 1, a1);
6452
- }
6453
-
6454
- static void iter_dfloat_math_s_cbrt(na_loop_t* const lp) {
6455
- size_t i = 0, n;
6456
- char *p1, *p2;
6457
- ssize_t s1, s2;
6458
- size_t *idx1, *idx2;
6459
- dtype x;
6460
-
6461
- INIT_COUNTER(lp, n);
6462
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
6463
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
6464
-
6465
- if (idx1) {
6466
- if (idx2) {
6467
- for (i = 0; i < n; i++) {
6468
- GET_DATA_INDEX(p1, idx1, dtype, x);
6469
- x = m_cbrt(x);
6470
- SET_DATA_INDEX(p2, idx2, dtype, x);
6471
- }
6472
- } else {
6473
- for (i = 0; i < n; i++) {
6474
- GET_DATA_INDEX(p1, idx1, dtype, x);
6475
- x = m_cbrt(x);
6476
- SET_DATA_STRIDE(p2, s2, dtype, x);
6477
- }
6478
- }
6479
- } else {
6480
- if (idx2) {
6481
- for (i = 0; i < n; i++) {
6482
- GET_DATA_STRIDE(p1, s1, dtype, x);
6483
- x = m_cbrt(x);
6484
- SET_DATA_INDEX(p2, idx2, dtype, x);
6485
- }
6486
- } else {
6487
- //
6488
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
6489
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
6490
- //
6491
- for (; i < n; i++) {
6492
- ((dtype*)p2)[i] = m_cbrt(((dtype*)p1)[i]);
6493
- }
6494
- //
6495
- return;
6496
- }
6497
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
6498
- //
6499
- for (i = 0; i < n; i++) {
6500
- *(dtype*)p2 = m_cbrt(*(dtype*)p1);
6501
- p1 += s1;
6502
- p2 += s2;
6503
- }
6504
- return;
6505
- //
6506
- }
6507
- }
6508
- for (i = 0; i < n; i++) {
6509
- GET_DATA_STRIDE(p1, s1, dtype, x);
6510
- x = m_cbrt(x);
6511
- SET_DATA_STRIDE(p2, s2, dtype, x);
6512
- }
6513
- //
6514
- }
6515
- }
6516
- }
6517
-
6518
- static VALUE dfloat_math_s_cbrt(VALUE mod, VALUE a1) {
6519
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6520
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6521
- ndfunc_t ndf = { iter_dfloat_math_s_cbrt, FULL_LOOP, 1, 1, ain, aout };
6522
-
6523
- return na_ndloop(&ndf, 1, a1);
6524
- }
6525
-
6526
- static void iter_dfloat_math_s_log(na_loop_t* const lp) {
6527
- size_t i = 0, n;
6528
- char *p1, *p2;
6529
- ssize_t s1, s2;
6530
- size_t *idx1, *idx2;
6531
- dtype x;
6532
-
6533
- INIT_COUNTER(lp, n);
6534
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
6535
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
6536
-
6537
- if (idx1) {
6538
- if (idx2) {
6539
- for (i = 0; i < n; i++) {
6540
- GET_DATA_INDEX(p1, idx1, dtype, x);
6541
- x = m_log(x);
6542
- SET_DATA_INDEX(p2, idx2, dtype, x);
6543
- }
6544
- } else {
6545
- for (i = 0; i < n; i++) {
6546
- GET_DATA_INDEX(p1, idx1, dtype, x);
6547
- x = m_log(x);
6548
- SET_DATA_STRIDE(p2, s2, dtype, x);
6549
- }
6550
- }
6551
- } else {
6552
- if (idx2) {
6553
- for (i = 0; i < n; i++) {
6554
- GET_DATA_STRIDE(p1, s1, dtype, x);
6555
- x = m_log(x);
6556
- SET_DATA_INDEX(p2, idx2, dtype, x);
6557
- }
6558
- } else {
6559
- //
6560
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
6561
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
6562
- //
6563
- for (; i < n; i++) {
6564
- ((dtype*)p2)[i] = m_log(((dtype*)p1)[i]);
6565
- }
6566
- //
6567
- return;
6568
- }
6569
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
6570
- //
6571
- for (i = 0; i < n; i++) {
6572
- *(dtype*)p2 = m_log(*(dtype*)p1);
6573
- p1 += s1;
6574
- p2 += s2;
6575
- }
6576
- return;
6577
- //
6578
- }
6579
- }
6580
- for (i = 0; i < n; i++) {
6581
- GET_DATA_STRIDE(p1, s1, dtype, x);
6582
- x = m_log(x);
6583
- SET_DATA_STRIDE(p2, s2, dtype, x);
6584
- }
6585
- //
6586
- }
6587
- }
6588
- }
6589
-
6590
- static VALUE dfloat_math_s_log(VALUE mod, VALUE a1) {
6591
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6592
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6593
- ndfunc_t ndf = { iter_dfloat_math_s_log, FULL_LOOP, 1, 1, ain, aout };
6594
-
6595
- return na_ndloop(&ndf, 1, a1);
6596
- }
6597
-
6598
- static void iter_dfloat_math_s_log2(na_loop_t* const lp) {
6599
- size_t i = 0, n;
6600
- char *p1, *p2;
6601
- ssize_t s1, s2;
6602
- size_t *idx1, *idx2;
6603
- dtype x;
6604
-
6605
- INIT_COUNTER(lp, n);
6606
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
6607
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
6608
-
6609
- if (idx1) {
6610
- if (idx2) {
6611
- for (i = 0; i < n; i++) {
6612
- GET_DATA_INDEX(p1, idx1, dtype, x);
6613
- x = m_log2(x);
6614
- SET_DATA_INDEX(p2, idx2, dtype, x);
6615
- }
6616
- } else {
6617
- for (i = 0; i < n; i++) {
6618
- GET_DATA_INDEX(p1, idx1, dtype, x);
6619
- x = m_log2(x);
6620
- SET_DATA_STRIDE(p2, s2, dtype, x);
6621
- }
6622
- }
6623
- } else {
6624
- if (idx2) {
6625
- for (i = 0; i < n; i++) {
6626
- GET_DATA_STRIDE(p1, s1, dtype, x);
6627
- x = m_log2(x);
6628
- SET_DATA_INDEX(p2, idx2, dtype, x);
6629
- }
6630
- } else {
6631
- //
6632
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
6633
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
6634
- //
6635
- for (; i < n; i++) {
6636
- ((dtype*)p2)[i] = m_log2(((dtype*)p1)[i]);
6637
- }
6638
- //
6639
- return;
6640
- }
6641
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
6642
- //
6643
- for (i = 0; i < n; i++) {
6644
- *(dtype*)p2 = m_log2(*(dtype*)p1);
6645
- p1 += s1;
6646
- p2 += s2;
6647
- }
6648
- return;
6649
- //
6650
- }
6651
- }
6652
- for (i = 0; i < n; i++) {
6653
- GET_DATA_STRIDE(p1, s1, dtype, x);
6654
- x = m_log2(x);
6655
- SET_DATA_STRIDE(p2, s2, dtype, x);
6656
- }
6657
- //
6658
- }
6659
- }
6660
- }
6661
-
6662
- static VALUE dfloat_math_s_log2(VALUE mod, VALUE a1) {
6663
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6664
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6665
- ndfunc_t ndf = { iter_dfloat_math_s_log2, FULL_LOOP, 1, 1, ain, aout };
6666
-
6667
- return na_ndloop(&ndf, 1, a1);
6668
- }
6669
-
6670
- static void iter_dfloat_math_s_log10(na_loop_t* const lp) {
6671
- size_t i = 0, n;
6672
- char *p1, *p2;
6673
- ssize_t s1, s2;
6674
- size_t *idx1, *idx2;
6675
- dtype x;
6676
-
6677
- INIT_COUNTER(lp, n);
6678
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
6679
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
6680
-
6681
- if (idx1) {
6682
- if (idx2) {
6683
- for (i = 0; i < n; i++) {
6684
- GET_DATA_INDEX(p1, idx1, dtype, x);
6685
- x = m_log10(x);
6686
- SET_DATA_INDEX(p2, idx2, dtype, x);
6687
- }
6688
- } else {
6689
- for (i = 0; i < n; i++) {
6690
- GET_DATA_INDEX(p1, idx1, dtype, x);
6691
- x = m_log10(x);
6692
- SET_DATA_STRIDE(p2, s2, dtype, x);
6693
- }
6694
- }
6695
- } else {
6696
- if (idx2) {
6697
- for (i = 0; i < n; i++) {
6698
- GET_DATA_STRIDE(p1, s1, dtype, x);
6699
- x = m_log10(x);
6700
- SET_DATA_INDEX(p2, idx2, dtype, x);
6701
- }
6702
- } else {
6703
- //
6704
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
6705
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
6706
- //
6707
- for (; i < n; i++) {
6708
- ((dtype*)p2)[i] = m_log10(((dtype*)p1)[i]);
6709
- }
6710
- //
6711
- return;
6712
- }
6713
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
6714
- //
6715
- for (i = 0; i < n; i++) {
6716
- *(dtype*)p2 = m_log10(*(dtype*)p1);
6717
- p1 += s1;
6718
- p2 += s2;
6719
- }
6720
- return;
6721
- //
6722
- }
6723
- }
6724
- for (i = 0; i < n; i++) {
6725
- GET_DATA_STRIDE(p1, s1, dtype, x);
6726
- x = m_log10(x);
6727
- SET_DATA_STRIDE(p2, s2, dtype, x);
6728
- }
6729
- //
6730
- }
6731
- }
6732
- }
6733
-
6734
- static VALUE dfloat_math_s_log10(VALUE mod, VALUE a1) {
6735
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6736
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6737
- ndfunc_t ndf = { iter_dfloat_math_s_log10, FULL_LOOP, 1, 1, ain, aout };
6738
-
6739
- return na_ndloop(&ndf, 1, a1);
6740
- }
6741
-
6742
- static void iter_dfloat_math_s_exp(na_loop_t* const lp) {
6743
- size_t i = 0, n;
6744
- char *p1, *p2;
6745
- ssize_t s1, s2;
6746
- size_t *idx1, *idx2;
6747
- dtype x;
6748
-
6749
- INIT_COUNTER(lp, n);
6750
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
6751
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
6752
-
6753
- if (idx1) {
6754
- if (idx2) {
6755
- for (i = 0; i < n; i++) {
6756
- GET_DATA_INDEX(p1, idx1, dtype, x);
6757
- x = m_exp(x);
6758
- SET_DATA_INDEX(p2, idx2, dtype, x);
6759
- }
6760
- } else {
6761
- for (i = 0; i < n; i++) {
6762
- GET_DATA_INDEX(p1, idx1, dtype, x);
6763
- x = m_exp(x);
6764
- SET_DATA_STRIDE(p2, s2, dtype, x);
6765
- }
6766
- }
6767
- } else {
6768
- if (idx2) {
6769
- for (i = 0; i < n; i++) {
6770
- GET_DATA_STRIDE(p1, s1, dtype, x);
6771
- x = m_exp(x);
6772
- SET_DATA_INDEX(p2, idx2, dtype, x);
6773
- }
6774
- } else {
6775
- //
6776
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
6777
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
6778
- //
6779
- for (; i < n; i++) {
6780
- ((dtype*)p2)[i] = m_exp(((dtype*)p1)[i]);
6781
- }
6782
- //
6783
- return;
6784
- }
6785
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
6786
- //
6787
- for (i = 0; i < n; i++) {
6788
- *(dtype*)p2 = m_exp(*(dtype*)p1);
6789
- p1 += s1;
6790
- p2 += s2;
6791
- }
6792
- return;
6793
- //
6794
- }
6795
- }
6796
- for (i = 0; i < n; i++) {
6797
- GET_DATA_STRIDE(p1, s1, dtype, x);
6798
- x = m_exp(x);
6799
- SET_DATA_STRIDE(p2, s2, dtype, x);
6800
- }
6801
- //
6802
- }
6803
- }
6804
- }
6805
-
6806
- static VALUE dfloat_math_s_exp(VALUE mod, VALUE a1) {
6807
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6808
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6809
- ndfunc_t ndf = { iter_dfloat_math_s_exp, FULL_LOOP, 1, 1, ain, aout };
6810
-
6811
- return na_ndloop(&ndf, 1, a1);
6812
- }
6813
-
6814
- static void iter_dfloat_math_s_exp2(na_loop_t* const lp) {
6815
- size_t i = 0, n;
6816
- char *p1, *p2;
6817
- ssize_t s1, s2;
6818
- size_t *idx1, *idx2;
6819
- dtype x;
6820
-
6821
- INIT_COUNTER(lp, n);
6822
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
6823
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
6824
-
6825
- if (idx1) {
6826
- if (idx2) {
6827
- for (i = 0; i < n; i++) {
6828
- GET_DATA_INDEX(p1, idx1, dtype, x);
6829
- x = m_exp2(x);
6830
- SET_DATA_INDEX(p2, idx2, dtype, x);
6831
- }
6832
- } else {
6833
- for (i = 0; i < n; i++) {
6834
- GET_DATA_INDEX(p1, idx1, dtype, x);
6835
- x = m_exp2(x);
6836
- SET_DATA_STRIDE(p2, s2, dtype, x);
6837
- }
6838
- }
6839
- } else {
6840
- if (idx2) {
6841
- for (i = 0; i < n; i++) {
6842
- GET_DATA_STRIDE(p1, s1, dtype, x);
6843
- x = m_exp2(x);
6844
- SET_DATA_INDEX(p2, idx2, dtype, x);
6845
- }
6846
- } else {
6847
- //
6848
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
6849
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
6850
- //
6851
- for (; i < n; i++) {
6852
- ((dtype*)p2)[i] = m_exp2(((dtype*)p1)[i]);
6853
- }
6854
- //
6855
- return;
6856
- }
6857
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
6858
- //
6859
- for (i = 0; i < n; i++) {
6860
- *(dtype*)p2 = m_exp2(*(dtype*)p1);
6861
- p1 += s1;
6862
- p2 += s2;
6863
- }
6864
- return;
6865
- //
6866
- }
6867
- }
6868
- for (i = 0; i < n; i++) {
6869
- GET_DATA_STRIDE(p1, s1, dtype, x);
6870
- x = m_exp2(x);
6871
- SET_DATA_STRIDE(p2, s2, dtype, x);
6872
- }
6873
- //
6874
- }
6875
- }
6876
- }
6877
-
6878
- static VALUE dfloat_math_s_exp2(VALUE mod, VALUE a1) {
6879
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6880
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6881
- ndfunc_t ndf = { iter_dfloat_math_s_exp2, FULL_LOOP, 1, 1, ain, aout };
6882
-
6883
- return na_ndloop(&ndf, 1, a1);
6884
- }
6885
-
6886
- static void iter_dfloat_math_s_exp10(na_loop_t* const lp) {
6887
- size_t i = 0, n;
6888
- char *p1, *p2;
6889
- ssize_t s1, s2;
6890
- size_t *idx1, *idx2;
6891
- dtype x;
6892
-
6893
- INIT_COUNTER(lp, n);
6894
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
6895
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
6896
-
6897
- if (idx1) {
6898
- if (idx2) {
6899
- for (i = 0; i < n; i++) {
6900
- GET_DATA_INDEX(p1, idx1, dtype, x);
6901
- x = m_exp10(x);
6902
- SET_DATA_INDEX(p2, idx2, dtype, x);
6903
- }
6904
- } else {
6905
- for (i = 0; i < n; i++) {
6906
- GET_DATA_INDEX(p1, idx1, dtype, x);
6907
- x = m_exp10(x);
6908
- SET_DATA_STRIDE(p2, s2, dtype, x);
6909
- }
6910
- }
6911
- } else {
6912
- if (idx2) {
6913
- for (i = 0; i < n; i++) {
6914
- GET_DATA_STRIDE(p1, s1, dtype, x);
6915
- x = m_exp10(x);
6916
- SET_DATA_INDEX(p2, idx2, dtype, x);
6917
- }
6918
- } else {
6919
- //
6920
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
6921
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
6922
- //
6923
- for (; i < n; i++) {
6924
- ((dtype*)p2)[i] = m_exp10(((dtype*)p1)[i]);
6925
- }
6926
- //
6927
- return;
6928
- }
6929
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
6930
- //
6931
- for (i = 0; i < n; i++) {
6932
- *(dtype*)p2 = m_exp10(*(dtype*)p1);
6933
- p1 += s1;
6934
- p2 += s2;
6935
- }
6936
- return;
6937
- //
6938
- }
6939
- }
6940
- for (i = 0; i < n; i++) {
6941
- GET_DATA_STRIDE(p1, s1, dtype, x);
6942
- x = m_exp10(x);
6943
- SET_DATA_STRIDE(p2, s2, dtype, x);
6944
- }
6945
- //
6946
- }
6947
- }
6948
- }
6949
-
6950
- static VALUE dfloat_math_s_exp10(VALUE mod, VALUE a1) {
6951
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6952
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6953
- ndfunc_t ndf = { iter_dfloat_math_s_exp10, FULL_LOOP, 1, 1, ain, aout };
6954
-
6955
- return na_ndloop(&ndf, 1, a1);
6956
- }
6957
-
6958
- static void iter_dfloat_math_s_sin(na_loop_t* const lp) {
6959
- size_t i = 0, n;
6960
- char *p1, *p2;
6961
- ssize_t s1, s2;
6962
- size_t *idx1, *idx2;
6963
- dtype x;
6964
-
6965
- INIT_COUNTER(lp, n);
6966
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
6967
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
6968
-
6969
- if (idx1) {
6970
- if (idx2) {
6971
- for (i = 0; i < n; i++) {
6972
- GET_DATA_INDEX(p1, idx1, dtype, x);
6973
- x = m_sin(x);
6974
- SET_DATA_INDEX(p2, idx2, dtype, x);
6975
- }
6976
- } else {
6977
- for (i = 0; i < n; i++) {
6978
- GET_DATA_INDEX(p1, idx1, dtype, x);
6979
- x = m_sin(x);
6980
- SET_DATA_STRIDE(p2, s2, dtype, x);
6981
- }
6982
- }
6983
- } else {
6984
- if (idx2) {
6985
- for (i = 0; i < n; i++) {
6986
- GET_DATA_STRIDE(p1, s1, dtype, x);
6987
- x = m_sin(x);
6988
- SET_DATA_INDEX(p2, idx2, dtype, x);
6989
- }
6990
- } else {
6991
- //
6992
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
6993
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
6994
- //
6995
- for (; i < n; i++) {
6996
- ((dtype*)p2)[i] = m_sin(((dtype*)p1)[i]);
6997
- }
6998
- //
6999
- return;
7000
- }
7001
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7002
- //
7003
- for (i = 0; i < n; i++) {
7004
- *(dtype*)p2 = m_sin(*(dtype*)p1);
7005
- p1 += s1;
7006
- p2 += s2;
7007
- }
7008
- return;
7009
- //
7010
- }
7011
- }
7012
- for (i = 0; i < n; i++) {
7013
- GET_DATA_STRIDE(p1, s1, dtype, x);
7014
- x = m_sin(x);
7015
- SET_DATA_STRIDE(p2, s2, dtype, x);
7016
- }
7017
- //
7018
- }
7019
- }
7020
- }
7021
-
7022
- static VALUE dfloat_math_s_sin(VALUE mod, VALUE a1) {
7023
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7024
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7025
- ndfunc_t ndf = { iter_dfloat_math_s_sin, FULL_LOOP, 1, 1, ain, aout };
7026
-
7027
- return na_ndloop(&ndf, 1, a1);
7028
- }
7029
-
7030
- static void iter_dfloat_math_s_cos(na_loop_t* const lp) {
7031
- size_t i = 0, n;
7032
- char *p1, *p2;
7033
- ssize_t s1, s2;
7034
- size_t *idx1, *idx2;
7035
- dtype x;
7036
-
7037
- INIT_COUNTER(lp, n);
7038
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
7039
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
7040
-
7041
- if (idx1) {
7042
- if (idx2) {
7043
- for (i = 0; i < n; i++) {
7044
- GET_DATA_INDEX(p1, idx1, dtype, x);
7045
- x = m_cos(x);
7046
- SET_DATA_INDEX(p2, idx2, dtype, x);
7047
- }
7048
- } else {
7049
- for (i = 0; i < n; i++) {
7050
- GET_DATA_INDEX(p1, idx1, dtype, x);
7051
- x = m_cos(x);
7052
- SET_DATA_STRIDE(p2, s2, dtype, x);
7053
- }
7054
- }
7055
- } else {
7056
- if (idx2) {
7057
- for (i = 0; i < n; i++) {
7058
- GET_DATA_STRIDE(p1, s1, dtype, x);
7059
- x = m_cos(x);
7060
- SET_DATA_INDEX(p2, idx2, dtype, x);
7061
- }
7062
- } else {
7063
- //
7064
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
7065
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
7066
- //
7067
- for (; i < n; i++) {
7068
- ((dtype*)p2)[i] = m_cos(((dtype*)p1)[i]);
7069
- }
7070
- //
7071
- return;
7072
- }
7073
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7074
- //
7075
- for (i = 0; i < n; i++) {
7076
- *(dtype*)p2 = m_cos(*(dtype*)p1);
7077
- p1 += s1;
7078
- p2 += s2;
7079
- }
7080
- return;
7081
- //
7082
- }
7083
- }
7084
- for (i = 0; i < n; i++) {
7085
- GET_DATA_STRIDE(p1, s1, dtype, x);
7086
- x = m_cos(x);
7087
- SET_DATA_STRIDE(p2, s2, dtype, x);
7088
- }
7089
- //
7090
- }
7091
- }
7092
- }
7093
-
7094
- static VALUE dfloat_math_s_cos(VALUE mod, VALUE a1) {
7095
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7096
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7097
- ndfunc_t ndf = { iter_dfloat_math_s_cos, FULL_LOOP, 1, 1, ain, aout };
7098
-
7099
- return na_ndloop(&ndf, 1, a1);
7100
- }
7101
-
7102
- static void iter_dfloat_math_s_tan(na_loop_t* const lp) {
7103
- size_t i = 0, n;
7104
- char *p1, *p2;
7105
- ssize_t s1, s2;
7106
- size_t *idx1, *idx2;
7107
- dtype x;
7108
-
7109
- INIT_COUNTER(lp, n);
7110
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
7111
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
7112
-
7113
- if (idx1) {
7114
- if (idx2) {
7115
- for (i = 0; i < n; i++) {
7116
- GET_DATA_INDEX(p1, idx1, dtype, x);
7117
- x = m_tan(x);
7118
- SET_DATA_INDEX(p2, idx2, dtype, x);
7119
- }
7120
- } else {
7121
- for (i = 0; i < n; i++) {
7122
- GET_DATA_INDEX(p1, idx1, dtype, x);
7123
- x = m_tan(x);
7124
- SET_DATA_STRIDE(p2, s2, dtype, x);
7125
- }
7126
- }
7127
- } else {
7128
- if (idx2) {
7129
- for (i = 0; i < n; i++) {
7130
- GET_DATA_STRIDE(p1, s1, dtype, x);
7131
- x = m_tan(x);
7132
- SET_DATA_INDEX(p2, idx2, dtype, x);
7133
- }
7134
- } else {
7135
- //
7136
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
7137
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
7138
- //
7139
- for (; i < n; i++) {
7140
- ((dtype*)p2)[i] = m_tan(((dtype*)p1)[i]);
7141
- }
7142
- //
7143
- return;
7144
- }
7145
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7146
- //
7147
- for (i = 0; i < n; i++) {
7148
- *(dtype*)p2 = m_tan(*(dtype*)p1);
7149
- p1 += s1;
7150
- p2 += s2;
7151
- }
7152
- return;
7153
- //
7154
- }
7155
- }
7156
- for (i = 0; i < n; i++) {
7157
- GET_DATA_STRIDE(p1, s1, dtype, x);
7158
- x = m_tan(x);
7159
- SET_DATA_STRIDE(p2, s2, dtype, x);
7160
- }
7161
- //
7162
- }
7163
- }
7164
- }
7165
-
7166
- static VALUE dfloat_math_s_tan(VALUE mod, VALUE a1) {
7167
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7168
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7169
- ndfunc_t ndf = { iter_dfloat_math_s_tan, FULL_LOOP, 1, 1, ain, aout };
7170
-
7171
- return na_ndloop(&ndf, 1, a1);
7172
- }
7173
-
7174
- static void iter_dfloat_math_s_asin(na_loop_t* const lp) {
7175
- size_t i = 0, n;
7176
- char *p1, *p2;
7177
- ssize_t s1, s2;
7178
- size_t *idx1, *idx2;
7179
- dtype x;
7180
-
7181
- INIT_COUNTER(lp, n);
7182
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
7183
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
7184
-
7185
- if (idx1) {
7186
- if (idx2) {
7187
- for (i = 0; i < n; i++) {
7188
- GET_DATA_INDEX(p1, idx1, dtype, x);
7189
- x = m_asin(x);
7190
- SET_DATA_INDEX(p2, idx2, dtype, x);
7191
- }
7192
- } else {
7193
- for (i = 0; i < n; i++) {
7194
- GET_DATA_INDEX(p1, idx1, dtype, x);
7195
- x = m_asin(x);
7196
- SET_DATA_STRIDE(p2, s2, dtype, x);
7197
- }
7198
- }
7199
- } else {
7200
- if (idx2) {
7201
- for (i = 0; i < n; i++) {
7202
- GET_DATA_STRIDE(p1, s1, dtype, x);
7203
- x = m_asin(x);
7204
- SET_DATA_INDEX(p2, idx2, dtype, x);
7205
- }
7206
- } else {
7207
- //
7208
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
7209
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
7210
- //
7211
- for (; i < n; i++) {
7212
- ((dtype*)p2)[i] = m_asin(((dtype*)p1)[i]);
7213
- }
7214
- //
7215
- return;
7216
- }
7217
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7218
- //
7219
- for (i = 0; i < n; i++) {
7220
- *(dtype*)p2 = m_asin(*(dtype*)p1);
7221
- p1 += s1;
7222
- p2 += s2;
7223
- }
7224
- return;
7225
- //
7226
- }
7227
- }
7228
- for (i = 0; i < n; i++) {
7229
- GET_DATA_STRIDE(p1, s1, dtype, x);
7230
- x = m_asin(x);
7231
- SET_DATA_STRIDE(p2, s2, dtype, x);
7232
- }
7233
- //
7234
- }
7235
- }
7236
- }
7237
-
7238
- static VALUE dfloat_math_s_asin(VALUE mod, VALUE a1) {
7239
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7240
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7241
- ndfunc_t ndf = { iter_dfloat_math_s_asin, FULL_LOOP, 1, 1, ain, aout };
7242
-
7243
- return na_ndloop(&ndf, 1, a1);
7244
- }
7245
-
7246
- static void iter_dfloat_math_s_acos(na_loop_t* const lp) {
7247
- size_t i = 0, n;
7248
- char *p1, *p2;
7249
- ssize_t s1, s2;
7250
- size_t *idx1, *idx2;
7251
- dtype x;
7252
-
7253
- INIT_COUNTER(lp, n);
7254
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
7255
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
7256
-
7257
- if (idx1) {
7258
- if (idx2) {
7259
- for (i = 0; i < n; i++) {
7260
- GET_DATA_INDEX(p1, idx1, dtype, x);
7261
- x = m_acos(x);
7262
- SET_DATA_INDEX(p2, idx2, dtype, x);
7263
- }
7264
- } else {
7265
- for (i = 0; i < n; i++) {
7266
- GET_DATA_INDEX(p1, idx1, dtype, x);
7267
- x = m_acos(x);
7268
- SET_DATA_STRIDE(p2, s2, dtype, x);
7269
- }
7270
- }
7271
- } else {
7272
- if (idx2) {
7273
- for (i = 0; i < n; i++) {
7274
- GET_DATA_STRIDE(p1, s1, dtype, x);
7275
- x = m_acos(x);
7276
- SET_DATA_INDEX(p2, idx2, dtype, x);
7277
- }
7278
- } else {
7279
- //
7280
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
7281
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
7282
- //
7283
- for (; i < n; i++) {
7284
- ((dtype*)p2)[i] = m_acos(((dtype*)p1)[i]);
7285
- }
7286
- //
7287
- return;
7288
- }
7289
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7290
- //
7291
- for (i = 0; i < n; i++) {
7292
- *(dtype*)p2 = m_acos(*(dtype*)p1);
7293
- p1 += s1;
7294
- p2 += s2;
7295
- }
7296
- return;
7297
- //
7298
- }
7299
- }
7300
- for (i = 0; i < n; i++) {
7301
- GET_DATA_STRIDE(p1, s1, dtype, x);
7302
- x = m_acos(x);
7303
- SET_DATA_STRIDE(p2, s2, dtype, x);
7304
- }
7305
- //
7306
- }
7307
- }
7308
- }
7309
-
7310
- static VALUE dfloat_math_s_acos(VALUE mod, VALUE a1) {
7311
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7312
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7313
- ndfunc_t ndf = { iter_dfloat_math_s_acos, FULL_LOOP, 1, 1, ain, aout };
7314
-
7315
- return na_ndloop(&ndf, 1, a1);
7316
- }
7317
-
7318
- static void iter_dfloat_math_s_atan(na_loop_t* const lp) {
7319
- size_t i = 0, n;
7320
- char *p1, *p2;
7321
- ssize_t s1, s2;
7322
- size_t *idx1, *idx2;
7323
- dtype x;
7324
-
7325
- INIT_COUNTER(lp, n);
7326
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
7327
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
7328
-
7329
- if (idx1) {
7330
- if (idx2) {
7331
- for (i = 0; i < n; i++) {
7332
- GET_DATA_INDEX(p1, idx1, dtype, x);
7333
- x = m_atan(x);
7334
- SET_DATA_INDEX(p2, idx2, dtype, x);
7335
- }
7336
- } else {
7337
- for (i = 0; i < n; i++) {
7338
- GET_DATA_INDEX(p1, idx1, dtype, x);
7339
- x = m_atan(x);
7340
- SET_DATA_STRIDE(p2, s2, dtype, x);
7341
- }
7342
- }
7343
- } else {
7344
- if (idx2) {
7345
- for (i = 0; i < n; i++) {
7346
- GET_DATA_STRIDE(p1, s1, dtype, x);
7347
- x = m_atan(x);
7348
- SET_DATA_INDEX(p2, idx2, dtype, x);
7349
- }
7350
- } else {
7351
- //
7352
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
7353
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
7354
- //
7355
- for (; i < n; i++) {
7356
- ((dtype*)p2)[i] = m_atan(((dtype*)p1)[i]);
7357
- }
7358
- //
7359
- return;
7360
- }
7361
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7362
- //
7363
- for (i = 0; i < n; i++) {
7364
- *(dtype*)p2 = m_atan(*(dtype*)p1);
7365
- p1 += s1;
7366
- p2 += s2;
7367
- }
7368
- return;
7369
- //
7370
- }
7371
- }
7372
- for (i = 0; i < n; i++) {
7373
- GET_DATA_STRIDE(p1, s1, dtype, x);
7374
- x = m_atan(x);
7375
- SET_DATA_STRIDE(p2, s2, dtype, x);
7376
- }
7377
- //
7378
- }
7379
- }
7380
- }
7381
-
7382
- static VALUE dfloat_math_s_atan(VALUE mod, VALUE a1) {
7383
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7384
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7385
- ndfunc_t ndf = { iter_dfloat_math_s_atan, FULL_LOOP, 1, 1, ain, aout };
7386
-
7387
- return na_ndloop(&ndf, 1, a1);
7388
- }
7389
-
7390
- static void iter_dfloat_math_s_sinh(na_loop_t* const lp) {
7391
- size_t i = 0, n;
7392
- char *p1, *p2;
7393
- ssize_t s1, s2;
7394
- size_t *idx1, *idx2;
7395
- dtype x;
7396
-
7397
- INIT_COUNTER(lp, n);
7398
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
7399
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
7400
-
7401
- if (idx1) {
7402
- if (idx2) {
7403
- for (i = 0; i < n; i++) {
7404
- GET_DATA_INDEX(p1, idx1, dtype, x);
7405
- x = m_sinh(x);
7406
- SET_DATA_INDEX(p2, idx2, dtype, x);
7407
- }
7408
- } else {
7409
- for (i = 0; i < n; i++) {
7410
- GET_DATA_INDEX(p1, idx1, dtype, x);
7411
- x = m_sinh(x);
7412
- SET_DATA_STRIDE(p2, s2, dtype, x);
7413
- }
7414
- }
7415
- } else {
7416
- if (idx2) {
7417
- for (i = 0; i < n; i++) {
7418
- GET_DATA_STRIDE(p1, s1, dtype, x);
7419
- x = m_sinh(x);
7420
- SET_DATA_INDEX(p2, idx2, dtype, x);
7421
- }
7422
- } else {
7423
- //
7424
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
7425
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
7426
- //
7427
- for (; i < n; i++) {
7428
- ((dtype*)p2)[i] = m_sinh(((dtype*)p1)[i]);
7429
- }
7430
- //
7431
- return;
7432
- }
7433
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7434
- //
7435
- for (i = 0; i < n; i++) {
7436
- *(dtype*)p2 = m_sinh(*(dtype*)p1);
7437
- p1 += s1;
7438
- p2 += s2;
7439
- }
7440
- return;
7441
- //
7442
- }
7443
- }
7444
- for (i = 0; i < n; i++) {
7445
- GET_DATA_STRIDE(p1, s1, dtype, x);
7446
- x = m_sinh(x);
7447
- SET_DATA_STRIDE(p2, s2, dtype, x);
7448
- }
7449
- //
7450
- }
7451
- }
7452
- }
7453
-
7454
- static VALUE dfloat_math_s_sinh(VALUE mod, VALUE a1) {
7455
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7456
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7457
- ndfunc_t ndf = { iter_dfloat_math_s_sinh, FULL_LOOP, 1, 1, ain, aout };
7458
-
7459
- return na_ndloop(&ndf, 1, a1);
7460
- }
7461
-
7462
- static void iter_dfloat_math_s_cosh(na_loop_t* const lp) {
7463
- size_t i = 0, n;
7464
- char *p1, *p2;
7465
- ssize_t s1, s2;
7466
- size_t *idx1, *idx2;
7467
- dtype x;
7468
-
7469
- INIT_COUNTER(lp, n);
7470
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
7471
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
7472
-
7473
- if (idx1) {
7474
- if (idx2) {
7475
- for (i = 0; i < n; i++) {
7476
- GET_DATA_INDEX(p1, idx1, dtype, x);
7477
- x = m_cosh(x);
7478
- SET_DATA_INDEX(p2, idx2, dtype, x);
7479
- }
7480
- } else {
7481
- for (i = 0; i < n; i++) {
7482
- GET_DATA_INDEX(p1, idx1, dtype, x);
7483
- x = m_cosh(x);
7484
- SET_DATA_STRIDE(p2, s2, dtype, x);
7485
- }
7486
- }
7487
- } else {
7488
- if (idx2) {
7489
- for (i = 0; i < n; i++) {
7490
- GET_DATA_STRIDE(p1, s1, dtype, x);
7491
- x = m_cosh(x);
7492
- SET_DATA_INDEX(p2, idx2, dtype, x);
7493
- }
7494
- } else {
7495
- //
7496
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
7497
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
7498
- //
7499
- for (; i < n; i++) {
7500
- ((dtype*)p2)[i] = m_cosh(((dtype*)p1)[i]);
7501
- }
7502
- //
7503
- return;
7504
- }
7505
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7506
- //
7507
- for (i = 0; i < n; i++) {
7508
- *(dtype*)p2 = m_cosh(*(dtype*)p1);
7509
- p1 += s1;
7510
- p2 += s2;
7511
- }
7512
- return;
7513
- //
7514
- }
7515
- }
7516
- for (i = 0; i < n; i++) {
7517
- GET_DATA_STRIDE(p1, s1, dtype, x);
7518
- x = m_cosh(x);
7519
- SET_DATA_STRIDE(p2, s2, dtype, x);
7520
- }
7521
- //
7522
- }
7523
- }
7524
- }
7525
-
7526
- static VALUE dfloat_math_s_cosh(VALUE mod, VALUE a1) {
7527
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7528
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7529
- ndfunc_t ndf = { iter_dfloat_math_s_cosh, FULL_LOOP, 1, 1, ain, aout };
7530
-
7531
- return na_ndloop(&ndf, 1, a1);
7532
- }
7533
-
7534
- static void iter_dfloat_math_s_tanh(na_loop_t* const lp) {
7535
- size_t i = 0, n;
7536
- char *p1, *p2;
7537
- ssize_t s1, s2;
7538
- size_t *idx1, *idx2;
7539
- dtype x;
7540
-
7541
- INIT_COUNTER(lp, n);
7542
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
7543
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
7544
-
7545
- if (idx1) {
7546
- if (idx2) {
7547
- for (i = 0; i < n; i++) {
7548
- GET_DATA_INDEX(p1, idx1, dtype, x);
7549
- x = m_tanh(x);
7550
- SET_DATA_INDEX(p2, idx2, dtype, x);
7551
- }
7552
- } else {
7553
- for (i = 0; i < n; i++) {
7554
- GET_DATA_INDEX(p1, idx1, dtype, x);
7555
- x = m_tanh(x);
7556
- SET_DATA_STRIDE(p2, s2, dtype, x);
7557
- }
7558
- }
7559
- } else {
7560
- if (idx2) {
7561
- for (i = 0; i < n; i++) {
7562
- GET_DATA_STRIDE(p1, s1, dtype, x);
7563
- x = m_tanh(x);
7564
- SET_DATA_INDEX(p2, idx2, dtype, x);
7565
- }
7566
- } else {
7567
- //
7568
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
7569
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
7570
- //
7571
- for (; i < n; i++) {
7572
- ((dtype*)p2)[i] = m_tanh(((dtype*)p1)[i]);
7573
- }
7574
- //
7575
- return;
7576
- }
7577
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7578
- //
7579
- for (i = 0; i < n; i++) {
7580
- *(dtype*)p2 = m_tanh(*(dtype*)p1);
7581
- p1 += s1;
7582
- p2 += s2;
7583
- }
7584
- return;
7585
- //
7586
- }
7587
- }
7588
- for (i = 0; i < n; i++) {
7589
- GET_DATA_STRIDE(p1, s1, dtype, x);
7590
- x = m_tanh(x);
7591
- SET_DATA_STRIDE(p2, s2, dtype, x);
7592
- }
7593
- //
7594
- }
7595
- }
7596
- }
7597
-
7598
- static VALUE dfloat_math_s_tanh(VALUE mod, VALUE a1) {
7599
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7600
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7601
- ndfunc_t ndf = { iter_dfloat_math_s_tanh, FULL_LOOP, 1, 1, ain, aout };
7602
-
7603
- return na_ndloop(&ndf, 1, a1);
7604
- }
7605
-
7606
- static void iter_dfloat_math_s_asinh(na_loop_t* const lp) {
7607
- size_t i = 0, n;
7608
- char *p1, *p2;
7609
- ssize_t s1, s2;
7610
- size_t *idx1, *idx2;
7611
- dtype x;
7612
-
7613
- INIT_COUNTER(lp, n);
7614
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
7615
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
7616
-
7617
- if (idx1) {
7618
- if (idx2) {
7619
- for (i = 0; i < n; i++) {
7620
- GET_DATA_INDEX(p1, idx1, dtype, x);
7621
- x = m_asinh(x);
7622
- SET_DATA_INDEX(p2, idx2, dtype, x);
7623
- }
7624
- } else {
7625
- for (i = 0; i < n; i++) {
7626
- GET_DATA_INDEX(p1, idx1, dtype, x);
7627
- x = m_asinh(x);
7628
- SET_DATA_STRIDE(p2, s2, dtype, x);
7629
- }
7630
- }
7631
- } else {
7632
- if (idx2) {
7633
- for (i = 0; i < n; i++) {
7634
- GET_DATA_STRIDE(p1, s1, dtype, x);
7635
- x = m_asinh(x);
7636
- SET_DATA_INDEX(p2, idx2, dtype, x);
7637
- }
7638
- } else {
7639
- //
7640
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
7641
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
7642
- //
7643
- for (; i < n; i++) {
7644
- ((dtype*)p2)[i] = m_asinh(((dtype*)p1)[i]);
7645
- }
7646
- //
7647
- return;
7648
- }
7649
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7650
- //
7651
- for (i = 0; i < n; i++) {
7652
- *(dtype*)p2 = m_asinh(*(dtype*)p1);
7653
- p1 += s1;
7654
- p2 += s2;
7655
- }
7656
- return;
7657
- //
7658
- }
7659
- }
7660
- for (i = 0; i < n; i++) {
7661
- GET_DATA_STRIDE(p1, s1, dtype, x);
7662
- x = m_asinh(x);
7663
- SET_DATA_STRIDE(p2, s2, dtype, x);
7664
- }
7665
- //
7666
- }
7667
- }
7668
- }
7669
-
7670
- static VALUE dfloat_math_s_asinh(VALUE mod, VALUE a1) {
7671
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7672
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7673
- ndfunc_t ndf = { iter_dfloat_math_s_asinh, FULL_LOOP, 1, 1, ain, aout };
7674
-
7675
- return na_ndloop(&ndf, 1, a1);
7676
- }
7677
-
7678
- static void iter_dfloat_math_s_acosh(na_loop_t* const lp) {
7679
- size_t i = 0, n;
7680
- char *p1, *p2;
7681
- ssize_t s1, s2;
7682
- size_t *idx1, *idx2;
7683
- dtype x;
7684
-
7685
- INIT_COUNTER(lp, n);
7686
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
7687
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
7688
-
7689
- if (idx1) {
7690
- if (idx2) {
7691
- for (i = 0; i < n; i++) {
7692
- GET_DATA_INDEX(p1, idx1, dtype, x);
7693
- x = m_acosh(x);
7694
- SET_DATA_INDEX(p2, idx2, dtype, x);
7695
- }
7696
- } else {
7697
- for (i = 0; i < n; i++) {
7698
- GET_DATA_INDEX(p1, idx1, dtype, x);
7699
- x = m_acosh(x);
7700
- SET_DATA_STRIDE(p2, s2, dtype, x);
7701
- }
7702
- }
7703
- } else {
7704
- if (idx2) {
7705
- for (i = 0; i < n; i++) {
7706
- GET_DATA_STRIDE(p1, s1, dtype, x);
7707
- x = m_acosh(x);
7708
- SET_DATA_INDEX(p2, idx2, dtype, x);
7709
- }
7710
- } else {
7711
- //
7712
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
7713
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
7714
- //
7715
- for (; i < n; i++) {
7716
- ((dtype*)p2)[i] = m_acosh(((dtype*)p1)[i]);
7717
- }
7718
- //
7719
- return;
7720
- }
7721
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7722
- //
7723
- for (i = 0; i < n; i++) {
7724
- *(dtype*)p2 = m_acosh(*(dtype*)p1);
7725
- p1 += s1;
7726
- p2 += s2;
7727
- }
7728
- return;
7729
- //
7730
- }
7731
- }
7732
- for (i = 0; i < n; i++) {
7733
- GET_DATA_STRIDE(p1, s1, dtype, x);
7734
- x = m_acosh(x);
7735
- SET_DATA_STRIDE(p2, s2, dtype, x);
7736
- }
7737
- //
7738
- }
7739
- }
7740
- }
7741
-
7742
- static VALUE dfloat_math_s_acosh(VALUE mod, VALUE a1) {
7743
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7744
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7745
- ndfunc_t ndf = { iter_dfloat_math_s_acosh, FULL_LOOP, 1, 1, ain, aout };
7746
-
7747
- return na_ndloop(&ndf, 1, a1);
7748
- }
7749
-
7750
- static void iter_dfloat_math_s_atanh(na_loop_t* const lp) {
7751
- size_t i = 0, n;
7752
- char *p1, *p2;
7753
- ssize_t s1, s2;
7754
- size_t *idx1, *idx2;
7755
- dtype x;
7756
-
7757
- INIT_COUNTER(lp, n);
7758
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
7759
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
7760
-
7761
- if (idx1) {
7762
- if (idx2) {
7763
- for (i = 0; i < n; i++) {
7764
- GET_DATA_INDEX(p1, idx1, dtype, x);
7765
- x = m_atanh(x);
7766
- SET_DATA_INDEX(p2, idx2, dtype, x);
7767
- }
7768
- } else {
7769
- for (i = 0; i < n; i++) {
7770
- GET_DATA_INDEX(p1, idx1, dtype, x);
7771
- x = m_atanh(x);
7772
- SET_DATA_STRIDE(p2, s2, dtype, x);
7773
- }
7774
- }
7775
- } else {
7776
- if (idx2) {
7777
- for (i = 0; i < n; i++) {
7778
- GET_DATA_STRIDE(p1, s1, dtype, x);
7779
- x = m_atanh(x);
7780
- SET_DATA_INDEX(p2, idx2, dtype, x);
7781
- }
7782
- } else {
7783
- //
7784
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
7785
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
7786
- //
7787
- for (; i < n; i++) {
7788
- ((dtype*)p2)[i] = m_atanh(((dtype*)p1)[i]);
7789
- }
7790
- //
7791
- return;
7792
- }
7793
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7794
- //
7795
- for (i = 0; i < n; i++) {
7796
- *(dtype*)p2 = m_atanh(*(dtype*)p1);
7797
- p1 += s1;
7798
- p2 += s2;
7799
- }
7800
- return;
7801
- //
7802
- }
7803
- }
7804
- for (i = 0; i < n; i++) {
7805
- GET_DATA_STRIDE(p1, s1, dtype, x);
7806
- x = m_atanh(x);
7807
- SET_DATA_STRIDE(p2, s2, dtype, x);
7808
- }
7809
- //
7810
- }
7811
- }
7812
- }
7813
-
7814
- static VALUE dfloat_math_s_atanh(VALUE mod, VALUE a1) {
7815
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7816
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7817
- ndfunc_t ndf = { iter_dfloat_math_s_atanh, FULL_LOOP, 1, 1, ain, aout };
7818
-
7819
- return na_ndloop(&ndf, 1, a1);
7820
- }
7821
-
7822
- static void iter_dfloat_math_s_sinc(na_loop_t* const lp) {
7823
- size_t i = 0, n;
7824
- char *p1, *p2;
7825
- ssize_t s1, s2;
7826
- size_t *idx1, *idx2;
7827
- dtype x;
7828
-
7829
- INIT_COUNTER(lp, n);
7830
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
7831
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
7832
-
7833
- if (idx1) {
7834
- if (idx2) {
7835
- for (i = 0; i < n; i++) {
7836
- GET_DATA_INDEX(p1, idx1, dtype, x);
7837
- x = m_sinc(x);
7838
- SET_DATA_INDEX(p2, idx2, dtype, x);
7839
- }
7840
- } else {
7841
- for (i = 0; i < n; i++) {
7842
- GET_DATA_INDEX(p1, idx1, dtype, x);
7843
- x = m_sinc(x);
7844
- SET_DATA_STRIDE(p2, s2, dtype, x);
7845
- }
7846
- }
7847
- } else {
7848
- if (idx2) {
7849
- for (i = 0; i < n; i++) {
7850
- GET_DATA_STRIDE(p1, s1, dtype, x);
7851
- x = m_sinc(x);
7852
- SET_DATA_INDEX(p2, idx2, dtype, x);
7853
- }
7854
- } else {
7855
- //
7856
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
7857
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
7858
- //
7859
- for (; i < n; i++) {
7860
- ((dtype*)p2)[i] = m_sinc(((dtype*)p1)[i]);
7861
- }
7862
- //
7863
- return;
7864
- }
7865
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7866
- //
7867
- for (i = 0; i < n; i++) {
7868
- *(dtype*)p2 = m_sinc(*(dtype*)p1);
7869
- p1 += s1;
7870
- p2 += s2;
7871
- }
7872
- return;
7873
- //
7874
- }
7875
- }
7876
- for (i = 0; i < n; i++) {
7877
- GET_DATA_STRIDE(p1, s1, dtype, x);
7878
- x = m_sinc(x);
7879
- SET_DATA_STRIDE(p2, s2, dtype, x);
7880
- }
7881
- //
7882
- }
7883
- }
7884
- }
7885
-
7886
- static VALUE dfloat_math_s_sinc(VALUE mod, VALUE a1) {
7887
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7888
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7889
- ndfunc_t ndf = { iter_dfloat_math_s_sinc, FULL_LOOP, 1, 1, ain, aout };
7890
-
7891
- return na_ndloop(&ndf, 1, a1);
7892
- }
7893
-
7894
- static void iter_dfloat_math_s_atan2(na_loop_t* const lp) {
7895
- size_t i;
7896
- char *p1, *p2, *p3;
7897
- ssize_t s1, s2, s3;
7898
- dtype x, y;
7899
- INIT_COUNTER(lp, i);
7900
- INIT_PTR(lp, 0, p1, s1);
7901
- INIT_PTR(lp, 1, p2, s2);
7902
- INIT_PTR(lp, 2, p3, s3);
7903
- for (; i--;) {
7904
- GET_DATA_STRIDE(p1, s1, dtype, x);
7905
- GET_DATA_STRIDE(p2, s2, dtype, y);
7906
- x = m_atan2(x, y);
7907
- SET_DATA_STRIDE(p3, s3, dtype, x);
7908
- }
7909
- }
7910
-
7911
- static VALUE dfloat_math_s_atan2(VALUE mod, VALUE a1, VALUE a2) {
7912
- ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
7913
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7914
- ndfunc_t ndf = { iter_dfloat_math_s_atan2, STRIDE_LOOP, 2, 1, ain, aout };
7915
- return na_ndloop(&ndf, 2, a1, a2);
7916
- }
7917
-
7918
- static void iter_dfloat_math_s_hypot(na_loop_t* const lp) {
7919
- size_t i;
7920
- char *p1, *p2, *p3;
7921
- ssize_t s1, s2, s3;
7922
- dtype x, y;
7923
- INIT_COUNTER(lp, i);
7924
- INIT_PTR(lp, 0, p1, s1);
7925
- INIT_PTR(lp, 1, p2, s2);
7926
- INIT_PTR(lp, 2, p3, s3);
7927
- for (; i--;) {
7928
- GET_DATA_STRIDE(p1, s1, dtype, x);
7929
- GET_DATA_STRIDE(p2, s2, dtype, y);
7930
- x = m_hypot(x, y);
7931
- SET_DATA_STRIDE(p3, s3, dtype, x);
7932
- }
7933
- }
7934
-
7935
- static VALUE dfloat_math_s_hypot(VALUE mod, VALUE a1, VALUE a2) {
7936
- ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
7937
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7938
- ndfunc_t ndf = { iter_dfloat_math_s_hypot, STRIDE_LOOP, 2, 1, ain, aout };
7939
- return na_ndloop(&ndf, 2, a1, a2);
7940
- }
7941
-
7942
- static void iter_dfloat_math_s_erf(na_loop_t* const lp) {
7943
- size_t i = 0, n;
7944
- char *p1, *p2;
7945
- ssize_t s1, s2;
7946
- size_t *idx1, *idx2;
7947
- dtype x;
7948
-
7949
- INIT_COUNTER(lp, n);
7950
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
7951
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
7952
-
7953
- if (idx1) {
7954
- if (idx2) {
7955
- for (i = 0; i < n; i++) {
7956
- GET_DATA_INDEX(p1, idx1, dtype, x);
7957
- x = m_erf(x);
7958
- SET_DATA_INDEX(p2, idx2, dtype, x);
7959
- }
7960
- } else {
7961
- for (i = 0; i < n; i++) {
7962
- GET_DATA_INDEX(p1, idx1, dtype, x);
7963
- x = m_erf(x);
7964
- SET_DATA_STRIDE(p2, s2, dtype, x);
7965
- }
7966
- }
7967
- } else {
7968
- if (idx2) {
7969
- for (i = 0; i < n; i++) {
7970
- GET_DATA_STRIDE(p1, s1, dtype, x);
7971
- x = m_erf(x);
7972
- SET_DATA_INDEX(p2, idx2, dtype, x);
7973
- }
7974
- } else {
7975
- //
7976
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
7977
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
7978
- //
7979
- for (; i < n; i++) {
7980
- ((dtype*)p2)[i] = m_erf(((dtype*)p1)[i]);
7981
- }
7982
- //
7983
- return;
7984
- }
7985
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
7986
- //
7987
- for (i = 0; i < n; i++) {
7988
- *(dtype*)p2 = m_erf(*(dtype*)p1);
7989
- p1 += s1;
7990
- p2 += s2;
7991
- }
7992
- return;
7993
- //
7994
- }
7995
- }
7996
- for (i = 0; i < n; i++) {
7997
- GET_DATA_STRIDE(p1, s1, dtype, x);
7998
- x = m_erf(x);
7999
- SET_DATA_STRIDE(p2, s2, dtype, x);
8000
- }
8001
- //
8002
- }
8003
- }
8004
- }
8005
-
8006
- static VALUE dfloat_math_s_erf(VALUE mod, VALUE a1) {
8007
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
8008
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
8009
- ndfunc_t ndf = { iter_dfloat_math_s_erf, FULL_LOOP, 1, 1, ain, aout };
8010
-
8011
- return na_ndloop(&ndf, 1, a1);
8012
- }
8013
-
8014
- static void iter_dfloat_math_s_erfc(na_loop_t* const lp) {
8015
- size_t i = 0, n;
8016
- char *p1, *p2;
8017
- ssize_t s1, s2;
8018
- size_t *idx1, *idx2;
8019
- dtype x;
8020
-
8021
- INIT_COUNTER(lp, n);
8022
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
8023
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
8024
-
8025
- if (idx1) {
8026
- if (idx2) {
8027
- for (i = 0; i < n; i++) {
8028
- GET_DATA_INDEX(p1, idx1, dtype, x);
8029
- x = m_erfc(x);
8030
- SET_DATA_INDEX(p2, idx2, dtype, x);
8031
- }
8032
- } else {
8033
- for (i = 0; i < n; i++) {
8034
- GET_DATA_INDEX(p1, idx1, dtype, x);
8035
- x = m_erfc(x);
8036
- SET_DATA_STRIDE(p2, s2, dtype, x);
8037
- }
8038
- }
8039
- } else {
8040
- if (idx2) {
8041
- for (i = 0; i < n; i++) {
8042
- GET_DATA_STRIDE(p1, s1, dtype, x);
8043
- x = m_erfc(x);
8044
- SET_DATA_INDEX(p2, idx2, dtype, x);
8045
- }
8046
- } else {
8047
- //
8048
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
8049
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
8050
- //
8051
- for (; i < n; i++) {
8052
- ((dtype*)p2)[i] = m_erfc(((dtype*)p1)[i]);
8053
- }
8054
- //
8055
- return;
8056
- }
8057
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
8058
- //
8059
- for (i = 0; i < n; i++) {
8060
- *(dtype*)p2 = m_erfc(*(dtype*)p1);
8061
- p1 += s1;
8062
- p2 += s2;
8063
- }
8064
- return;
8065
- //
8066
- }
8067
- }
8068
- for (i = 0; i < n; i++) {
8069
- GET_DATA_STRIDE(p1, s1, dtype, x);
8070
- x = m_erfc(x);
8071
- SET_DATA_STRIDE(p2, s2, dtype, x);
8072
- }
8073
- //
8074
- }
8075
- }
8076
- }
8077
-
8078
- static VALUE dfloat_math_s_erfc(VALUE mod, VALUE a1) {
8079
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
8080
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
8081
- ndfunc_t ndf = { iter_dfloat_math_s_erfc, FULL_LOOP, 1, 1, ain, aout };
8082
-
8083
- return na_ndloop(&ndf, 1, a1);
8084
- }
8085
-
8086
- static void iter_dfloat_math_s_log1p(na_loop_t* const lp) {
8087
- size_t i = 0, n;
8088
- char *p1, *p2;
8089
- ssize_t s1, s2;
8090
- size_t *idx1, *idx2;
8091
- dtype x;
8092
-
8093
- INIT_COUNTER(lp, n);
8094
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
8095
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
8096
-
8097
- if (idx1) {
8098
- if (idx2) {
8099
- for (i = 0; i < n; i++) {
8100
- GET_DATA_INDEX(p1, idx1, dtype, x);
8101
- x = m_log1p(x);
8102
- SET_DATA_INDEX(p2, idx2, dtype, x);
8103
- }
8104
- } else {
8105
- for (i = 0; i < n; i++) {
8106
- GET_DATA_INDEX(p1, idx1, dtype, x);
8107
- x = m_log1p(x);
8108
- SET_DATA_STRIDE(p2, s2, dtype, x);
8109
- }
8110
- }
8111
- } else {
8112
- if (idx2) {
8113
- for (i = 0; i < n; i++) {
8114
- GET_DATA_STRIDE(p1, s1, dtype, x);
8115
- x = m_log1p(x);
8116
- SET_DATA_INDEX(p2, idx2, dtype, x);
8117
- }
8118
- } else {
8119
- //
8120
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
8121
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
8122
- //
8123
- for (; i < n; i++) {
8124
- ((dtype*)p2)[i] = m_log1p(((dtype*)p1)[i]);
8125
- }
8126
- //
8127
- return;
8128
- }
8129
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
8130
- //
8131
- for (i = 0; i < n; i++) {
8132
- *(dtype*)p2 = m_log1p(*(dtype*)p1);
8133
- p1 += s1;
8134
- p2 += s2;
8135
- }
8136
- return;
8137
- //
8138
- }
8139
- }
8140
- for (i = 0; i < n; i++) {
8141
- GET_DATA_STRIDE(p1, s1, dtype, x);
8142
- x = m_log1p(x);
8143
- SET_DATA_STRIDE(p2, s2, dtype, x);
8144
- }
8145
- //
8146
- }
8147
- }
8148
- }
8149
-
8150
- static VALUE dfloat_math_s_log1p(VALUE mod, VALUE a1) {
8151
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
8152
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
8153
- ndfunc_t ndf = { iter_dfloat_math_s_log1p, FULL_LOOP, 1, 1, ain, aout };
8154
-
8155
- return na_ndloop(&ndf, 1, a1);
8156
- }
8157
-
8158
- static void iter_dfloat_math_s_expm1(na_loop_t* const lp) {
8159
- size_t i = 0, n;
8160
- char *p1, *p2;
8161
- ssize_t s1, s2;
8162
- size_t *idx1, *idx2;
8163
- dtype x;
8164
-
8165
- INIT_COUNTER(lp, n);
8166
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
8167
- INIT_PTR_IDX(lp, 1, p2, s2, idx2);
8168
-
8169
- if (idx1) {
8170
- if (idx2) {
8171
- for (i = 0; i < n; i++) {
8172
- GET_DATA_INDEX(p1, idx1, dtype, x);
8173
- x = m_expm1(x);
8174
- SET_DATA_INDEX(p2, idx2, dtype, x);
8175
- }
8176
- } else {
8177
- for (i = 0; i < n; i++) {
8178
- GET_DATA_INDEX(p1, idx1, dtype, x);
8179
- x = m_expm1(x);
8180
- SET_DATA_STRIDE(p2, s2, dtype, x);
8181
- }
8182
- }
8183
- } else {
8184
- if (idx2) {
8185
- for (i = 0; i < n; i++) {
8186
- GET_DATA_STRIDE(p1, s1, dtype, x);
8187
- x = m_expm1(x);
8188
- SET_DATA_INDEX(p2, idx2, dtype, x);
8189
- }
8190
- } else {
8191
- //
8192
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
8193
- if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
8194
- //
8195
- for (; i < n; i++) {
8196
- ((dtype*)p2)[i] = m_expm1(((dtype*)p1)[i]);
8197
- }
8198
- //
8199
- return;
8200
- }
8201
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
8202
- //
8203
- for (i = 0; i < n; i++) {
8204
- *(dtype*)p2 = m_expm1(*(dtype*)p1);
8205
- p1 += s1;
8206
- p2 += s2;
8207
- }
8208
- return;
8209
- //
8210
- }
8211
- }
8212
- for (i = 0; i < n; i++) {
8213
- GET_DATA_STRIDE(p1, s1, dtype, x);
8214
- x = m_expm1(x);
8215
- SET_DATA_STRIDE(p2, s2, dtype, x);
8216
- }
8217
- //
8218
- }
8219
- }
8220
- }
8221
-
8222
- static VALUE dfloat_math_s_expm1(VALUE mod, VALUE a1) {
8223
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
8224
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
8225
- ndfunc_t ndf = { iter_dfloat_math_s_expm1, FULL_LOOP, 1, 1, ain, aout };
8226
-
8227
- return na_ndloop(&ndf, 1, a1);
8228
- }
8229
-
8230
- static void iter_dfloat_math_s_ldexp(na_loop_t* const lp) {
8231
- size_t i;
8232
- char *p1, *p2, *p3;
8233
- ssize_t s1, s2, s3;
8234
- dtype x, y;
8235
- INIT_COUNTER(lp, i);
8236
- INIT_PTR(lp, 0, p1, s1);
8237
- INIT_PTR(lp, 1, p2, s2);
8238
- INIT_PTR(lp, 2, p3, s3);
8239
- for (; i--;) {
8240
- GET_DATA_STRIDE(p1, s1, dtype, x);
8241
- GET_DATA_STRIDE(p2, s2, dtype, y);
8242
- x = m_ldexp(x, y);
8243
- SET_DATA_STRIDE(p3, s3, dtype, x);
8244
- }
8245
- }
8246
-
8247
- static VALUE dfloat_math_s_ldexp(VALUE mod, VALUE a1, VALUE a2) {
8248
- ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
8249
- ndfunc_arg_out_t aout[1] = { { cT, 0 } };
8250
- ndfunc_t ndf = { iter_dfloat_math_s_ldexp, STRIDE_LOOP, 2, 1, ain, aout };
8251
- return na_ndloop(&ndf, 2, a1, a2);
8252
- }
8253
-
8254
- static void iter_dfloat_math_s_frexp(na_loop_t* const lp) {
8255
- size_t i;
8256
- char *p1, *p2, *p3;
8257
- ssize_t s1, s2, s3;
8258
- dtype x;
8259
- int y;
8260
- INIT_COUNTER(lp, i);
8261
- INIT_PTR(lp, 0, p1, s1);
8262
- INIT_PTR(lp, 1, p2, s2);
8263
- INIT_PTR(lp, 2, p3, s3);
8264
- for (; i--;) {
8265
- GET_DATA_STRIDE(p1, s1, dtype, x);
8266
- x = m_frexp(x, &y);
8267
- SET_DATA_STRIDE(p2, s2, dtype, x);
8268
- SET_DATA_STRIDE(p3, s3, int32_t, y);
8269
- }
8270
- }
8271
-
8272
- static VALUE dfloat_math_s_frexp(VALUE mod, VALUE a1) {
8273
- ndfunc_arg_in_t ain[1] = { { cT, 0 } };
8274
- ndfunc_arg_out_t aout[2] = { { cT, 0 }, { numo_cInt32, 0 } };
8275
- ndfunc_t ndf = { iter_dfloat_math_s_frexp, STRIDE_LOOP, 1, 2, ain, aout };
8276
- return na_ndloop(&ndf, 1, a1);
8277
- }
8278
-
8279
6393
  void Init_numo_dfloat(void) {
8280
6394
  VALUE hCast, mNumo;
8281
6395