hyper_complex 1.0.1 → 1.0.2
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 +4 -5
- 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: 359c611274e4cd54774d252bf6e6b7556eab487aded12616dba3ee046e807082
|
|
4
|
+
data.tar.gz: e54b127fc5dfc23496d006e0f61e487e4ce87b66ff4b3038745ce4d2254ea3fe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e581a06cb28dbebe85fa77314df34800ef92b03251ce5b33c049e650671512d734b5a27d03b0ba2fb78b64f55e0948bcd92975d91f9de47674ec57c5fc0c9b19
|
|
7
|
+
data.tar.gz: b419d5f33447eb8ae628586d1b9fb2b1b17a05b047719b17023c7dc193d4c92dafbd610d0361974daabdfc5eadd66dda6f2eb93758a36d82dab158da0063a318
|
data/lib/hyper_complex.rb
CHANGED
|
@@ -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