From 0c70d9c71455122c6d67777c216e47133b8f8416 Mon Sep 17 00:00:00 2001 From: expikr <77922942+expikr@users.noreply.github.com> Date: Wed, 8 Nov 2023 04:10:43 +0800 Subject: [PATCH] use Peer Type Resolution for standalone complex fn use peer type resolution Update complex.zig Revert "use peer type resolution" This reverts commit 1bc681ca5b36d2b55b5efab5a5dbec7e8a17332e. Revert "Update pow.zig" This reverts commit 5487e8d3159f832b5a0bf29a06bd12575182464f. Update pow.zig Revert "Update pow.zig" This reverts commit 521153d1ef004d627c785f2d3fe5e6497dc15073. Update pow.zig --- lib/std/math/complex/acos.zig | 4 ++-- lib/std/math/complex/acosh.zig | 4 ++-- lib/std/math/complex/asin.zig | 4 ++-- lib/std/math/complex/asinh.zig | 4 ++-- lib/std/math/complex/atan.zig | 4 ++-- lib/std/math/complex/atanh.zig | 4 ++-- lib/std/math/complex/conj.zig | 4 ++-- lib/std/math/complex/cos.zig | 4 ++-- lib/std/math/complex/cosh.zig | 4 ++-- lib/std/math/complex/exp.zig | 4 ++-- lib/std/math/complex/ldexp.zig | 4 ++-- lib/std/math/complex/log.zig | 4 ++-- lib/std/math/complex/proj.zig | 4 ++-- lib/std/math/complex/sin.zig | 4 ++-- lib/std/math/complex/sinh.zig | 4 ++-- lib/std/math/complex/sqrt.zig | 4 ++-- lib/std/math/complex/tan.zig | 4 ++-- lib/std/math/complex/tanh.zig | 4 ++-- 18 files changed, 36 insertions(+), 36 deletions(-) diff --git a/lib/std/math/complex/acos.zig b/lib/std/math/complex/acos.zig index 12aec799e67db8196de0a01ccca55f6353461da2..e7f0f1f021f626306149b726b2c982a6a6721d08 100644 --- a/lib/std/math/complex/acos.zig +++ b/lib/std/math/complex/acos.zig @@ -5,8 +5,8 @@ const cmath = math.complex; const Complex = cmath.Complex; /// Returns the arc-cosine of z. -pub fn acos(z: anytype) Complex(@TypeOf(z.re)) { - const T = @TypeOf(z.re); +pub fn acos(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); const q = cmath.asin(z); return Complex(T).init(@as(T, math.pi) / 2 - q.re, -q.im); } diff --git a/lib/std/math/complex/acosh.zig b/lib/std/math/complex/acosh.zig index 6f20e4dda27fb09d941d92244f283fe6d7250489..4eab21914bcef6c1de79e5925d0a6392f0677708 100644 --- a/lib/std/math/complex/acosh.zig +++ b/lib/std/math/complex/acosh.zig @@ -5,8 +5,8 @@ const cmath = math.complex; const Complex = cmath.Complex; /// Returns the hyperbolic arc-cosine of z. -pub fn acosh(z: anytype) Complex(@TypeOf(z.re)) { - const T = @TypeOf(z.re); +pub fn acosh(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); const q = cmath.acos(z); return Complex(T).init(-q.im, q.re); } diff --git a/lib/std/math/complex/asin.zig b/lib/std/math/complex/asin.zig index e4b97c693dbe746ce50c37c2b049d66bef4e9998..aad337c6e2eef9b4cbd5e1156adee7bcf973c1cb 100644 --- a/lib/std/math/complex/asin.zig +++ b/lib/std/math/complex/asin.zig @@ -5,8 +5,8 @@ const cmath = math.complex; const Complex = cmath.Complex; // Returns the arc-sine of z. -pub fn asin(z: anytype) Complex(@TypeOf(z.re)) { - const T = @TypeOf(z.re); +pub fn asin(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); const x = z.re; const y = z.im; diff --git a/lib/std/math/complex/asinh.zig b/lib/std/math/complex/asinh.zig index bd1b8ee016b3741cabf6d3d55ec9fee59bb80386..67daabcf002af76105d07089fb1c34ce13e0fd7b 100644 --- a/lib/std/math/complex/asinh.zig +++ b/lib/std/math/complex/asinh.zig @@ -5,8 +5,8 @@ const cmath = math.complex; const Complex = cmath.Complex; /// Returns the hyperbolic arc-sine of z. -pub fn asinh(z: anytype) Complex(@TypeOf(z.re)) { - const T = @TypeOf(z.re); +pub fn asinh(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); const q = Complex(T).init(-z.im, z.re); const r = cmath.asin(q); return Complex(T).init(r.im, -r.re); diff --git a/lib/std/math/complex/atan.zig b/lib/std/math/complex/atan.zig index 028a9f746c472a5e72b9b6f61a1e110b886413d8..5af14fb629e3a570c15e3c7fed8ff5684431f5d7 100644 --- a/lib/std/math/complex/atan.zig +++ b/lib/std/math/complex/atan.zig @@ -11,8 +11,8 @@ const cmath = math.complex; const Complex = cmath.Complex; /// Returns the arc-tangent of z. -pub fn atan(z: anytype) @TypeOf(z) { - const T = @TypeOf(z.re); +pub fn atan(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); return switch (T) { f32 => atan32(z), f64 => atan64(z), diff --git a/lib/std/math/complex/atanh.zig b/lib/std/math/complex/atanh.zig index 01ddf7a9025d571c9ff18971417c5caf7b1e4bfa..b9dcae6ac81a3d91898f336bc4485ee6070d71f5 100644 --- a/lib/std/math/complex/atanh.zig +++ b/lib/std/math/complex/atanh.zig @@ -5,8 +5,8 @@ const cmath = math.complex; const Complex = cmath.Complex; /// Returns the hyperbolic arc-tangent of z. -pub fn atanh(z: anytype) Complex(@TypeOf(z.re)) { - const T = @TypeOf(z.re); +pub fn atanh(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); const q = Complex(T).init(-z.im, z.re); const r = cmath.atan(q); return Complex(T).init(r.im, -r.re); diff --git a/lib/std/math/complex/conj.zig b/lib/std/math/complex/conj.zig index 7427e44caa3867eb374317b30dfb00a442385408..b470b5b442aefda06aeca6073ca1f2584abc3848 100644 --- a/lib/std/math/complex/conj.zig +++ b/lib/std/math/complex/conj.zig @@ -5,8 +5,8 @@ const cmath = math.complex; const Complex = cmath.Complex; /// Returns the complex conjugate of z. -pub fn conj(z: anytype) Complex(@TypeOf(z.re)) { - const T = @TypeOf(z.re); +pub fn conj(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); return Complex(T).init(z.re, -z.im); } diff --git a/lib/std/math/complex/cos.zig b/lib/std/math/complex/cos.zig index 1c470c44c12c9398c2db1af01cba19826afd10aa..3b14ba47a3835081a457a240c386fd729860c727 100644 --- a/lib/std/math/complex/cos.zig +++ b/lib/std/math/complex/cos.zig @@ -5,8 +5,8 @@ const cmath = math.complex; const Complex = cmath.Complex; /// Returns the cosine of z. -pub fn cos(z: anytype) Complex(@TypeOf(z.re)) { - const T = @TypeOf(z.re); +pub fn cos(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); const p = Complex(T).init(-z.im, z.re); return cmath.cosh(p); } diff --git a/lib/std/math/complex/cosh.zig b/lib/std/math/complex/cosh.zig index b83562601d2fecd9395dfb3b02ecde687ee7bb7f..fe987a75e7e5f8e5834067be85b795854160ef52 100644 --- a/lib/std/math/complex/cosh.zig +++ b/lib/std/math/complex/cosh.zig @@ -13,8 +13,8 @@ const Complex = cmath.Complex; const ldexp_cexp = @import("ldexp.zig").ldexp_cexp; /// Returns the hyperbolic arc-cosine of z. -pub fn cosh(z: anytype) Complex(@TypeOf(z.re)) { - const T = @TypeOf(z.re); +pub fn cosh(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); return switch (T) { f32 => cosh32(z), f64 => cosh64(z), diff --git a/lib/std/math/complex/exp.zig b/lib/std/math/complex/exp.zig index 6b645ece48ee48427260dffc2b8bca0d3c74fa67..5b70e547acf14415b3d78cac419071a130f83b0d 100644 --- a/lib/std/math/complex/exp.zig +++ b/lib/std/math/complex/exp.zig @@ -13,8 +13,8 @@ const Complex = cmath.Complex; const ldexp_cexp = @import("ldexp.zig").ldexp_cexp; /// Returns e raised to the power of z (e^z). -pub fn exp(z: anytype) @TypeOf(z) { - const T = @TypeOf(z.re); +pub fn exp(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); return switch (T) { f32 => exp32(z), diff --git a/lib/std/math/complex/ldexp.zig b/lib/std/math/complex/ldexp.zig index 201b6305af372c931378fe2deb7e2c42dca3753f..7a19b5f2ceb752c5f91d8dfb44d765251ee67fe8 100644 --- a/lib/std/math/complex/ldexp.zig +++ b/lib/std/math/complex/ldexp.zig @@ -12,8 +12,8 @@ const cmath = math.complex; const Complex = cmath.Complex; /// Returns exp(z) scaled to avoid overflow. -pub fn ldexp_cexp(z: anytype, expt: i32) @TypeOf(z) { - const T = @TypeOf(z.re); +pub fn ldexp_cexp(z: anytype, expt: i32) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); return switch (T) { f32 => ldexp_cexp32(z, expt), diff --git a/lib/std/math/complex/log.zig b/lib/std/math/complex/log.zig index 6d1b06d2720d5d5d65d55b7dae861219cdfdc744..c7258881023874c53b5e54e068e88a3d5671e19c 100644 --- a/lib/std/math/complex/log.zig +++ b/lib/std/math/complex/log.zig @@ -5,8 +5,8 @@ const cmath = math.complex; const Complex = cmath.Complex; /// Returns the natural logarithm of z. -pub fn log(z: anytype) Complex(@TypeOf(z.re)) { - const T = @TypeOf(z.re); +pub fn log(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); const r = cmath.abs(z); const phi = cmath.arg(z); diff --git a/lib/std/math/complex/proj.zig b/lib/std/math/complex/proj.zig index 0b4b7b7a17730169700b56e4d59a9cd10977bcd3..4c67c92fe9199200cd349ea0b17819f40e545f69 100644 --- a/lib/std/math/complex/proj.zig +++ b/lib/std/math/complex/proj.zig @@ -5,8 +5,8 @@ const cmath = math.complex; const Complex = cmath.Complex; /// Returns the projection of z onto the riemann sphere. -pub fn proj(z: anytype) Complex(@TypeOf(z.re)) { - const T = @TypeOf(z.re); +pub fn proj(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); if (math.isInf(z.re) or math.isInf(z.im)) { return Complex(T).init(math.inf(T), math.copysign(@as(T, 0.0), z.re)); diff --git a/lib/std/math/complex/sin.zig b/lib/std/math/complex/sin.zig index 7fa3fcf923f917724900f4a41dc04f0349da7962..b966957456ce9fd940676d8ffb88b91897b6ed54 100644 --- a/lib/std/math/complex/sin.zig +++ b/lib/std/math/complex/sin.zig @@ -5,8 +5,8 @@ const cmath = math.complex; const Complex = cmath.Complex; /// Returns the sine of z. -pub fn sin(z: anytype) Complex(@TypeOf(z.re)) { - const T = @TypeOf(z.re); +pub fn sin(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); const p = Complex(T).init(-z.im, z.re); const q = cmath.sinh(p); return Complex(T).init(q.im, -q.re); diff --git a/lib/std/math/complex/sinh.zig b/lib/std/math/complex/sinh.zig index c5aad570f8159120d6630b18ec1d6c900f6cf5fa..5b3bf94a41ab1d3d6407f542ccfe12d1ba8d0bbc 100644 --- a/lib/std/math/complex/sinh.zig +++ b/lib/std/math/complex/sinh.zig @@ -13,8 +13,8 @@ const Complex = cmath.Complex; const ldexp_cexp = @import("ldexp.zig").ldexp_cexp; /// Returns the hyperbolic sine of z. -pub fn sinh(z: anytype) @TypeOf(z) { - const T = @TypeOf(z.re); +pub fn sinh(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); return switch (T) { f32 => sinh32(z), f64 => sinh64(z), diff --git a/lib/std/math/complex/sqrt.zig b/lib/std/math/complex/sqrt.zig index 5ecbd564f7db340de8a9f6fcf612f134ae5732c4..fe2880e355ea6e392860f67fd514fdcd9f729fcb 100644 --- a/lib/std/math/complex/sqrt.zig +++ b/lib/std/math/complex/sqrt.zig @@ -12,8 +12,8 @@ const Complex = cmath.Complex; /// Returns the square root of z. The real and imaginary parts of the result have the same sign /// as the imaginary part of z. -pub fn sqrt(z: anytype) @TypeOf(z) { - const T = @TypeOf(z.re); +pub fn sqrt(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); return switch (T) { f32 => sqrt32(z), diff --git a/lib/std/math/complex/tan.zig b/lib/std/math/complex/tan.zig index a0ce5d18e0d1e1fa5e5d4ffb885242f52e15705b..4e22ab9eb09b27fc8f5e987587661d3bb9e6a39e 100644 --- a/lib/std/math/complex/tan.zig +++ b/lib/std/math/complex/tan.zig @@ -5,8 +5,8 @@ const cmath = math.complex; const Complex = cmath.Complex; /// Returns the tangent of z. -pub fn tan(z: anytype) Complex(@TypeOf(z.re)) { - const T = @TypeOf(z.re); +pub fn tan(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); const q = Complex(T).init(-z.im, z.re); const r = cmath.tanh(q); return Complex(T).init(r.im, -r.re); diff --git a/lib/std/math/complex/tanh.zig b/lib/std/math/complex/tanh.zig index 65074f28e14be30379f4e5a64fb35d5e97ba1ca1..02ba0bf91c371d3f138c055841e41690f4fb38f5 100644 --- a/lib/std/math/complex/tanh.zig +++ b/lib/std/math/complex/tanh.zig @@ -11,8 +11,8 @@ const cmath = math.complex; const Complex = cmath.Complex; /// Returns the hyperbolic tangent of z. -pub fn tanh(z: anytype) @TypeOf(z) { - const T = @TypeOf(z.re); +pub fn tanh(z: anytype) Complex(@TypeOf(z.re, z.im)) { + const T = @TypeOf(z.re, z.im); return switch (T) { f32 => tanh32(z), f64 => tanh64(z), -- 2.54.0