mathn 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/{LICENSE.txt → BSDL} +3 -3
- data/COPYING +56 -0
- data/LEGAL +60 -0
- data/README.md +46 -5
- data/lib/mathn/complex.rb +14 -0
- data/lib/mathn/rational.rb +14 -0
- data/lib/mathn.rb +114 -121
- metadata +13 -54
- data/.gitignore +0 -12
- data/.travis.yml +0 -5
- data/Gemfile +0 -4
- data/Rakefile +0 -16
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/ext/mathn/complex/complex.c +0 -7
- data/ext/mathn/complex/extconf.rb +0 -4
- data/ext/mathn/rational/extconf.rb +0 -4
- data/ext/mathn/rational/rational.c +0 -7
- data/mathn.gemspec +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8a6ea5b1a70a7d6b9db70b50924c925d5f39660de41e0929381de99daf75e9fb
|
4
|
+
data.tar.gz: 872cdbbec5bf3bd00445cb6e775ab20170bf6db86e0a1316c76359bd1acb544e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ff741cbf1014ae45507c4d83264e687bc0d4b28711dd00a75068c2e8f9a943f6b9a5a763963d6f9d14e3ca79e8bcbe1b58f6da5be7f08cd929dbb68f92d9265
|
7
|
+
data.tar.gz: 43838f787c3d818931fea2911ce2fd0b83a809398c398c1bdc5feeeadb1915b0dacd8511763fe7f89a290e3a67f9da2890dc0a2d5c6991e0eb59020f03a6f58f
|
data/{LICENSE.txt → BSDL}
RENAMED
@@ -4,10 +4,10 @@ Redistribution and use in source and binary forms, with or without
|
|
4
4
|
modification, are permitted provided that the following conditions
|
5
5
|
are met:
|
6
6
|
1. Redistributions of source code must retain the above copyright
|
7
|
-
notice, this list of conditions and the following disclaimer.
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
8
|
2. Redistributions in binary form must reproduce the above copyright
|
9
|
-
notice, this list of conditions and the following disclaimer in the
|
10
|
-
documentation and/or other materials provided with the distribution.
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
11
|
|
12
12
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
13
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
data/COPYING
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a. place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b. use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c. give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d. make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a. distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b. accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c. give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d. make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
data/LEGAL
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# -*- rdoc -*-
|
2
|
+
|
3
|
+
= LEGAL NOTICE INFORMATION
|
4
|
+
--------------------------
|
5
|
+
|
6
|
+
All the files in this distribution are covered under either the Ruby's
|
7
|
+
license (see the file COPYING) or public-domain except some files
|
8
|
+
mentioned below.
|
9
|
+
|
10
|
+
== MIT License
|
11
|
+
>>>
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
13
|
+
a copy of this software and associated documentation files (the
|
14
|
+
"Software"), to deal in the Software without restriction, including
|
15
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
16
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
17
|
+
permit persons to whom the Software is furnished to do so, subject to
|
18
|
+
the following conditions:
|
19
|
+
|
20
|
+
The above copyright notice and this permission notice shall be
|
21
|
+
included in all copies or substantial portions of the Software.
|
22
|
+
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
24
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
25
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
26
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
27
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
28
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
29
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
30
|
+
|
31
|
+
== Old-style BSD license
|
32
|
+
>>>
|
33
|
+
Redistribution and use in source and binary forms, with or without
|
34
|
+
modification, are permitted provided that the following conditions
|
35
|
+
are met:
|
36
|
+
1. Redistributions of source code must retain the above copyright
|
37
|
+
notice, this list of conditions and the following disclaimer.
|
38
|
+
2. Redistributions in binary form must reproduce the above copyright
|
39
|
+
notice, this list of conditions and the following disclaimer in the
|
40
|
+
documentation and/or other materials provided with the distribution.
|
41
|
+
3. Neither the name of the University nor the names of its contributors
|
42
|
+
may be used to endorse or promote products derived from this software
|
43
|
+
without specific prior written permission.
|
44
|
+
|
45
|
+
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
46
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
47
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
48
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
49
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
50
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
51
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
52
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
53
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
54
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
55
|
+
SUCH DAMAGE.
|
56
|
+
|
57
|
+
IMPORTANT NOTE::
|
58
|
+
|
59
|
+
From ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
60
|
+
paragraph 3 above is now null and void.
|
data/README.md
CHANGED
@@ -1,8 +1,47 @@
|
|
1
1
|
# Mathn
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/ruby/mathn.svg?branch=master)](https://travis-ci.org/ruby/mathn)
|
4
4
|
|
5
|
-
|
5
|
+
mathn serves to make mathematical operations more precise in Ruby and to integrate other mathematical standard libraries.
|
6
|
+
|
7
|
+
Without mathn:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
3 / 2 => 1 # Integer
|
11
|
+
```
|
12
|
+
|
13
|
+
With mathn:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
3 / 2 => 3/2 # Rational
|
17
|
+
```
|
18
|
+
|
19
|
+
mathn keeps value in exact terms.
|
20
|
+
|
21
|
+
Without mathn:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
20 / 9 * 3 * 14 / 7 * 3 / 2 # => 18
|
25
|
+
```
|
26
|
+
|
27
|
+
With mathn:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
20 / 9 * 3 * 14 / 7 * 3 / 2 # => 20
|
31
|
+
```
|
32
|
+
|
33
|
+
## Global Behavioral changes
|
34
|
+
|
35
|
+
While older version of 'mathn', just by required, caused changes to
|
36
|
+
the behavior (and even the types) of operations on classes like
|
37
|
+
Integer newer `mathn` introduces the refinements `Math::N`, and you
|
38
|
+
have to enable it.
|
39
|
+
|
40
|
+
Before ruby 2.5, `mathn` was part of the ruby standard library. It was
|
41
|
+
was [deprecated in ruby 2.2.0](https://github.com/ruby/ruby/blob/v2_2_0/NEWS#stdlib-compatibility-issues-excluding-feature-bug-fixes),
|
42
|
+
and [removed from ruby 2.5.0](https://github.com/ruby/ruby/blob/ruby_2_5/NEWS#stdlib-compatibility-issues-excluding-feature-bug-fixes).
|
43
|
+
In order to use the library with a current version of ruby,
|
44
|
+
you must install it as a gem.
|
6
45
|
|
7
46
|
## Installation
|
8
47
|
|
@@ -22,7 +61,10 @@ Or install it yourself as:
|
|
22
61
|
|
23
62
|
## Usage
|
24
63
|
|
25
|
-
|
64
|
+
```ruby
|
65
|
+
require 'mathn'
|
66
|
+
using Math::N
|
67
|
+
```
|
26
68
|
|
27
69
|
## Development
|
28
70
|
|
@@ -32,10 +74,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
74
|
|
33
75
|
## Contributing
|
34
76
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
77
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/mathn.
|
36
78
|
|
37
79
|
|
38
80
|
## License
|
39
81
|
|
40
82
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
data/lib/mathn.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
2
|
-
#--
|
3
|
-
# $Release Version: 0.5 $
|
4
|
-
# $Revision: 1.1.1.1.4.1 $
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
6
3
|
##
|
7
4
|
# = mathn
|
@@ -11,10 +8,12 @@
|
|
11
8
|
#
|
12
9
|
# Without mathn:
|
13
10
|
#
|
11
|
+
# using Math::N
|
14
12
|
# 3 / 2 => 1 # Integer
|
15
13
|
#
|
16
14
|
# With mathn:
|
17
15
|
#
|
16
|
+
# using Math::N
|
18
17
|
# 3 / 2 => 3/2 # Rational
|
19
18
|
#
|
20
19
|
# mathn keeps value in exact terms.
|
@@ -25,146 +24,140 @@
|
|
25
24
|
#
|
26
25
|
# With mathn:
|
27
26
|
#
|
27
|
+
# using Math::N
|
28
28
|
# 20 / 9 * 3 * 14 / 7 * 3 / 2 # => 20
|
29
29
|
#
|
30
30
|
#
|
31
|
-
# When you require 'mathn', the libraries for
|
32
|
-
# are also loaded.
|
31
|
+
# When you require 'mathn', the libraries for CMath is also loaded.
|
33
32
|
#
|
34
33
|
# == Copyright
|
35
34
|
#
|
36
35
|
# Author: Keiju ISHITSUKA (SHL Japan Inc.)
|
37
|
-
#--
|
38
|
-
# class Numeric follows to make this documentation findable in a reasonable
|
39
|
-
# location
|
40
36
|
|
41
|
-
|
37
|
+
require "cmath"
|
38
|
+
require_relative "mathn/complex"
|
39
|
+
require_relative "mathn/rational"
|
42
40
|
|
43
|
-
|
41
|
+
module Math::N
|
42
|
+
# The version string
|
43
|
+
VERSION = "0.2.0"
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
require "mathn/rational"
|
50
|
-
require "mathn/complex"
|
51
|
-
|
52
|
-
unless defined?(Math.exp!)
|
53
|
-
Object.instance_eval{remove_const :Math}
|
54
|
-
Math = CMath # :nodoc:
|
55
|
-
end
|
56
|
-
|
57
|
-
##
|
58
|
-
# When mathn is required, Integer's division is enhanced to
|
59
|
-
# return more precise values from mathematical expressions.
|
60
|
-
#
|
61
|
-
# 2/3*3 # => 0
|
62
|
-
# require 'mathn'
|
63
|
-
# 2/3*3 # => 2
|
64
|
-
#
|
65
|
-
# (2**72) / ((2**70) * 3) # => 4/3
|
66
|
-
|
67
|
-
class Integer
|
68
|
-
remove_method :/
|
45
|
+
refine ::Numeric do
|
46
|
+
alias canonicalize itself
|
47
|
+
end
|
69
48
|
|
70
|
-
|
71
|
-
# +/+ defines the Rational division for Bignum.
|
72
|
-
#
|
73
|
-
# (2**72) / ((2**70) * 3) # => 4/3
|
49
|
+
using self # for canonicalize methods
|
74
50
|
|
75
|
-
|
76
|
-
end
|
51
|
+
def +(other) super.canonicalize end
|
52
|
+
def -(other) super.canonicalize end
|
53
|
+
def *(other) super.canonicalize end
|
54
|
+
def /(other) super.canonicalize end
|
55
|
+
def quo(other) super.canonicalize end
|
56
|
+
def **(other) super.canonicalize end
|
77
57
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
#
|
86
|
-
# After require 'mathn', this is changed to:
|
87
|
-
#
|
88
|
-
# require 'mathn'
|
89
|
-
# Math.sqrt(4/9) # => 2/3
|
90
|
-
# Math.sqrt(4.0/9.0) # => 0.666666666666667
|
91
|
-
# Math.sqrt(- 4/9) # => Complex(0, 2/3)
|
92
|
-
|
93
|
-
module Math
|
94
|
-
remove_method(:sqrt)
|
95
|
-
|
96
|
-
##
|
97
|
-
# Computes the square root of +a+. It makes use of Complex and
|
98
|
-
# Rational to have no rounding errors if possible.
|
99
|
-
#
|
100
|
-
# Math.sqrt(4/9) # => 2/3
|
101
|
-
# Math.sqrt(- 4/9) # => Complex(0, 2/3)
|
102
|
-
# Math.sqrt(4.0/9.0) # => 0.666666666666667
|
103
|
-
|
104
|
-
def sqrt(a)
|
105
|
-
if a.kind_of?(Complex)
|
106
|
-
sqrt!(a)
|
107
|
-
elsif a.respond_to?(:nan?) and a.nan?
|
108
|
-
a
|
109
|
-
elsif a >= 0
|
110
|
-
rsqrt(a)
|
111
|
-
else
|
112
|
-
Complex(0,rsqrt(-a))
|
58
|
+
# Transplant per methods.
|
59
|
+
canon = public_instance_methods(false).map do |n, h|
|
60
|
+
[n, instance_method(n)]
|
61
|
+
end
|
62
|
+
for klass in [::Integer, ::Rational, ::Complex]
|
63
|
+
refine klass do
|
64
|
+
canon.each {|n, m| define_method(n, m)}
|
113
65
|
end
|
114
66
|
end
|
115
67
|
|
116
68
|
##
|
117
|
-
#
|
118
|
-
#
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
69
|
+
# Enhance Integer's division to return more precise values from
|
70
|
+
# mathematical expressions.
|
71
|
+
refine ::Integer do
|
72
|
+
|
73
|
+
##
|
74
|
+
# +/+ defines the Rational division for Integer.
|
75
|
+
#
|
76
|
+
# require 'mathn'
|
77
|
+
# 2/3*3 # => 0
|
78
|
+
# (2**72) / ((2**70) * 3) # => 1
|
79
|
+
#
|
80
|
+
# using Math::N
|
81
|
+
# 2/3*3 # => 2
|
82
|
+
# (2**72) / ((2**70) * 3) # => 4/3
|
83
|
+
alias / quo
|
84
|
+
end
|
133
85
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
86
|
+
math = refine ::Math do
|
87
|
+
module_function
|
88
|
+
|
89
|
+
##
|
90
|
+
# Computes the square root of +a+. It makes use of Complex and
|
91
|
+
# Rational to have no rounding errors if possible.
|
92
|
+
#
|
93
|
+
# Standard Math module behaviour:
|
94
|
+
# Math.sqrt(4/9) # => 0.0
|
95
|
+
# Math.sqrt(4.0/9.0) # => 0.6666666666666666
|
96
|
+
# Math.sqrt(- 4/9) # => Errno::EDOM: Numerical argument out of domain - sqrt
|
97
|
+
#
|
98
|
+
# When using 'Math::N', this is changed to:
|
99
|
+
#
|
100
|
+
# require 'mathn'
|
101
|
+
# using Math::N
|
102
|
+
# Math.sqrt(4/9) # => 2/3
|
103
|
+
# Math.sqrt(4.0/9.0) # => 0.666666666666666
|
104
|
+
# Math.sqrt(- 4/9) # => Complex(0, 2/3)
|
105
|
+
|
106
|
+
def sqrt(a)
|
107
|
+
return super unless a.respond_to?(:negative?)
|
108
|
+
return a if a.respond_to?(:nan?) and a.nan?
|
109
|
+
negative = a.negative?
|
110
|
+
|
111
|
+
# Compute square root of a non negative number.
|
112
|
+
case a
|
113
|
+
when Float
|
114
|
+
a = super(a.abs)
|
115
|
+
when Rational
|
116
|
+
a = sqrt(a.numerator.abs).quo sqrt(a.denominator.abs)
|
117
|
+
else
|
118
|
+
rt = Integer.sqrt(a = a.abs)
|
119
|
+
a = rt * rt == a ? rt : super(a)
|
156
120
|
end
|
157
|
-
|
158
|
-
|
121
|
+
negative ? Complex(0, a) : a
|
122
|
+
end
|
123
|
+
|
124
|
+
##
|
125
|
+
# Computes the cubic root of +a+. It makes use of Complex and
|
126
|
+
# Rational to have no rounding errors if possible.
|
127
|
+
#
|
128
|
+
# Standard Math module behaviour:
|
129
|
+
# Math.cbrt(8/27) # => 0.0
|
130
|
+
# Math.cbrt(8.0/27.0) # => 0.666666666666666
|
131
|
+
# Math.cbrt(- 8/27) # => -1.0
|
132
|
+
#
|
133
|
+
# When using 'Math::N', this is changed to:
|
134
|
+
#
|
135
|
+
# require 'mathn'
|
136
|
+
# using Math::N
|
137
|
+
# Math.cbrt(8/27) # => (2/3)
|
138
|
+
# Math.cbrt(8.0/27.0) # => 0.666666666666666
|
139
|
+
# Math.cbrt(-8/27) # => (-2/3)
|
140
|
+
|
141
|
+
def cbrt(a)
|
142
|
+
case a
|
143
|
+
when Integer
|
144
|
+
rt = super
|
145
|
+
rt ** 3 == a ? Integer(rt) : rt
|
146
|
+
when Rational
|
147
|
+
cbrt(a.numerator).quo cbrt(a.denominator)
|
148
|
+
when Complex
|
149
|
+
a ** (1/3r)
|
159
150
|
else
|
160
|
-
|
151
|
+
super
|
161
152
|
end
|
162
153
|
end
|
163
154
|
end
|
164
155
|
|
165
|
-
|
166
|
-
|
156
|
+
# Transplant module functions.
|
157
|
+
refine ::Math.singleton_class do
|
158
|
+
math.private_instance_methods(false).each do |m|
|
159
|
+
next unless math.respond_to?(m)
|
160
|
+
public define_method(m, Math.instance_method(m))
|
161
|
+
end
|
167
162
|
end
|
168
|
-
module_function :sqrt
|
169
|
-
module_function :rsqrt
|
170
163
|
end
|
metadata
CHANGED
@@ -1,51 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mathn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keiju ISHITSUKA
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2024-10-31 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
13
|
+
name: cmath
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: '0'
|
20
|
-
type: :
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake-compiler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
19
|
+
type: :runtime
|
49
20
|
prerelease: false
|
50
21
|
version_requirements: !ruby/object:Gem::Requirement
|
51
22
|
requirements:
|
@@ -54,32 +25,22 @@ dependencies:
|
|
54
25
|
version: '0'
|
55
26
|
description: Deprecated library that extends math operations.
|
56
27
|
email:
|
57
|
-
-
|
28
|
+
- keiju@ishitsuka.com
|
58
29
|
executables: []
|
59
|
-
extensions:
|
60
|
-
- ext/mathn/complex/extconf.rb
|
61
|
-
- ext/mathn/rational/extconf.rb
|
30
|
+
extensions: []
|
62
31
|
extra_rdoc_files: []
|
63
32
|
files:
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-
|
67
|
-
- LICENSE.txt
|
33
|
+
- BSDL
|
34
|
+
- COPYING
|
35
|
+
- LEGAL
|
68
36
|
- README.md
|
69
|
-
- Rakefile
|
70
|
-
- bin/console
|
71
|
-
- bin/setup
|
72
|
-
- ext/mathn/complex/complex.c
|
73
|
-
- ext/mathn/complex/extconf.rb
|
74
|
-
- ext/mathn/rational/extconf.rb
|
75
|
-
- ext/mathn/rational/rational.c
|
76
37
|
- lib/mathn.rb
|
77
|
-
- mathn.
|
38
|
+
- lib/mathn/complex.rb
|
39
|
+
- lib/mathn/rational.rb
|
78
40
|
homepage: https://github.com/ruby/mathn
|
79
41
|
licenses:
|
80
42
|
- BSD-2-Clause
|
81
43
|
metadata: {}
|
82
|
-
post_install_message:
|
83
44
|
rdoc_options: []
|
84
45
|
require_paths:
|
85
46
|
- lib
|
@@ -87,16 +48,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
48
|
requirements:
|
88
49
|
- - ">="
|
89
50
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
51
|
+
version: '2.5'
|
91
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
53
|
requirements:
|
93
54
|
- - ">="
|
94
55
|
- !ruby/object:Gem::Version
|
95
56
|
version: '0'
|
96
57
|
requirements: []
|
97
|
-
|
98
|
-
rubygems_version: 2.6.12
|
99
|
-
signing_key:
|
58
|
+
rubygems_version: 3.6.0.dev
|
100
59
|
specification_version: 4
|
101
60
|
summary: Deprecated library that extends math operations.
|
102
61
|
test_files: []
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rake/testtask"
|
3
|
-
|
4
|
-
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs << "test" << "test/lib"
|
6
|
-
t.libs << "lib"
|
7
|
-
t.test_files = FileList['test/**/test_*.rb']
|
8
|
-
end
|
9
|
-
|
10
|
-
ENV['RUBYOPT'] = "-w"
|
11
|
-
|
12
|
-
require 'rake/extensiontask'
|
13
|
-
Rake::ExtensionTask.new("mathn/complex")
|
14
|
-
Rake::ExtensionTask.new("mathn/rational")
|
15
|
-
|
16
|
-
task :default => [:compile, :test]
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "mathn"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/ext/mathn/complex/complex.c
DELETED
data/mathn.gemspec
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
Gem::Specification.new do |spec|
|
3
|
-
spec.name = "mathn"
|
4
|
-
spec.version = "0.1.0"
|
5
|
-
spec.authors = ["Keiju ISHITSUKA"]
|
6
|
-
spec.email = [nil]
|
7
|
-
|
8
|
-
spec.summary = "Deprecated library that extends math operations."
|
9
|
-
spec.description = "Deprecated library that extends math operations."
|
10
|
-
spec.homepage = "https://github.com/ruby/mathn"
|
11
|
-
spec.license = "BSD-2-Clause"
|
12
|
-
|
13
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
14
|
-
f.match(%r{^(test|spec|features)/})
|
15
|
-
end
|
16
|
-
spec.extensions = ["ext/mathn/complex/extconf.rb", "ext/mathn/rational/extconf.rb"]
|
17
|
-
spec.bindir = "exe"
|
18
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "rake-compiler"
|
24
|
-
end
|