numo-narray-alt 0.9.7 → 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.
- checksums.yaml +4 -4
- data/README.md +24 -10
- data/ext/numo/narray/numo/narray.h +2 -2
- data/ext/numo/narray/numo/types/complex.h +2 -2
- data/ext/numo/narray/src/mh/math/acos.h +9 -0
- data/ext/numo/narray/src/mh/math/acosh.h +9 -0
- data/ext/numo/narray/src/mh/math/asin.h +9 -0
- data/ext/numo/narray/src/mh/math/asinh.h +9 -0
- data/ext/numo/narray/src/mh/math/atan.h +9 -0
- data/ext/numo/narray/src/mh/math/atan2.h +29 -0
- data/ext/numo/narray/src/mh/math/atanh.h +9 -0
- data/ext/numo/narray/src/mh/math/cbrt.h +9 -0
- data/ext/numo/narray/src/mh/math/cos.h +9 -0
- data/ext/numo/narray/src/mh/math/cosh.h +9 -0
- data/ext/numo/narray/src/mh/math/erf.h +9 -0
- data/ext/numo/narray/src/mh/math/erfc.h +9 -0
- data/ext/numo/narray/src/mh/math/exp.h +9 -0
- data/ext/numo/narray/src/mh/math/exp10.h +9 -0
- data/ext/numo/narray/src/mh/math/exp2.h +9 -0
- data/ext/numo/narray/src/mh/math/expm1.h +9 -0
- data/ext/numo/narray/src/mh/math/frexp.h +30 -0
- data/ext/numo/narray/src/mh/math/hypot.h +29 -0
- data/ext/numo/narray/src/mh/math/ldexp.h +29 -0
- data/ext/numo/narray/src/mh/math/log.h +9 -0
- data/ext/numo/narray/src/mh/math/log10.h +9 -0
- data/ext/numo/narray/src/mh/math/log1p.h +9 -0
- data/ext/numo/narray/src/mh/math/log2.h +9 -0
- data/ext/numo/narray/src/mh/math/sin.h +9 -0
- data/ext/numo/narray/src/mh/math/sinc.h +9 -0
- data/ext/numo/narray/src/mh/math/sinh.h +9 -0
- data/ext/numo/narray/src/mh/math/sqrt.h +203 -0
- data/ext/numo/narray/src/mh/math/tan.h +9 -0
- data/ext/numo/narray/src/mh/math/tanh.h +9 -0
- data/ext/numo/narray/src/mh/math/unary_func.h +70 -0
- data/ext/numo/narray/src/mh/mean.h +1 -8
- data/ext/numo/narray/src/mh/rms.h +1 -8
- data/ext/numo/narray/src/mh/stddev.h +1 -8
- data/ext/numo/narray/src/mh/var.h +1 -8
- data/ext/numo/narray/src/t_dcomplex.c +236 -1707
- data/ext/numo/narray/src/t_dfloat.c +66 -1952
- data/ext/numo/narray/src/t_robject.c +4 -4
- data/ext/numo/narray/src/t_scomplex.c +236 -1707
- data/ext/numo/narray/src/t_sfloat.c +66 -1952
- metadata +33 -3
|
@@ -42,11 +42,53 @@ extern VALUE cRT;
|
|
|
42
42
|
#include "mh/var.h"
|
|
43
43
|
#include "mh/stddev.h"
|
|
44
44
|
#include "mh/rms.h"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
#include "mh/math/sqrt.h"
|
|
46
|
+
#include "mh/math/cbrt.h"
|
|
47
|
+
#include "mh/math/log.h"
|
|
48
|
+
#include "mh/math/log2.h"
|
|
49
|
+
#include "mh/math/log10.h"
|
|
50
|
+
#include "mh/math/exp.h"
|
|
51
|
+
#include "mh/math/exp2.h"
|
|
52
|
+
#include "mh/math/exp10.h"
|
|
53
|
+
#include "mh/math/sin.h"
|
|
54
|
+
#include "mh/math/cos.h"
|
|
55
|
+
#include "mh/math/tan.h"
|
|
56
|
+
#include "mh/math/asin.h"
|
|
57
|
+
#include "mh/math/acos.h"
|
|
58
|
+
#include "mh/math/atan.h"
|
|
59
|
+
#include "mh/math/sinh.h"
|
|
60
|
+
#include "mh/math/cosh.h"
|
|
61
|
+
#include "mh/math/tanh.h"
|
|
62
|
+
#include "mh/math/asinh.h"
|
|
63
|
+
#include "mh/math/acosh.h"
|
|
64
|
+
#include "mh/math/atanh.h"
|
|
65
|
+
#include "mh/math/sinc.h"
|
|
66
|
+
|
|
67
|
+
DEF_NARRAY_FLT_MEAN_METHOD_FUNC(scomplex, numo_cSComplex, scomplex, numo_cSComplex)
|
|
68
|
+
DEF_NARRAY_FLT_VAR_METHOD_FUNC(scomplex, numo_cSComplex, float, numo_cSFloat)
|
|
69
|
+
DEF_NARRAY_FLT_STDDEV_METHOD_FUNC(scomplex, numo_cSComplex, float, numo_cSFloat)
|
|
70
|
+
DEF_NARRAY_FLT_RMS_METHOD_FUNC(scomplex, numo_cSComplex, float, numo_cSFloat)
|
|
71
|
+
DEF_NARRAY_FLT_SQRT_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
72
|
+
DEF_NARRAY_FLT_CBRT_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
73
|
+
DEF_NARRAY_FLT_LOG_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
74
|
+
DEF_NARRAY_FLT_LOG2_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
75
|
+
DEF_NARRAY_FLT_LOG10_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
76
|
+
DEF_NARRAY_FLT_EXP_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
77
|
+
DEF_NARRAY_FLT_EXP2_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
78
|
+
DEF_NARRAY_FLT_EXP10_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
79
|
+
DEF_NARRAY_FLT_SIN_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
80
|
+
DEF_NARRAY_FLT_COS_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
81
|
+
DEF_NARRAY_FLT_TAN_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
82
|
+
DEF_NARRAY_FLT_ASIN_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
83
|
+
DEF_NARRAY_FLT_ACOS_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
84
|
+
DEF_NARRAY_FLT_ATAN_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
85
|
+
DEF_NARRAY_FLT_SINH_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
86
|
+
DEF_NARRAY_FLT_COSH_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
87
|
+
DEF_NARRAY_FLT_TANH_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
88
|
+
DEF_NARRAY_FLT_ASINH_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
89
|
+
DEF_NARRAY_FLT_ACOSH_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
90
|
+
DEF_NARRAY_FLT_ATANH_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
91
|
+
DEF_NARRAY_FLT_SINC_METHOD_FUNC(scomplex, numo_cSComplex)
|
|
50
92
|
|
|
51
93
|
static VALUE scomplex_store(VALUE, VALUE);
|
|
52
94
|
|
|
@@ -4744,1715 +4786,77 @@ static VALUE scomplex_poly(VALUE self, VALUE args) {
|
|
|
4744
4786
|
|
|
4745
4787
|
VALUE mTM;
|
|
4746
4788
|
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
char *p1, *p2;
|
|
4750
|
-
ssize_t s1, s2;
|
|
4751
|
-
size_t *idx1, *idx2;
|
|
4752
|
-
dtype x;
|
|
4753
|
-
|
|
4754
|
-
INIT_COUNTER(lp, n);
|
|
4755
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
4756
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
4757
|
-
|
|
4758
|
-
if (idx1) {
|
|
4759
|
-
if (idx2) {
|
|
4760
|
-
for (i = 0; i < n; i++) {
|
|
4761
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
4762
|
-
x = m_sqrt(x);
|
|
4763
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
4764
|
-
}
|
|
4765
|
-
} else {
|
|
4766
|
-
for (i = 0; i < n; i++) {
|
|
4767
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
4768
|
-
x = m_sqrt(x);
|
|
4769
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
4770
|
-
}
|
|
4771
|
-
}
|
|
4772
|
-
} else {
|
|
4773
|
-
if (idx2) {
|
|
4774
|
-
for (i = 0; i < n; i++) {
|
|
4775
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
4776
|
-
x = m_sqrt(x);
|
|
4777
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
4778
|
-
}
|
|
4779
|
-
} else {
|
|
4780
|
-
//
|
|
4781
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
4782
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
4783
|
-
//
|
|
4784
|
-
for (; i < n; i++) {
|
|
4785
|
-
((dtype*)p2)[i] = m_sqrt(((dtype*)p1)[i]);
|
|
4786
|
-
}
|
|
4787
|
-
//
|
|
4788
|
-
return;
|
|
4789
|
-
}
|
|
4790
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
4791
|
-
//
|
|
4792
|
-
for (i = 0; i < n; i++) {
|
|
4793
|
-
*(dtype*)p2 = m_sqrt(*(dtype*)p1);
|
|
4794
|
-
p1 += s1;
|
|
4795
|
-
p2 += s2;
|
|
4796
|
-
}
|
|
4797
|
-
return;
|
|
4798
|
-
//
|
|
4799
|
-
}
|
|
4800
|
-
}
|
|
4801
|
-
for (i = 0; i < n; i++) {
|
|
4802
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
4803
|
-
x = m_sqrt(x);
|
|
4804
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
4805
|
-
}
|
|
4806
|
-
//
|
|
4807
|
-
}
|
|
4808
|
-
}
|
|
4809
|
-
}
|
|
4810
|
-
|
|
4811
|
-
/*
|
|
4812
|
-
Calculate sqrt(x).
|
|
4813
|
-
@overload sqrt(x)
|
|
4814
|
-
@param [Numo::NArray,Numeric] x input value
|
|
4815
|
-
@return [Numo::SComplex] result of sqrt(x).
|
|
4816
|
-
*/
|
|
4817
|
-
static VALUE scomplex_math_s_sqrt(VALUE mod, VALUE a1) {
|
|
4818
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
4819
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
4820
|
-
ndfunc_t ndf = { iter_scomplex_math_s_sqrt, FULL_LOOP, 1, 1, ain, aout };
|
|
4821
|
-
|
|
4822
|
-
return na_ndloop(&ndf, 1, a1);
|
|
4823
|
-
}
|
|
4824
|
-
|
|
4825
|
-
static void iter_scomplex_math_s_cbrt(na_loop_t* const lp) {
|
|
4826
|
-
size_t i = 0, n;
|
|
4827
|
-
char *p1, *p2;
|
|
4828
|
-
ssize_t s1, s2;
|
|
4829
|
-
size_t *idx1, *idx2;
|
|
4830
|
-
dtype x;
|
|
4831
|
-
|
|
4832
|
-
INIT_COUNTER(lp, n);
|
|
4833
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
4834
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
4835
|
-
|
|
4836
|
-
if (idx1) {
|
|
4837
|
-
if (idx2) {
|
|
4838
|
-
for (i = 0; i < n; i++) {
|
|
4839
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
4840
|
-
x = m_cbrt(x);
|
|
4841
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
4842
|
-
}
|
|
4843
|
-
} else {
|
|
4844
|
-
for (i = 0; i < n; i++) {
|
|
4845
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
4846
|
-
x = m_cbrt(x);
|
|
4847
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
4848
|
-
}
|
|
4849
|
-
}
|
|
4850
|
-
} else {
|
|
4851
|
-
if (idx2) {
|
|
4852
|
-
for (i = 0; i < n; i++) {
|
|
4853
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
4854
|
-
x = m_cbrt(x);
|
|
4855
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
4856
|
-
}
|
|
4857
|
-
} else {
|
|
4858
|
-
//
|
|
4859
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
4860
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
4861
|
-
//
|
|
4862
|
-
for (; i < n; i++) {
|
|
4863
|
-
((dtype*)p2)[i] = m_cbrt(((dtype*)p1)[i]);
|
|
4864
|
-
}
|
|
4865
|
-
//
|
|
4866
|
-
return;
|
|
4867
|
-
}
|
|
4868
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
4869
|
-
//
|
|
4870
|
-
for (i = 0; i < n; i++) {
|
|
4871
|
-
*(dtype*)p2 = m_cbrt(*(dtype*)p1);
|
|
4872
|
-
p1 += s1;
|
|
4873
|
-
p2 += s2;
|
|
4874
|
-
}
|
|
4875
|
-
return;
|
|
4876
|
-
//
|
|
4877
|
-
}
|
|
4878
|
-
}
|
|
4879
|
-
for (i = 0; i < n; i++) {
|
|
4880
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
4881
|
-
x = m_cbrt(x);
|
|
4882
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
4883
|
-
}
|
|
4884
|
-
//
|
|
4885
|
-
}
|
|
4886
|
-
}
|
|
4887
|
-
}
|
|
4888
|
-
|
|
4889
|
-
/*
|
|
4890
|
-
Calculate cbrt(x).
|
|
4891
|
-
@overload cbrt(x)
|
|
4892
|
-
@param [Numo::NArray,Numeric] x input value
|
|
4893
|
-
@return [Numo::SComplex] result of cbrt(x).
|
|
4894
|
-
*/
|
|
4895
|
-
static VALUE scomplex_math_s_cbrt(VALUE mod, VALUE a1) {
|
|
4896
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
4897
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
4898
|
-
ndfunc_t ndf = { iter_scomplex_math_s_cbrt, FULL_LOOP, 1, 1, ain, aout };
|
|
4789
|
+
void Init_numo_scomplex(void) {
|
|
4790
|
+
VALUE hCast, mNumo;
|
|
4899
4791
|
|
|
4900
|
-
|
|
4901
|
-
}
|
|
4792
|
+
mNumo = rb_define_module("Numo");
|
|
4902
4793
|
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4794
|
+
id_pow = rb_intern("**");
|
|
4795
|
+
id_cast = rb_intern("cast");
|
|
4796
|
+
id_copysign = rb_intern("copysign");
|
|
4797
|
+
id_eq = rb_intern("eq");
|
|
4798
|
+
id_imag = rb_intern("imag");
|
|
4799
|
+
id_mulsum = rb_intern("mulsum");
|
|
4800
|
+
id_ne = rb_intern("ne");
|
|
4801
|
+
id_nearly_eq = rb_intern("nearly_eq");
|
|
4802
|
+
id_real = rb_intern("real");
|
|
4803
|
+
id_to_a = rb_intern("to_a");
|
|
4909
4804
|
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4805
|
+
/**
|
|
4806
|
+
* Document-class: Numo::SComplex
|
|
4807
|
+
*
|
|
4808
|
+
* Single precision floating point (32bit) complex number N-dimensional array class.
|
|
4809
|
+
*/
|
|
4810
|
+
cT = rb_define_class_under(mNumo, "SComplex", cNArray);
|
|
4913
4811
|
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
for (i = 0; i < n; i++) {
|
|
4917
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
4918
|
-
x = m_log(x);
|
|
4919
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
4920
|
-
}
|
|
4921
|
-
} else {
|
|
4922
|
-
for (i = 0; i < n; i++) {
|
|
4923
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
4924
|
-
x = m_log(x);
|
|
4925
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
4926
|
-
}
|
|
4927
|
-
}
|
|
4928
|
-
} else {
|
|
4929
|
-
if (idx2) {
|
|
4930
|
-
for (i = 0; i < n; i++) {
|
|
4931
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
4932
|
-
x = m_log(x);
|
|
4933
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
4934
|
-
}
|
|
4935
|
-
} else {
|
|
4936
|
-
//
|
|
4937
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
4938
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
4939
|
-
//
|
|
4940
|
-
for (; i < n; i++) {
|
|
4941
|
-
((dtype*)p2)[i] = m_log(((dtype*)p1)[i]);
|
|
4942
|
-
}
|
|
4943
|
-
//
|
|
4944
|
-
return;
|
|
4945
|
-
}
|
|
4946
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
4947
|
-
//
|
|
4948
|
-
for (i = 0; i < n; i++) {
|
|
4949
|
-
*(dtype*)p2 = m_log(*(dtype*)p1);
|
|
4950
|
-
p1 += s1;
|
|
4951
|
-
p2 += s2;
|
|
4952
|
-
}
|
|
4953
|
-
return;
|
|
4954
|
-
//
|
|
4955
|
-
}
|
|
4956
|
-
}
|
|
4957
|
-
for (i = 0; i < n; i++) {
|
|
4958
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
4959
|
-
x = m_log(x);
|
|
4960
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
4961
|
-
}
|
|
4962
|
-
//
|
|
4963
|
-
}
|
|
4964
|
-
}
|
|
4965
|
-
}
|
|
4812
|
+
// alias of SComplex
|
|
4813
|
+
rb_define_const(mNumo, "Complex32", numo_cSComplex);
|
|
4966
4814
|
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
@return [Numo::SComplex] result of log(x).
|
|
4972
|
-
*/
|
|
4973
|
-
static VALUE scomplex_math_s_log(VALUE mod, VALUE a1) {
|
|
4974
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
4975
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
4976
|
-
ndfunc_t ndf = { iter_scomplex_math_s_log, FULL_LOOP, 1, 1, ain, aout };
|
|
4815
|
+
hCast = rb_hash_new();
|
|
4816
|
+
/* Upcasting rules of SComplex. */
|
|
4817
|
+
rb_define_const(cT, "UPCAST", hCast);
|
|
4818
|
+
rb_hash_aset(hCast, rb_cArray, cT);
|
|
4977
4819
|
|
|
4978
|
-
|
|
4979
|
-
|
|
4820
|
+
#ifdef RUBY_INTEGER_UNIFICATION
|
|
4821
|
+
rb_hash_aset(hCast, rb_cInteger, cT);
|
|
4822
|
+
#else
|
|
4823
|
+
rb_hash_aset(hCast, rb_cFixnum, cT);
|
|
4824
|
+
rb_hash_aset(hCast, rb_cBignum, cT);
|
|
4825
|
+
#endif
|
|
4826
|
+
rb_hash_aset(hCast, rb_cFloat, cT);
|
|
4827
|
+
rb_hash_aset(hCast, rb_cComplex, cT);
|
|
4828
|
+
rb_hash_aset(hCast, numo_cRObject, numo_cRObject);
|
|
4829
|
+
rb_hash_aset(hCast, numo_cDComplex, numo_cDComplex);
|
|
4830
|
+
rb_hash_aset(hCast, numo_cSComplex, numo_cSComplex);
|
|
4831
|
+
rb_hash_aset(hCast, numo_cDFloat, numo_cDComplex);
|
|
4832
|
+
rb_hash_aset(hCast, numo_cSFloat, numo_cSComplex);
|
|
4833
|
+
rb_hash_aset(hCast, numo_cInt64, numo_cSComplex);
|
|
4834
|
+
rb_hash_aset(hCast, numo_cInt32, numo_cSComplex);
|
|
4835
|
+
rb_hash_aset(hCast, numo_cInt16, numo_cSComplex);
|
|
4836
|
+
rb_hash_aset(hCast, numo_cInt8, numo_cSComplex);
|
|
4837
|
+
rb_hash_aset(hCast, numo_cUInt64, numo_cSComplex);
|
|
4838
|
+
rb_hash_aset(hCast, numo_cUInt32, numo_cSComplex);
|
|
4839
|
+
rb_hash_aset(hCast, numo_cUInt16, numo_cSComplex);
|
|
4840
|
+
rb_hash_aset(hCast, numo_cUInt8, numo_cSComplex);
|
|
4841
|
+
rb_obj_freeze(hCast);
|
|
4980
4842
|
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
dtype
|
|
4843
|
+
/* Element size of SComplex in bits. */
|
|
4844
|
+
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
|
|
4845
|
+
/* Element size of SComplex in bytes. */
|
|
4846
|
+
rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
|
|
4847
|
+
/* Stride size of contiguous SComplex array. */
|
|
4848
|
+
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
|
|
4849
|
+
/* Machine epsilon of SComplex */
|
|
4850
|
+
rb_define_const(cT, "EPSILON", M_EPSILON);
|
|
4851
|
+
/* The largest representable value of SComplex */
|
|
4852
|
+
rb_define_const(cT, "MAX", M_MAX);
|
|
4853
|
+
/* The smallest representable value of SComplex */
|
|
4854
|
+
rb_define_const(cT, "MIN", M_MIN);
|
|
4855
|
+
rb_define_alloc_func(cT, scomplex_s_alloc_func);
|
|
4856
|
+
rb_define_method(cT, "allocate", scomplex_allocate, 0);
|
|
4857
|
+
rb_define_method(cT, "extract", scomplex_extract, 0);
|
|
4987
4858
|
|
|
4988
|
-
|
|
4989
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
4990
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
4991
|
-
|
|
4992
|
-
if (idx1) {
|
|
4993
|
-
if (idx2) {
|
|
4994
|
-
for (i = 0; i < n; i++) {
|
|
4995
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
4996
|
-
x = m_log2(x);
|
|
4997
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
4998
|
-
}
|
|
4999
|
-
} else {
|
|
5000
|
-
for (i = 0; i < n; i++) {
|
|
5001
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5002
|
-
x = m_log2(x);
|
|
5003
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5004
|
-
}
|
|
5005
|
-
}
|
|
5006
|
-
} else {
|
|
5007
|
-
if (idx2) {
|
|
5008
|
-
for (i = 0; i < n; i++) {
|
|
5009
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5010
|
-
x = m_log2(x);
|
|
5011
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5012
|
-
}
|
|
5013
|
-
} else {
|
|
5014
|
-
//
|
|
5015
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
5016
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
5017
|
-
//
|
|
5018
|
-
for (; i < n; i++) {
|
|
5019
|
-
((dtype*)p2)[i] = m_log2(((dtype*)p1)[i]);
|
|
5020
|
-
}
|
|
5021
|
-
//
|
|
5022
|
-
return;
|
|
5023
|
-
}
|
|
5024
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
5025
|
-
//
|
|
5026
|
-
for (i = 0; i < n; i++) {
|
|
5027
|
-
*(dtype*)p2 = m_log2(*(dtype*)p1);
|
|
5028
|
-
p1 += s1;
|
|
5029
|
-
p2 += s2;
|
|
5030
|
-
}
|
|
5031
|
-
return;
|
|
5032
|
-
//
|
|
5033
|
-
}
|
|
5034
|
-
}
|
|
5035
|
-
for (i = 0; i < n; i++) {
|
|
5036
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5037
|
-
x = m_log2(x);
|
|
5038
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5039
|
-
}
|
|
5040
|
-
//
|
|
5041
|
-
}
|
|
5042
|
-
}
|
|
5043
|
-
}
|
|
5044
|
-
|
|
5045
|
-
/*
|
|
5046
|
-
Calculate log2(x).
|
|
5047
|
-
@overload log2(x)
|
|
5048
|
-
@param [Numo::NArray,Numeric] x input value
|
|
5049
|
-
@return [Numo::SComplex] result of log2(x).
|
|
5050
|
-
*/
|
|
5051
|
-
static VALUE scomplex_math_s_log2(VALUE mod, VALUE a1) {
|
|
5052
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
5053
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
5054
|
-
ndfunc_t ndf = { iter_scomplex_math_s_log2, FULL_LOOP, 1, 1, ain, aout };
|
|
5055
|
-
|
|
5056
|
-
return na_ndloop(&ndf, 1, a1);
|
|
5057
|
-
}
|
|
5058
|
-
|
|
5059
|
-
static void iter_scomplex_math_s_log10(na_loop_t* const lp) {
|
|
5060
|
-
size_t i = 0, n;
|
|
5061
|
-
char *p1, *p2;
|
|
5062
|
-
ssize_t s1, s2;
|
|
5063
|
-
size_t *idx1, *idx2;
|
|
5064
|
-
dtype x;
|
|
5065
|
-
|
|
5066
|
-
INIT_COUNTER(lp, n);
|
|
5067
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
5068
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
5069
|
-
|
|
5070
|
-
if (idx1) {
|
|
5071
|
-
if (idx2) {
|
|
5072
|
-
for (i = 0; i < n; i++) {
|
|
5073
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5074
|
-
x = m_log10(x);
|
|
5075
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5076
|
-
}
|
|
5077
|
-
} else {
|
|
5078
|
-
for (i = 0; i < n; i++) {
|
|
5079
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5080
|
-
x = m_log10(x);
|
|
5081
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5082
|
-
}
|
|
5083
|
-
}
|
|
5084
|
-
} else {
|
|
5085
|
-
if (idx2) {
|
|
5086
|
-
for (i = 0; i < n; i++) {
|
|
5087
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5088
|
-
x = m_log10(x);
|
|
5089
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5090
|
-
}
|
|
5091
|
-
} else {
|
|
5092
|
-
//
|
|
5093
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
5094
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
5095
|
-
//
|
|
5096
|
-
for (; i < n; i++) {
|
|
5097
|
-
((dtype*)p2)[i] = m_log10(((dtype*)p1)[i]);
|
|
5098
|
-
}
|
|
5099
|
-
//
|
|
5100
|
-
return;
|
|
5101
|
-
}
|
|
5102
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
5103
|
-
//
|
|
5104
|
-
for (i = 0; i < n; i++) {
|
|
5105
|
-
*(dtype*)p2 = m_log10(*(dtype*)p1);
|
|
5106
|
-
p1 += s1;
|
|
5107
|
-
p2 += s2;
|
|
5108
|
-
}
|
|
5109
|
-
return;
|
|
5110
|
-
//
|
|
5111
|
-
}
|
|
5112
|
-
}
|
|
5113
|
-
for (i = 0; i < n; i++) {
|
|
5114
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5115
|
-
x = m_log10(x);
|
|
5116
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5117
|
-
}
|
|
5118
|
-
//
|
|
5119
|
-
}
|
|
5120
|
-
}
|
|
5121
|
-
}
|
|
5122
|
-
|
|
5123
|
-
/*
|
|
5124
|
-
Calculate log10(x).
|
|
5125
|
-
@overload log10(x)
|
|
5126
|
-
@param [Numo::NArray,Numeric] x input value
|
|
5127
|
-
@return [Numo::SComplex] result of log10(x).
|
|
5128
|
-
*/
|
|
5129
|
-
static VALUE scomplex_math_s_log10(VALUE mod, VALUE a1) {
|
|
5130
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
5131
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
5132
|
-
ndfunc_t ndf = { iter_scomplex_math_s_log10, FULL_LOOP, 1, 1, ain, aout };
|
|
5133
|
-
|
|
5134
|
-
return na_ndloop(&ndf, 1, a1);
|
|
5135
|
-
}
|
|
5136
|
-
|
|
5137
|
-
static void iter_scomplex_math_s_exp(na_loop_t* const lp) {
|
|
5138
|
-
size_t i = 0, n;
|
|
5139
|
-
char *p1, *p2;
|
|
5140
|
-
ssize_t s1, s2;
|
|
5141
|
-
size_t *idx1, *idx2;
|
|
5142
|
-
dtype x;
|
|
5143
|
-
|
|
5144
|
-
INIT_COUNTER(lp, n);
|
|
5145
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
5146
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
5147
|
-
|
|
5148
|
-
if (idx1) {
|
|
5149
|
-
if (idx2) {
|
|
5150
|
-
for (i = 0; i < n; i++) {
|
|
5151
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5152
|
-
x = m_exp(x);
|
|
5153
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5154
|
-
}
|
|
5155
|
-
} else {
|
|
5156
|
-
for (i = 0; i < n; i++) {
|
|
5157
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5158
|
-
x = m_exp(x);
|
|
5159
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5160
|
-
}
|
|
5161
|
-
}
|
|
5162
|
-
} else {
|
|
5163
|
-
if (idx2) {
|
|
5164
|
-
for (i = 0; i < n; i++) {
|
|
5165
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5166
|
-
x = m_exp(x);
|
|
5167
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5168
|
-
}
|
|
5169
|
-
} else {
|
|
5170
|
-
//
|
|
5171
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
5172
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
5173
|
-
//
|
|
5174
|
-
for (; i < n; i++) {
|
|
5175
|
-
((dtype*)p2)[i] = m_exp(((dtype*)p1)[i]);
|
|
5176
|
-
}
|
|
5177
|
-
//
|
|
5178
|
-
return;
|
|
5179
|
-
}
|
|
5180
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
5181
|
-
//
|
|
5182
|
-
for (i = 0; i < n; i++) {
|
|
5183
|
-
*(dtype*)p2 = m_exp(*(dtype*)p1);
|
|
5184
|
-
p1 += s1;
|
|
5185
|
-
p2 += s2;
|
|
5186
|
-
}
|
|
5187
|
-
return;
|
|
5188
|
-
//
|
|
5189
|
-
}
|
|
5190
|
-
}
|
|
5191
|
-
for (i = 0; i < n; i++) {
|
|
5192
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5193
|
-
x = m_exp(x);
|
|
5194
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5195
|
-
}
|
|
5196
|
-
//
|
|
5197
|
-
}
|
|
5198
|
-
}
|
|
5199
|
-
}
|
|
5200
|
-
|
|
5201
|
-
/*
|
|
5202
|
-
Calculate exp(x).
|
|
5203
|
-
@overload exp(x)
|
|
5204
|
-
@param [Numo::NArray,Numeric] x input value
|
|
5205
|
-
@return [Numo::SComplex] result of exp(x).
|
|
5206
|
-
*/
|
|
5207
|
-
static VALUE scomplex_math_s_exp(VALUE mod, VALUE a1) {
|
|
5208
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
5209
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
5210
|
-
ndfunc_t ndf = { iter_scomplex_math_s_exp, FULL_LOOP, 1, 1, ain, aout };
|
|
5211
|
-
|
|
5212
|
-
return na_ndloop(&ndf, 1, a1);
|
|
5213
|
-
}
|
|
5214
|
-
|
|
5215
|
-
static void iter_scomplex_math_s_exp2(na_loop_t* const lp) {
|
|
5216
|
-
size_t i = 0, n;
|
|
5217
|
-
char *p1, *p2;
|
|
5218
|
-
ssize_t s1, s2;
|
|
5219
|
-
size_t *idx1, *idx2;
|
|
5220
|
-
dtype x;
|
|
5221
|
-
|
|
5222
|
-
INIT_COUNTER(lp, n);
|
|
5223
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
5224
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
5225
|
-
|
|
5226
|
-
if (idx1) {
|
|
5227
|
-
if (idx2) {
|
|
5228
|
-
for (i = 0; i < n; i++) {
|
|
5229
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5230
|
-
x = m_exp2(x);
|
|
5231
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5232
|
-
}
|
|
5233
|
-
} else {
|
|
5234
|
-
for (i = 0; i < n; i++) {
|
|
5235
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5236
|
-
x = m_exp2(x);
|
|
5237
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5238
|
-
}
|
|
5239
|
-
}
|
|
5240
|
-
} else {
|
|
5241
|
-
if (idx2) {
|
|
5242
|
-
for (i = 0; i < n; i++) {
|
|
5243
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5244
|
-
x = m_exp2(x);
|
|
5245
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5246
|
-
}
|
|
5247
|
-
} else {
|
|
5248
|
-
//
|
|
5249
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
5250
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
5251
|
-
//
|
|
5252
|
-
for (; i < n; i++) {
|
|
5253
|
-
((dtype*)p2)[i] = m_exp2(((dtype*)p1)[i]);
|
|
5254
|
-
}
|
|
5255
|
-
//
|
|
5256
|
-
return;
|
|
5257
|
-
}
|
|
5258
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
5259
|
-
//
|
|
5260
|
-
for (i = 0; i < n; i++) {
|
|
5261
|
-
*(dtype*)p2 = m_exp2(*(dtype*)p1);
|
|
5262
|
-
p1 += s1;
|
|
5263
|
-
p2 += s2;
|
|
5264
|
-
}
|
|
5265
|
-
return;
|
|
5266
|
-
//
|
|
5267
|
-
}
|
|
5268
|
-
}
|
|
5269
|
-
for (i = 0; i < n; i++) {
|
|
5270
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5271
|
-
x = m_exp2(x);
|
|
5272
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5273
|
-
}
|
|
5274
|
-
//
|
|
5275
|
-
}
|
|
5276
|
-
}
|
|
5277
|
-
}
|
|
5278
|
-
|
|
5279
|
-
/*
|
|
5280
|
-
Calculate exp2(x).
|
|
5281
|
-
@overload exp2(x)
|
|
5282
|
-
@param [Numo::NArray,Numeric] x input value
|
|
5283
|
-
@return [Numo::SComplex] result of exp2(x).
|
|
5284
|
-
*/
|
|
5285
|
-
static VALUE scomplex_math_s_exp2(VALUE mod, VALUE a1) {
|
|
5286
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
5287
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
5288
|
-
ndfunc_t ndf = { iter_scomplex_math_s_exp2, FULL_LOOP, 1, 1, ain, aout };
|
|
5289
|
-
|
|
5290
|
-
return na_ndloop(&ndf, 1, a1);
|
|
5291
|
-
}
|
|
5292
|
-
|
|
5293
|
-
static void iter_scomplex_math_s_exp10(na_loop_t* const lp) {
|
|
5294
|
-
size_t i = 0, n;
|
|
5295
|
-
char *p1, *p2;
|
|
5296
|
-
ssize_t s1, s2;
|
|
5297
|
-
size_t *idx1, *idx2;
|
|
5298
|
-
dtype x;
|
|
5299
|
-
|
|
5300
|
-
INIT_COUNTER(lp, n);
|
|
5301
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
5302
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
5303
|
-
|
|
5304
|
-
if (idx1) {
|
|
5305
|
-
if (idx2) {
|
|
5306
|
-
for (i = 0; i < n; i++) {
|
|
5307
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5308
|
-
x = m_exp10(x);
|
|
5309
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5310
|
-
}
|
|
5311
|
-
} else {
|
|
5312
|
-
for (i = 0; i < n; i++) {
|
|
5313
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5314
|
-
x = m_exp10(x);
|
|
5315
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5316
|
-
}
|
|
5317
|
-
}
|
|
5318
|
-
} else {
|
|
5319
|
-
if (idx2) {
|
|
5320
|
-
for (i = 0; i < n; i++) {
|
|
5321
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5322
|
-
x = m_exp10(x);
|
|
5323
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5324
|
-
}
|
|
5325
|
-
} else {
|
|
5326
|
-
//
|
|
5327
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
5328
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
5329
|
-
//
|
|
5330
|
-
for (; i < n; i++) {
|
|
5331
|
-
((dtype*)p2)[i] = m_exp10(((dtype*)p1)[i]);
|
|
5332
|
-
}
|
|
5333
|
-
//
|
|
5334
|
-
return;
|
|
5335
|
-
}
|
|
5336
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
5337
|
-
//
|
|
5338
|
-
for (i = 0; i < n; i++) {
|
|
5339
|
-
*(dtype*)p2 = m_exp10(*(dtype*)p1);
|
|
5340
|
-
p1 += s1;
|
|
5341
|
-
p2 += s2;
|
|
5342
|
-
}
|
|
5343
|
-
return;
|
|
5344
|
-
//
|
|
5345
|
-
}
|
|
5346
|
-
}
|
|
5347
|
-
for (i = 0; i < n; i++) {
|
|
5348
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5349
|
-
x = m_exp10(x);
|
|
5350
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5351
|
-
}
|
|
5352
|
-
//
|
|
5353
|
-
}
|
|
5354
|
-
}
|
|
5355
|
-
}
|
|
5356
|
-
|
|
5357
|
-
/*
|
|
5358
|
-
Calculate exp10(x).
|
|
5359
|
-
@overload exp10(x)
|
|
5360
|
-
@param [Numo::NArray,Numeric] x input value
|
|
5361
|
-
@return [Numo::SComplex] result of exp10(x).
|
|
5362
|
-
*/
|
|
5363
|
-
static VALUE scomplex_math_s_exp10(VALUE mod, VALUE a1) {
|
|
5364
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
5365
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
5366
|
-
ndfunc_t ndf = { iter_scomplex_math_s_exp10, FULL_LOOP, 1, 1, ain, aout };
|
|
5367
|
-
|
|
5368
|
-
return na_ndloop(&ndf, 1, a1);
|
|
5369
|
-
}
|
|
5370
|
-
|
|
5371
|
-
static void iter_scomplex_math_s_sin(na_loop_t* const lp) {
|
|
5372
|
-
size_t i = 0, n;
|
|
5373
|
-
char *p1, *p2;
|
|
5374
|
-
ssize_t s1, s2;
|
|
5375
|
-
size_t *idx1, *idx2;
|
|
5376
|
-
dtype x;
|
|
5377
|
-
|
|
5378
|
-
INIT_COUNTER(lp, n);
|
|
5379
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
5380
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
5381
|
-
|
|
5382
|
-
if (idx1) {
|
|
5383
|
-
if (idx2) {
|
|
5384
|
-
for (i = 0; i < n; i++) {
|
|
5385
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5386
|
-
x = m_sin(x);
|
|
5387
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5388
|
-
}
|
|
5389
|
-
} else {
|
|
5390
|
-
for (i = 0; i < n; i++) {
|
|
5391
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5392
|
-
x = m_sin(x);
|
|
5393
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5394
|
-
}
|
|
5395
|
-
}
|
|
5396
|
-
} else {
|
|
5397
|
-
if (idx2) {
|
|
5398
|
-
for (i = 0; i < n; i++) {
|
|
5399
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5400
|
-
x = m_sin(x);
|
|
5401
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5402
|
-
}
|
|
5403
|
-
} else {
|
|
5404
|
-
//
|
|
5405
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
5406
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
5407
|
-
//
|
|
5408
|
-
for (; i < n; i++) {
|
|
5409
|
-
((dtype*)p2)[i] = m_sin(((dtype*)p1)[i]);
|
|
5410
|
-
}
|
|
5411
|
-
//
|
|
5412
|
-
return;
|
|
5413
|
-
}
|
|
5414
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
5415
|
-
//
|
|
5416
|
-
for (i = 0; i < n; i++) {
|
|
5417
|
-
*(dtype*)p2 = m_sin(*(dtype*)p1);
|
|
5418
|
-
p1 += s1;
|
|
5419
|
-
p2 += s2;
|
|
5420
|
-
}
|
|
5421
|
-
return;
|
|
5422
|
-
//
|
|
5423
|
-
}
|
|
5424
|
-
}
|
|
5425
|
-
for (i = 0; i < n; i++) {
|
|
5426
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5427
|
-
x = m_sin(x);
|
|
5428
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5429
|
-
}
|
|
5430
|
-
//
|
|
5431
|
-
}
|
|
5432
|
-
}
|
|
5433
|
-
}
|
|
5434
|
-
|
|
5435
|
-
/*
|
|
5436
|
-
Calculate sin(x).
|
|
5437
|
-
@overload sin(x)
|
|
5438
|
-
@param [Numo::NArray,Numeric] x input value
|
|
5439
|
-
@return [Numo::SComplex] result of sin(x).
|
|
5440
|
-
*/
|
|
5441
|
-
static VALUE scomplex_math_s_sin(VALUE mod, VALUE a1) {
|
|
5442
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
5443
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
5444
|
-
ndfunc_t ndf = { iter_scomplex_math_s_sin, FULL_LOOP, 1, 1, ain, aout };
|
|
5445
|
-
|
|
5446
|
-
return na_ndloop(&ndf, 1, a1);
|
|
5447
|
-
}
|
|
5448
|
-
|
|
5449
|
-
static void iter_scomplex_math_s_cos(na_loop_t* const lp) {
|
|
5450
|
-
size_t i = 0, n;
|
|
5451
|
-
char *p1, *p2;
|
|
5452
|
-
ssize_t s1, s2;
|
|
5453
|
-
size_t *idx1, *idx2;
|
|
5454
|
-
dtype x;
|
|
5455
|
-
|
|
5456
|
-
INIT_COUNTER(lp, n);
|
|
5457
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
5458
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
5459
|
-
|
|
5460
|
-
if (idx1) {
|
|
5461
|
-
if (idx2) {
|
|
5462
|
-
for (i = 0; i < n; i++) {
|
|
5463
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5464
|
-
x = m_cos(x);
|
|
5465
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5466
|
-
}
|
|
5467
|
-
} else {
|
|
5468
|
-
for (i = 0; i < n; i++) {
|
|
5469
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5470
|
-
x = m_cos(x);
|
|
5471
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5472
|
-
}
|
|
5473
|
-
}
|
|
5474
|
-
} else {
|
|
5475
|
-
if (idx2) {
|
|
5476
|
-
for (i = 0; i < n; i++) {
|
|
5477
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5478
|
-
x = m_cos(x);
|
|
5479
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5480
|
-
}
|
|
5481
|
-
} else {
|
|
5482
|
-
//
|
|
5483
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
5484
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
5485
|
-
//
|
|
5486
|
-
for (; i < n; i++) {
|
|
5487
|
-
((dtype*)p2)[i] = m_cos(((dtype*)p1)[i]);
|
|
5488
|
-
}
|
|
5489
|
-
//
|
|
5490
|
-
return;
|
|
5491
|
-
}
|
|
5492
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
5493
|
-
//
|
|
5494
|
-
for (i = 0; i < n; i++) {
|
|
5495
|
-
*(dtype*)p2 = m_cos(*(dtype*)p1);
|
|
5496
|
-
p1 += s1;
|
|
5497
|
-
p2 += s2;
|
|
5498
|
-
}
|
|
5499
|
-
return;
|
|
5500
|
-
//
|
|
5501
|
-
}
|
|
5502
|
-
}
|
|
5503
|
-
for (i = 0; i < n; i++) {
|
|
5504
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5505
|
-
x = m_cos(x);
|
|
5506
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5507
|
-
}
|
|
5508
|
-
//
|
|
5509
|
-
}
|
|
5510
|
-
}
|
|
5511
|
-
}
|
|
5512
|
-
|
|
5513
|
-
/*
|
|
5514
|
-
Calculate cos(x).
|
|
5515
|
-
@overload cos(x)
|
|
5516
|
-
@param [Numo::NArray,Numeric] x input value
|
|
5517
|
-
@return [Numo::SComplex] result of cos(x).
|
|
5518
|
-
*/
|
|
5519
|
-
static VALUE scomplex_math_s_cos(VALUE mod, VALUE a1) {
|
|
5520
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
5521
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
5522
|
-
ndfunc_t ndf = { iter_scomplex_math_s_cos, FULL_LOOP, 1, 1, ain, aout };
|
|
5523
|
-
|
|
5524
|
-
return na_ndloop(&ndf, 1, a1);
|
|
5525
|
-
}
|
|
5526
|
-
|
|
5527
|
-
static void iter_scomplex_math_s_tan(na_loop_t* const lp) {
|
|
5528
|
-
size_t i = 0, n;
|
|
5529
|
-
char *p1, *p2;
|
|
5530
|
-
ssize_t s1, s2;
|
|
5531
|
-
size_t *idx1, *idx2;
|
|
5532
|
-
dtype x;
|
|
5533
|
-
|
|
5534
|
-
INIT_COUNTER(lp, n);
|
|
5535
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
5536
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
5537
|
-
|
|
5538
|
-
if (idx1) {
|
|
5539
|
-
if (idx2) {
|
|
5540
|
-
for (i = 0; i < n; i++) {
|
|
5541
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5542
|
-
x = m_tan(x);
|
|
5543
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5544
|
-
}
|
|
5545
|
-
} else {
|
|
5546
|
-
for (i = 0; i < n; i++) {
|
|
5547
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5548
|
-
x = m_tan(x);
|
|
5549
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5550
|
-
}
|
|
5551
|
-
}
|
|
5552
|
-
} else {
|
|
5553
|
-
if (idx2) {
|
|
5554
|
-
for (i = 0; i < n; i++) {
|
|
5555
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5556
|
-
x = m_tan(x);
|
|
5557
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5558
|
-
}
|
|
5559
|
-
} else {
|
|
5560
|
-
//
|
|
5561
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
5562
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
5563
|
-
//
|
|
5564
|
-
for (; i < n; i++) {
|
|
5565
|
-
((dtype*)p2)[i] = m_tan(((dtype*)p1)[i]);
|
|
5566
|
-
}
|
|
5567
|
-
//
|
|
5568
|
-
return;
|
|
5569
|
-
}
|
|
5570
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
5571
|
-
//
|
|
5572
|
-
for (i = 0; i < n; i++) {
|
|
5573
|
-
*(dtype*)p2 = m_tan(*(dtype*)p1);
|
|
5574
|
-
p1 += s1;
|
|
5575
|
-
p2 += s2;
|
|
5576
|
-
}
|
|
5577
|
-
return;
|
|
5578
|
-
//
|
|
5579
|
-
}
|
|
5580
|
-
}
|
|
5581
|
-
for (i = 0; i < n; i++) {
|
|
5582
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5583
|
-
x = m_tan(x);
|
|
5584
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5585
|
-
}
|
|
5586
|
-
//
|
|
5587
|
-
}
|
|
5588
|
-
}
|
|
5589
|
-
}
|
|
5590
|
-
|
|
5591
|
-
/*
|
|
5592
|
-
Calculate tan(x).
|
|
5593
|
-
@overload tan(x)
|
|
5594
|
-
@param [Numo::NArray,Numeric] x input value
|
|
5595
|
-
@return [Numo::SComplex] result of tan(x).
|
|
5596
|
-
*/
|
|
5597
|
-
static VALUE scomplex_math_s_tan(VALUE mod, VALUE a1) {
|
|
5598
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
5599
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
5600
|
-
ndfunc_t ndf = { iter_scomplex_math_s_tan, FULL_LOOP, 1, 1, ain, aout };
|
|
5601
|
-
|
|
5602
|
-
return na_ndloop(&ndf, 1, a1);
|
|
5603
|
-
}
|
|
5604
|
-
|
|
5605
|
-
static void iter_scomplex_math_s_asin(na_loop_t* const lp) {
|
|
5606
|
-
size_t i = 0, n;
|
|
5607
|
-
char *p1, *p2;
|
|
5608
|
-
ssize_t s1, s2;
|
|
5609
|
-
size_t *idx1, *idx2;
|
|
5610
|
-
dtype x;
|
|
5611
|
-
|
|
5612
|
-
INIT_COUNTER(lp, n);
|
|
5613
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
5614
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
5615
|
-
|
|
5616
|
-
if (idx1) {
|
|
5617
|
-
if (idx2) {
|
|
5618
|
-
for (i = 0; i < n; i++) {
|
|
5619
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5620
|
-
x = m_asin(x);
|
|
5621
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5622
|
-
}
|
|
5623
|
-
} else {
|
|
5624
|
-
for (i = 0; i < n; i++) {
|
|
5625
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5626
|
-
x = m_asin(x);
|
|
5627
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5628
|
-
}
|
|
5629
|
-
}
|
|
5630
|
-
} else {
|
|
5631
|
-
if (idx2) {
|
|
5632
|
-
for (i = 0; i < n; i++) {
|
|
5633
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5634
|
-
x = m_asin(x);
|
|
5635
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5636
|
-
}
|
|
5637
|
-
} else {
|
|
5638
|
-
//
|
|
5639
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
5640
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
5641
|
-
//
|
|
5642
|
-
for (; i < n; i++) {
|
|
5643
|
-
((dtype*)p2)[i] = m_asin(((dtype*)p1)[i]);
|
|
5644
|
-
}
|
|
5645
|
-
//
|
|
5646
|
-
return;
|
|
5647
|
-
}
|
|
5648
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
5649
|
-
//
|
|
5650
|
-
for (i = 0; i < n; i++) {
|
|
5651
|
-
*(dtype*)p2 = m_asin(*(dtype*)p1);
|
|
5652
|
-
p1 += s1;
|
|
5653
|
-
p2 += s2;
|
|
5654
|
-
}
|
|
5655
|
-
return;
|
|
5656
|
-
//
|
|
5657
|
-
}
|
|
5658
|
-
}
|
|
5659
|
-
for (i = 0; i < n; i++) {
|
|
5660
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5661
|
-
x = m_asin(x);
|
|
5662
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5663
|
-
}
|
|
5664
|
-
//
|
|
5665
|
-
}
|
|
5666
|
-
}
|
|
5667
|
-
}
|
|
5668
|
-
|
|
5669
|
-
/*
|
|
5670
|
-
Calculate asin(x).
|
|
5671
|
-
@overload asin(x)
|
|
5672
|
-
@param [Numo::NArray,Numeric] x input value
|
|
5673
|
-
@return [Numo::SComplex] result of asin(x).
|
|
5674
|
-
*/
|
|
5675
|
-
static VALUE scomplex_math_s_asin(VALUE mod, VALUE a1) {
|
|
5676
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
5677
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
5678
|
-
ndfunc_t ndf = { iter_scomplex_math_s_asin, FULL_LOOP, 1, 1, ain, aout };
|
|
5679
|
-
|
|
5680
|
-
return na_ndloop(&ndf, 1, a1);
|
|
5681
|
-
}
|
|
5682
|
-
|
|
5683
|
-
static void iter_scomplex_math_s_acos(na_loop_t* const lp) {
|
|
5684
|
-
size_t i = 0, n;
|
|
5685
|
-
char *p1, *p2;
|
|
5686
|
-
ssize_t s1, s2;
|
|
5687
|
-
size_t *idx1, *idx2;
|
|
5688
|
-
dtype x;
|
|
5689
|
-
|
|
5690
|
-
INIT_COUNTER(lp, n);
|
|
5691
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
5692
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
5693
|
-
|
|
5694
|
-
if (idx1) {
|
|
5695
|
-
if (idx2) {
|
|
5696
|
-
for (i = 0; i < n; i++) {
|
|
5697
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5698
|
-
x = m_acos(x);
|
|
5699
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5700
|
-
}
|
|
5701
|
-
} else {
|
|
5702
|
-
for (i = 0; i < n; i++) {
|
|
5703
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5704
|
-
x = m_acos(x);
|
|
5705
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5706
|
-
}
|
|
5707
|
-
}
|
|
5708
|
-
} else {
|
|
5709
|
-
if (idx2) {
|
|
5710
|
-
for (i = 0; i < n; i++) {
|
|
5711
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5712
|
-
x = m_acos(x);
|
|
5713
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5714
|
-
}
|
|
5715
|
-
} else {
|
|
5716
|
-
//
|
|
5717
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
5718
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
5719
|
-
//
|
|
5720
|
-
for (; i < n; i++) {
|
|
5721
|
-
((dtype*)p2)[i] = m_acos(((dtype*)p1)[i]);
|
|
5722
|
-
}
|
|
5723
|
-
//
|
|
5724
|
-
return;
|
|
5725
|
-
}
|
|
5726
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
5727
|
-
//
|
|
5728
|
-
for (i = 0; i < n; i++) {
|
|
5729
|
-
*(dtype*)p2 = m_acos(*(dtype*)p1);
|
|
5730
|
-
p1 += s1;
|
|
5731
|
-
p2 += s2;
|
|
5732
|
-
}
|
|
5733
|
-
return;
|
|
5734
|
-
//
|
|
5735
|
-
}
|
|
5736
|
-
}
|
|
5737
|
-
for (i = 0; i < n; i++) {
|
|
5738
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5739
|
-
x = m_acos(x);
|
|
5740
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5741
|
-
}
|
|
5742
|
-
//
|
|
5743
|
-
}
|
|
5744
|
-
}
|
|
5745
|
-
}
|
|
5746
|
-
|
|
5747
|
-
/*
|
|
5748
|
-
Calculate acos(x).
|
|
5749
|
-
@overload acos(x)
|
|
5750
|
-
@param [Numo::NArray,Numeric] x input value
|
|
5751
|
-
@return [Numo::SComplex] result of acos(x).
|
|
5752
|
-
*/
|
|
5753
|
-
static VALUE scomplex_math_s_acos(VALUE mod, VALUE a1) {
|
|
5754
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
5755
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
5756
|
-
ndfunc_t ndf = { iter_scomplex_math_s_acos, FULL_LOOP, 1, 1, ain, aout };
|
|
5757
|
-
|
|
5758
|
-
return na_ndloop(&ndf, 1, a1);
|
|
5759
|
-
}
|
|
5760
|
-
|
|
5761
|
-
static void iter_scomplex_math_s_atan(na_loop_t* const lp) {
|
|
5762
|
-
size_t i = 0, n;
|
|
5763
|
-
char *p1, *p2;
|
|
5764
|
-
ssize_t s1, s2;
|
|
5765
|
-
size_t *idx1, *idx2;
|
|
5766
|
-
dtype x;
|
|
5767
|
-
|
|
5768
|
-
INIT_COUNTER(lp, n);
|
|
5769
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
5770
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
5771
|
-
|
|
5772
|
-
if (idx1) {
|
|
5773
|
-
if (idx2) {
|
|
5774
|
-
for (i = 0; i < n; i++) {
|
|
5775
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5776
|
-
x = m_atan(x);
|
|
5777
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5778
|
-
}
|
|
5779
|
-
} else {
|
|
5780
|
-
for (i = 0; i < n; i++) {
|
|
5781
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5782
|
-
x = m_atan(x);
|
|
5783
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5784
|
-
}
|
|
5785
|
-
}
|
|
5786
|
-
} else {
|
|
5787
|
-
if (idx2) {
|
|
5788
|
-
for (i = 0; i < n; i++) {
|
|
5789
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5790
|
-
x = m_atan(x);
|
|
5791
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5792
|
-
}
|
|
5793
|
-
} else {
|
|
5794
|
-
//
|
|
5795
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
5796
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
5797
|
-
//
|
|
5798
|
-
for (; i < n; i++) {
|
|
5799
|
-
((dtype*)p2)[i] = m_atan(((dtype*)p1)[i]);
|
|
5800
|
-
}
|
|
5801
|
-
//
|
|
5802
|
-
return;
|
|
5803
|
-
}
|
|
5804
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
5805
|
-
//
|
|
5806
|
-
for (i = 0; i < n; i++) {
|
|
5807
|
-
*(dtype*)p2 = m_atan(*(dtype*)p1);
|
|
5808
|
-
p1 += s1;
|
|
5809
|
-
p2 += s2;
|
|
5810
|
-
}
|
|
5811
|
-
return;
|
|
5812
|
-
//
|
|
5813
|
-
}
|
|
5814
|
-
}
|
|
5815
|
-
for (i = 0; i < n; i++) {
|
|
5816
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5817
|
-
x = m_atan(x);
|
|
5818
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5819
|
-
}
|
|
5820
|
-
//
|
|
5821
|
-
}
|
|
5822
|
-
}
|
|
5823
|
-
}
|
|
5824
|
-
|
|
5825
|
-
/*
|
|
5826
|
-
Calculate atan(x).
|
|
5827
|
-
@overload atan(x)
|
|
5828
|
-
@param [Numo::NArray,Numeric] x input value
|
|
5829
|
-
@return [Numo::SComplex] result of atan(x).
|
|
5830
|
-
*/
|
|
5831
|
-
static VALUE scomplex_math_s_atan(VALUE mod, VALUE a1) {
|
|
5832
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
5833
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
5834
|
-
ndfunc_t ndf = { iter_scomplex_math_s_atan, FULL_LOOP, 1, 1, ain, aout };
|
|
5835
|
-
|
|
5836
|
-
return na_ndloop(&ndf, 1, a1);
|
|
5837
|
-
}
|
|
5838
|
-
|
|
5839
|
-
static void iter_scomplex_math_s_sinh(na_loop_t* const lp) {
|
|
5840
|
-
size_t i = 0, n;
|
|
5841
|
-
char *p1, *p2;
|
|
5842
|
-
ssize_t s1, s2;
|
|
5843
|
-
size_t *idx1, *idx2;
|
|
5844
|
-
dtype x;
|
|
5845
|
-
|
|
5846
|
-
INIT_COUNTER(lp, n);
|
|
5847
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
5848
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
5849
|
-
|
|
5850
|
-
if (idx1) {
|
|
5851
|
-
if (idx2) {
|
|
5852
|
-
for (i = 0; i < n; i++) {
|
|
5853
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5854
|
-
x = m_sinh(x);
|
|
5855
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5856
|
-
}
|
|
5857
|
-
} else {
|
|
5858
|
-
for (i = 0; i < n; i++) {
|
|
5859
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5860
|
-
x = m_sinh(x);
|
|
5861
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5862
|
-
}
|
|
5863
|
-
}
|
|
5864
|
-
} else {
|
|
5865
|
-
if (idx2) {
|
|
5866
|
-
for (i = 0; i < n; i++) {
|
|
5867
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5868
|
-
x = m_sinh(x);
|
|
5869
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5870
|
-
}
|
|
5871
|
-
} else {
|
|
5872
|
-
//
|
|
5873
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
5874
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
5875
|
-
//
|
|
5876
|
-
for (; i < n; i++) {
|
|
5877
|
-
((dtype*)p2)[i] = m_sinh(((dtype*)p1)[i]);
|
|
5878
|
-
}
|
|
5879
|
-
//
|
|
5880
|
-
return;
|
|
5881
|
-
}
|
|
5882
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
5883
|
-
//
|
|
5884
|
-
for (i = 0; i < n; i++) {
|
|
5885
|
-
*(dtype*)p2 = m_sinh(*(dtype*)p1);
|
|
5886
|
-
p1 += s1;
|
|
5887
|
-
p2 += s2;
|
|
5888
|
-
}
|
|
5889
|
-
return;
|
|
5890
|
-
//
|
|
5891
|
-
}
|
|
5892
|
-
}
|
|
5893
|
-
for (i = 0; i < n; i++) {
|
|
5894
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5895
|
-
x = m_sinh(x);
|
|
5896
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5897
|
-
}
|
|
5898
|
-
//
|
|
5899
|
-
}
|
|
5900
|
-
}
|
|
5901
|
-
}
|
|
5902
|
-
|
|
5903
|
-
/*
|
|
5904
|
-
Calculate sinh(x).
|
|
5905
|
-
@overload sinh(x)
|
|
5906
|
-
@param [Numo::NArray,Numeric] x input value
|
|
5907
|
-
@return [Numo::SComplex] result of sinh(x).
|
|
5908
|
-
*/
|
|
5909
|
-
static VALUE scomplex_math_s_sinh(VALUE mod, VALUE a1) {
|
|
5910
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
5911
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
5912
|
-
ndfunc_t ndf = { iter_scomplex_math_s_sinh, FULL_LOOP, 1, 1, ain, aout };
|
|
5913
|
-
|
|
5914
|
-
return na_ndloop(&ndf, 1, a1);
|
|
5915
|
-
}
|
|
5916
|
-
|
|
5917
|
-
static void iter_scomplex_math_s_cosh(na_loop_t* const lp) {
|
|
5918
|
-
size_t i = 0, n;
|
|
5919
|
-
char *p1, *p2;
|
|
5920
|
-
ssize_t s1, s2;
|
|
5921
|
-
size_t *idx1, *idx2;
|
|
5922
|
-
dtype x;
|
|
5923
|
-
|
|
5924
|
-
INIT_COUNTER(lp, n);
|
|
5925
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
5926
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
5927
|
-
|
|
5928
|
-
if (idx1) {
|
|
5929
|
-
if (idx2) {
|
|
5930
|
-
for (i = 0; i < n; i++) {
|
|
5931
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5932
|
-
x = m_cosh(x);
|
|
5933
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5934
|
-
}
|
|
5935
|
-
} else {
|
|
5936
|
-
for (i = 0; i < n; i++) {
|
|
5937
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
5938
|
-
x = m_cosh(x);
|
|
5939
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5940
|
-
}
|
|
5941
|
-
}
|
|
5942
|
-
} else {
|
|
5943
|
-
if (idx2) {
|
|
5944
|
-
for (i = 0; i < n; i++) {
|
|
5945
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5946
|
-
x = m_cosh(x);
|
|
5947
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
5948
|
-
}
|
|
5949
|
-
} else {
|
|
5950
|
-
//
|
|
5951
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
5952
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
5953
|
-
//
|
|
5954
|
-
for (; i < n; i++) {
|
|
5955
|
-
((dtype*)p2)[i] = m_cosh(((dtype*)p1)[i]);
|
|
5956
|
-
}
|
|
5957
|
-
//
|
|
5958
|
-
return;
|
|
5959
|
-
}
|
|
5960
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
5961
|
-
//
|
|
5962
|
-
for (i = 0; i < n; i++) {
|
|
5963
|
-
*(dtype*)p2 = m_cosh(*(dtype*)p1);
|
|
5964
|
-
p1 += s1;
|
|
5965
|
-
p2 += s2;
|
|
5966
|
-
}
|
|
5967
|
-
return;
|
|
5968
|
-
//
|
|
5969
|
-
}
|
|
5970
|
-
}
|
|
5971
|
-
for (i = 0; i < n; i++) {
|
|
5972
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
5973
|
-
x = m_cosh(x);
|
|
5974
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
5975
|
-
}
|
|
5976
|
-
//
|
|
5977
|
-
}
|
|
5978
|
-
}
|
|
5979
|
-
}
|
|
5980
|
-
|
|
5981
|
-
/*
|
|
5982
|
-
Calculate cosh(x).
|
|
5983
|
-
@overload cosh(x)
|
|
5984
|
-
@param [Numo::NArray,Numeric] x input value
|
|
5985
|
-
@return [Numo::SComplex] result of cosh(x).
|
|
5986
|
-
*/
|
|
5987
|
-
static VALUE scomplex_math_s_cosh(VALUE mod, VALUE a1) {
|
|
5988
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
5989
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
5990
|
-
ndfunc_t ndf = { iter_scomplex_math_s_cosh, FULL_LOOP, 1, 1, ain, aout };
|
|
5991
|
-
|
|
5992
|
-
return na_ndloop(&ndf, 1, a1);
|
|
5993
|
-
}
|
|
5994
|
-
|
|
5995
|
-
static void iter_scomplex_math_s_tanh(na_loop_t* const lp) {
|
|
5996
|
-
size_t i = 0, n;
|
|
5997
|
-
char *p1, *p2;
|
|
5998
|
-
ssize_t s1, s2;
|
|
5999
|
-
size_t *idx1, *idx2;
|
|
6000
|
-
dtype x;
|
|
6001
|
-
|
|
6002
|
-
INIT_COUNTER(lp, n);
|
|
6003
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
6004
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
6005
|
-
|
|
6006
|
-
if (idx1) {
|
|
6007
|
-
if (idx2) {
|
|
6008
|
-
for (i = 0; i < n; i++) {
|
|
6009
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
6010
|
-
x = m_tanh(x);
|
|
6011
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
6012
|
-
}
|
|
6013
|
-
} else {
|
|
6014
|
-
for (i = 0; i < n; i++) {
|
|
6015
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
6016
|
-
x = m_tanh(x);
|
|
6017
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
6018
|
-
}
|
|
6019
|
-
}
|
|
6020
|
-
} else {
|
|
6021
|
-
if (idx2) {
|
|
6022
|
-
for (i = 0; i < n; i++) {
|
|
6023
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
6024
|
-
x = m_tanh(x);
|
|
6025
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
6026
|
-
}
|
|
6027
|
-
} else {
|
|
6028
|
-
//
|
|
6029
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
6030
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
6031
|
-
//
|
|
6032
|
-
for (; i < n; i++) {
|
|
6033
|
-
((dtype*)p2)[i] = m_tanh(((dtype*)p1)[i]);
|
|
6034
|
-
}
|
|
6035
|
-
//
|
|
6036
|
-
return;
|
|
6037
|
-
}
|
|
6038
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
6039
|
-
//
|
|
6040
|
-
for (i = 0; i < n; i++) {
|
|
6041
|
-
*(dtype*)p2 = m_tanh(*(dtype*)p1);
|
|
6042
|
-
p1 += s1;
|
|
6043
|
-
p2 += s2;
|
|
6044
|
-
}
|
|
6045
|
-
return;
|
|
6046
|
-
//
|
|
6047
|
-
}
|
|
6048
|
-
}
|
|
6049
|
-
for (i = 0; i < n; i++) {
|
|
6050
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
6051
|
-
x = m_tanh(x);
|
|
6052
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
6053
|
-
}
|
|
6054
|
-
//
|
|
6055
|
-
}
|
|
6056
|
-
}
|
|
6057
|
-
}
|
|
6058
|
-
|
|
6059
|
-
/*
|
|
6060
|
-
Calculate tanh(x).
|
|
6061
|
-
@overload tanh(x)
|
|
6062
|
-
@param [Numo::NArray,Numeric] x input value
|
|
6063
|
-
@return [Numo::SComplex] result of tanh(x).
|
|
6064
|
-
*/
|
|
6065
|
-
static VALUE scomplex_math_s_tanh(VALUE mod, VALUE a1) {
|
|
6066
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
6067
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
6068
|
-
ndfunc_t ndf = { iter_scomplex_math_s_tanh, FULL_LOOP, 1, 1, ain, aout };
|
|
6069
|
-
|
|
6070
|
-
return na_ndloop(&ndf, 1, a1);
|
|
6071
|
-
}
|
|
6072
|
-
|
|
6073
|
-
static void iter_scomplex_math_s_asinh(na_loop_t* const lp) {
|
|
6074
|
-
size_t i = 0, n;
|
|
6075
|
-
char *p1, *p2;
|
|
6076
|
-
ssize_t s1, s2;
|
|
6077
|
-
size_t *idx1, *idx2;
|
|
6078
|
-
dtype x;
|
|
6079
|
-
|
|
6080
|
-
INIT_COUNTER(lp, n);
|
|
6081
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
6082
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
6083
|
-
|
|
6084
|
-
if (idx1) {
|
|
6085
|
-
if (idx2) {
|
|
6086
|
-
for (i = 0; i < n; i++) {
|
|
6087
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
6088
|
-
x = m_asinh(x);
|
|
6089
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
6090
|
-
}
|
|
6091
|
-
} else {
|
|
6092
|
-
for (i = 0; i < n; i++) {
|
|
6093
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
6094
|
-
x = m_asinh(x);
|
|
6095
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
6096
|
-
}
|
|
6097
|
-
}
|
|
6098
|
-
} else {
|
|
6099
|
-
if (idx2) {
|
|
6100
|
-
for (i = 0; i < n; i++) {
|
|
6101
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
6102
|
-
x = m_asinh(x);
|
|
6103
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
6104
|
-
}
|
|
6105
|
-
} else {
|
|
6106
|
-
//
|
|
6107
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
6108
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
6109
|
-
//
|
|
6110
|
-
for (; i < n; i++) {
|
|
6111
|
-
((dtype*)p2)[i] = m_asinh(((dtype*)p1)[i]);
|
|
6112
|
-
}
|
|
6113
|
-
//
|
|
6114
|
-
return;
|
|
6115
|
-
}
|
|
6116
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
6117
|
-
//
|
|
6118
|
-
for (i = 0; i < n; i++) {
|
|
6119
|
-
*(dtype*)p2 = m_asinh(*(dtype*)p1);
|
|
6120
|
-
p1 += s1;
|
|
6121
|
-
p2 += s2;
|
|
6122
|
-
}
|
|
6123
|
-
return;
|
|
6124
|
-
//
|
|
6125
|
-
}
|
|
6126
|
-
}
|
|
6127
|
-
for (i = 0; i < n; i++) {
|
|
6128
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
6129
|
-
x = m_asinh(x);
|
|
6130
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
6131
|
-
}
|
|
6132
|
-
//
|
|
6133
|
-
}
|
|
6134
|
-
}
|
|
6135
|
-
}
|
|
6136
|
-
|
|
6137
|
-
/*
|
|
6138
|
-
Calculate asinh(x).
|
|
6139
|
-
@overload asinh(x)
|
|
6140
|
-
@param [Numo::NArray,Numeric] x input value
|
|
6141
|
-
@return [Numo::SComplex] result of asinh(x).
|
|
6142
|
-
*/
|
|
6143
|
-
static VALUE scomplex_math_s_asinh(VALUE mod, VALUE a1) {
|
|
6144
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
6145
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
6146
|
-
ndfunc_t ndf = { iter_scomplex_math_s_asinh, FULL_LOOP, 1, 1, ain, aout };
|
|
6147
|
-
|
|
6148
|
-
return na_ndloop(&ndf, 1, a1);
|
|
6149
|
-
}
|
|
6150
|
-
|
|
6151
|
-
static void iter_scomplex_math_s_acosh(na_loop_t* const lp) {
|
|
6152
|
-
size_t i = 0, n;
|
|
6153
|
-
char *p1, *p2;
|
|
6154
|
-
ssize_t s1, s2;
|
|
6155
|
-
size_t *idx1, *idx2;
|
|
6156
|
-
dtype x;
|
|
6157
|
-
|
|
6158
|
-
INIT_COUNTER(lp, n);
|
|
6159
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
6160
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
6161
|
-
|
|
6162
|
-
if (idx1) {
|
|
6163
|
-
if (idx2) {
|
|
6164
|
-
for (i = 0; i < n; i++) {
|
|
6165
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
6166
|
-
x = m_acosh(x);
|
|
6167
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
6168
|
-
}
|
|
6169
|
-
} else {
|
|
6170
|
-
for (i = 0; i < n; i++) {
|
|
6171
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
6172
|
-
x = m_acosh(x);
|
|
6173
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
6174
|
-
}
|
|
6175
|
-
}
|
|
6176
|
-
} else {
|
|
6177
|
-
if (idx2) {
|
|
6178
|
-
for (i = 0; i < n; i++) {
|
|
6179
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
6180
|
-
x = m_acosh(x);
|
|
6181
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
6182
|
-
}
|
|
6183
|
-
} else {
|
|
6184
|
-
//
|
|
6185
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
6186
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
6187
|
-
//
|
|
6188
|
-
for (; i < n; i++) {
|
|
6189
|
-
((dtype*)p2)[i] = m_acosh(((dtype*)p1)[i]);
|
|
6190
|
-
}
|
|
6191
|
-
//
|
|
6192
|
-
return;
|
|
6193
|
-
}
|
|
6194
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
6195
|
-
//
|
|
6196
|
-
for (i = 0; i < n; i++) {
|
|
6197
|
-
*(dtype*)p2 = m_acosh(*(dtype*)p1);
|
|
6198
|
-
p1 += s1;
|
|
6199
|
-
p2 += s2;
|
|
6200
|
-
}
|
|
6201
|
-
return;
|
|
6202
|
-
//
|
|
6203
|
-
}
|
|
6204
|
-
}
|
|
6205
|
-
for (i = 0; i < n; i++) {
|
|
6206
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
6207
|
-
x = m_acosh(x);
|
|
6208
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
6209
|
-
}
|
|
6210
|
-
//
|
|
6211
|
-
}
|
|
6212
|
-
}
|
|
6213
|
-
}
|
|
6214
|
-
|
|
6215
|
-
/*
|
|
6216
|
-
Calculate acosh(x).
|
|
6217
|
-
@overload acosh(x)
|
|
6218
|
-
@param [Numo::NArray,Numeric] x input value
|
|
6219
|
-
@return [Numo::SComplex] result of acosh(x).
|
|
6220
|
-
*/
|
|
6221
|
-
static VALUE scomplex_math_s_acosh(VALUE mod, VALUE a1) {
|
|
6222
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
6223
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
6224
|
-
ndfunc_t ndf = { iter_scomplex_math_s_acosh, FULL_LOOP, 1, 1, ain, aout };
|
|
6225
|
-
|
|
6226
|
-
return na_ndloop(&ndf, 1, a1);
|
|
6227
|
-
}
|
|
6228
|
-
|
|
6229
|
-
static void iter_scomplex_math_s_atanh(na_loop_t* const lp) {
|
|
6230
|
-
size_t i = 0, n;
|
|
6231
|
-
char *p1, *p2;
|
|
6232
|
-
ssize_t s1, s2;
|
|
6233
|
-
size_t *idx1, *idx2;
|
|
6234
|
-
dtype x;
|
|
6235
|
-
|
|
6236
|
-
INIT_COUNTER(lp, n);
|
|
6237
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
6238
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
6239
|
-
|
|
6240
|
-
if (idx1) {
|
|
6241
|
-
if (idx2) {
|
|
6242
|
-
for (i = 0; i < n; i++) {
|
|
6243
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
6244
|
-
x = m_atanh(x);
|
|
6245
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
6246
|
-
}
|
|
6247
|
-
} else {
|
|
6248
|
-
for (i = 0; i < n; i++) {
|
|
6249
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
6250
|
-
x = m_atanh(x);
|
|
6251
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
6252
|
-
}
|
|
6253
|
-
}
|
|
6254
|
-
} else {
|
|
6255
|
-
if (idx2) {
|
|
6256
|
-
for (i = 0; i < n; i++) {
|
|
6257
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
6258
|
-
x = m_atanh(x);
|
|
6259
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
6260
|
-
}
|
|
6261
|
-
} else {
|
|
6262
|
-
//
|
|
6263
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
6264
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
6265
|
-
//
|
|
6266
|
-
for (; i < n; i++) {
|
|
6267
|
-
((dtype*)p2)[i] = m_atanh(((dtype*)p1)[i]);
|
|
6268
|
-
}
|
|
6269
|
-
//
|
|
6270
|
-
return;
|
|
6271
|
-
}
|
|
6272
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
6273
|
-
//
|
|
6274
|
-
for (i = 0; i < n; i++) {
|
|
6275
|
-
*(dtype*)p2 = m_atanh(*(dtype*)p1);
|
|
6276
|
-
p1 += s1;
|
|
6277
|
-
p2 += s2;
|
|
6278
|
-
}
|
|
6279
|
-
return;
|
|
6280
|
-
//
|
|
6281
|
-
}
|
|
6282
|
-
}
|
|
6283
|
-
for (i = 0; i < n; i++) {
|
|
6284
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
6285
|
-
x = m_atanh(x);
|
|
6286
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
6287
|
-
}
|
|
6288
|
-
//
|
|
6289
|
-
}
|
|
6290
|
-
}
|
|
6291
|
-
}
|
|
6292
|
-
|
|
6293
|
-
/*
|
|
6294
|
-
Calculate atanh(x).
|
|
6295
|
-
@overload atanh(x)
|
|
6296
|
-
@param [Numo::NArray,Numeric] x input value
|
|
6297
|
-
@return [Numo::SComplex] result of atanh(x).
|
|
6298
|
-
*/
|
|
6299
|
-
static VALUE scomplex_math_s_atanh(VALUE mod, VALUE a1) {
|
|
6300
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
6301
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
6302
|
-
ndfunc_t ndf = { iter_scomplex_math_s_atanh, FULL_LOOP, 1, 1, ain, aout };
|
|
6303
|
-
|
|
6304
|
-
return na_ndloop(&ndf, 1, a1);
|
|
6305
|
-
}
|
|
6306
|
-
|
|
6307
|
-
static void iter_scomplex_math_s_sinc(na_loop_t* const lp) {
|
|
6308
|
-
size_t i = 0, n;
|
|
6309
|
-
char *p1, *p2;
|
|
6310
|
-
ssize_t s1, s2;
|
|
6311
|
-
size_t *idx1, *idx2;
|
|
6312
|
-
dtype x;
|
|
6313
|
-
|
|
6314
|
-
INIT_COUNTER(lp, n);
|
|
6315
|
-
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
|
6316
|
-
INIT_PTR_IDX(lp, 1, p2, s2, idx2);
|
|
6317
|
-
|
|
6318
|
-
if (idx1) {
|
|
6319
|
-
if (idx2) {
|
|
6320
|
-
for (i = 0; i < n; i++) {
|
|
6321
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
6322
|
-
x = m_sinc(x);
|
|
6323
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
6324
|
-
}
|
|
6325
|
-
} else {
|
|
6326
|
-
for (i = 0; i < n; i++) {
|
|
6327
|
-
GET_DATA_INDEX(p1, idx1, dtype, x);
|
|
6328
|
-
x = m_sinc(x);
|
|
6329
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
6330
|
-
}
|
|
6331
|
-
}
|
|
6332
|
-
} else {
|
|
6333
|
-
if (idx2) {
|
|
6334
|
-
for (i = 0; i < n; i++) {
|
|
6335
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
6336
|
-
x = m_sinc(x);
|
|
6337
|
-
SET_DATA_INDEX(p2, idx2, dtype, x);
|
|
6338
|
-
}
|
|
6339
|
-
} else {
|
|
6340
|
-
//
|
|
6341
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype))) {
|
|
6342
|
-
if (s1 == sizeof(dtype) && s2 == sizeof(dtype)) {
|
|
6343
|
-
//
|
|
6344
|
-
for (; i < n; i++) {
|
|
6345
|
-
((dtype*)p2)[i] = m_sinc(((dtype*)p1)[i]);
|
|
6346
|
-
}
|
|
6347
|
-
//
|
|
6348
|
-
return;
|
|
6349
|
-
}
|
|
6350
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype))) {
|
|
6351
|
-
//
|
|
6352
|
-
for (i = 0; i < n; i++) {
|
|
6353
|
-
*(dtype*)p2 = m_sinc(*(dtype*)p1);
|
|
6354
|
-
p1 += s1;
|
|
6355
|
-
p2 += s2;
|
|
6356
|
-
}
|
|
6357
|
-
return;
|
|
6358
|
-
//
|
|
6359
|
-
}
|
|
6360
|
-
}
|
|
6361
|
-
for (i = 0; i < n; i++) {
|
|
6362
|
-
GET_DATA_STRIDE(p1, s1, dtype, x);
|
|
6363
|
-
x = m_sinc(x);
|
|
6364
|
-
SET_DATA_STRIDE(p2, s2, dtype, x);
|
|
6365
|
-
}
|
|
6366
|
-
//
|
|
6367
|
-
}
|
|
6368
|
-
}
|
|
6369
|
-
}
|
|
6370
|
-
|
|
6371
|
-
/*
|
|
6372
|
-
Calculate sinc(x).
|
|
6373
|
-
@overload sinc(x)
|
|
6374
|
-
@param [Numo::NArray,Numeric] x input value
|
|
6375
|
-
@return [Numo::SComplex] result of sinc(x).
|
|
6376
|
-
*/
|
|
6377
|
-
static VALUE scomplex_math_s_sinc(VALUE mod, VALUE a1) {
|
|
6378
|
-
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
|
6379
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
|
6380
|
-
ndfunc_t ndf = { iter_scomplex_math_s_sinc, FULL_LOOP, 1, 1, ain, aout };
|
|
6381
|
-
|
|
6382
|
-
return na_ndloop(&ndf, 1, a1);
|
|
6383
|
-
}
|
|
6384
|
-
|
|
6385
|
-
void Init_numo_scomplex(void) {
|
|
6386
|
-
VALUE hCast, mNumo;
|
|
6387
|
-
|
|
6388
|
-
mNumo = rb_define_module("Numo");
|
|
6389
|
-
|
|
6390
|
-
id_pow = rb_intern("**");
|
|
6391
|
-
id_cast = rb_intern("cast");
|
|
6392
|
-
id_copysign = rb_intern("copysign");
|
|
6393
|
-
id_eq = rb_intern("eq");
|
|
6394
|
-
id_imag = rb_intern("imag");
|
|
6395
|
-
id_mulsum = rb_intern("mulsum");
|
|
6396
|
-
id_ne = rb_intern("ne");
|
|
6397
|
-
id_nearly_eq = rb_intern("nearly_eq");
|
|
6398
|
-
id_real = rb_intern("real");
|
|
6399
|
-
id_to_a = rb_intern("to_a");
|
|
6400
|
-
|
|
6401
|
-
/**
|
|
6402
|
-
* Document-class: Numo::SComplex
|
|
6403
|
-
*
|
|
6404
|
-
* Single precision floating point (32bit) complex number N-dimensional array class.
|
|
6405
|
-
*/
|
|
6406
|
-
cT = rb_define_class_under(mNumo, "SComplex", cNArray);
|
|
6407
|
-
|
|
6408
|
-
// alias of SComplex
|
|
6409
|
-
rb_define_const(mNumo, "Complex32", numo_cSComplex);
|
|
6410
|
-
|
|
6411
|
-
hCast = rb_hash_new();
|
|
6412
|
-
/* Upcasting rules of SComplex. */
|
|
6413
|
-
rb_define_const(cT, "UPCAST", hCast);
|
|
6414
|
-
rb_hash_aset(hCast, rb_cArray, cT);
|
|
6415
|
-
|
|
6416
|
-
#ifdef RUBY_INTEGER_UNIFICATION
|
|
6417
|
-
rb_hash_aset(hCast, rb_cInteger, cT);
|
|
6418
|
-
#else
|
|
6419
|
-
rb_hash_aset(hCast, rb_cFixnum, cT);
|
|
6420
|
-
rb_hash_aset(hCast, rb_cBignum, cT);
|
|
6421
|
-
#endif
|
|
6422
|
-
rb_hash_aset(hCast, rb_cFloat, cT);
|
|
6423
|
-
rb_hash_aset(hCast, rb_cComplex, cT);
|
|
6424
|
-
rb_hash_aset(hCast, numo_cRObject, numo_cRObject);
|
|
6425
|
-
rb_hash_aset(hCast, numo_cDComplex, numo_cDComplex);
|
|
6426
|
-
rb_hash_aset(hCast, numo_cSComplex, numo_cSComplex);
|
|
6427
|
-
rb_hash_aset(hCast, numo_cDFloat, numo_cDComplex);
|
|
6428
|
-
rb_hash_aset(hCast, numo_cSFloat, numo_cSComplex);
|
|
6429
|
-
rb_hash_aset(hCast, numo_cInt64, numo_cSComplex);
|
|
6430
|
-
rb_hash_aset(hCast, numo_cInt32, numo_cSComplex);
|
|
6431
|
-
rb_hash_aset(hCast, numo_cInt16, numo_cSComplex);
|
|
6432
|
-
rb_hash_aset(hCast, numo_cInt8, numo_cSComplex);
|
|
6433
|
-
rb_hash_aset(hCast, numo_cUInt64, numo_cSComplex);
|
|
6434
|
-
rb_hash_aset(hCast, numo_cUInt32, numo_cSComplex);
|
|
6435
|
-
rb_hash_aset(hCast, numo_cUInt16, numo_cSComplex);
|
|
6436
|
-
rb_hash_aset(hCast, numo_cUInt8, numo_cSComplex);
|
|
6437
|
-
rb_obj_freeze(hCast);
|
|
6438
|
-
|
|
6439
|
-
/* Element size of SComplex in bits. */
|
|
6440
|
-
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
|
|
6441
|
-
/* Element size of SComplex in bytes. */
|
|
6442
|
-
rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
|
|
6443
|
-
/* Stride size of contiguous SComplex array. */
|
|
6444
|
-
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
|
|
6445
|
-
/* Machine epsilon of SComplex */
|
|
6446
|
-
rb_define_const(cT, "EPSILON", M_EPSILON);
|
|
6447
|
-
/* The largest representable value of SComplex */
|
|
6448
|
-
rb_define_const(cT, "MAX", M_MAX);
|
|
6449
|
-
/* The smallest representable value of SComplex */
|
|
6450
|
-
rb_define_const(cT, "MIN", M_MIN);
|
|
6451
|
-
rb_define_alloc_func(cT, scomplex_s_alloc_func);
|
|
6452
|
-
rb_define_method(cT, "allocate", scomplex_allocate, 0);
|
|
6453
|
-
rb_define_method(cT, "extract", scomplex_extract, 0);
|
|
6454
|
-
|
|
6455
|
-
rb_define_method(cT, "store", scomplex_store, 1);
|
|
4859
|
+
rb_define_method(cT, "store", scomplex_store, 1);
|
|
6456
4860
|
|
|
6457
4861
|
rb_define_singleton_method(cT, "cast", scomplex_s_cast, 1);
|
|
6458
4862
|
rb_define_method(cT, "[]", scomplex_aref, -1);
|
|
@@ -6568,27 +4972,152 @@ void Init_numo_scomplex(void) {
|
|
|
6568
4972
|
* This module contains mathematical functions for Numo::SComplex.
|
|
6569
4973
|
*/
|
|
6570
4974
|
mTM = rb_define_module_under(cT, "Math");
|
|
6571
|
-
|
|
4975
|
+
/**
|
|
4976
|
+
* Calculate sqrt(x).
|
|
4977
|
+
* @overload sqrt(x)
|
|
4978
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
4979
|
+
* @return [Numo::SComplex] result of sqrt(x).
|
|
4980
|
+
*/
|
|
6572
4981
|
rb_define_module_function(mTM, "sqrt", scomplex_math_s_sqrt, 1);
|
|
4982
|
+
/**
|
|
4983
|
+
* Calculate cbrt(x).
|
|
4984
|
+
* @overload cbrt(x)
|
|
4985
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
4986
|
+
* @return [Numo::SComplex] result of cbrt(x).
|
|
4987
|
+
*/
|
|
6573
4988
|
rb_define_module_function(mTM, "cbrt", scomplex_math_s_cbrt, 1);
|
|
4989
|
+
/**
|
|
4990
|
+
* Calculate log(x).
|
|
4991
|
+
* @overload log(x)
|
|
4992
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
4993
|
+
* @return [Numo::SComplex] result of log(x).
|
|
4994
|
+
*/
|
|
6574
4995
|
rb_define_module_function(mTM, "log", scomplex_math_s_log, 1);
|
|
4996
|
+
/**
|
|
4997
|
+
* Calculate log2(x).
|
|
4998
|
+
* @overload log2(x)
|
|
4999
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5000
|
+
* @return [Numo::SComplex] result of log2(x).
|
|
5001
|
+
*/
|
|
6575
5002
|
rb_define_module_function(mTM, "log2", scomplex_math_s_log2, 1);
|
|
5003
|
+
/**
|
|
5004
|
+
* Calculate log10(x).
|
|
5005
|
+
* @overload log10(x)
|
|
5006
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5007
|
+
* @return [Numo::SComplex] result of log10(x).
|
|
5008
|
+
*/
|
|
6576
5009
|
rb_define_module_function(mTM, "log10", scomplex_math_s_log10, 1);
|
|
5010
|
+
/**
|
|
5011
|
+
* Calculate exp(x).
|
|
5012
|
+
* @overload exp(x)
|
|
5013
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5014
|
+
* @return [Numo::SComplex] result of exp(x).
|
|
5015
|
+
*/
|
|
6577
5016
|
rb_define_module_function(mTM, "exp", scomplex_math_s_exp, 1);
|
|
5017
|
+
/**
|
|
5018
|
+
* Calculate exp2(x).
|
|
5019
|
+
* @overload exp2(x)
|
|
5020
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5021
|
+
* @return [Numo::SComplex] result of exp2(x).
|
|
5022
|
+
*/
|
|
6578
5023
|
rb_define_module_function(mTM, "exp2", scomplex_math_s_exp2, 1);
|
|
5024
|
+
/**
|
|
5025
|
+
* Calculate exp10(x).
|
|
5026
|
+
* @overload exp10(x)
|
|
5027
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5028
|
+
* @return [Numo::SComplex] result of exp10(x).
|
|
5029
|
+
*/
|
|
6579
5030
|
rb_define_module_function(mTM, "exp10", scomplex_math_s_exp10, 1);
|
|
5031
|
+
/**
|
|
5032
|
+
* Calculate sin(x).
|
|
5033
|
+
* @overload sin(x)
|
|
5034
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5035
|
+
* @return [Numo::SComplex] result of sin(x).
|
|
5036
|
+
*/
|
|
6580
5037
|
rb_define_module_function(mTM, "sin", scomplex_math_s_sin, 1);
|
|
5038
|
+
/**
|
|
5039
|
+
* Calculate cos(x).
|
|
5040
|
+
* @overload cos(x)
|
|
5041
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5042
|
+
* @return [Numo::SComplex] result of cos(x).
|
|
5043
|
+
*/
|
|
6581
5044
|
rb_define_module_function(mTM, "cos", scomplex_math_s_cos, 1);
|
|
5045
|
+
/**
|
|
5046
|
+
* Calculate tan(x).
|
|
5047
|
+
* @overload tan(x)
|
|
5048
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5049
|
+
* @return [Numo::SComplex] result of tan(x).
|
|
5050
|
+
*/
|
|
6582
5051
|
rb_define_module_function(mTM, "tan", scomplex_math_s_tan, 1);
|
|
5052
|
+
/**
|
|
5053
|
+
* Calculate asin(x).
|
|
5054
|
+
* @overload asin(x)
|
|
5055
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5056
|
+
* @return [Numo::SComplex] result of asin(x).
|
|
5057
|
+
*/
|
|
6583
5058
|
rb_define_module_function(mTM, "asin", scomplex_math_s_asin, 1);
|
|
5059
|
+
/**
|
|
5060
|
+
* Calculate acos(x).
|
|
5061
|
+
* @overload acos(x)
|
|
5062
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5063
|
+
* @return [Numo::SComplex] result of acos(x).
|
|
5064
|
+
*/
|
|
6584
5065
|
rb_define_module_function(mTM, "acos", scomplex_math_s_acos, 1);
|
|
5066
|
+
/**
|
|
5067
|
+
* Calculate atan(x).
|
|
5068
|
+
* @overload atan(x)
|
|
5069
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5070
|
+
* @return [Numo::SComplex] result of atan(x).
|
|
5071
|
+
*/
|
|
6585
5072
|
rb_define_module_function(mTM, "atan", scomplex_math_s_atan, 1);
|
|
5073
|
+
/**
|
|
5074
|
+
* Calculate sinh(x).
|
|
5075
|
+
* @overload sinh(x)
|
|
5076
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5077
|
+
* @return [Numo::SComplex] result of sinh(x).
|
|
5078
|
+
*/
|
|
6586
5079
|
rb_define_module_function(mTM, "sinh", scomplex_math_s_sinh, 1);
|
|
5080
|
+
/**
|
|
5081
|
+
* Calculate cosh(x).
|
|
5082
|
+
* @overload cosh(x)
|
|
5083
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5084
|
+
* @return [Numo::SComplex] result of cosh(x).
|
|
5085
|
+
*/
|
|
6587
5086
|
rb_define_module_function(mTM, "cosh", scomplex_math_s_cosh, 1);
|
|
5087
|
+
/**
|
|
5088
|
+
* Calculate tanh(x).
|
|
5089
|
+
* @overload tanh(x)
|
|
5090
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5091
|
+
* @return [Numo::SComplex] result of tanh(x).
|
|
5092
|
+
*/
|
|
6588
5093
|
rb_define_module_function(mTM, "tanh", scomplex_math_s_tanh, 1);
|
|
5094
|
+
/**
|
|
5095
|
+
* Calculate asinh(x).
|
|
5096
|
+
* @overload asinh(x)
|
|
5097
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5098
|
+
* @return [Numo::SComplex] result of asinh(x).
|
|
5099
|
+
*/
|
|
6589
5100
|
rb_define_module_function(mTM, "asinh", scomplex_math_s_asinh, 1);
|
|
5101
|
+
/**
|
|
5102
|
+
* Calculate acosh(x).
|
|
5103
|
+
* @overload acosh(x)
|
|
5104
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5105
|
+
* @return [Numo::SComplex] result of acosh(x).
|
|
5106
|
+
*/
|
|
6590
5107
|
rb_define_module_function(mTM, "acosh", scomplex_math_s_acosh, 1);
|
|
5108
|
+
/**
|
|
5109
|
+
* Calculate atanh(x).
|
|
5110
|
+
* @overload atanh(x)
|
|
5111
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5112
|
+
* @return [Numo::SComplex] result of atanh(x).
|
|
5113
|
+
*/
|
|
6591
5114
|
rb_define_module_function(mTM, "atanh", scomplex_math_s_atanh, 1);
|
|
5115
|
+
/**
|
|
5116
|
+
* Calculate sinc(x).
|
|
5117
|
+
* @overload sinc(x)
|
|
5118
|
+
* @param [Numo::NArray,Numeric] x input value
|
|
5119
|
+
* @return [Numo::SComplex] result of sinc(x).
|
|
5120
|
+
*/
|
|
6592
5121
|
rb_define_module_function(mTM, "sinc", scomplex_math_s_sinc, 1);
|
|
6593
5122
|
|
|
6594
5123
|
// how to do this?
|