mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tools: make v test-cleancode
test everything by default (#10050)
This commit is contained in:
@ -19,12 +19,7 @@ pub fn complex(re f64, im f64) Complex {
|
||||
// To String method
|
||||
pub fn (c Complex) str() string {
|
||||
mut out := '${c.re:f}'
|
||||
out += if c.im >= 0 {
|
||||
'+${c.im:f}'
|
||||
}
|
||||
else {
|
||||
'${c.im:f}'
|
||||
}
|
||||
out += if c.im >= 0 { '+${c.im:f}' } else { '${c.im:f}' }
|
||||
out += 'i'
|
||||
return out
|
||||
}
|
||||
@ -34,11 +29,11 @@ pub fn (c Complex) str() string {
|
||||
pub fn (c Complex) abs() f64 {
|
||||
return C.hypot(c.re, c.im)
|
||||
}
|
||||
|
||||
pub fn (c Complex) mod() f64 {
|
||||
return c.abs()
|
||||
}
|
||||
|
||||
|
||||
// Complex Angle
|
||||
pub fn (c Complex) angle() f64 {
|
||||
return math.atan2(c.im, c.re)
|
||||
@ -56,19 +51,14 @@ pub fn (c1 Complex) - (c2 Complex) Complex {
|
||||
|
||||
// Complex Multiplication c1 * c2
|
||||
pub fn (c1 Complex) * (c2 Complex) Complex {
|
||||
return Complex{
|
||||
(c1.re * c2.re) + ((c1.im * c2.im) * -1),
|
||||
(c1.re * c2.im) + (c1.im * c2.re)
|
||||
}
|
||||
return Complex{(c1.re * c2.re) + ((c1.im * c2.im) * -1), (c1.re * c2.im) + (c1.im * c2.re)}
|
||||
}
|
||||
|
||||
// Complex Division c1 / c2
|
||||
pub fn (c1 Complex) / (c2 Complex) Complex {
|
||||
denom := (c2.re * c2.re) + (c2.im * c2.im)
|
||||
return Complex {
|
||||
((c1.re * c2.re) + ((c1.im * -c2.im) * -1))/denom,
|
||||
((c1.re * -c2.im) + (c1.im * c2.re))/denom
|
||||
}
|
||||
return Complex{((c1.re * c2.re) + ((c1.im * -c2.im) * -1)) / denom, ((c1.re * -c2.im) +
|
||||
(c1.im * c2.re)) / denom}
|
||||
}
|
||||
|
||||
// Complex Addition c1.add(c2)
|
||||
@ -83,23 +73,18 @@ pub fn (c1 Complex) subtract(c2 Complex) Complex {
|
||||
|
||||
// Complex Multiplication c1.multiply(c2)
|
||||
pub fn (c1 Complex) multiply(c2 Complex) Complex {
|
||||
return Complex{
|
||||
(c1.re * c2.re) + ((c1.im * c2.im) * -1),
|
||||
(c1.re * c2.im) + (c1.im * c2.re)
|
||||
}
|
||||
return Complex{(c1.re * c2.re) + ((c1.im * c2.im) * -1), (c1.re * c2.im) + (c1.im * c2.re)}
|
||||
}
|
||||
|
||||
// Complex Division c1.divide(c2)
|
||||
pub fn (c1 Complex) divide(c2 Complex) Complex {
|
||||
denom := (c2.re * c2.re) + (c2.im * c2.im)
|
||||
return Complex {
|
||||
((c1.re * c2.re) + ((c1.im * -c2.im) * -1)) / denom,
|
||||
((c1.re * -c2.im) + (c1.im * c2.re)) / denom
|
||||
}
|
||||
return Complex{((c1.re * c2.re) + ((c1.im * -c2.im) * -1)) / denom, ((c1.re * -c2.im) +
|
||||
(c1.im * c2.re)) / denom}
|
||||
}
|
||||
|
||||
// Complex Conjugate
|
||||
pub fn (c Complex) conjugate() Complex{
|
||||
pub fn (c Complex) conjugate() Complex {
|
||||
return Complex{c.re, -c.im}
|
||||
}
|
||||
|
||||
@ -114,10 +99,7 @@ pub fn (c Complex) addinv() Complex {
|
||||
// Based on
|
||||
// http://tutorial.math.lamar.edu/Extras/ComplexPrimer/Arithmetic.aspx
|
||||
pub fn (c Complex) mulinv() Complex {
|
||||
return Complex {
|
||||
c.re / (c.re * c.re + c.im * c.im),
|
||||
-c.im / (c.re * c.re + c.im * c.im)
|
||||
}
|
||||
return Complex{c.re / (c.re * c.re + c.im * c.im), -c.im / (c.re * c.re + c.im * c.im)}
|
||||
}
|
||||
|
||||
// Complex Power
|
||||
@ -126,10 +108,7 @@ pub fn (c Complex) mulinv() Complex {
|
||||
pub fn (c Complex) pow(n f64) Complex {
|
||||
r := math.pow(c.abs(), n)
|
||||
angle := c.angle()
|
||||
return Complex {
|
||||
r * math.cos(n * angle),
|
||||
r * math.sin(n * angle)
|
||||
}
|
||||
return Complex{r * math.cos(n * angle), r * math.sin(n * angle)}
|
||||
}
|
||||
|
||||
// Complex nth root
|
||||
@ -143,20 +122,14 @@ pub fn (c Complex) root(n f64) Complex {
|
||||
// https://www.math.wisc.edu/~angenent/Free-Lecture-Notes/freecomplexnumbers.pdf
|
||||
pub fn (c Complex) exp() Complex {
|
||||
a := math.exp(c.re)
|
||||
return Complex {
|
||||
a * math.cos(c.im),
|
||||
a * math.sin(c.im)
|
||||
}
|
||||
return Complex{a * math.cos(c.im), a * math.sin(c.im)}
|
||||
}
|
||||
|
||||
// Complex Natural Logarithm
|
||||
// Based on
|
||||
// http://www.chemistrylearning.com/logarithm-of-complex-number/
|
||||
pub fn (c Complex) ln() Complex {
|
||||
return Complex {
|
||||
math.log(c.abs()),
|
||||
c.angle()
|
||||
}
|
||||
return Complex{math.log(c.abs()), c.angle()}
|
||||
}
|
||||
|
||||
// Complex Log Base Complex
|
||||
@ -170,7 +143,7 @@ pub fn (c Complex) log(base Complex) Complex {
|
||||
// Based on
|
||||
// http://mathworld.wolfram.com/ComplexArgument.html
|
||||
pub fn (c Complex) arg() f64 {
|
||||
return math.atan2(c.im,c.re)
|
||||
return math.atan2(c.im, c.re)
|
||||
}
|
||||
|
||||
// Complex raised to Complex Power
|
||||
@ -178,33 +151,24 @@ pub fn (c Complex) arg() f64 {
|
||||
// http://mathworld.wolfram.com/ComplexExponentiation.html
|
||||
pub fn (c Complex) cpow(p Complex) Complex {
|
||||
a := c.arg()
|
||||
b := math.pow(c.re,2) + math.pow(c.im,2)
|
||||
d := p.re * a + (1.0/2) * p.im * math.log(b)
|
||||
t1 := math.pow(b,p.re/2) * math.exp(-p.im*a)
|
||||
return Complex{
|
||||
t1 * math.cos(d),
|
||||
t1 * math.sin(d)
|
||||
}
|
||||
b := math.pow(c.re, 2) + math.pow(c.im, 2)
|
||||
d := p.re * a + (1.0 / 2) * p.im * math.log(b)
|
||||
t1 := math.pow(b, p.re / 2) * math.exp(-p.im * a)
|
||||
return Complex{t1 * math.cos(d), t1 * math.sin(d)}
|
||||
}
|
||||
|
||||
// Complex Sin
|
||||
// Based on
|
||||
// http://www.milefoot.com/math/complex/functionsofi.htm
|
||||
pub fn (c Complex) sin() Complex {
|
||||
return Complex{
|
||||
math.sin(c.re) * math.cosh(c.im),
|
||||
math.cos(c.re) * math.sinh(c.im)
|
||||
}
|
||||
return Complex{math.sin(c.re) * math.cosh(c.im), math.cos(c.re) * math.sinh(c.im)}
|
||||
}
|
||||
|
||||
// Complex Cosine
|
||||
// Based on
|
||||
// http://www.milefoot.com/math/complex/functionsofi.htm
|
||||
pub fn (c Complex) cos() Complex {
|
||||
return Complex{
|
||||
math.cos(c.re) * math.cosh(c.im),
|
||||
-(math.sin(c.re) * math.sinh(c.im))
|
||||
}
|
||||
return Complex{math.cos(c.re) * math.cosh(c.im), -(math.sin(c.re) * math.sinh(c.im))}
|
||||
}
|
||||
|
||||
// Complex Tangent
|
||||
@ -225,102 +189,71 @@ pub fn (c Complex) cot() Complex {
|
||||
// Based on
|
||||
// http://www.suitcaseofdreams.net/Trigonometric_Functions.htm
|
||||
pub fn (c Complex) sec() Complex {
|
||||
return complex(1,0).divide(c.cos())
|
||||
return complex(1, 0).divide(c.cos())
|
||||
}
|
||||
|
||||
// Complex Cosecant
|
||||
// Based on
|
||||
// http://www.suitcaseofdreams.net/Trigonometric_Functions.htm
|
||||
pub fn (c Complex) csc() Complex {
|
||||
return complex(1,0).divide(c.sin())
|
||||
return complex(1, 0).divide(c.sin())
|
||||
}
|
||||
|
||||
// Complex Arc Sin / Sin Inverse
|
||||
// Based on
|
||||
// http://www.milefoot.com/math/complex/summaryops.htm
|
||||
pub fn (c Complex) asin() Complex {
|
||||
return complex(0,-1).multiply(
|
||||
complex(0,1)
|
||||
.multiply(c)
|
||||
.add(
|
||||
complex(1,0)
|
||||
.subtract(c.pow(2))
|
||||
.root(2)
|
||||
)
|
||||
.ln()
|
||||
)
|
||||
return complex(0, -1).multiply(complex(0, 1).multiply(c).add(complex(1, 0).subtract(c.pow(2)).root(2)).ln())
|
||||
}
|
||||
|
||||
// Complex Arc Consine / Consine Inverse
|
||||
// Based on
|
||||
// http://www.milefoot.com/math/complex/summaryops.htm
|
||||
pub fn (c Complex) acos() Complex {
|
||||
return complex(0,-1).multiply(
|
||||
c.add(
|
||||
complex(0,1)
|
||||
.multiply(
|
||||
complex(1,0)
|
||||
.subtract(c.pow(2))
|
||||
.root(2)
|
||||
)
|
||||
)
|
||||
.ln()
|
||||
)
|
||||
return complex(0, -1).multiply(c.add(complex(0, 1).multiply(complex(1, 0).subtract(c.pow(2)).root(2))).ln())
|
||||
}
|
||||
|
||||
// Complex Arc Tangent / Tangent Inverse
|
||||
// Based on
|
||||
// http://www.milefoot.com/math/complex/summaryops.htm
|
||||
pub fn (c Complex) atan() Complex {
|
||||
i := complex(0,1)
|
||||
return complex(0,1.0/2).multiply(
|
||||
i.add(c)
|
||||
.divide(
|
||||
i.subtract(c)
|
||||
)
|
||||
.ln()
|
||||
)
|
||||
i := complex(0, 1)
|
||||
return complex(0, 1.0 / 2).multiply(i.add(c).divide(i.subtract(c)).ln())
|
||||
}
|
||||
|
||||
// Complex Arc Cotangent / Cotangent Inverse
|
||||
// Based on
|
||||
// http://www.suitcaseofdreams.net/Inverse_Functions.htm
|
||||
pub fn (c Complex) acot() Complex {
|
||||
return complex(1,0).divide(c).atan()
|
||||
return complex(1, 0).divide(c).atan()
|
||||
}
|
||||
|
||||
// Complex Arc Secant / Secant Inverse
|
||||
// Based on
|
||||
// http://www.suitcaseofdreams.net/Inverse_Functions.htm
|
||||
pub fn (c Complex) asec() Complex {
|
||||
return complex(1,0).divide(c).acos()
|
||||
return complex(1, 0).divide(c).acos()
|
||||
}
|
||||
|
||||
// Complex Arc Cosecant / Cosecant Inverse
|
||||
// Based on
|
||||
// http://www.suitcaseofdreams.net/Inverse_Functions.htm
|
||||
pub fn (c Complex) acsc() Complex {
|
||||
return complex(1,0).divide(c).asin()
|
||||
return complex(1, 0).divide(c).asin()
|
||||
}
|
||||
|
||||
// Complex Hyperbolic Sin
|
||||
// Based on
|
||||
// http://www.milefoot.com/math/complex/functionsofi.htm
|
||||
pub fn (c Complex) sinh() Complex {
|
||||
return Complex{
|
||||
math.cos(c.im) * math.sinh(c.re),
|
||||
math.sin(c.im) * math.cosh(c.re)
|
||||
}
|
||||
return Complex{math.cos(c.im) * math.sinh(c.re), math.sin(c.im) * math.cosh(c.re)}
|
||||
}
|
||||
|
||||
// Complex Hyperbolic Cosine
|
||||
// Based on
|
||||
// http://www.milefoot.com/math/complex/functionsofi.htm
|
||||
pub fn (c Complex) cosh() Complex {
|
||||
return Complex{
|
||||
math.cos(c.im) * math.cosh(c.re),
|
||||
math.sin(c.im) * math.sinh(c.re)
|
||||
}
|
||||
return Complex{math.cos(c.im) * math.cosh(c.re), math.sin(c.im) * math.sinh(c.re)}
|
||||
}
|
||||
|
||||
// Complex Hyperbolic Tangent
|
||||
@ -341,25 +274,21 @@ pub fn (c Complex) coth() Complex {
|
||||
// Based on
|
||||
// http://www.suitcaseofdreams.net/Hyperbolic_Functions.htm
|
||||
pub fn (c Complex) sech() Complex {
|
||||
return complex(1,0).divide(c.cosh())
|
||||
return complex(1, 0).divide(c.cosh())
|
||||
}
|
||||
|
||||
// Complex Hyperbolic Cosecant
|
||||
// Based on
|
||||
// http://www.suitcaseofdreams.net/Hyperbolic_Functions.htm
|
||||
pub fn (c Complex) csch() Complex {
|
||||
return complex(1,0).divide(c.sinh())
|
||||
return complex(1, 0).divide(c.sinh())
|
||||
}
|
||||
|
||||
// Complex Hyperbolic Arc Sin / Sin Inverse
|
||||
// Based on
|
||||
// http://www.suitcaseofdreams.net/Inverse__Hyperbolic_Functions.htm
|
||||
pub fn (c Complex) asinh() Complex {
|
||||
return c.add(
|
||||
c.pow(2)
|
||||
.add(complex(1,0))
|
||||
.root(2)
|
||||
).ln()
|
||||
return c.add(c.pow(2).add(complex(1, 0)).root(2)).ln()
|
||||
}
|
||||
|
||||
// Complex Hyperbolic Arc Consine / Consine Inverse
|
||||
@ -367,22 +296,10 @@ pub fn (c Complex) asinh() Complex {
|
||||
// http://www.suitcaseofdreams.net/Inverse__Hyperbolic_Functions.htm
|
||||
pub fn (c Complex) acosh() Complex {
|
||||
if c.re > 1 {
|
||||
return c.add(
|
||||
c.pow(2)
|
||||
.subtract(complex(1,0))
|
||||
.root(2)
|
||||
).ln()
|
||||
}
|
||||
else {
|
||||
one := complex(1,0)
|
||||
return c.add(
|
||||
c.add(one)
|
||||
.root(2)
|
||||
.multiply(
|
||||
c.subtract(one)
|
||||
.root(2)
|
||||
)
|
||||
).ln()
|
||||
return c.add(c.pow(2).subtract(complex(1, 0)).root(2)).ln()
|
||||
} else {
|
||||
one := complex(1, 0)
|
||||
return c.add(c.add(one).root(2).multiply(c.subtract(one).root(2))).ln()
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,29 +307,11 @@ pub fn (c Complex) acosh() Complex {
|
||||
// Based on
|
||||
// http://www.suitcaseofdreams.net/Inverse__Hyperbolic_Functions.htm
|
||||
pub fn (c Complex) atanh() Complex {
|
||||
one := complex(1,0)
|
||||
one := complex(1, 0)
|
||||
if c.re < 1 {
|
||||
return complex(1.0/2,0).multiply(
|
||||
one
|
||||
.add(c)
|
||||
.divide(
|
||||
one
|
||||
.subtract(c)
|
||||
)
|
||||
.ln()
|
||||
)
|
||||
}
|
||||
else {
|
||||
return complex(1.0/2,0).multiply(
|
||||
one
|
||||
.add(c)
|
||||
.ln()
|
||||
.subtract(
|
||||
one
|
||||
.subtract(c)
|
||||
.ln()
|
||||
)
|
||||
)
|
||||
return complex(1.0 / 2, 0).multiply(one.add(c).divide(one.subtract(c)).ln())
|
||||
} else {
|
||||
return complex(1.0 / 2, 0).multiply(one.add(c).ln().subtract(one.subtract(c).ln()))
|
||||
}
|
||||
}
|
||||
|
||||
@ -420,29 +319,12 @@ pub fn (c Complex) atanh() Complex {
|
||||
// Based on
|
||||
// http://www.suitcaseofdreams.net/Inverse__Hyperbolic_Functions.htm
|
||||
pub fn (c Complex) acoth() Complex {
|
||||
one := complex(1,0)
|
||||
one := complex(1, 0)
|
||||
if c.re < 0 || c.re > 1 {
|
||||
return complex(1.0/2,0).multiply(
|
||||
c
|
||||
.add(one)
|
||||
.divide(
|
||||
c.subtract(one)
|
||||
)
|
||||
.ln()
|
||||
)
|
||||
}
|
||||
else {
|
||||
return complex(1.0 / 2, 0).multiply(c.add(one).divide(c.subtract(one)).ln())
|
||||
} else {
|
||||
div := one.divide(c)
|
||||
return complex(1.0/2,0).multiply(
|
||||
one
|
||||
.add(div)
|
||||
.ln()
|
||||
.subtract(
|
||||
one
|
||||
.subtract(div)
|
||||
.ln()
|
||||
)
|
||||
)
|
||||
return complex(1.0 / 2, 0).multiply(one.add(div).ln().subtract(one.subtract(div).ln()))
|
||||
}
|
||||
}
|
||||
|
||||
@ -452,51 +334,37 @@ pub fn (c Complex) acoth() Complex {
|
||||
// For certain scenarios, Result mismatch in crossverification with Wolfram Alpha - analysis pending
|
||||
// pub fn (c Complex) asech() Complex {
|
||||
// one := complex(1,0)
|
||||
// if(c.re < -1.0) {
|
||||
// return one.subtract(
|
||||
// one.subtract(
|
||||
// c.pow(2)
|
||||
// )
|
||||
// .root(2)
|
||||
// )
|
||||
// .divide(c)
|
||||
// .ln()
|
||||
// }
|
||||
// else {
|
||||
// return one.add(
|
||||
// one.subtract(
|
||||
// c.pow(2)
|
||||
// )
|
||||
// .root(2)
|
||||
// )
|
||||
// .divide(c)
|
||||
// .ln()
|
||||
// }
|
||||
// if(c.re < -1.0) {
|
||||
// return one.subtract(
|
||||
// one.subtract(
|
||||
// c.pow(2)
|
||||
// )
|
||||
// .root(2)
|
||||
// )
|
||||
// .divide(c)
|
||||
// .ln()
|
||||
// }
|
||||
// else {
|
||||
// return one.add(
|
||||
// one.subtract(
|
||||
// c.pow(2)
|
||||
// )
|
||||
// .root(2)
|
||||
// )
|
||||
// .divide(c)
|
||||
// .ln()
|
||||
// }
|
||||
// }
|
||||
|
||||
// Complex Hyperbolic Arc Cosecant / Cosecant Inverse
|
||||
// Based on
|
||||
// http://www.suitcaseofdreams.net/Inverse__Hyperbolic_Functions.htm
|
||||
pub fn (c Complex) acsch() Complex {
|
||||
one := complex(1,0)
|
||||
one := complex(1, 0)
|
||||
if c.re < 0 {
|
||||
return one.subtract(
|
||||
one.add(
|
||||
c.pow(2)
|
||||
)
|
||||
.root(2)
|
||||
)
|
||||
.divide(c)
|
||||
.ln()
|
||||
return one.subtract(one.add(c.pow(2)).root(2)).divide(c).ln()
|
||||
} else {
|
||||
return one.add(
|
||||
one.add(
|
||||
c.pow(2)
|
||||
)
|
||||
.root(2)
|
||||
)
|
||||
.divide(c)
|
||||
.ln()
|
||||
return one.add(one.add(c.pow(2)).root(2)).divide(c).ln()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,124 +11,124 @@ fn tst_res(str1 string, str2 string) bool {
|
||||
fn test_complex_addition() {
|
||||
// Test is based on and verified from practice examples of Khan Academy
|
||||
// https://www.khanacademy.org/math/precalculus/imaginary-and-complex-numbers
|
||||
mut c1 := cmplx.complex(0,-10)
|
||||
mut c2 := cmplx.complex(-40,8)
|
||||
mut c1 := cmplx.complex(0, -10)
|
||||
mut c2 := cmplx.complex(-40, 8)
|
||||
mut result := c1 + c2
|
||||
assert result.equals(cmplx.complex(-40,-2))
|
||||
c1 = cmplx.complex(-71,2)
|
||||
c2 = cmplx.complex(88,-12)
|
||||
assert result.equals(cmplx.complex(-40, -2))
|
||||
c1 = cmplx.complex(-71, 2)
|
||||
c2 = cmplx.complex(88, -12)
|
||||
result = c1 + c2
|
||||
assert result.equals(cmplx.complex(17,-10))
|
||||
c1 = cmplx.complex(0,-30)
|
||||
c2 = cmplx.complex(52,-30)
|
||||
assert result.equals(cmplx.complex(17, -10))
|
||||
c1 = cmplx.complex(0, -30)
|
||||
c2 = cmplx.complex(52, -30)
|
||||
result = c1 + c2
|
||||
assert result.equals(cmplx.complex(52,-60))
|
||||
c1 = cmplx.complex(12,-9)
|
||||
c2 = cmplx.complex(32,-6)
|
||||
assert result.equals(cmplx.complex(52, -60))
|
||||
c1 = cmplx.complex(12, -9)
|
||||
c2 = cmplx.complex(32, -6)
|
||||
result = c1 + c2
|
||||
assert result.equals(cmplx.complex(44,-15))
|
||||
assert result.equals(cmplx.complex(44, -15))
|
||||
}
|
||||
|
||||
fn test_complex_subtraction() {
|
||||
// Test is based on and verified from practice examples of Khan Academy
|
||||
// https://www.khanacademy.org/math/precalculus/imaginary-and-complex-numbers
|
||||
mut c1 := cmplx.complex(-8,0)
|
||||
mut c2 := cmplx.complex(6,30)
|
||||
mut c1 := cmplx.complex(-8, 0)
|
||||
mut c2 := cmplx.complex(6, 30)
|
||||
mut result := c1 - c2
|
||||
assert result.equals(cmplx.complex(-14,-30))
|
||||
c1 = cmplx.complex(-19,7)
|
||||
c2 = cmplx.complex(29,32)
|
||||
assert result.equals(cmplx.complex(-14, -30))
|
||||
c1 = cmplx.complex(-19, 7)
|
||||
c2 = cmplx.complex(29, 32)
|
||||
result = c1 - c2
|
||||
assert result.equals(cmplx.complex(-48,-25))
|
||||
c1 = cmplx.complex(12,0)
|
||||
c2 = cmplx.complex(23,13)
|
||||
assert result.equals(cmplx.complex(-48, -25))
|
||||
c1 = cmplx.complex(12, 0)
|
||||
c2 = cmplx.complex(23, 13)
|
||||
result = c1 - c2
|
||||
assert result.equals(cmplx.complex(-11,-13))
|
||||
c1 = cmplx.complex(-14,3)
|
||||
c2 = cmplx.complex(0,14)
|
||||
assert result.equals(cmplx.complex(-11, -13))
|
||||
c1 = cmplx.complex(-14, 3)
|
||||
c2 = cmplx.complex(0, 14)
|
||||
result = c1 - c2
|
||||
assert result.equals(cmplx.complex(-14,-11))
|
||||
assert result.equals(cmplx.complex(-14, -11))
|
||||
}
|
||||
|
||||
fn test_complex_multiplication() {
|
||||
// Test is based on and verified from practice examples of Khan Academy
|
||||
// https://www.khanacademy.org/math/precalculus/imaginary-and-complex-numbers
|
||||
mut c1 := cmplx.complex(1,2)
|
||||
mut c2 := cmplx.complex(1,-4)
|
||||
mut c1 := cmplx.complex(1, 2)
|
||||
mut c2 := cmplx.complex(1, -4)
|
||||
mut result := c1 * c2
|
||||
assert result.equals(cmplx.complex(9,-2))
|
||||
c1 = cmplx.complex(-4,-4)
|
||||
c2 = cmplx.complex(-5,-3)
|
||||
assert result.equals(cmplx.complex(9, -2))
|
||||
c1 = cmplx.complex(-4, -4)
|
||||
c2 = cmplx.complex(-5, -3)
|
||||
result = c1 * c2
|
||||
assert result.equals(cmplx.complex(8,32))
|
||||
c1 = cmplx.complex(4,4)
|
||||
c2 = cmplx.complex(-2,-5)
|
||||
assert result.equals(cmplx.complex(8, 32))
|
||||
c1 = cmplx.complex(4, 4)
|
||||
c2 = cmplx.complex(-2, -5)
|
||||
result = c1 * c2
|
||||
assert result.equals(cmplx.complex(12,-28))
|
||||
c1 = cmplx.complex(2,-2)
|
||||
c2 = cmplx.complex(4,-4)
|
||||
assert result.equals(cmplx.complex(12, -28))
|
||||
c1 = cmplx.complex(2, -2)
|
||||
c2 = cmplx.complex(4, -4)
|
||||
result = c1 * c2
|
||||
assert result.equals(cmplx.complex(0,-16))
|
||||
assert result.equals(cmplx.complex(0, -16))
|
||||
}
|
||||
|
||||
fn test_complex_division() {
|
||||
// Test is based on and verified from practice examples of Khan Academy
|
||||
// https://www.khanacademy.org/math/precalculus/imaginary-and-complex-numbers
|
||||
mut c1 := cmplx.complex(-9,-6)
|
||||
mut c2 := cmplx.complex(-3,-2)
|
||||
mut c1 := cmplx.complex(-9, -6)
|
||||
mut c2 := cmplx.complex(-3, -2)
|
||||
mut result := c1 / c2
|
||||
assert result.equals(cmplx.complex(3,0))
|
||||
c1 = cmplx.complex(-23,11)
|
||||
c2 = cmplx.complex(5,1)
|
||||
assert result.equals(cmplx.complex(3, 0))
|
||||
c1 = cmplx.complex(-23, 11)
|
||||
c2 = cmplx.complex(5, 1)
|
||||
result = c1 / c2
|
||||
assert result.equals(cmplx.complex(-4,3))
|
||||
c1 = cmplx.complex(8,-2)
|
||||
c2 = cmplx.complex(-4,1)
|
||||
assert result.equals(cmplx.complex(-4, 3))
|
||||
c1 = cmplx.complex(8, -2)
|
||||
c2 = cmplx.complex(-4, 1)
|
||||
result = c1 / c2
|
||||
assert result.equals(cmplx.complex(-2,0))
|
||||
c1 = cmplx.complex(11,24)
|
||||
c2 = cmplx.complex(-4,-1)
|
||||
assert result.equals(cmplx.complex(-2, 0))
|
||||
c1 = cmplx.complex(11, 24)
|
||||
c2 = cmplx.complex(-4, -1)
|
||||
result = c1 / c2
|
||||
assert result.equals(cmplx.complex(-4,-5))
|
||||
assert result.equals(cmplx.complex(-4, -5))
|
||||
}
|
||||
|
||||
fn test_complex_conjugate() {
|
||||
// Test is based on and verified from practice examples of Khan Academy
|
||||
// https://www.khanacademy.org/math/precalculus/imaginary-and-complex-numbers
|
||||
mut c1 := cmplx.complex(0,8)
|
||||
mut c1 := cmplx.complex(0, 8)
|
||||
mut result := c1.conjugate()
|
||||
assert result.equals(cmplx.complex(0,-8))
|
||||
c1 = cmplx.complex(7,3)
|
||||
assert result.equals(cmplx.complex(0, -8))
|
||||
c1 = cmplx.complex(7, 3)
|
||||
result = c1.conjugate()
|
||||
assert result.equals(cmplx.complex(7,-3))
|
||||
c1 = cmplx.complex(2,2)
|
||||
assert result.equals(cmplx.complex(7, -3))
|
||||
c1 = cmplx.complex(2, 2)
|
||||
result = c1.conjugate()
|
||||
assert result.equals(cmplx.complex(2,-2))
|
||||
c1 = cmplx.complex(7,0)
|
||||
assert result.equals(cmplx.complex(2, -2))
|
||||
c1 = cmplx.complex(7, 0)
|
||||
result = c1.conjugate()
|
||||
assert result.equals(cmplx.complex(7,0))
|
||||
assert result.equals(cmplx.complex(7, 0))
|
||||
}
|
||||
|
||||
fn test_complex_equals() {
|
||||
mut c1 := cmplx.complex(0,8)
|
||||
mut c2 := cmplx.complex(0,8)
|
||||
mut c1 := cmplx.complex(0, 8)
|
||||
mut c2 := cmplx.complex(0, 8)
|
||||
assert c1.equals(c2)
|
||||
c1 = cmplx.complex(-3,19)
|
||||
c2 = cmplx.complex(-3,19)
|
||||
c1 = cmplx.complex(-3, 19)
|
||||
c2 = cmplx.complex(-3, 19)
|
||||
assert c1.equals(c2)
|
||||
}
|
||||
|
||||
fn test_complex_abs() {
|
||||
mut c1 := cmplx.complex(3,4)
|
||||
mut c1 := cmplx.complex(3, 4)
|
||||
assert c1.abs() == 5
|
||||
c1 = cmplx.complex(1,2)
|
||||
c1 = cmplx.complex(1, 2)
|
||||
assert c1.abs() == math.sqrt(5)
|
||||
assert c1.abs() == c1.conjugate().abs()
|
||||
c1 = cmplx.complex(7,0)
|
||||
c1 = cmplx.complex(7, 0)
|
||||
assert c1.abs() == 7
|
||||
}
|
||||
|
||||
fn test_complex_angle(){
|
||||
fn test_complex_angle() {
|
||||
// Test is based on and verified from practice examples of Khan Academy
|
||||
// https://www.khanacademy.org/math/precalculus/imaginary-and-complex-numbers
|
||||
mut c := cmplx.complex(1, 0)
|
||||
@ -145,52 +145,51 @@ fn test_complex_angle(){
|
||||
assert cc.angle() + c.angle() == 0
|
||||
}
|
||||
|
||||
|
||||
fn test_complex_addinv() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(-5,-7)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(-5, -7)
|
||||
mut result := c1.addinv()
|
||||
assert result.equals(c2)
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(3,-4)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(3, -4)
|
||||
result = c1.addinv()
|
||||
assert result.equals(c2)
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(1,2)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(1, 2)
|
||||
result = c1.addinv()
|
||||
assert result.equals(c2)
|
||||
}
|
||||
|
||||
fn test_complex_mulinv() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(0.067568,-0.094595)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(0.067568, -0.094595)
|
||||
mut result := c1.mulinv()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
println(c2.str())
|
||||
println(result.str())
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-0.12,-0.16)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-0.12, -0.16)
|
||||
result = c1.mulinv()
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.2,0.4)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.2, 0.4)
|
||||
result = c1.mulinv()
|
||||
assert result.equals(c2)
|
||||
}
|
||||
|
||||
fn test_complex_mod() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut result := c1.mod()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert tst_res(result.str(), '8.602325')
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
result = c1.mod()
|
||||
assert result == 5
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
result = c1.mod()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert tst_res(result.str(), '2.236068')
|
||||
@ -198,18 +197,18 @@ fn test_complex_mod() {
|
||||
|
||||
fn test_complex_pow() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(-24.0,70.0)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(-24.0, 70.0)
|
||||
mut result := c1.pow(2)
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(117,44)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(117, 44)
|
||||
result = c1.pow(3)
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-7,-24)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-7, -24)
|
||||
result = c1.pow(4)
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -217,18 +216,18 @@ fn test_complex_pow() {
|
||||
|
||||
fn test_complex_root() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(2.607904,1.342074)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(2.607904, 1.342074)
|
||||
mut result := c1.root(2)
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(1.264953,1.150614)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(1.264953, 1.150614)
|
||||
result = c1.root(3)
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(1.068059,-0.595482)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(1.068059, -0.595482)
|
||||
result = c1.root(4)
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -236,18 +235,18 @@ fn test_complex_root() {
|
||||
|
||||
fn test_complex_exp() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(111.889015,97.505457)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(111.889015, 97.505457)
|
||||
mut result := c1.exp()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-0.032543,-0.037679)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-0.032543, -0.037679)
|
||||
result = c1.exp()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.153092,-0.334512)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.153092, -0.334512)
|
||||
result = c1.exp()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -255,18 +254,18 @@ fn test_complex_exp() {
|
||||
|
||||
fn test_complex_ln() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(2.152033,0.950547)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(2.152033, 0.950547)
|
||||
mut result := c1.ln()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(1.609438,2.214297)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(1.609438, 2.214297)
|
||||
result = c1.ln()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(0.804719,-2.034444)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(0.804719, -2.034444)
|
||||
result = c1.ln()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -274,18 +273,18 @@ fn test_complex_ln() {
|
||||
|
||||
fn test_complex_arg() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(2.152033,0.950547)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(2.152033, 0.950547)
|
||||
mut result := c1.arg()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert tst_res(result.str(), '0.950547')
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(1.609438,2.214297)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(1.609438, 2.214297)
|
||||
result = c1.arg()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert tst_res(result.str(), '2.214297')
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(0.804719,-2.034444)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(0.804719, -2.034444)
|
||||
result = c1.arg()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert tst_res(result.str(), '-2.034444')
|
||||
@ -293,21 +292,21 @@ fn test_complex_arg() {
|
||||
|
||||
fn test_complex_log() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut b1 := cmplx.complex(-6,-2)
|
||||
mut c2 := cmplx.complex(0.232873,-1.413175)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut b1 := cmplx.complex(-6, -2)
|
||||
mut c2 := cmplx.complex(0.232873, -1.413175)
|
||||
mut result := c1.log(b1)
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
b1 = cmplx.complex(3,-1)
|
||||
c2 = cmplx.complex(0.152198,-0.409312)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
b1 = cmplx.complex(3, -1)
|
||||
c2 = cmplx.complex(0.152198, -0.409312)
|
||||
result = c1.log(b1)
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
b1 = cmplx.complex(0,9)
|
||||
c2 = cmplx.complex(-0.298243,1.197981)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
b1 = cmplx.complex(0, 9)
|
||||
c2 = cmplx.complex(-0.298243, 1.197981)
|
||||
result = c1.log(b1)
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -315,21 +314,21 @@ fn test_complex_log() {
|
||||
|
||||
fn test_complex_cpow() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut r1 := cmplx.complex(2,2)
|
||||
mut c2 := cmplx.complex(11.022341,-0.861785)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut r1 := cmplx.complex(2, 2)
|
||||
mut c2 := cmplx.complex(11.022341, -0.861785)
|
||||
mut result := c1.cpow(r1)
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
r1 = cmplx.complex(-4,-2)
|
||||
c2 = cmplx.complex(0.118303,0.063148)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
r1 = cmplx.complex(-4, -2)
|
||||
c2 = cmplx.complex(0.118303, 0.063148)
|
||||
result = c1.cpow(r1)
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
r1 = cmplx.complex(8,-9)
|
||||
c2 = cmplx.complex(-0.000000,0.000007)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
r1 = cmplx.complex(8, -9)
|
||||
c2 = cmplx.complex(-0.000000, 0.000007)
|
||||
result = c1.cpow(r1)
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -337,18 +336,18 @@ fn test_complex_cpow() {
|
||||
|
||||
fn test_complex_sin() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(-525.794515,155.536550)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(-525.794515, 155.536550)
|
||||
mut result := c1.sin()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-3.853738,-27.016813)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-3.853738, -27.016813)
|
||||
result = c1.sin()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-3.165779,-1.959601)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-3.165779, -1.959601)
|
||||
result = c1.sin()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -356,18 +355,18 @@ fn test_complex_sin() {
|
||||
|
||||
fn test_complex_cos() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(155.536809,525.793641)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(155.536809, 525.793641)
|
||||
mut result := c1.cos()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-27.034946,3.851153)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-27.034946, 3.851153)
|
||||
result = c1.cos()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(2.032723,-3.051898)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(2.032723, -3.051898)
|
||||
result = c1.cos()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -375,18 +374,18 @@ fn test_complex_cos() {
|
||||
|
||||
fn test_complex_tan() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(-0.000001,1.000001)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(-0.000001, 1.000001)
|
||||
mut result := c1.tan()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(0.000187,0.999356)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(0.000187, 0.999356)
|
||||
result = c1.tan()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.033813,-1.014794)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.033813, -1.014794)
|
||||
result = c1.tan()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -394,18 +393,18 @@ fn test_complex_tan() {
|
||||
|
||||
fn test_complex_cot() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(-0.000001,-0.999999)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(-0.000001, -0.999999)
|
||||
mut result := c1.cot()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(0.000188,-1.000644)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(0.000188, -1.000644)
|
||||
result = c1.cot()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.032798,0.984329)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.032798, 0.984329)
|
||||
result = c1.cot()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -413,18 +412,18 @@ fn test_complex_cot() {
|
||||
|
||||
fn test_complex_sec() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(0.000517,-0.001749)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(0.000517, -0.001749)
|
||||
mut result := c1.sec()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-0.036253,-0.005164)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-0.036253, -0.005164)
|
||||
result = c1.sec()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(0.151176,0.226974)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(0.151176, 0.226974)
|
||||
result = c1.sec()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -432,18 +431,18 @@ fn test_complex_sec() {
|
||||
|
||||
fn test_complex_csc() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(-0.001749,-0.000517)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(-0.001749, -0.000517)
|
||||
mut result := c1.csc()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-0.005174,0.036276)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-0.005174, 0.036276)
|
||||
result = c1.csc()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.228375,0.141363)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.228375, 0.141363)
|
||||
result = c1.csc()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -451,18 +450,18 @@ fn test_complex_csc() {
|
||||
|
||||
fn test_complex_asin() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(0.617064,2.846289)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(0.617064, 2.846289)
|
||||
mut result := c1.asin()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-0.633984,2.305509)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-0.633984, 2.305509)
|
||||
result = c1.asin()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.427079,-1.528571)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.427079, -1.528571)
|
||||
result = c1.asin()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -470,18 +469,18 @@ fn test_complex_asin() {
|
||||
|
||||
fn test_complex_acos() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(0.953732,-2.846289)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(0.953732, -2.846289)
|
||||
mut result := c1.acos()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(2.204780,-2.305509)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(2.204780, -2.305509)
|
||||
result = c1.acos()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(1.997875,1.528571)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(1.997875, 1.528571)
|
||||
result = c1.acos()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -489,18 +488,18 @@ fn test_complex_acos() {
|
||||
|
||||
fn test_complex_atan() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(1.502727,0.094441)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(1.502727, 0.094441)
|
||||
mut result := c1.atan()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-1.448307,0.158997)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-1.448307, 0.158997)
|
||||
result = c1.atan()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-1.338973,-0.402359)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-1.338973, -0.402359)
|
||||
result = c1.atan()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -508,18 +507,18 @@ fn test_complex_atan() {
|
||||
|
||||
fn test_complex_acot() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(0.068069,-0.094441)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(0.068069, -0.094441)
|
||||
mut result := c1.acot()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-0.122489,-0.158997)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-0.122489, -0.158997)
|
||||
result = c1.acot()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.231824,0.402359)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.231824, 0.402359)
|
||||
result = c1.acot()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -527,18 +526,18 @@ fn test_complex_acot() {
|
||||
|
||||
fn test_complex_asec() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(1.503480,0.094668)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(1.503480, 0.094668)
|
||||
mut result := c1.asec()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(1.689547,0.160446)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(1.689547, 0.160446)
|
||||
result = c1.asec()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(1.757114,-0.396568)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(1.757114, -0.396568)
|
||||
result = c1.asec()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -546,18 +545,18 @@ fn test_complex_asec() {
|
||||
|
||||
fn test_complex_acsc() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(0.067317,-0.094668)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(0.067317, -0.094668)
|
||||
mut result := c1.acsc()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-0.118751,-0.160446)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-0.118751, -0.160446)
|
||||
result = c1.acsc()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.186318,0.396568)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.186318, 0.396568)
|
||||
result = c1.acsc()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -565,18 +564,18 @@ fn test_complex_acsc() {
|
||||
|
||||
fn test_complex_sinh() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(55.941968,48.754942)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(55.941968, 48.754942)
|
||||
mut result := c1.sinh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(6.548120,-7.619232)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(6.548120, -7.619232)
|
||||
result = c1.sinh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(0.489056,-1.403119)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(0.489056, -1.403119)
|
||||
result = c1.sinh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -584,18 +583,18 @@ fn test_complex_sinh() {
|
||||
|
||||
fn test_complex_cosh() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(55.947047,48.750515)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(55.947047, 48.750515)
|
||||
mut result := c1.cosh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-6.580663,7.581553)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-6.580663, 7.581553)
|
||||
result = c1.cosh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.642148,1.068607)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.642148, 1.068607)
|
||||
result = c1.cosh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -603,18 +602,18 @@ fn test_complex_cosh() {
|
||||
|
||||
fn test_complex_tanh() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(0.999988,0.000090)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(0.999988, 0.000090)
|
||||
mut result := c1.tanh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-1.000710,0.004908)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-1.000710, 0.004908)
|
||||
result = c1.tanh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-1.166736,0.243458)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-1.166736, 0.243458)
|
||||
result = c1.tanh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -622,18 +621,18 @@ fn test_complex_tanh() {
|
||||
|
||||
fn test_complex_coth() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(1.000012,-0.000090)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(1.000012, -0.000090)
|
||||
mut result := c1.coth()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-0.999267,-0.004901)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-0.999267, -0.004901)
|
||||
result = c1.coth()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.821330,-0.171384)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.821330, -0.171384)
|
||||
result = c1.coth()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -641,18 +640,18 @@ fn test_complex_coth() {
|
||||
|
||||
fn test_complex_sech() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(0.010160,-0.008853)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(0.010160, -0.008853)
|
||||
mut result := c1.sech()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-0.065294,-0.075225)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-0.065294, -0.075225)
|
||||
result = c1.sech()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.413149,-0.687527)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.413149, -0.687527)
|
||||
result = c1.sech()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -660,18 +659,18 @@ fn test_complex_sech() {
|
||||
|
||||
fn test_complex_csch() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(0.010159,-0.008854)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(0.010159, -0.008854)
|
||||
mut result := c1.csch()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(0.064877,0.075490)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(0.064877, 0.075490)
|
||||
result = c1.csch()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(0.221501,0.635494)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(0.221501, 0.635494)
|
||||
result = c1.csch()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -679,18 +678,18 @@ fn test_complex_csch() {
|
||||
|
||||
fn test_complex_asinh() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(2.844098,0.947341)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(2.844098, 0.947341)
|
||||
mut result := c1.asinh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-2.299914,0.917617)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-2.299914, 0.917617)
|
||||
result = c1.asinh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-1.469352,-1.063440)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-1.469352, -1.063440)
|
||||
result = c1.asinh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -698,18 +697,18 @@ fn test_complex_asinh() {
|
||||
|
||||
fn test_complex_acosh() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(2.846289,0.953732)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(2.846289, 0.953732)
|
||||
mut result := c1.acosh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(2.305509,2.204780)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(2.305509, 2.204780)
|
||||
result = c1.acosh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(1.528571,-1.997875)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(1.528571, -1.997875)
|
||||
result = c1.acosh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -717,18 +716,18 @@ fn test_complex_acosh() {
|
||||
|
||||
fn test_complex_atanh() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(0.067066,1.476056)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(0.067066, 1.476056)
|
||||
mut result := c1.atanh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-0.117501,1.409921)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-0.117501, 1.409921)
|
||||
result = c1.atanh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.173287,-1.178097)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.173287, -1.178097)
|
||||
result = c1.atanh()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -736,18 +735,18 @@ fn test_complex_atanh() {
|
||||
|
||||
fn test_complex_acoth() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(0.067066,-0.094740)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(0.067066, -0.094740)
|
||||
mut result := c1.acoth()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-0.117501,-0.160875)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-0.117501, -0.160875)
|
||||
result = c1.acoth()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.173287,0.392699)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.173287, 0.392699)
|
||||
result = c1.acoth()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
@ -774,18 +773,18 @@ fn test_complex_acoth() {
|
||||
|
||||
fn test_complex_acsch() {
|
||||
// Tests were also verified on Wolfram Alpha
|
||||
mut c1 := cmplx.complex(5,7)
|
||||
mut c2 := cmplx.complex(0.067819,-0.094518)
|
||||
mut c1 := cmplx.complex(5, 7)
|
||||
mut c2 := cmplx.complex(0.067819, -0.094518)
|
||||
mut result := c1.acsch()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-3,4)
|
||||
c2 = cmplx.complex(-0.121246,-0.159507)
|
||||
c1 = cmplx.complex(-3, 4)
|
||||
c2 = cmplx.complex(-0.121246, -0.159507)
|
||||
result = c1.acsch()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
c1 = cmplx.complex(-1,-2)
|
||||
c2 = cmplx.complex(-0.215612,0.401586)
|
||||
c1 = cmplx.complex(-1, -2)
|
||||
c2 = cmplx.complex(-0.215612, 0.401586)
|
||||
result = c1.acsch()
|
||||
// Some issue with precision comparison in f64 using == operator hence serializing to string
|
||||
assert result.str().eq(c2.str())
|
||||
|
Reference in New Issue
Block a user