gsl4r 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL +22 -0
- data/LICENSE +19 -0
- data/LICENSE.LGPLv3 +165 -0
- data/README +55 -0
- data/Rakefile +97 -0
- data/TODO +1 -0
- data/lib/gsl4r.rb +18 -0
- data/lib/gsl4r/complex.rb +434 -0
- data/lib/gsl4r/f +174 -0
- data/lib/gsl4r/harness.rb +58 -0
- data/lib/gsl4r/platform.rb +8 -0
- data/lib/gsl4r/util.rb +85 -0
- data/lib/gsl4r/vector.rb +29 -0
- data/test/complex_test.rb +490 -0
- data/test/complex_tests.rb +28 -0
- data/test/gsl_complex_tests_gen +0 -0
- data/test/gsl_complex_tests_gen.c +791 -0
- metadata +73 -0
data/lib/gsl4r/f
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
[Function]
|
2
|
+
[Function]
|
3
|
+
gsl_complex gsl_complex_pow (gsl complex z, gsl complex a )
|
4
|
+
The function returns the complex number z raised to the complex power a, za . This
|
5
|
+
is computed as exp(log(z)
|
6
|
+
∗ a) using complex logarithms and complex exponentials.
|
7
|
+
[Function]
|
8
|
+
gsl_complex gsl_complex_pow_real (gsl complex z, double x )
|
9
|
+
This function returns the complex number z raised to the real power x, zx .
|
10
|
+
[Function]
|
11
|
+
gsl_complex gsl_complex_exp (gsl complex z )
|
12
|
+
This function returns the complex exponential of the complex number z, exp(z).
|
13
|
+
Chapter 5: Complex Numbers 24
|
14
|
+
[Function]
|
15
|
+
gsl_complex gsl_complex_log (gsl complex z )
|
16
|
+
This function returns the complex natural logarithm (base e) of the complex number
|
17
|
+
z, log(z). The branch cut is the negative real axis.
|
18
|
+
[Function]
|
19
|
+
gsl_complex gsl_complex_log10 (gsl complex z )
|
20
|
+
This function returns the complex base-10 logarithm of the complex number z,
|
21
|
+
log10 (z).
|
22
|
+
[Function]
|
23
|
+
gsl_complex gsl_complex_log_b (gsl complex z, gsl complex b )
|
24
|
+
This function returns the complex base-b logarithm of the complex number z, logb (z).
|
25
|
+
This quantity is computed as the ratio log(z)/ log(b).
|
26
|
+
5.5 Complex Trigonometric Functions
|
27
|
+
[Function]
|
28
|
+
gsl_complex gsl_complex_sin (gsl complex z )
|
29
|
+
This function returns the complex sine of the complex number z, sin(z) = (exp(iz)
|
30
|
+
−
|
31
|
+
exp(
|
32
|
+
−iz))/(2i).
|
33
|
+
[Function]
|
34
|
+
gsl_complex gsl_complex_cos (gsl complex z )
|
35
|
+
This function returns the complex cosine of the complex number z, cos(z) = (exp(iz)+
|
36
|
+
exp(
|
37
|
+
−iz))/2.
|
38
|
+
[Function]
|
39
|
+
gsl_complex gsl_complex_tan (gsl complex z )
|
40
|
+
This function returns the complex tangent of the complex number z,
|
41
|
+
tan(z) = sin(z)/ cos(z).
|
42
|
+
[Function]
|
43
|
+
gsl_complex gsl_complex_sec (gsl complex z )
|
44
|
+
This function returns the complex secant of the complex number z, sec(z) = 1/ cos(z).
|
45
|
+
[Function]
|
46
|
+
gsl_complex gsl_complex_csc (gsl complex z )
|
47
|
+
This function returns the complex cosecant of the complex number z, csc(z) =
|
48
|
+
1/ sin(z).
|
49
|
+
[Function]
|
50
|
+
gsl_complex gsl_complex_cot (gsl complex z )
|
51
|
+
This function returns the complex cotangent of the complex number z, cot(z) =
|
52
|
+
1/ tan(z).
|
53
|
+
5.6 Inverse Complex Trigonometric Functions
|
54
|
+
[Function]
|
55
|
+
gsl_complex gsl_complex_arcsin (gsl complex z )
|
56
|
+
This function returns the complex arcsine of the complex number z, arcsin(z). The
|
57
|
+
branch cuts are on the real axis, less than
|
58
|
+
−1 and greater than 1.
|
59
|
+
[Function]
|
60
|
+
gsl_complex gsl_complex_arcsin_real (double z )
|
61
|
+
This function returns the complex arcsine of the real number z, arcsin(z). For z
|
62
|
+
between
|
63
|
+
−1 and 1, the function returns a real value in the range [−π/2, π/2]. For z
|
64
|
+
less than
|
65
|
+
−1 the result has a real part of −π/2 and a positive imaginary part. For z
|
66
|
+
greater than 1 the result has a real part of π/2 and a negative imaginary part.
|
67
|
+
Chapter 5: Complex Numbers 25
|
68
|
+
[Function]
|
69
|
+
gsl_complex gsl_complex_arccos (gsl complex z )
|
70
|
+
This function returns the complex arccosine of the complex number z, arccos(z). The
|
71
|
+
branch cuts are on the real axis, less than
|
72
|
+
−1 and greater than 1.
|
73
|
+
[Function]
|
74
|
+
gsl_complex gsl_complex_arccos_real (double z )
|
75
|
+
This function returns the complex arccosine of the real number z, arccos(z). For z
|
76
|
+
between
|
77
|
+
−1 and 1, the function returns a real value in the range [0, π]. For z less
|
78
|
+
than
|
79
|
+
−1 the result has a real part of π and a negative imaginary part. For z greater
|
80
|
+
than 1 the result is purely imaginary and positive.
|
81
|
+
[Function]
|
82
|
+
gsl_complex gsl_complex_arctan (gsl complex z )
|
83
|
+
This function returns the complex arctangent of the complex number z, arctan(z).
|
84
|
+
The branch cuts are on the imaginary axis, below
|
85
|
+
−i and above i.
|
86
|
+
[Function]
|
87
|
+
gsl_complex gsl_complex_arcsec (gsl complex z )
|
88
|
+
This function returns the complex arcsecant of the complex number z, arcsec(z) =
|
89
|
+
arccos(1/z).
|
90
|
+
[Function]
|
91
|
+
gsl_complex gsl_complex_arcsec_real (double z )
|
92
|
+
This function returns the complex arcsecant of the real number z,
|
93
|
+
arcsec(z) = arccos(1/z).
|
94
|
+
[Function]
|
95
|
+
gsl_complex gsl_complex_arccsc (gsl complex z )
|
96
|
+
This function returns the complex arccosecant of the complex number z, arccsc(z) =
|
97
|
+
arcsin(1/z).
|
98
|
+
[Function]
|
99
|
+
gsl_complex gsl_complex_arccsc_real (double z )
|
100
|
+
This function returns the complex arccosecant of the real number z, arccsc(z) =
|
101
|
+
arcsin(1/z).
|
102
|
+
[Function]
|
103
|
+
gsl_complex gsl_complex_arccot (gsl complex z )
|
104
|
+
This function returns the complex arccotangent of the complex number z, arccot(z) =
|
105
|
+
arctan(1/z).
|
106
|
+
5.7 Complex Hyperbolic Functions
|
107
|
+
[Function]
|
108
|
+
gsl_complex gsl_complex_sinh (gsl complex z )
|
109
|
+
This function returns the complex hyperbolic sine of the complex number z, sinh(z) =
|
110
|
+
(exp(z)
|
111
|
+
− exp(−z))/2.
|
112
|
+
[Function]
|
113
|
+
gsl_complex gsl_complex_cosh (gsl complex z )
|
114
|
+
This function returns the complex hyperbolic cosine of the complex number z,
|
115
|
+
cosh(z) = (exp(z) + exp(
|
116
|
+
−z))/2.
|
117
|
+
[Function]
|
118
|
+
gsl_complex gsl_complex_tanh (gsl complex z )
|
119
|
+
This function returns the complex hyperbolic tangent of the complex number z,
|
120
|
+
tanh(z) = sinh(z)/ cosh(z).
|
121
|
+
[Function]
|
122
|
+
gsl_complex gsl_complex_sech (gsl complex z )
|
123
|
+
This function returns the complex hyperbolic secant of the complex number z,
|
124
|
+
sech(z) = 1/ cosh(z).
|
125
|
+
Chapter 5: Complex Numbers 26
|
126
|
+
[Function]
|
127
|
+
gsl_complex gsl_complex_csch (gsl complex z )
|
128
|
+
This function returns the complex hyperbolic cosecant of the complex number z,
|
129
|
+
csch(z) = 1/ sinh(z).
|
130
|
+
[Function]
|
131
|
+
gsl_complex gsl_complex_coth (gsl complex z )
|
132
|
+
This function returns the complex hyperbolic cotangent of the complex number z,
|
133
|
+
coth(z) = 1/ tanh(z).
|
134
|
+
5.8 Inverse Complex Hyperbolic Functions
|
135
|
+
[Function]
|
136
|
+
gsl_complex gsl_complex_arcsinh (gsl complex z )
|
137
|
+
This function returns the complex hyperbolic arcsine of the complex number z,
|
138
|
+
arcsinh(z). The branch cuts are on the imaginary axis, below
|
139
|
+
−i and above i.
|
140
|
+
[Function]
|
141
|
+
gsl_complex gsl_complex_arccosh (gsl complex z )
|
142
|
+
This function returns the complex hyperbolic arccosine of the complex number z,
|
143
|
+
arccosh(z). The branch cut is on the real axis, less than 1. Note that in this case
|
144
|
+
we use the negative square root in formula 4.6.21 of Abramowitz & Stegun giving
|
145
|
+
arccosh(z) = log(z
|
146
|
+
− √z
|
147
|
+
2
|
148
|
+
− 1).
|
149
|
+
[Function]
|
150
|
+
gsl_complex gsl_complex_arccosh_real (double z )
|
151
|
+
This function returns the complex hyperbolic arccosine of the real number z,
|
152
|
+
arccosh(z).
|
153
|
+
[Function]
|
154
|
+
gsl_complex gsl_complex_arctanh (gsl complex z )
|
155
|
+
This function returns the complex hyperbolic arctangent of the complex number z,
|
156
|
+
arctanh(z). The branch cuts are on the real axis, less than
|
157
|
+
−1 and greater than 1.
|
158
|
+
[Function]
|
159
|
+
gsl_complex gsl_complex_arctanh_real (double z )
|
160
|
+
This function returns the complex hyperbolic arctangent of the real number z,
|
161
|
+
arctanh(z).
|
162
|
+
[Function]
|
163
|
+
gsl_complex gsl_complex_arcsech (gsl complex z )
|
164
|
+
This function returns the complex hyperbolic arcsecant of the complex number z,
|
165
|
+
arcsech(z) = arccosh(1/z).
|
166
|
+
[Function]
|
167
|
+
gsl_complex gsl_complex_arccsch (gsl complex z )
|
168
|
+
This function returns the complex hyperbolic arccosecant of the complex number z,
|
169
|
+
arccsch(z) = arcsin(1/z).
|
170
|
+
[Function]
|
171
|
+
gsl_complex gsl_complex_arccoth (gsl complex z )
|
172
|
+
This function returns the complex hyperbolic arccotangent of the complex number z,
|
173
|
+
arccoth(z) = arctanh(1/z).
|
174
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# == Other Info
|
4
|
+
#
|
5
|
+
# Author:: Colby Gutierrez-Kraybill
|
6
|
+
# Version:: $Id$
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
|
11
|
+
module GSL4r
|
12
|
+
module Harness
|
13
|
+
attr_accessor :c_includes, :c_libs, :c_tests, :c_src_name, :c_binary
|
14
|
+
attr_accessor :r_header, :r_footer
|
15
|
+
|
16
|
+
TEST_DIR = "test"
|
17
|
+
|
18
|
+
def write_c_tests
|
19
|
+
f = File.new("#{TEST_DIR}/#{@c_src_name}", "w")
|
20
|
+
f.puts "/* Auto generated by #{self.class.name} */"
|
21
|
+
f.puts "#include <stdio.h>"
|
22
|
+
@c_includes.each { |i|
|
23
|
+
f.puts "#include \"#{i}\""
|
24
|
+
}
|
25
|
+
f.puts "int main( int argc, char **argv )\n{\n"
|
26
|
+
|
27
|
+
f.puts " puts(\"#{@r_header}\");"
|
28
|
+
|
29
|
+
@c_tests.each { |t|
|
30
|
+
t_fqmn_a = self.class.name.split("::")
|
31
|
+
t_fqmn_a.pop
|
32
|
+
src = ""
|
33
|
+
eval <<-end_eval
|
34
|
+
src = ::#{t_fqmn_a.join("::")}::Methods::#{t}
|
35
|
+
end_eval
|
36
|
+
f.puts " /* #{t} */"
|
37
|
+
f.puts src
|
38
|
+
}
|
39
|
+
|
40
|
+
f.puts " puts(\"#{@r_footer}\");"
|
41
|
+
|
42
|
+
f.puts " return(0);\n}\n"
|
43
|
+
f.close
|
44
|
+
end
|
45
|
+
|
46
|
+
def compile_c_tests
|
47
|
+
compile_s = "#{@c_compiler} #{@c_flags.join(" ")} " +
|
48
|
+
"-o #{TEST_DIR}/#{@c_binary} #{TEST_DIR}/#{@c_src_name}"
|
49
|
+
p compile_s
|
50
|
+
`#{compile_s}`
|
51
|
+
end
|
52
|
+
|
53
|
+
def run_c_tests( filename )
|
54
|
+
`#{TEST_DIR}/#{@c_binary} > test/#{filename}`
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
data/lib/gsl4r/util.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# == Other Info
|
4
|
+
#
|
5
|
+
# Author:: Colby Gutierrez-Kraybill
|
6
|
+
# Version:: $Id$
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
|
11
|
+
module GSL4r
|
12
|
+
module Util
|
13
|
+
|
14
|
+
$c_var_num = 0
|
15
|
+
|
16
|
+
def attach_gsl_function( method_name, args, return_var, args_type=nil, return_type=nil )
|
17
|
+
|
18
|
+
# This function is attached to the extended ::FFI::Library
|
19
|
+
# module from the calling namespace, e.g. ::GSL4r::Complex::Methods
|
20
|
+
attach_function method_name, args, return_var
|
21
|
+
|
22
|
+
if ( args_type != nil )
|
23
|
+
# prepare c and ruby args code
|
24
|
+
c_src = ""
|
25
|
+
c_call_vars = []
|
26
|
+
c_return_name = "c_r#{$c_var_num}"
|
27
|
+
r_src = []
|
28
|
+
if ( ! args_type.is_a?(Array) )
|
29
|
+
args_type = Array.new([args_type])
|
30
|
+
end
|
31
|
+
args_type.each { |a_t|
|
32
|
+
c_var_name = "v#{$c_var_num += 1}"
|
33
|
+
c_src << (a_t.respond_to?("c_type") ?
|
34
|
+
" #{a_t.c_type} #{c_var_name};\n" : "#{a_t.to_s} #{c_var_name} ")
|
35
|
+
c_src << (a_t.respond_to?("c_assignment") ?
|
36
|
+
" #{a_t.c_assignment("#{c_var_name}")}\n" : "= (#{a_t.to_s})2.0;\n")
|
37
|
+
c_call_vars << "#{c_var_name}"
|
38
|
+
|
39
|
+
r_src << (a_t.respond_to?("r_type") ?
|
40
|
+
" #{c_var_name} = #{a_t.r_type}.create" : "")
|
41
|
+
r_src << (a_t.respond_to?("r_assignment") ?
|
42
|
+
" #{a_t.r_assignment("#{c_var_name}")}" : " #{c_var_name} = 2.0")
|
43
|
+
} # args_type.each
|
44
|
+
|
45
|
+
# prepare c return type
|
46
|
+
c_src << (return_type.respond_to?("c_type") ?
|
47
|
+
" #{return_type.c_type} #{c_return_name};\n" :
|
48
|
+
" #{return_type.to_s} #{c_return_name};\n")
|
49
|
+
|
50
|
+
# prepare c call
|
51
|
+
c_src << " #{c_return_name} = #{method_name}(#{c_call_vars.join(",")});\n"
|
52
|
+
|
53
|
+
# now generate the ruby code for the unit test
|
54
|
+
c_src << " puts(" << %Q{\\"def test_#{method_name}()\\"} << ");\n"
|
55
|
+
|
56
|
+
# TODO, Need to insert ruby object instantiation code here!
|
57
|
+
#
|
58
|
+
r_src.each { |v|
|
59
|
+
c_src << " puts(" << %Q{\\"#{v}\\"} << ");\n"
|
60
|
+
}
|
61
|
+
|
62
|
+
r_r1 = "r_r1" # ruby result
|
63
|
+
c_src << " puts(" << %Q{\\" #{r_r1} = ::#{self.to_s}::#{method_name}(#{c_call_vars.join(",")})\\"} << ");\n"
|
64
|
+
if ( return_type.respond_to?("c_to_r_assignment") )
|
65
|
+
r_r2 = "r_r2" # ruby result comparitor
|
66
|
+
c_src << " puts(" << %Q{\\" #{r_r2} = #{return_type.r_type}.new\\"} << ");\n"
|
67
|
+
c_src << " #{return_type.c_to_r_assignment(r_r2,c_return_name)}"
|
68
|
+
c_src << " printf(" << %Q{\\" assert r_r1.equals(r_r2)\\\\n\\"} << ");\n"
|
69
|
+
else
|
70
|
+
c_src << " printf(" << %Q{\\" assert_in_delta r_r1, %.15g, EPSILON\\\\n\\"} << ", #{c_return_name});\n"
|
71
|
+
end
|
72
|
+
|
73
|
+
c_src << " puts(" << %Q{\\"end\\"} << ");"
|
74
|
+
|
75
|
+
|
76
|
+
eval <<-end_eval
|
77
|
+
def c_test_#{method_name}
|
78
|
+
# Build list of arguments and their values
|
79
|
+
"#{c_src}"
|
80
|
+
end
|
81
|
+
end_eval
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/gsl4r/vector.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# == Other Info
|
4
|
+
#
|
5
|
+
# Author:: Colby Gutierrez-Kraybill
|
6
|
+
# Version:: $Id$
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
require 'ffi'
|
11
|
+
|
12
|
+
module GSL4r
|
13
|
+
|
14
|
+
extend ::FFI::Library
|
15
|
+
|
16
|
+
ffi_lib 'gsl'
|
17
|
+
|
18
|
+
class Vector
|
19
|
+
attach_function :gsl_vector_alloc, [ :size_t ], :pointer
|
20
|
+
attach_function :gsl_vector_calloc, [ :size_t ], :pointer
|
21
|
+
attach_function :gsl_vector_free, [ :pointer ], :void
|
22
|
+
|
23
|
+
# initializing
|
24
|
+
attach_function :gsl_vector_set_all, [ :pointer, :double ], :void
|
25
|
+
attach_function :gsl_vector_set_zero, [ :pointer ], :void
|
26
|
+
attach_function :gsl_vector_set_basis, [ :pointer, :size_t ], :int
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,490 @@
|
|
1
|
+
$: << File.join('..','lib')
|
2
|
+
require 'test/unit'
|
3
|
+
require 'test/unit/autorunner'
|
4
|
+
require 'gsl4r/complex'
|
5
|
+
include GSL4r::Complex
|
6
|
+
class ComplexTests < Test::Unit::TestCase
|
7
|
+
EPSILON = 5.0e-15
|
8
|
+
def test_gsl_complex_tanh()
|
9
|
+
v64 = GSL_Complex.create
|
10
|
+
v64.set(2.0,2.0)
|
11
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_tanh(v64)
|
12
|
+
r_r2 = GSL_Complex.new
|
13
|
+
r_r2.set(1.02383559457047,-0.0283929528682323)
|
14
|
+
assert r_r1.equals(r_r2)
|
15
|
+
end
|
16
|
+
def test_gsl_complex_pow_real()
|
17
|
+
v37 = GSL_Complex.create
|
18
|
+
v37.set(2.0,2.0)
|
19
|
+
|
20
|
+
v38 = 2.0
|
21
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_pow_real(v37,v38)
|
22
|
+
r_r2 = GSL_Complex.new
|
23
|
+
r_r2.set(4.89858719658941e-16,8)
|
24
|
+
assert r_r1.equals(r_r2)
|
25
|
+
end
|
26
|
+
def test_gsl_complex_sinh()
|
27
|
+
v60 = GSL_Complex.create
|
28
|
+
v60.set(2.0,2.0)
|
29
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_sinh(v60)
|
30
|
+
r_r2 = GSL_Complex.new
|
31
|
+
r_r2.set(-1.50930648532362,3.42095486111701)
|
32
|
+
assert r_r1.equals(r_r2)
|
33
|
+
end
|
34
|
+
def test_gsl_complex_sqrt()
|
35
|
+
v31 = GSL_Complex.create
|
36
|
+
v31.set(2.0,2.0)
|
37
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_sqrt(v31)
|
38
|
+
r_r2 = GSL_Complex.new
|
39
|
+
r_r2.set(1.55377397403004,0.643594252905582)
|
40
|
+
assert r_r1.equals(r_r2)
|
41
|
+
end
|
42
|
+
def test_gsl_complex_arccsc()
|
43
|
+
v56 = GSL_Complex.create
|
44
|
+
v56.set(2.0,2.0)
|
45
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arccsc(v56)
|
46
|
+
r_r2 = GSL_Complex.new
|
47
|
+
r_r2.set(0.24452216513554,-0.254895573340551)
|
48
|
+
assert r_r1.equals(r_r2)
|
49
|
+
end
|
50
|
+
def test_gsl_complex_div_imag()
|
51
|
+
v26 = GSL_Complex.create
|
52
|
+
v26.set(2.0,2.0)
|
53
|
+
|
54
|
+
v27 = 2.0
|
55
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_div_imag(v26,v27)
|
56
|
+
r_r2 = GSL_Complex.new
|
57
|
+
r_r2.set(1,-1)
|
58
|
+
assert r_r1.equals(r_r2)
|
59
|
+
end
|
60
|
+
def test_gsl_complex_abs2()
|
61
|
+
v3 = GSL_Complex.create
|
62
|
+
v3.set(2.0,2.0)
|
63
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_abs2(v3)
|
64
|
+
assert_in_delta r_r1, 8, EPSILON
|
65
|
+
end
|
66
|
+
def test_gsl_complex_arccos()
|
67
|
+
v52 = GSL_Complex.create
|
68
|
+
v52.set(2.0,2.0)
|
69
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arccos(v52)
|
70
|
+
r_r2 = GSL_Complex.new
|
71
|
+
r_r2.set(0.816547182096851,-1.73432452148797)
|
72
|
+
assert r_r1.equals(r_r2)
|
73
|
+
end
|
74
|
+
def test_gsl_complex_arccoth()
|
75
|
+
v73 = GSL_Complex.create
|
76
|
+
v73.set(2.0,2.0)
|
77
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arccoth(v73)
|
78
|
+
r_r2 = GSL_Complex.new
|
79
|
+
r_r2.set(0.238877861256859,-0.259573057123261)
|
80
|
+
assert r_r1.equals(r_r2)
|
81
|
+
end
|
82
|
+
def test_gsl_complex_div_real()
|
83
|
+
v18 = GSL_Complex.create
|
84
|
+
v18.set(2.0,2.0)
|
85
|
+
|
86
|
+
v19 = 2.0
|
87
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_div_real(v18,v19)
|
88
|
+
r_r2 = GSL_Complex.new
|
89
|
+
r_r2.set(1,1)
|
90
|
+
assert r_r1.equals(r_r2)
|
91
|
+
end
|
92
|
+
def test_gsl_complex_tan()
|
93
|
+
v48 = GSL_Complex.create
|
94
|
+
v48.set(2.0,2.0)
|
95
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_tan(v48)
|
96
|
+
r_r2 = GSL_Complex.new
|
97
|
+
r_r2.set(-0.0283929528682323,1.02383559457047)
|
98
|
+
assert r_r1.equals(r_r2)
|
99
|
+
end
|
100
|
+
def test_gsl_complex_arcsech()
|
101
|
+
v69 = GSL_Complex.create
|
102
|
+
v69.set(2.0,2.0)
|
103
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arcsech(v69)
|
104
|
+
r_r2 = GSL_Complex.new
|
105
|
+
r_r2.set(0.254895573340551,-1.32627416165936)
|
106
|
+
assert r_r1.equals(r_r2)
|
107
|
+
end
|
108
|
+
def test_gsl_complex_div()
|
109
|
+
v10 = GSL_Complex.create
|
110
|
+
v10.set(2.0,2.0)
|
111
|
+
v11 = GSL_Complex.create
|
112
|
+
v11.set(2.0,2.0)
|
113
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_div(v10,v11)
|
114
|
+
r_r2 = GSL_Complex.new
|
115
|
+
r_r2.set(1,0)
|
116
|
+
assert r_r1.equals(r_r2)
|
117
|
+
end
|
118
|
+
def test_gsl_complex_sin()
|
119
|
+
v44 = GSL_Complex.create
|
120
|
+
v44.set(2.0,2.0)
|
121
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_sin(v44)
|
122
|
+
r_r2 = GSL_Complex.new
|
123
|
+
r_r2.set(3.42095486111701,-1.50930648532362)
|
124
|
+
assert r_r1.equals(r_r2)
|
125
|
+
end
|
126
|
+
def test_gsl_complex_coth()
|
127
|
+
v65 = GSL_Complex.create
|
128
|
+
v65.set(2.0,2.0)
|
129
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_coth(v65)
|
130
|
+
r_r2 = GSL_Complex.new
|
131
|
+
r_r2.set(0.975968735117309,0.0270655117325545)
|
132
|
+
assert r_r1.equals(r_r2)
|
133
|
+
end
|
134
|
+
def test_gsl_complex_exp()
|
135
|
+
v39 = GSL_Complex.create
|
136
|
+
v39.set(2.0,2.0)
|
137
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_exp(v39)
|
138
|
+
r_r2 = GSL_Complex.new
|
139
|
+
r_r2.set(-3.07493232063936,6.71884969742825)
|
140
|
+
assert r_r1.equals(r_r2)
|
141
|
+
end
|
142
|
+
def test_gsl_complex_cosh()
|
143
|
+
v61 = GSL_Complex.create
|
144
|
+
v61.set(2.0,2.0)
|
145
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_cosh(v61)
|
146
|
+
r_r2 = GSL_Complex.new
|
147
|
+
r_r2.set(-1.56562583531574,3.29789483631124)
|
148
|
+
assert r_r1.equals(r_r2)
|
149
|
+
end
|
150
|
+
def test_gsl_complex_sqrt_real()
|
151
|
+
|
152
|
+
v32 = 2.0
|
153
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_sqrt_real(v32)
|
154
|
+
r_r2 = GSL_Complex.new
|
155
|
+
r_r2.set(1.4142135623731,0)
|
156
|
+
assert r_r1.equals(r_r2)
|
157
|
+
end
|
158
|
+
def test_gsl_complex_arccsc_real()
|
159
|
+
|
160
|
+
v57 = 2.0
|
161
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arccsc_real(v57)
|
162
|
+
r_r2 = GSL_Complex.new
|
163
|
+
r_r2.set(0.523598775598299,0)
|
164
|
+
assert r_r1.equals(r_r2)
|
165
|
+
end
|
166
|
+
def test_gsl_complex_conjugate()
|
167
|
+
v28 = GSL_Complex.create
|
168
|
+
v28.set(2.0,2.0)
|
169
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_conjugate(v28)
|
170
|
+
r_r2 = GSL_Complex.new
|
171
|
+
r_r2.set(2,-2)
|
172
|
+
assert r_r1.equals(r_r2)
|
173
|
+
end
|
174
|
+
def test_gsl_complex_arccos_real()
|
175
|
+
|
176
|
+
v53 = 2.0
|
177
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arccos_real(v53)
|
178
|
+
r_r2 = GSL_Complex.new
|
179
|
+
r_r2.set(0,1.31695789692482)
|
180
|
+
assert r_r1.equals(r_r2)
|
181
|
+
end
|
182
|
+
def test_gsl_complex_add_imag()
|
183
|
+
v20 = GSL_Complex.create
|
184
|
+
v20.set(2.0,2.0)
|
185
|
+
|
186
|
+
v21 = 2.0
|
187
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_add_imag(v20,v21)
|
188
|
+
r_r2 = GSL_Complex.new
|
189
|
+
r_r2.set(2,4)
|
190
|
+
assert r_r1.equals(r_r2)
|
191
|
+
end
|
192
|
+
def test_gsl_complex_cot()
|
193
|
+
v49 = GSL_Complex.create
|
194
|
+
v49.set(2.0,2.0)
|
195
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_cot(v49)
|
196
|
+
r_r2 = GSL_Complex.new
|
197
|
+
r_r2.set(-0.0270655117325545,-0.975968735117309)
|
198
|
+
assert r_r1.equals(r_r2)
|
199
|
+
end
|
200
|
+
def test_gsl_complex_arccsch()
|
201
|
+
v70 = GSL_Complex.create
|
202
|
+
v70.set(2.0,2.0)
|
203
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arccsch(v70)
|
204
|
+
r_r2 = GSL_Complex.new
|
205
|
+
r_r2.set(0.254895573340551,-0.24452216513554)
|
206
|
+
assert r_r1.equals(r_r2)
|
207
|
+
end
|
208
|
+
def test_gsl_complex_add_real()
|
209
|
+
v12 = GSL_Complex.create
|
210
|
+
v12.set(2.0,2.0)
|
211
|
+
|
212
|
+
v13 = 2.0
|
213
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_add_real(v12,v13)
|
214
|
+
r_r2 = GSL_Complex.new
|
215
|
+
r_r2.set(4,2)
|
216
|
+
assert r_r1.equals(r_r2)
|
217
|
+
end
|
218
|
+
def test_gsl_complex_cos()
|
219
|
+
v45 = GSL_Complex.create
|
220
|
+
v45.set(2.0,2.0)
|
221
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_cos(v45)
|
222
|
+
r_r2 = GSL_Complex.new
|
223
|
+
r_r2.set(-1.56562583531574,-3.29789483631124)
|
224
|
+
assert r_r1.equals(r_r2)
|
225
|
+
end
|
226
|
+
def test_gsl_complex_arcsinh()
|
227
|
+
v66 = GSL_Complex.create
|
228
|
+
v66.set(2.0,2.0)
|
229
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arcsinh(v66)
|
230
|
+
r_r2 = GSL_Complex.new
|
231
|
+
r_r2.set(1.73432452148797,0.754249144698046)
|
232
|
+
assert r_r1.equals(r_r2)
|
233
|
+
end
|
234
|
+
def test_gsl_complex_add()
|
235
|
+
v4 = GSL_Complex.create
|
236
|
+
v4.set(2.0,2.0)
|
237
|
+
v5 = GSL_Complex.create
|
238
|
+
v5.set(2.0,2.0)
|
239
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_add(v4,v5)
|
240
|
+
r_r2 = GSL_Complex.new
|
241
|
+
r_r2.set(4,4)
|
242
|
+
assert r_r1.equals(r_r2)
|
243
|
+
end
|
244
|
+
def test_gsl_complex_log()
|
245
|
+
v40 = GSL_Complex.create
|
246
|
+
v40.set(2.0,2.0)
|
247
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_log(v40)
|
248
|
+
r_r2 = GSL_Complex.new
|
249
|
+
r_r2.set(1.03972077083992,0.785398163397448)
|
250
|
+
assert r_r1.equals(r_r2)
|
251
|
+
end
|
252
|
+
def test_gsl_complex_sech()
|
253
|
+
v62 = GSL_Complex.create
|
254
|
+
v62.set(2.0,2.0)
|
255
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_sech(v62)
|
256
|
+
r_r2 = GSL_Complex.new
|
257
|
+
r_r2.set(-0.117475142661415,-0.24745418582076)
|
258
|
+
assert r_r1.equals(r_r2)
|
259
|
+
end
|
260
|
+
def test_gsl_complex_polar()
|
261
|
+
|
262
|
+
v33 = 2.0
|
263
|
+
|
264
|
+
v34 = 2.0
|
265
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_polar(v33,v34)
|
266
|
+
r_r2 = GSL_Complex.new
|
267
|
+
r_r2.set(-0.832293673094285,1.81859485365136)
|
268
|
+
assert r_r1.equals(r_r2)
|
269
|
+
end
|
270
|
+
def test_gsl_complex_arctan()
|
271
|
+
v58 = GSL_Complex.create
|
272
|
+
v58.set(2.0,2.0)
|
273
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arctan(v58)
|
274
|
+
r_r2 = GSL_Complex.new
|
275
|
+
r_r2.set(1.31122326967164,0.238877861256859)
|
276
|
+
assert r_r1.equals(r_r2)
|
277
|
+
end
|
278
|
+
def test_gsl_complex_inverse()
|
279
|
+
v29 = GSL_Complex.create
|
280
|
+
v29.set(2.0,2.0)
|
281
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_inverse(v29)
|
282
|
+
r_r2 = GSL_Complex.new
|
283
|
+
r_r2.set(0.25,-0.25)
|
284
|
+
assert r_r1.equals(r_r2)
|
285
|
+
end
|
286
|
+
def test_gsl_complex_arcsec()
|
287
|
+
v54 = GSL_Complex.create
|
288
|
+
v54.set(2.0,2.0)
|
289
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arcsec(v54)
|
290
|
+
r_r2 = GSL_Complex.new
|
291
|
+
r_r2.set(1.32627416165936,0.254895573340551)
|
292
|
+
assert r_r1.equals(r_r2)
|
293
|
+
end
|
294
|
+
def test_gsl_complex_sub_imag()
|
295
|
+
v22 = GSL_Complex.create
|
296
|
+
v22.set(2.0,2.0)
|
297
|
+
|
298
|
+
v23 = 2.0
|
299
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_sub_imag(v22,v23)
|
300
|
+
r_r2 = GSL_Complex.new
|
301
|
+
r_r2.set(2,0)
|
302
|
+
assert r_r1.equals(r_r2)
|
303
|
+
end
|
304
|
+
def test_gsl_complex_arcsin()
|
305
|
+
v50 = GSL_Complex.create
|
306
|
+
v50.set(2.0,2.0)
|
307
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arcsin(v50)
|
308
|
+
r_r2 = GSL_Complex.new
|
309
|
+
r_r2.set(0.754249144698046,1.73432452148797)
|
310
|
+
assert r_r1.equals(r_r2)
|
311
|
+
end
|
312
|
+
def test_gsl_complex_arg()
|
313
|
+
v1 = GSL_Complex.create
|
314
|
+
v1.set(2.0,2.0)
|
315
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arg(v1)
|
316
|
+
assert_in_delta r_r1, 0.785398163397448, EPSILON
|
317
|
+
end
|
318
|
+
def test_gsl_complex_arctanh()
|
319
|
+
v71 = GSL_Complex.create
|
320
|
+
v71.set(2.0,2.0)
|
321
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arctanh(v71)
|
322
|
+
r_r2 = GSL_Complex.new
|
323
|
+
r_r2.set(0.238877861256859,1.31122326967164)
|
324
|
+
assert r_r1.equals(r_r2)
|
325
|
+
end
|
326
|
+
def test_gsl_complex_sub_real()
|
327
|
+
v14 = GSL_Complex.create
|
328
|
+
v14.set(2.0,2.0)
|
329
|
+
|
330
|
+
v15 = 2.0
|
331
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_sub_real(v14,v15)
|
332
|
+
r_r2 = GSL_Complex.new
|
333
|
+
r_r2.set(0,2)
|
334
|
+
assert r_r1.equals(r_r2)
|
335
|
+
end
|
336
|
+
def test_gsl_complex_sec()
|
337
|
+
v46 = GSL_Complex.create
|
338
|
+
v46.set(2.0,2.0)
|
339
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_sec(v46)
|
340
|
+
r_r2 = GSL_Complex.new
|
341
|
+
r_r2.set(-0.117475142661415,0.24745418582076)
|
342
|
+
assert r_r1.equals(r_r2)
|
343
|
+
end
|
344
|
+
def test_gsl_complex_arccosh()
|
345
|
+
v67 = GSL_Complex.create
|
346
|
+
v67.set(2.0,2.0)
|
347
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arccosh(v67)
|
348
|
+
r_r2 = GSL_Complex.new
|
349
|
+
r_r2.set(1.73432452148797,0.816547182096851)
|
350
|
+
assert r_r1.equals(r_r2)
|
351
|
+
end
|
352
|
+
def test_gsl_complex_sub()
|
353
|
+
v6 = GSL_Complex.create
|
354
|
+
v6.set(2.0,2.0)
|
355
|
+
v7 = GSL_Complex.create
|
356
|
+
v7.set(2.0,2.0)
|
357
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_sub(v6,v7)
|
358
|
+
r_r2 = GSL_Complex.new
|
359
|
+
r_r2.set(0,0)
|
360
|
+
assert r_r1.equals(r_r2)
|
361
|
+
end
|
362
|
+
def test_gsl_complex_log10()
|
363
|
+
v41 = GSL_Complex.create
|
364
|
+
v41.set(2.0,2.0)
|
365
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_log10(v41)
|
366
|
+
r_r2 = GSL_Complex.new
|
367
|
+
r_r2.set(0.451544993495972,0.34109408846046)
|
368
|
+
assert r_r1.equals(r_r2)
|
369
|
+
end
|
370
|
+
def test_gsl_complex_csch()
|
371
|
+
v63 = GSL_Complex.create
|
372
|
+
v63.set(2.0,2.0)
|
373
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_csch(v63)
|
374
|
+
r_r2 = GSL_Complex.new
|
375
|
+
r_r2.set(-0.107954592221385,-0.244687073586957)
|
376
|
+
assert r_r1.equals(r_r2)
|
377
|
+
end
|
378
|
+
def test_gsl_complex_pow()
|
379
|
+
v35 = GSL_Complex.create
|
380
|
+
v35.set(2.0,2.0)
|
381
|
+
v36 = GSL_Complex.create
|
382
|
+
v36.set(2.0,2.0)
|
383
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_pow(v35,v36)
|
384
|
+
r_r2 = GSL_Complex.new
|
385
|
+
r_r2.set(-1.4525046270557,-0.8098895463353)
|
386
|
+
assert r_r1.equals(r_r2)
|
387
|
+
end
|
388
|
+
def test_gsl_complex_arccot()
|
389
|
+
v59 = GSL_Complex.create
|
390
|
+
v59.set(2.0,2.0)
|
391
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arccot(v59)
|
392
|
+
r_r2 = GSL_Complex.new
|
393
|
+
r_r2.set(0.259573057123261,-0.238877861256859)
|
394
|
+
assert r_r1.equals(r_r2)
|
395
|
+
end
|
396
|
+
def test_gsl_complex_negative()
|
397
|
+
v30 = GSL_Complex.create
|
398
|
+
v30.set(2.0,2.0)
|
399
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_negative(v30)
|
400
|
+
r_r2 = GSL_Complex.new
|
401
|
+
r_r2.set(-2,-2)
|
402
|
+
assert r_r1.equals(r_r2)
|
403
|
+
end
|
404
|
+
def test_gsl_complex_arcsec_real()
|
405
|
+
|
406
|
+
v55 = 2.0
|
407
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arcsec_real(v55)
|
408
|
+
r_r2 = GSL_Complex.new
|
409
|
+
r_r2.set(1.0471975511966,0)
|
410
|
+
assert r_r1.equals(r_r2)
|
411
|
+
end
|
412
|
+
def test_gsl_complex_mul_imag()
|
413
|
+
v24 = GSL_Complex.create
|
414
|
+
v24.set(2.0,2.0)
|
415
|
+
|
416
|
+
v25 = 2.0
|
417
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_mul_imag(v24,v25)
|
418
|
+
r_r2 = GSL_Complex.new
|
419
|
+
r_r2.set(-4,4)
|
420
|
+
assert r_r1.equals(r_r2)
|
421
|
+
end
|
422
|
+
def test_gsl_complex_arcsin_real()
|
423
|
+
|
424
|
+
v51 = 2.0
|
425
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arcsin_real(v51)
|
426
|
+
r_r2 = GSL_Complex.new
|
427
|
+
r_r2.set(1.5707963267949,-1.31695789692482)
|
428
|
+
assert r_r1.equals(r_r2)
|
429
|
+
end
|
430
|
+
def test_gsl_complex_abs()
|
431
|
+
v2 = GSL_Complex.create
|
432
|
+
v2.set(2.0,2.0)
|
433
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_abs(v2)
|
434
|
+
assert_in_delta r_r1, 2.82842712474619, EPSILON
|
435
|
+
end
|
436
|
+
def test_gsl_complex_arctanh_real()
|
437
|
+
|
438
|
+
v72 = 2.0
|
439
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arctanh_real(v72)
|
440
|
+
r_r2 = GSL_Complex.new
|
441
|
+
r_r2.set(0.549306144334055,-1.5707963267949)
|
442
|
+
assert r_r1.equals(r_r2)
|
443
|
+
end
|
444
|
+
def test_gsl_complex_mul_real()
|
445
|
+
v16 = GSL_Complex.create
|
446
|
+
v16.set(2.0,2.0)
|
447
|
+
|
448
|
+
v17 = 2.0
|
449
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_mul_real(v16,v17)
|
450
|
+
r_r2 = GSL_Complex.new
|
451
|
+
r_r2.set(4,4)
|
452
|
+
assert r_r1.equals(r_r2)
|
453
|
+
end
|
454
|
+
def test_gsl_complex_csc()
|
455
|
+
v47 = GSL_Complex.create
|
456
|
+
v47.set(2.0,2.0)
|
457
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_csc(v47)
|
458
|
+
r_r2 = GSL_Complex.new
|
459
|
+
r_r2.set(0.244687073586957,0.107954592221385)
|
460
|
+
assert r_r1.equals(r_r2)
|
461
|
+
end
|
462
|
+
def test_gsl_complex_arccosh_real()
|
463
|
+
|
464
|
+
v68 = 2.0
|
465
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_arccosh_real(v68)
|
466
|
+
r_r2 = GSL_Complex.new
|
467
|
+
r_r2.set(1.31695789692482,0)
|
468
|
+
assert r_r1.equals(r_r2)
|
469
|
+
end
|
470
|
+
def test_gsl_complex_mul()
|
471
|
+
v8 = GSL_Complex.create
|
472
|
+
v8.set(2.0,2.0)
|
473
|
+
v9 = GSL_Complex.create
|
474
|
+
v9.set(2.0,2.0)
|
475
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_mul(v8,v9)
|
476
|
+
r_r2 = GSL_Complex.new
|
477
|
+
r_r2.set(0,8)
|
478
|
+
assert r_r1.equals(r_r2)
|
479
|
+
end
|
480
|
+
def test_gsl_complex_log_b()
|
481
|
+
v42 = GSL_Complex.create
|
482
|
+
v42.set(2.0,2.0)
|
483
|
+
v43 = GSL_Complex.create
|
484
|
+
v43.set(2.0,2.0)
|
485
|
+
r_r1 = ::GSL4r::Complex::Methods::gsl_complex_log_b(v42,v43)
|
486
|
+
r_r2 = GSL_Complex.new
|
487
|
+
r_r2.set(1,0)
|
488
|
+
assert r_r1.equals(r_r2)
|
489
|
+
end
|
490
|
+
end
|