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