dydx 0.1.41421 → 0.2.7000000

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 220e4986b77c2c86709b2fdd5c237c4bfdd14e7a
4
- data.tar.gz: fdf1336073d4c594af4ff01b1818d86790ee821d
3
+ metadata.gz: 0fb2cc411ba1a3f064111073b75e1c9d9238fc09
4
+ data.tar.gz: 40e0a6bbcb3e9aab50986dfd939b0b889318c3ed
5
5
  SHA512:
6
- metadata.gz: d0378ecf27babc0f72147e1c580d113aef606c4c75ce061df0bba1a98279615c6491900b7a9078f03cba499cd814c4574ab25b15fa572f17c0e41f64398074db
7
- data.tar.gz: 43e1aeee044edb2b3e23fbe4c1f4e541d07c3584bc30d73a76283705b49029c24961cbad68e50d9328bfd479ab6c509a5201eca1ab737934535555991d9396d7
6
+ metadata.gz: dedb117f68c38f55cc9ac145092dcc876c043323282f1dc84dabfdbfdbe49a3184e69ca96bed61d7b5eca7742d8d0472125b01faa213f708db9587db19d89306
7
+ data.tar.gz: b393c043a34db3e0753a6a07bb34bd5b233df880313b8c854e0405df0e6d5b0c820546020c923603c10da99cd0ff576f111b8c05e48fa81be29467d5bb16be8e
data/README.md CHANGED
@@ -1,16 +1,14 @@
1
- # Dydx is new MATH Language on Ruby.
1
+ # This gem is obsolete. See [Hilbert](https://github.com/gogotanaka/Hilbert)
2
2
 
3
3
  ### Since you report a bug, I will fix it within 24 hours.
4
4
 
5
5
  [![Build Status](https://travis-ci.org/gogotanaka/dydx.svg?branch=master)](https://travis-ci.org/gogotanaka/dydx)
6
6
 
7
- The most important thing in this DSL is
8
-
9
- we can handle math in the same sense sense of the math on paper.
7
+ Q makes it possible to enjoy mathematics on PC without losing the feeling that you can get from using Pen and Paper.
10
8
 
11
9
  ex. limit, trigonometric functions and logarithmic.
12
10
 
13
- ## We should enjoy MATH even using PC.
11
+ ## We can enjoy mathematics even using PC.
14
12
  (to say nothing of using pen.)
15
13
 
16
14
  After `inlcude Dydx` , ruby become like other language.
@@ -92,31 +90,6 @@ Dydx
92
90
  |- Integrand
93
91
  ```
94
92
 
95
- ## Installation
96
-
97
- Add this line to your application's Gemfile:
98
-
99
- gem 'dydx'
100
-
101
- And then execute:
102
-
103
- $ bundle
104
-
105
- Or install it yourself as:
106
-
107
- $ gem install dydx
108
-
109
- ## Usage
110
-
111
- include Dydx
112
-
113
- ## Contributing
114
-
115
- 1. Fork it ( https://github.com/gogotanaka/dydx/fork )
116
- 2. Create your feature branch (`git checkout -b my-new-feature`)
117
- 3. Commit your changes (`git commit -am 'Add some feature'`)
118
- 4. Push to the branch (`git push origin my-new-feature`)
119
- 5. Create a new Pull Request
120
93
 
121
94
  ## Test
122
95
 
@@ -4,6 +4,8 @@ require 'dydx/delta'
4
4
  require 'dydx/function'
5
5
  require 'dydx/integrand'
6
6
 
7
+ require 'dydx/api'
8
+
7
9
  module Dydx
8
10
  include Algebra
9
11
  %w(f g h temp_cal_f).each do |functioner|
@@ -11,15 +13,13 @@ module Dydx
11
13
  function = eval("$#{functioner}")
12
14
  return eval("$#{functioner} = Function.new(*vars)") unless function
13
15
 
14
- fail ArgumentError, "invalid number of values (#{vars.count} for #{function.vars.count})" unless function.vars.count == vars.count
16
+ unless function.vars.count == vars.count
17
+ fail ArgumentError, "invalid number of values (#{vars.count} for #{function.vars.count})"
18
+ end
19
+
15
20
  return function if function.vars == vars || !function.algebra
16
21
 
17
- subst_hash = Hash[*[function.vars, vars].transpose.flatten]
18
- begin
19
- function.algebra.subst(subst_hash).to_f
20
- rescue ArgumentError
21
- eval(function.algebra.subst(subst_hash).to_s)
22
- end
22
+ function.evalue(vars)
23
23
  end
24
24
  end
25
25
 
@@ -0,0 +1,16 @@
1
+ module Dydx
2
+ module API
3
+ class << self
4
+ def store_func(vars, formula, symbol)
5
+ func_obj = Function.new(*vars)
6
+ func_obj <=(formula)
7
+ eval("$#{symbol.to_s} = func_obj")
8
+ end
9
+
10
+ def eval_func(nums, symbol)
11
+ func = eval("$#{symbol.to_s}")
12
+ func.evalue(nums)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -10,6 +10,15 @@ module Dydx
10
10
  self
11
11
  end
12
12
 
13
+ def evalue(nums)
14
+ subst_hash = Hash[*[@vars, nums].transpose.flatten]
15
+ begin
16
+ @algebra.subst(subst_hash).to_f
17
+ rescue ArgumentError
18
+ eval(@algebra.subst(subst_hash).to_s)
19
+ end
20
+ end
21
+
13
22
  def differentiate(sym = :x)
14
23
  @algebra.differentiate(sym)
15
24
  end
@@ -1,3 +1,3 @@
1
1
  module Dydx
2
- VERSION = '0.1.41421'
2
+ VERSION = '0.2.7000000'
3
3
  end
@@ -17,4 +17,11 @@ describe Dydx do
17
17
  expect(d/dx(g(x))).to eq(cos(x))
18
18
  expect(S(g(x), dx)[0, pi / 2]).to eq(1.0)
19
19
  end
20
+
21
+ it 'API' do
22
+ expect(Dydx::API.store_func([x, y], x + y, :tmp)).not_to eq(nil)
23
+ expect(Dydx::API.eval_func([1,2], :tmp)).to eq(3.0)
24
+ expect(Dydx::API.store_func([:x], (1 + 1/x) ** x, :tmp)).not_to eq(nil)
25
+ expect(Dydx::API.eval_func([100000], :tmp)).to eq(2.7182682371744895)
26
+ end
20
27
  end
@@ -62,4 +62,9 @@ describe Dydx::Function do
62
62
  g(x) <= d/dx(f(x))
63
63
  expect(g(pi)).to eq(-1)
64
64
  end
65
+
66
+ it 'ex7' do
67
+ f(x) <= (1 + 1/x) ** x
68
+ expect(f(100000)).to eq(2.7182682371744895)
69
+ end
65
70
  end
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.41421
4
+ version: 0.2.7000000
5
5
  platform: ruby
6
6
  authors:
7
7
  - gogotanaka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-18 00:00:00.000000000 Z
11
+ date: 2014-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,6 +85,7 @@ files:
85
85
  - lib/dydx/algebra/operator/parts/num.rb
86
86
  - lib/dydx/algebra/operator/parts/symbol.rb
87
87
  - lib/dydx/algebra/set.rb
88
+ - lib/dydx/api.rb
88
89
  - lib/dydx/delta.rb
89
90
  - lib/dydx/function.rb
90
91
  - lib/dydx/helper.rb
@@ -121,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
122
  version: '0'
122
123
  requirements: []
123
124
  rubyforge_project:
124
- rubygems_version: 2.4.1
125
+ rubygems_version: 2.2.2
125
126
  signing_key:
126
127
  specification_version: 4
127
128
  summary: We can enjoy the math.