quaternion_c2 0.1.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/quaternion_c2/to_type.rb +11 -7
- data/lib/quaternion_c2/unary.rb +12 -0
- data/quaternion_c2.gemspec +4 -4
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7db82b9a71381584904b5b2524a76f8f352eeb5b34ca834374c4bce5d370b959
|
4
|
+
data.tar.gz: 987d2a9893ef41f0d079931931a648e853d31ae4b54c9822d3179ab8c0bf459d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a37154fffef6c3a892040f0762ecfb644e0d966fdc091e9e532102fddea4234c86cd03dcf510ccaf865c9e8e1f3dfa85da3ff796fa76dedf79cf16c858e7dd22
|
7
|
+
data.tar.gz: 7cf6bd82f8abae76704202a7c891e88111074428571dfa5fa6e61914248c0ace059d6be84d055450bd8d9be7372dc3e812786acaf53f14297b50f722d2cd4197
|
@@ -121,11 +121,8 @@ class Quaternion
|
|
121
121
|
end
|
122
122
|
|
123
123
|
class << self
|
124
|
-
|
125
|
-
|
126
|
-
#
|
127
|
-
def parse(str, strict = false)
|
128
|
-
regexp = %r{
|
124
|
+
RE, RE_STRICT = [false, true].collect do |strict|
|
125
|
+
%r{
|
129
126
|
\A
|
130
127
|
\s*+
|
131
128
|
(?:(?'real' [+-]?+ \g'rational' ) (?![ijk]))?+
|
@@ -133,13 +130,20 @@ class Quaternion
|
|
133
130
|
(?:(?'imag_j' \g'head_or_sign' \g'rational'?+) j )?+
|
134
131
|
(?:(?'imag_k' \g'head_or_sign' \g'rational'?+) k )?+
|
135
132
|
\s*+
|
136
|
-
|
137
|
-
(?'head_or_sign' (
|
133
|
+
|(?!)
|
134
|
+
(?'head_or_sign' (?<!\S) [+-]?+ | [+-])
|
138
135
|
(?'digits' \d++ (?:#{strict ? "_" : "_++"} \d++)*+)
|
139
136
|
(?'int_or_float' (?:\g'digits')?+ (?:\. \g'digits')?+
|
140
137
|
(?<=\d) (?:e [+-]?+ \g'digits')?+)
|
141
138
|
(?'rational' \g'int_or_float' (?:/ \g'digits')?+)
|
142
139
|
}xi
|
140
|
+
end
|
141
|
+
private_constant :RE, :RE_STRICT
|
142
|
+
|
143
|
+
private
|
144
|
+
|
145
|
+
def parse(str, strict = false)
|
146
|
+
regexp = strict ? RE_STRICT : RE
|
143
147
|
|
144
148
|
# regexp.match(str) always succeeds (even if str is empty)
|
145
149
|
components = regexp.match(str).captures[0,4]
|
data/lib/quaternion_c2/unary.rb
CHANGED
@@ -9,6 +9,18 @@ class Quaternion
|
|
9
9
|
# * +@ #=> self
|
10
10
|
# * -@ #=> 0 - self
|
11
11
|
|
12
|
+
##
|
13
|
+
# Returns negation of the value.
|
14
|
+
#
|
15
|
+
# @return [Quaternion]
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# -Quaternion(1, 2, 3, 4) #=> (-1-2i-3j-4k)
|
19
|
+
#
|
20
|
+
def -@
|
21
|
+
__new__(-@a, -@b)
|
22
|
+
end
|
23
|
+
|
12
24
|
##
|
13
25
|
# Returns its conjugate.
|
14
26
|
#
|
data/quaternion_c2.gemspec
CHANGED
@@ -3,12 +3,12 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "quaternion_c2"
|
6
|
-
spec.version = "0.
|
6
|
+
spec.version = "0.9.0"
|
7
7
|
spec.authors = ["Masahiro Nomoto"]
|
8
8
|
spec.email = ["hmmnrst@users.noreply.github.com"]
|
9
9
|
|
10
10
|
spec.summary = %q{Quaternion class}
|
11
|
-
spec.description = %q{
|
11
|
+
spec.description = %q{Provides a numeric class Quaternion which is similar to a built-in class Complex.}
|
12
12
|
spec.homepage = "https://github.com/hmmnrst/quaternion_c2"
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_development_dependency "bundler"
|
23
|
-
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "rake"
|
24
24
|
spec.add_development_dependency "rspec", "~> 3.0"
|
25
25
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quaternion_c2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro Nomoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,8 +52,8 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description:
|
56
|
-
|
55
|
+
description: Provides a numeric class Quaternion which is similar to a built-in class
|
56
|
+
Complex.
|
57
57
|
email:
|
58
58
|
- hmmnrst@users.noreply.github.com
|
59
59
|
executables: []
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
103
|
rubyforge_project:
|
104
|
-
rubygems_version:
|
104
|
+
rubygems_version: 3.0.0.beta3
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: Quaternion class
|