aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/math/number/complex.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/math/number/complex.lux')
-rw-r--r--stdlib/source/library/lux/math/number/complex.lux74
1 files changed, 37 insertions, 37 deletions
diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux
index 8708b9c7f..58a8cd4be 100644
--- a/stdlib/source/library/lux/math/number/complex.lux
+++ b/stdlib/source/library/lux/math/number/complex.lux
@@ -22,34 +22,34 @@
[#real Frac
#imaginary Frac]))
-(def: .public complex
+(def .public complex
(syntax (_ [real <code>.any
?imaginary (<>.maybe <code>.any)])
(in (list (` [..#real (~ real)
..#imaginary (~ (maybe.else (' +0.0) ?imaginary))])))))
-(def: .public i
+(def .public i
Complex
(..complex +0.0 +1.0))
-(def: .public +one
+(def .public +one
Complex
(..complex +1.0 +0.0))
-(def: .public -one
+(def .public -one
Complex
(..complex -1.0 +0.0))
-(def: .public zero
+(def .public zero
Complex
(..complex +0.0 +0.0))
-(def: .public (not_a_number? complex)
+(def .public (not_a_number? complex)
(-> Complex Bit)
(or (f.not_a_number? (the #real complex))
(f.not_a_number? (the #imaginary complex))))
-(def: .public (= param input)
+(def .public (= param input)
(-> Complex Complex Bit)
(and (f.= (the #real param)
(the #real input))
@@ -57,7 +57,7 @@
(the #imaginary input))))
(with_template [<name> <op>]
- [(def: .public (<name> param input)
+ [(def .public (<name> param input)
(-> Complex Complex Complex)
[#real (<op> (the #real param)
(the #real input))
@@ -68,13 +68,13 @@
[- f.-]
)
-(def: .public equivalence
+(def .public equivalence
(Equivalence Complex)
(implementation
- (def: = ..=)))
+ (def = ..=)))
(with_template [<name> <transform>]
- [(def: .public <name>
+ [(def .public <name>
(-> Complex Complex)
(|>> (revised #real <transform>)
(revised #imaginary <transform>)))]
@@ -83,18 +83,18 @@
[signum f.signum]
)
-(def: .public conjugate
+(def .public conjugate
(-> Complex Complex)
(revised #imaginary f.opposite))
-(def: .public (*' param input)
+(def .public (*' param input)
(-> Frac Complex Complex)
[#real (f.* param
(the #real input))
#imaginary (f.* param
(the #imaginary input))])
-(def: .public (* param input)
+(def .public (* param input)
(-> Complex Complex Complex)
[#real (f.- (f.* (the #imaginary param)
(the #imaginary input))
@@ -105,7 +105,7 @@
(f.* (the #imaginary param)
(the #real input)))])
-(def: .public (/ param input)
+(def .public (/ param input)
(-> Complex Complex Complex)
(let [(open "[0]") param]
(if (f.< (f.abs #imaginary)
@@ -119,13 +119,13 @@
[..#real (|> (the ..#imaginary input) (f.* quot) (f.+ (the ..#real input)) (f./ denom))
..#imaginary (|> (the ..#imaginary input) (f.- (f.* quot (the ..#real input))) (f./ denom))]))))
-(def: .public (/' param subject)
+(def .public (/' param subject)
(-> Frac Complex Complex)
(let [(open "[0]") subject]
[..#real (f./ param #real)
..#imaginary (f./ param #imaginary)]))
-(def: .public (% param input)
+(def .public (% param input)
(-> Complex Complex Complex)
(let [scaled (/ param input)
quotient (|> scaled
@@ -134,7 +134,7 @@
(- (* quotient param)
input)))
-(def: .public (cos subject)
+(def .public (cos subject)
(-> Complex Complex)
(let [(open "[0]") subject]
[..#real (f.* (f.cosh #imaginary)
@@ -142,7 +142,7 @@
..#imaginary (f.opposite (f.* (f.sinh #imaginary)
(f.sin #real)))]))
-(def: .public (cosh subject)
+(def .public (cosh subject)
(-> Complex Complex)
(let [(open "[0]") subject]
[..#real (f.* (f.cos #imaginary)
@@ -150,7 +150,7 @@
..#imaginary (f.* (f.sin #imaginary)
(f.sinh #real))]))
-(def: .public (sin subject)
+(def .public (sin subject)
(-> Complex Complex)
(let [(open "[0]") subject]
[..#real (f.* (f.cosh #imaginary)
@@ -158,7 +158,7 @@
..#imaginary (f.* (f.sinh #imaginary)
(f.cos #real))]))
-(def: .public (sinh subject)
+(def .public (sinh subject)
(-> Complex Complex)
(let [(open "[0]") subject]
[..#real (f.* (f.cos #imaginary)
@@ -166,7 +166,7 @@
..#imaginary (f.* (f.sin #imaginary)
(f.cosh #real))]))
-(def: .public (tan subject)
+(def .public (tan subject)
(-> Complex Complex)
(let [(open "[0]") subject
r2 (f.* +2.0 #real)
@@ -175,7 +175,7 @@
[..#real (f./ d (f.sin r2))
..#imaginary (f./ d (f.sinh i2))]))
-(def: .public (tanh subject)
+(def .public (tanh subject)
(-> Complex Complex)
(let [(open "[0]") subject
r2 (f.* +2.0 #real)
@@ -184,7 +184,7 @@
[..#real (f./ d (f.sinh r2))
..#imaginary (f./ d (f.sin i2))]))
-(def: .public (abs subject)
+(def .public (abs subject)
(-> Complex Frac)
(let [(open "[0]") subject]
(if (f.< (f.abs #imaginary)
@@ -200,21 +200,21 @@
(f.* (f.pow +0.5 (f.+ +1.0 (f.* q q)))
(f.abs #real)))))))
-(def: .public (exp subject)
+(def .public (exp subject)
(-> Complex Complex)
(let [(open "[0]") subject
r_exp (f.exp #real)]
[..#real (f.* r_exp (f.cos #imaginary))
..#imaginary (f.* r_exp (f.sin #imaginary))]))
-(def: .public (log subject)
+(def .public (log subject)
(-> Complex Complex)
(let [(open "[0]") subject]
[..#real (|> subject ..abs f.log)
..#imaginary (f.atan_2 #real #imaginary)]))
(with_template [<name> <type> <op>]
- [(def: .public (<name> param input)
+ [(def .public (<name> param input)
(-> <type> Complex Complex)
(|> input log (<op> param) exp))]
@@ -222,11 +222,11 @@
[pow' Frac ..*']
)
-(def: (with_sign sign magnitude)
+(def (with_sign sign magnitude)
(-> Frac Frac Frac)
(f.* (f.signum sign) magnitude))
-(def: .public (root_2 input)
+(def .public (root_2 input)
(-> Complex Complex)
(let [(open "[0]") input
t (|> input ..abs (f.+ (f.abs #real)) (f./ +2.0) (f.pow +0.5))]
@@ -238,11 +238,11 @@
..#imaginary (f./ (f.* +2.0 t)
#imaginary)])))
-(def: (root_2-1z input)
+(def (root_2-1z input)
(-> Complex Complex)
(|> (complex +1.0) (- (* input input)) ..root_2))
-(def: .public (reciprocal (open "[0]"))
+(def .public (reciprocal (open "[0]"))
(-> Complex Complex)
(if (f.< (f.abs #imaginary)
(f.abs #real))
@@ -257,14 +257,14 @@
[..#real scale
..#imaginary (|> scale f.opposite (f.* q))])))
-(def: .public (acos input)
+(def .public (acos input)
(-> Complex Complex)
(|> input
(..+ (|> input ..root_2-1z (..* ..i)))
..log
(..* (..opposite ..i))))
-(def: .public (asin input)
+(def .public (asin input)
(-> Complex Complex)
(|> input
..root_2-1z
@@ -272,7 +272,7 @@
..log
(..* (..opposite ..i))))
-(def: .public (atan input)
+(def .public (atan input)
(-> Complex Complex)
(|> input
(..+ ..i)
@@ -280,11 +280,11 @@
..log
(..* (../ (..complex +2.0) ..i))))
-(def: .public (argument (open "[0]"))
+(def .public (argument (open "[0]"))
(-> Complex Frac)
(f.atan_2 #real #imaginary))
-(def: .public (roots nth input)
+(def .public (roots nth input)
(-> Nat Complex (List Complex))
(case nth
0 (list)
@@ -304,7 +304,7 @@
[..#real real
..#imaginary imaginary])))))))
-(def: .public (approximately? margin_of_error standard value)
+(def .public (approximately? margin_of_error standard value)
(-> Frac Complex Complex Bit)
(and (f.approximately? margin_of_error
(the ..#real standard)