hyper_complex 1.0.1 → 1.0.3
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 +4 -4
- data/lib/hyper_complex.rb +6 -7
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b0bc6516a0b577f4f8c44a73b8571aff3bc6448ec36bce71dbc28375a79c4791
|
|
4
|
+
data.tar.gz: 11174573c035667c70a6fb64860aa57928b4b992eae317a7cd24a0b0c942f54b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cc759f0157228dbad43184b761a3c189796659b91bf5b78bbe19b0ec9d5d837081bd01eb824a10c19cf62bd38842841ebb6230b73cfe9aac061921cefeaba151
|
|
7
|
+
data.tar.gz: 2e53ca441e6ad468255b05695ff1512638fc55a2b48adf7cfad8285b9c70413fd814b5bb2b7bdbc6a5ef92da69c0a4379156b9e19cfd18db3fd16c205e88c61f
|
data/lib/hyper_complex.rb
CHANGED
|
@@ -188,7 +188,7 @@ class HyperComplex < Numeric
|
|
|
188
188
|
# e6| e6 e7 e4 -e5 -e2 e3 -e0 -e1
|
|
189
189
|
# e7| e7 -e6 e5 e4 -e3 -e2 e1 -e0
|
|
190
190
|
#
|
|
191
|
-
def print_mt(dim)
|
|
191
|
+
def print_mt(dim)
|
|
192
192
|
table = @@mt = calc_mt(dim) if dim > @@mt.length
|
|
193
193
|
ss = dim
|
|
194
194
|
sf = ss.to_s.length + 3
|
|
@@ -576,7 +576,7 @@ class HyperComplex < Numeric
|
|
|
576
576
|
# @example
|
|
577
577
|
# HyperComplex[1, 2, 3, 4].mul(HyperComplex[4, 3, 2, 1]) #=> HyperComplex[-12, 6, 24, 12]
|
|
578
578
|
#
|
|
579
|
-
def mul(other)
|
|
579
|
+
def mul(other)
|
|
580
580
|
sar, oar = homogenize(other)
|
|
581
581
|
ss = sar.length
|
|
582
582
|
return __new__(sar[0] * oar[0] - oar[1] * sar[1], oar[1] * sar[0] + sar[1] * oar[0]) if ss == 2
|
|
@@ -765,16 +765,15 @@ class HyperComplex < Numeric
|
|
|
765
765
|
#
|
|
766
766
|
# @param other [Numeric]
|
|
767
767
|
# @return [HyperComplex]
|
|
768
|
+
# @raise ArgumentError
|
|
768
769
|
#
|
|
769
770
|
# @example
|
|
770
771
|
# HyperComplex[1, 2, 3, 4]**HyperComplex[4, 3, 2, 1]
|
|
771
772
|
# #=> HyperComplex[9.648225704568818, -5.4921479890865506, -8.477947559523633, -4.2389737797618166]
|
|
772
773
|
#
|
|
773
774
|
def **(other) # rubocop:disable Metrics/AbcSize
|
|
774
|
-
unless other.is_a?(Numeric)
|
|
775
|
-
|
|
776
|
-
return num1**num2
|
|
777
|
-
end
|
|
775
|
+
raise ArgumentError, 'Argument must be Numeric' unless other.is_a?(Numeric)
|
|
776
|
+
|
|
778
777
|
if other.zero?
|
|
779
778
|
return __new__(*Array.new(dim, Float::NAN)) if zero?
|
|
780
779
|
|
|
@@ -810,7 +809,7 @@ class HyperComplex < Numeric
|
|
|
810
809
|
q *= other
|
|
811
810
|
HyperComplex.polar(Math.exp(q.real), 1, q.imag)
|
|
812
811
|
else
|
|
813
|
-
|
|
812
|
+
num2, num1 = coerce(other)
|
|
814
813
|
num1**num2
|
|
815
814
|
end
|
|
816
815
|
end
|
data/lib/version.rb
CHANGED