dydx 0.1.31 → 0.1.314

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -59
  3. data/lib/dydx.rb +7 -4
  4. data/lib/dydx/algebra.rb +0 -66
  5. data/lib/dydx/algebra/formula.rb +15 -2
  6. data/lib/dydx/algebra/inverse.rb +14 -0
  7. data/lib/dydx/algebra/set.rb +253 -19
  8. data/lib/dydx/helper.rb +5 -0
  9. data/lib/dydx/integrand.rb +7 -2
  10. data/lib/dydx/version.rb +1 -1
  11. data/spec/dydx_spec.rb +10 -29
  12. data/spec/lib/algebra/formula_spec.rb +6 -0
  13. data/spec/lib/algebra/set_spec.rb +227 -0
  14. data/spec/lib/delta_spec.rb +26 -0
  15. data/spec/lib/function_spec.rb +61 -33
  16. data/spec/lib/integrand_spec.rb +2 -2
  17. metadata +4 -40
  18. data/lib/dydx/algebra/operator.rb +0 -5
  19. data/lib/dydx/algebra/set/base.rb +0 -9
  20. data/lib/dydx/algebra/set/cos.rb +0 -22
  21. data/lib/dydx/algebra/set/e.rb +0 -16
  22. data/lib/dydx/algebra/set/fixnum.rb +0 -14
  23. data/lib/dydx/algebra/set/float.rb +0 -14
  24. data/lib/dydx/algebra/set/log.rb +0 -22
  25. data/lib/dydx/algebra/set/log10.rb +0 -22
  26. data/lib/dydx/algebra/set/log2.rb +0 -22
  27. data/lib/dydx/algebra/set/num.rb +0 -22
  28. data/lib/dydx/algebra/set/pi.rb +0 -16
  29. data/lib/dydx/algebra/set/sin.rb +0 -22
  30. data/lib/dydx/algebra/set/symbol.rb +0 -14
  31. data/lib/dydx/algebra/set/tan.rb +0 -17
  32. data/spec/lib/algebra/set/cos_spec.rb +0 -18
  33. data/spec/lib/algebra/set/e_spec.rb +0 -27
  34. data/spec/lib/algebra/set/fixnum_spec.rb +0 -65
  35. data/spec/lib/algebra/set/float_spec.rb +0 -65
  36. data/spec/lib/algebra/set/log10_spec.rb +0 -16
  37. data/spec/lib/algebra/set/log2_spec.rb +0 -16
  38. data/spec/lib/algebra/set/log_spec.rb +0 -15
  39. data/spec/lib/algebra/set/num_spec.rb +0 -23
  40. data/spec/lib/algebra/set/pi_spec.rb +0 -25
  41. data/spec/lib/algebra/set/sin_spec.rb +0 -14
  42. data/spec/lib/algebra/set/symbol_spec.rb +0 -22
  43. data/spec/lib/algebra/set/tan_spec.rb +0 -13
@@ -20,12 +20,12 @@ describe Dydx:Integrand do
20
20
 
21
21
  it 'ex3' do
22
22
  f(x) <= sin(x)
23
- expect(S(f(x), dx)[0, Math::PI/2]).to eq(1.0)
23
+ expect(S(f(x), dx)[0, pi / 2]).to eq(1.0)
24
24
  end
25
25
 
26
26
  it 'ex4' do
27
27
  f(x) <= cos(x)
28
- expect(S(f(x), dx)[0, Math::PI]).to eq(0.0)
28
+ expect(S(f(x), dx)[0, pi]).to eq(0.0)
29
29
  end
30
30
 
31
31
  it 'ex5' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dydx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.31
4
+ version: 0.1.314
5
5
  platform: ruby
6
6
  authors:
7
7
  - gogotanaka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-31 00:00:00.000000000 Z
11
+ date: 2014-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,7 +73,6 @@ files:
73
73
  - lib/dydx/algebra.rb
74
74
  - lib/dydx/algebra/formula.rb
75
75
  - lib/dydx/algebra/inverse.rb
76
- - lib/dydx/algebra/operator.rb
77
76
  - lib/dydx/algebra/operator/formula.rb
78
77
  - lib/dydx/algebra/operator/general.rb
79
78
  - lib/dydx/algebra/operator/inverse.rb
@@ -87,19 +86,6 @@ files:
87
86
  - lib/dydx/algebra/operator/parts/num.rb
88
87
  - lib/dydx/algebra/operator/parts/symbol.rb
89
88
  - lib/dydx/algebra/set.rb
90
- - lib/dydx/algebra/set/base.rb
91
- - lib/dydx/algebra/set/cos.rb
92
- - lib/dydx/algebra/set/e.rb
93
- - lib/dydx/algebra/set/fixnum.rb
94
- - lib/dydx/algebra/set/float.rb
95
- - lib/dydx/algebra/set/log.rb
96
- - lib/dydx/algebra/set/log10.rb
97
- - lib/dydx/algebra/set/log2.rb
98
- - lib/dydx/algebra/set/num.rb
99
- - lib/dydx/algebra/set/pi.rb
100
- - lib/dydx/algebra/set/sin.rb
101
- - lib/dydx/algebra/set/symbol.rb
102
- - lib/dydx/algebra/set/tan.rb
103
89
  - lib/dydx/delta.rb
104
90
  - lib/dydx/function.rb
105
91
  - lib/dydx/helper.rb
@@ -110,18 +96,7 @@ files:
110
96
  - spec/lib/algebra/operator/parts/base_spec.rb
111
97
  - spec/lib/algebra/operator/parts/formula_spec.rb
112
98
  - spec/lib/algebra/operator/parts/inverse_spec.rb
113
- - spec/lib/algebra/set/cos_spec.rb
114
- - spec/lib/algebra/set/e_spec.rb
115
- - spec/lib/algebra/set/fixnum_spec.rb
116
- - spec/lib/algebra/set/float_spec.rb
117
- - spec/lib/algebra/set/log10_spec.rb
118
- - spec/lib/algebra/set/log2_spec.rb
119
- - spec/lib/algebra/set/log_spec.rb
120
- - spec/lib/algebra/set/num_spec.rb
121
- - spec/lib/algebra/set/pi_spec.rb
122
- - spec/lib/algebra/set/sin_spec.rb
123
- - spec/lib/algebra/set/symbol_spec.rb
124
- - spec/lib/algebra/set/tan_spec.rb
99
+ - spec/lib/algebra/set_spec.rb
125
100
  - spec/lib/delta_spec.rb
126
101
  - spec/lib/function_spec.rb
127
102
  - spec/lib/helper_spec.rb
@@ -157,18 +132,7 @@ test_files:
157
132
  - spec/lib/algebra/operator/parts/base_spec.rb
158
133
  - spec/lib/algebra/operator/parts/formula_spec.rb
159
134
  - spec/lib/algebra/operator/parts/inverse_spec.rb
160
- - spec/lib/algebra/set/cos_spec.rb
161
- - spec/lib/algebra/set/e_spec.rb
162
- - spec/lib/algebra/set/fixnum_spec.rb
163
- - spec/lib/algebra/set/float_spec.rb
164
- - spec/lib/algebra/set/log10_spec.rb
165
- - spec/lib/algebra/set/log2_spec.rb
166
- - spec/lib/algebra/set/log_spec.rb
167
- - spec/lib/algebra/set/num_spec.rb
168
- - spec/lib/algebra/set/pi_spec.rb
169
- - spec/lib/algebra/set/sin_spec.rb
170
- - spec/lib/algebra/set/symbol_spec.rb
171
- - spec/lib/algebra/set/tan_spec.rb
135
+ - spec/lib/algebra/set_spec.rb
172
136
  - spec/lib/delta_spec.rb
173
137
  - spec/lib/function_spec.rb
174
138
  - spec/lib/helper_spec.rb
@@ -1,5 +0,0 @@
1
- require 'dydx/algebra/operator/parts'
2
- require 'dydx/algebra/operator/inverse'
3
- require 'dydx/algebra/operator/formula'
4
- require 'dydx/algebra/operator/num'
5
- require 'dydx/algebra/operator/general'
@@ -1,9 +0,0 @@
1
- module Dydx
2
- module Algebra
3
- module Set
4
- class Base
5
- include Helper
6
- end
7
- end
8
- end
9
- end
@@ -1,22 +0,0 @@
1
- module Dydx
2
- module Algebra
3
- module Set
4
- class Cos < Base
5
- attr_accessor :x
6
-
7
- def initialize(x)
8
- @x = x
9
- end
10
-
11
- def to_s
12
- "cos( #{x.to_s} )"
13
- end
14
-
15
- def differentiate(sym=:x)
16
- -1 * sin(x) * x.d(sym)
17
- end
18
- alias_method :d, :differentiate
19
- end
20
- end
21
- end
22
- end
@@ -1,16 +0,0 @@
1
- module Dydx
2
- module Algebra
3
- module Set
4
- class E < Base
5
- def differentiate(sym=:x)
6
- e0
7
- end
8
- alias_method :d, :differentiate
9
-
10
- def to_s
11
- 'e'
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,14 +0,0 @@
1
- module Dydx
2
- module Algebra
3
- module Set
4
- Fixnum.class_eval do
5
- include Helper
6
-
7
- def differentiate(sym=:x)
8
- e0
9
- end
10
- alias_method :d, :differentiate
11
- end
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- module Dydx
2
- module Algebra
3
- module Set
4
- Float.class_eval do
5
- include Helper
6
-
7
- def differentiate(sym=:x)
8
- e0
9
- end
10
- alias_method :d, :differentiate
11
- end
12
- end
13
- end
14
- end
@@ -1,22 +0,0 @@
1
- module Dydx
2
- module Algebra
3
- module Set
4
- class Log < Base
5
- attr_accessor :f
6
-
7
- def initialize(f)
8
- @f = f
9
- end
10
-
11
- def differentiate(sym=:x)
12
- f.d(sym) / (f)
13
- end
14
- alias_method :d, :differentiate
15
-
16
- def to_s
17
- "log( #{f.to_s} )"
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,22 +0,0 @@
1
- module Dydx
2
- module Algebra
3
- module Set
4
- class Log10 < Base
5
- attr_accessor :f
6
-
7
- def initialize(f)
8
- @f = f
9
- end
10
-
11
- def to_s
12
- "log10( #{f.to_s} )"
13
- end
14
-
15
- def differentiate(sym=:x)
16
- f.d(sym) / (f * log(10))
17
- end
18
- alias_method :d, :differentiate
19
- end
20
- end
21
- end
22
- end
@@ -1,22 +0,0 @@
1
- module Dydx
2
- module Algebra
3
- module Set
4
- class Log2 < Base
5
- attr_accessor :f
6
-
7
- def initialize(f)
8
- @f = f
9
- end
10
-
11
- def to_s
12
- "log2( #{f.to_s} )"
13
- end
14
-
15
- def differentiate(sym=:x)
16
- f.d(sym) / (f * log(2))
17
- end
18
- alias_method :d, :differentiate
19
- end
20
- end
21
- end
22
- end
@@ -1,22 +0,0 @@
1
- module Dydx
2
- module Algebra
3
- module Set
4
- class Num < Base
5
- attr_accessor :n
6
-
7
- def initialize(n)
8
- @n = n
9
- end
10
-
11
- def differentiate(sym=:x)
12
- e0
13
- end
14
- alias_method :d, :differentiate
15
-
16
- def to_s
17
- @n.to_s
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,16 +0,0 @@
1
- module Dydx
2
- module Algebra
3
- module Set
4
- class Pi < Base
5
- def differentiate(sym=:x)
6
- _(0)
7
- end
8
- alias_method :d, :differentiate
9
-
10
- def to_s
11
- 'pi'
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,22 +0,0 @@
1
- module Dydx
2
- module Algebra
3
- module Set
4
- class Sin < Base
5
- attr_accessor :x
6
-
7
- def initialize(x)
8
- @x = x
9
- end
10
-
11
- def to_s
12
- "sin( #{x.to_s} )"
13
- end
14
-
15
- def differentiate(sym=:x)
16
- cos(x) * x.d(sym)
17
- end
18
- alias_method :d, :differentiate
19
- end
20
- end
21
- end
22
- end
@@ -1,14 +0,0 @@
1
- module Dydx
2
- module Algebra
3
- module Set
4
- Symbol.class_eval do
5
- include Helper
6
-
7
- def differentiate(sym=:x)
8
- self == sym ? e1 : e0
9
- end
10
- alias_method :d, :differentiate
11
- end
12
- end
13
- end
14
- end
@@ -1,17 +0,0 @@
1
- module Dydx
2
- module Algebra
3
- module Set
4
- class Tan < Base
5
- attr_accessor :x
6
-
7
- def initialize(x)
8
- @x = x
9
- end
10
-
11
- def to_s
12
- "tan( #{x.to_s} )"
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dydx::Algebra::Set::Cos do
4
- it{ expect(cos(0).to_s).to eq('1') }
5
- it{ expect(cos(pi).to_s).to eq('-1') }
6
- it{ expect(cos(2 * pi).to_s).to eq('1') }
7
-
8
- describe '#to_s' do
9
- it{ expect(cos(:x).to_s).to eq('cos( x )') }
10
- end
11
-
12
- describe '#differentiate' do
13
- it{ expect(cos(:x).d.to_s).to eq('( - sin( x ) )') }
14
- end
15
-
16
- describe 'Calculate' do
17
- end
18
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dydx::Algebra::Set::E do
4
- it{ expect(e).to eq(e) }
5
-
6
- describe '#to_s' do
7
- it{ expect(e.to_s).to eq('e') }
8
- end
9
-
10
- describe '#differentiate' do
11
- it{ expect(e.d(:x).to_s).to eq(_(0).to_s) }
12
- it{ expect((e ^ :x).d(:x).to_s).to eq('( e ^ x )') }
13
- it{ expect((e ^ (:x + :y)).d(:x).to_s).to eq('( e ^ ( x + y ) )') }
14
- end
15
-
16
- describe 'Calculate' do
17
- context 'With Fixnum' do
18
- it{ expect(e + 0).to eq(e) }
19
- it{ expect(e - 0).to eq(e) }
20
- it{ expect((e * 0).to_s).to eq('0') }
21
- it{ expect(e * 1).to eq(e) }
22
- it{ expect{(e / 0).to_s}.to raise_error(ZeroDivisionError) }
23
- it{ expect(e / 1).to eq(e) }
24
- it{ expect((e ^ 0).to_s).to eq('1') }
25
- end
26
- end
27
- end
@@ -1,65 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Fixnum do
4
- describe '#to_s' do
5
- it{ expect(1.to_s).to eq('1') }
6
- end
7
-
8
- describe '#differentiate' do
9
- it{ expect(3.d(:x).to_s).to eq('0') }
10
- end
11
-
12
- describe 'Calculate' do
13
- context 'With Formula' do
14
- let(:formula) { (:x + :y) }
15
- it{ expect((0 + formula).to_s).to eq(formula.to_s) }
16
- it{ expect((0 - formula).to_s).to eq('( - ( x + y ) )') }
17
- it{ expect((0 * formula).to_s).to eq('0') }
18
- it{ expect((1 * formula).to_s).to eq(formula.to_s) }
19
- it{ expect((0 / formula).to_s).to eq('0') }
20
- it{ expect((1 / formula).to_s).to eq('( 1 / ( x + y ) )') }
21
- it{ expect((0 ^ formula).to_s).to eq('0') }
22
- it{ expect((1 ^ formula).to_s).to eq('1') }
23
- end
24
-
25
- context 'With Symbol' do
26
- it{ expect(0 + :x).to eq(:x) }
27
- it{ expect((0 - :x).to_s).to eq('( - x )') }
28
- it{ expect((0 * :x).to_s).to eq('0') }
29
- it{ expect(1 * :x).to eq(:x) }
30
- it{ expect((0 / :x).to_s).to eq('0') }
31
- it{ expect((1 / :x).to_s).to eq('( 1 / x )') }
32
- it{ expect((0 ^ :x).to_s).to eq('0') }
33
- it{ expect((1 ^ :x).to_s).to eq('1') }
34
- end
35
-
36
- context 'With Fixnum' do
37
- it{ expect(0 + 3).to eq(3) }
38
- it{ expect(3 + 0).to eq(3) }
39
- it{ expect(2 + 3).to eq(5) }
40
-
41
- it{ expect(0 - 3).to eq(-3) }
42
- it{ expect(3 - 0).to eq(3) }
43
- it{ expect(2 - 3).to eq(-1) }
44
-
45
- it{ expect(0 * 3).to eq(0) }
46
- it{ expect(3 * 0).to eq(0) }
47
- it{ expect(1 * 3).to eq(3) }
48
- it{ expect(3 * 1).to eq(3) }
49
- it{ expect(3 * 2).to eq(6) }
50
-
51
- it{ expect((0 / 3).to_s).to eq('0') }
52
- it{ expect{(3 / 0).to_s}.to raise_error(ZeroDivisionError) }
53
- it{ expect((3 / 1).to_s).to eq('3') }
54
- # TODO:
55
- it{ expect((2 / 3).to_s).to eq('0') }
56
-
57
-
58
- it{ expect((0 ^ 3).to_s).to eq('0') }
59
- it{ expect((3 ^ 0).to_s).to eq('1') }
60
- it{ expect((1 ^ 3).to_s).to eq('1') }
61
- it{ expect((3 ^ 1).to_s).to eq('3') }
62
- it{ expect((3 ^ 2).to_s).to eq('9') }
63
- end
64
- end
65
- end