hpsqrt 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/README.md +4 -0
- data/lib/hpsqrt.rb +12 -1
- data/lib/hpsqrt/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9e8c696801667af06718bf68800c0bc364372971f6e9708fa3bc99f878bd37a
|
4
|
+
data.tar.gz: '0813db15d0b31c395c14060af5947830fcd5d6c2a95627a83cc4cd9671414de6'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80eda9901b98547e6aef9813d3b737f79de8af71577220c7f4bc34f8c8cef02e4d00dfcb3ada2bd199fd90cf5bf6049de8d7a838dad176fdce3e4d1cfd4f26b4
|
7
|
+
data.tar.gz: dbfff2f96f8889fb21a97847e8b318ad77e2216940ffcca57ec41bfd58767e1c4123df03e9eaf90f92bf4b8ca7bad7ff0e6558c20c9c8620cb02b6489860c5f3
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
data/lib/hpsqrt.rb
CHANGED
@@ -20,6 +20,7 @@ class HpSqrt < Numeric
|
|
20
20
|
|
21
21
|
def initialize(terms)
|
22
22
|
@terms = terms.freeze
|
23
|
+
@cache = {}
|
23
24
|
freeze
|
24
25
|
end
|
25
26
|
|
@@ -117,6 +118,16 @@ class HpSqrt < Numeric
|
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
121
|
+
def <=>(other)
|
122
|
+
if self==other
|
123
|
+
0
|
124
|
+
elsif !self.real? || !other.real?
|
125
|
+
nil
|
126
|
+
else
|
127
|
+
self.real <=> other.real
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
120
131
|
def rect
|
121
132
|
to_c.rect
|
122
133
|
end
|
@@ -132,7 +143,7 @@ class HpSqrt < Numeric
|
|
132
143
|
alias_method :phase, :arg
|
133
144
|
|
134
145
|
def to_c
|
135
|
-
@terms.map {|t, c|
|
146
|
+
@cache[:to_c] ||= @terms.map {|t, c|
|
136
147
|
t.number * Math.sqrt(Complex(t.sqrt)) * c
|
137
148
|
}.sum.to_c
|
138
149
|
end
|
data/lib/hpsqrt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hpsqrt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshida Tetsuya
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|