rubysl-complex 1.0.0
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 +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE +25 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/complex.rb +1 -0
- data/lib/rubysl/complex.rb +2 -0
- data/lib/rubysl/complex/complex.rb +659 -0
- data/lib/rubysl/complex/version.rb +5 -0
- data/rubysl-complex.gemspec +23 -0
- data/spec/Complex_spec.rb +9 -0
- data/spec/abs2_spec.rb +10 -0
- data/spec/abs_spec.rb +10 -0
- data/spec/angle_spec.rb +7 -0
- data/spec/arg_spec.rb +7 -0
- data/spec/coerce_spec.rb +11 -0
- data/spec/comparison_spec.rb +23 -0
- data/spec/conj_spec.rb +7 -0
- data/spec/conjugate_spec.rb +7 -0
- data/spec/constants_spec.rb +9 -0
- data/spec/denominator_spec.rb +20 -0
- data/spec/divide_spec.rb +9 -0
- data/spec/equal_value_spec.rb +9 -0
- data/spec/exponent_spec.rb +10 -0
- data/spec/float/angle_spec.rb +9 -0
- data/spec/float/arg_spec.rb +9 -0
- data/spec/generic_spec.rb +25 -0
- data/spec/hash_spec.rb +10 -0
- data/spec/imag_spec.rb +10 -0
- data/spec/image_spec.rb +7 -0
- data/spec/inspect_spec.rb +10 -0
- data/spec/math/acos_spec.rb +30 -0
- data/spec/math/acosh_spec.rb +30 -0
- data/spec/math/asin_spec.rb +30 -0
- data/spec/math/asinh_spec.rb +30 -0
- data/spec/math/atan2_spec.rb +30 -0
- data/spec/math/atan_spec.rb +30 -0
- data/spec/math/atanh_spec.rb +34 -0
- data/spec/math/cos_spec.rb +30 -0
- data/spec/math/cosh_spec.rb +30 -0
- data/spec/math/exp_spec.rb +30 -0
- data/spec/math/fixtures/classes.rb +3 -0
- data/spec/math/log10_spec.rb +30 -0
- data/spec/math/log_spec.rb +30 -0
- data/spec/math/shared/acos.rb +41 -0
- data/spec/math/shared/acosh.rb +37 -0
- data/spec/math/shared/asin.rb +47 -0
- data/spec/math/shared/asinh.rb +32 -0
- data/spec/math/shared/atan.rb +32 -0
- data/spec/math/shared/atan2.rb +34 -0
- data/spec/math/shared/atanh.rb +30 -0
- data/spec/math/shared/cos.rb +30 -0
- data/spec/math/shared/cosh.rb +28 -0
- data/spec/math/shared/exp.rb +28 -0
- data/spec/math/shared/log.rb +39 -0
- data/spec/math/shared/log10.rb +41 -0
- data/spec/math/shared/sin.rb +30 -0
- data/spec/math/shared/sinh.rb +28 -0
- data/spec/math/shared/sqrt.rb +34 -0
- data/spec/math/shared/tan.rb +28 -0
- data/spec/math/shared/tanh.rb +32 -0
- data/spec/math/sin_spec.rb +30 -0
- data/spec/math/sinh_spec.rb +30 -0
- data/spec/math/sqrt_spec.rb +30 -0
- data/spec/math/tan_spec.rb +30 -0
- data/spec/math/tanh_spec.rb +30 -0
- data/spec/minus_spec.rb +9 -0
- data/spec/modulo_spec.rb +29 -0
- data/spec/multiply_spec.rb +9 -0
- data/spec/new_spec.rb +41 -0
- data/spec/numerator_spec.rb +12 -0
- data/spec/numeric/angle_spec.rb +11 -0
- data/spec/numeric/arg_spec.rb +11 -0
- data/spec/numeric/conj_spec.rb +11 -0
- data/spec/numeric/conjugate_spec.rb +11 -0
- data/spec/numeric/im_spec.rb +9 -0
- data/spec/numeric/imag_spec.rb +11 -0
- data/spec/numeric/image_spec.rb +11 -0
- data/spec/numeric/polar_spec.rb +11 -0
- data/spec/numeric/real_spec.rb +11 -0
- data/spec/plus_spec.rb +9 -0
- data/spec/polar_spec.rb +13 -0
- data/spec/real_spec.rb +10 -0
- data/spec/to_s_spec.rb +9 -0
- metadata +259 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require './lib/rubysl/complex/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "rubysl-complex"
|
6
|
+
spec.version = RubySL::Complex::VERSION
|
7
|
+
spec.authors = ["Brian Shirai"]
|
8
|
+
spec.email = ["brixen@gmail.com"]
|
9
|
+
spec.description = %q{Ruby standard library complex.}
|
10
|
+
spec.summary = %q{Ruby standard library complex.}
|
11
|
+
spec.homepage = "https://github.com/rubysl/rubysl-complex"
|
12
|
+
spec.license = "BSD"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
+
spec.add_development_dependency "mspec", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
|
23
|
+
end
|
data/spec/abs2_spec.rb
ADDED
data/spec/abs_spec.rb
ADDED
data/spec/angle_spec.rb
ADDED
data/spec/arg_spec.rb
ADDED
data/spec/coerce_spec.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
ruby_version_is ""..."1.9" do
|
3
|
+
|
4
|
+
require 'complex'
|
5
|
+
|
6
|
+
describe "Complex#<=>" do
|
7
|
+
it "compares the absolute values of self and other" do
|
8
|
+
(Complex(1, 2) <=> Complex(2, 1)).should == 0
|
9
|
+
(Complex(-3, -10) <=> Complex(2, 1)).should > 0
|
10
|
+
(Complex(3, 5) <=> Complex(100.0, -190.5)).should < 0
|
11
|
+
|
12
|
+
(Complex(3, 4) <=> 5).should == 0
|
13
|
+
(Complex(3, 4) <=> -5).should == 0
|
14
|
+
(Complex(-3, -4) <=> -5).should == 0
|
15
|
+
|
16
|
+
(Complex(3, 4) <=> 6).should < 0
|
17
|
+
(Complex(3, 4) <=> -4).should > 0
|
18
|
+
|
19
|
+
(Complex(3, 4) <=> 6.0).should < 0
|
20
|
+
(Complex(3, 4) <=> -4.0).should > 0
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/conj_spec.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path('../../../shared/complex/denominator', __FILE__)
|
2
|
+
|
3
|
+
ruby_version_is ""..."1.9" do
|
4
|
+
|
5
|
+
require 'complex'
|
6
|
+
|
7
|
+
# FIXME:
|
8
|
+
# Complex#denominator requires the rational library,
|
9
|
+
# as Integer#denominator is defined by it.
|
10
|
+
# I think this method is pretty buggy, as there is no
|
11
|
+
# denominator for Floats and rational might not always
|
12
|
+
# be loaded, both resulting in a method missing exception.
|
13
|
+
# Also, the documentation for Complex#denominator does
|
14
|
+
# not mention a dependency for rational.
|
15
|
+
require "rational"
|
16
|
+
|
17
|
+
describe "Complex#denominator" do
|
18
|
+
it_behaves_like(:complex_denominator, :denominator)
|
19
|
+
end
|
20
|
+
end
|
data/spec/divide_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
ruby_version_is ""..."1.9" do
|
2
|
+
|
3
|
+
require 'complex'
|
4
|
+
require "rational"
|
5
|
+
|
6
|
+
describe "Complex.generic?" do
|
7
|
+
it "returns true when given an Integer, Float or Rational" do
|
8
|
+
Complex.generic?(1).should == true
|
9
|
+
Complex.generic?(-1).should == true
|
10
|
+
|
11
|
+
Complex.generic?(20.3).should == true
|
12
|
+
Complex.generic?(-20.3).should == true
|
13
|
+
|
14
|
+
Complex.generic?(bignum_value).should == true
|
15
|
+
Complex.generic?(-bignum_value).should == true
|
16
|
+
|
17
|
+
Complex.generic?(Rational(3, 4)).should == true
|
18
|
+
Complex.generic?(-Rational(3, 4)).should == true
|
19
|
+
|
20
|
+
Complex.generic?(:symbol).should == false
|
21
|
+
Complex.generic?("string").should == false
|
22
|
+
Complex.generic?(mock("Object")).should == false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/hash_spec.rb
ADDED
data/spec/imag_spec.rb
ADDED
data/spec/image_spec.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'complex'
|
2
|
+
require File.expand_path('../shared/acos', __FILE__)
|
3
|
+
|
4
|
+
describe "Math#acos" do
|
5
|
+
it_behaves_like :complex_math_acos, :_, IncludesMath.new
|
6
|
+
|
7
|
+
it "is a private instance method" do
|
8
|
+
IncludesMath.should have_private_instance_method(:acos)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ruby_version_is ""..."1.9" do
|
13
|
+
describe "Math#acos!" do
|
14
|
+
it_behaves_like :complex_math_acos_bang, :_, IncludesMath.new
|
15
|
+
|
16
|
+
it "is a private instance method" do
|
17
|
+
IncludesMath.should have_private_instance_method(:acos!)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Math.acos" do
|
23
|
+
it_behaves_like :complex_math_acos, :_, Math
|
24
|
+
end
|
25
|
+
|
26
|
+
ruby_version_is ""..."1.9" do
|
27
|
+
describe "Math.acos!" do
|
28
|
+
it_behaves_like :complex_math_acos_bang, :_, Math
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'complex'
|
2
|
+
require File.expand_path('../shared/acosh', __FILE__)
|
3
|
+
|
4
|
+
describe "Math#acosh" do
|
5
|
+
it_behaves_like :complex_math_acosh, :_, IncludesMath.new
|
6
|
+
|
7
|
+
it "is a private instance method" do
|
8
|
+
IncludesMath.should have_private_instance_method(:acosh)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ruby_version_is ""..."1.9" do
|
13
|
+
describe "Math#acosh!" do
|
14
|
+
it_behaves_like :complex_math_acosh_bang, :_, IncludesMath.new
|
15
|
+
|
16
|
+
it "is a private instance method" do
|
17
|
+
IncludesMath.should have_private_instance_method(:acosh!)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Math.acosh" do
|
23
|
+
it_behaves_like :complex_math_acosh, :_, Math
|
24
|
+
end
|
25
|
+
|
26
|
+
ruby_version_is ""..."1.9" do
|
27
|
+
describe "Math.acosh!" do
|
28
|
+
it_behaves_like :complex_math_acosh_bang, :_, Math
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'complex'
|
2
|
+
require File.expand_path('../shared/asin', __FILE__)
|
3
|
+
|
4
|
+
describe "Math#asin" do
|
5
|
+
it_behaves_like :complex_math_asin, :_, IncludesMath.new
|
6
|
+
|
7
|
+
it "is a private instance method" do
|
8
|
+
IncludesMath.should have_private_instance_method(:asin)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ruby_version_is ""..."1.9" do
|
13
|
+
describe "Math#asin!" do
|
14
|
+
it_behaves_like :complex_math_asin_bang, :_, IncludesMath.new
|
15
|
+
|
16
|
+
it "is a private instance method" do
|
17
|
+
IncludesMath.should have_private_instance_method(:asin!)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Math.asin" do
|
23
|
+
it_behaves_like :complex_math_asin, :_, Math
|
24
|
+
end
|
25
|
+
|
26
|
+
ruby_version_is ""..."1.9" do
|
27
|
+
describe "Math.asin!" do
|
28
|
+
it_behaves_like :complex_math_asin_bang, :_, Math
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'complex'
|
2
|
+
require File.expand_path('../shared/asinh', __FILE__)
|
3
|
+
|
4
|
+
describe "Math#asinh" do
|
5
|
+
it_behaves_like :complex_math_asinh, :_, IncludesMath.new
|
6
|
+
|
7
|
+
it "is a private instance method" do
|
8
|
+
IncludesMath.should have_private_instance_method(:asinh)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ruby_version_is ""..."1.9" do
|
13
|
+
describe "Math#asinh!" do
|
14
|
+
it_behaves_like :complex_math_asinh_bang, :_, IncludesMath.new
|
15
|
+
|
16
|
+
it "is a private instance method" do
|
17
|
+
IncludesMath.should have_private_instance_method(:asinh!)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Math.asinh" do
|
23
|
+
it_behaves_like :complex_math_asinh, :_, Math
|
24
|
+
end
|
25
|
+
|
26
|
+
ruby_version_is ""..."1.9" do
|
27
|
+
describe "Math.asinh!" do
|
28
|
+
it_behaves_like :complex_math_asinh_bang, :_, Math
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'complex'
|
2
|
+
require File.expand_path('../shared/atan2', __FILE__)
|
3
|
+
|
4
|
+
describe "Math#atan2" do
|
5
|
+
it_behaves_like :complex_math_atan2, :_, IncludesMath.new
|
6
|
+
|
7
|
+
it "is a private instance method" do
|
8
|
+
IncludesMath.should have_private_instance_method(:atan2)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ruby_version_is ""..."1.9" do
|
13
|
+
describe "Math#atan2!" do
|
14
|
+
it_behaves_like :complex_math_atan2_bang, :_, IncludesMath.new
|
15
|
+
|
16
|
+
it "is a private instance method" do
|
17
|
+
IncludesMath.should have_private_instance_method(:atan2!)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Math.atan2" do
|
23
|
+
it_behaves_like :complex_math_atan2, :_, Math
|
24
|
+
end
|
25
|
+
|
26
|
+
ruby_version_is ""..."1.9" do
|
27
|
+
describe "Math.atan2!" do
|
28
|
+
it_behaves_like :complex_math_atan2_bang, :_, Math
|
29
|
+
end
|
30
|
+
end
|