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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d88b2d11e25c9e32b47da0a78ab589b19b6178805f83117e1932dbe9a0a7742d
4
- data.tar.gz: 42ce76689c5b0201bb7e69d52a70463bca8d9d36436dc1114e086d20de213ee4
3
+ metadata.gz: a9e8c696801667af06718bf68800c0bc364372971f6e9708fa3bc99f878bd37a
4
+ data.tar.gz: '0813db15d0b31c395c14060af5947830fcd5d6c2a95627a83cc4cd9671414de6'
5
5
  SHA512:
6
- metadata.gz: 3a0091b5dc265672bf576f379cdfaf795b0f047a8673b0a684d2d4a925a8c7d6c609e24c9b5bdab554e963591e9c38a3c5922e339e78cafbf6b2e68a9b3a490a
7
- data.tar.gz: a67a0452e23028c70d1d0206c7b247bdd217dc32ec8f249946291e0ab8131ede0def44e03088b707a5eed9e7d16e5a24bd5b9cc4174e1b308f6052297c29cb94
6
+ metadata.gz: 80eda9901b98547e6aef9813d3b737f79de8af71577220c7f4bc34f8c8cef02e4d00dfcb3ada2bd199fd90cf5bf6049de8d7a838dad176fdce3e4d1cfd4f26b4
7
+ data.tar.gz: dbfff2f96f8889fb21a97847e8b318ad77e2216940ffcca57ec41bfd58767e1c4123df03e9eaf90f92bf4b8ca7bad7ff0e6558c20c9c8620cb02b6489860c5f3
data/.travis.yml CHANGED
@@ -2,5 +2,6 @@
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.7.0
6
- before_install: gem install bundler -v 2.1.0.pre.1
5
+ - 2.6.3
6
+ before_install:
7
+ - gem install bundler -v '~> 2.0.1'
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # HpSqrt
2
2
 
3
+ - master: [![Build Status](https://travis-ci.org/yoshida-eth0/ruby-sqrt.svg?branch=master)](https://travis-ci.org/yoshida-eth0/ruby-sqrt)
4
+
5
+ ## Overview
6
+
3
7
  High precision square root library for Ruby.
4
8
 
5
9
  ## Installation
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
@@ -1,3 +1,3 @@
1
1
  class HpSqrt < Numeric
2
- VERSION = "1.5.0"
2
+ VERSION = "1.6.0"
3
3
  end
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.5.0
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-15 00:00:00.000000000 Z
11
+ date: 2019-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler