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 +4 -4
- data/README.md +3 -30
- data/lib/dydx.rb +7 -7
- data/lib/dydx/api.rb +16 -0
- data/lib/dydx/function.rb +9 -0
- data/lib/dydx/version.rb +1 -1
- data/spec/dydx_spec.rb +7 -0
- data/spec/lib/function_spec.rb +5 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fb2cc411ba1a3f064111073b75e1c9d9238fc09
|
4
|
+
data.tar.gz: 40e0a6bbcb3e9aab50986dfd939b0b889318c3ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dedb117f68c38f55cc9ac145092dcc876c043323282f1dc84dabfdbfdbe49a3184e69ca96bed61d7b5eca7742d8d0472125b01faa213f708db9587db19d89306
|
7
|
+
data.tar.gz: b393c043a34db3e0753a6a07bb34bd5b233df880313b8c854e0405df0e6d5b0c820546020c923603c10da99cd0ff576f111b8c05e48fa81be29467d5bb16be8e
|
data/README.md
CHANGED
@@ -1,16 +1,14 @@
|
|
1
|
-
#
|
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
|
-
|
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
|
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
|
|
data/lib/dydx.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
|
data/lib/dydx/api.rb
ADDED
@@ -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
|
data/lib/dydx/function.rb
CHANGED
@@ -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
|
data/lib/dydx/version.rb
CHANGED
data/spec/dydx_spec.rb
CHANGED
@@ -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
|
data/spec/lib/function_spec.rb
CHANGED
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.
|
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-
|
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.
|
125
|
+
rubygems_version: 2.2.2
|
125
126
|
signing_key:
|
126
127
|
specification_version: 4
|
127
128
|
summary: We can enjoy the math.
|