Commit 0c70d9c714

expikr <77922942+expikr@users.noreply.github.com>
2023-11-07 21:10:43
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
1 parent 9fce1d1
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);
 }
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);
 }
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;
 
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);
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),
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);
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);
 }
 
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);
 }
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),
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),
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),
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);
 
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));
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);
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),
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),
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);
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),