Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add simple vectorized impls for Log(x, y), Log10, Hypot
  • Loading branch information
stephentoub committed Jan 30, 2024
commit b16f0c03a90cecfa9ea8eac884bd88a92acd66a0
Original file line number Diff line number Diff line change
Expand Up @@ -12771,11 +12771,11 @@ public static Vector512<T> Invoke(Vector512<T> x)
internal readonly struct HypotOperator<T> : IBinaryOperator<T>
where T : IRootFunctions<T>
{
public static bool Vectorizable => false; // TODO: Vectorize
public static bool Vectorizable => true;
public static T Invoke(T x, T y) => T.Hypot(x, y);
public static Vector128<T> Invoke(Vector128<T> x, Vector128<T> y) => throw new NotSupportedException();
public static Vector256<T> Invoke(Vector256<T> x, Vector256<T> y) => throw new NotSupportedException();
public static Vector512<T> Invoke(Vector512<T> x, Vector512<T> y) => throw new NotSupportedException();
public static Vector128<T> Invoke(Vector128<T> x, Vector128<T> y) => Vector128.Sqrt((x * x) + (y * y));
public static Vector256<T> Invoke(Vector256<T> x, Vector256<T> y) => Vector256.Sqrt((x * x) + (y * y));
public static Vector512<T> Invoke(Vector512<T> x, Vector512<T> y) => Vector512.Sqrt((x * x) + (y * y));
}

/// <summary>T.Acos(x)</summary>
Expand Down Expand Up @@ -14500,11 +14500,12 @@ public static Vector512<float> Invoke(Vector512<float> x)
internal readonly struct Log10Operator<T> : IUnaryOperator<T, T>
where T : ILogarithmicFunctions<T>
{
public static bool Vectorizable => false; // TODO: Vectorize
private static readonly double s_log10 = Math.Log(10d);
public static bool Vectorizable => LogOperator<T>.Vectorizable;
public static T Invoke(T x) => T.Log10(x);
public static Vector128<T> Invoke(Vector128<T> x) => throw new NotSupportedException();
public static Vector256<T> Invoke(Vector256<T> x) => throw new NotSupportedException();
public static Vector512<T> Invoke(Vector512<T> x) => throw new NotSupportedException();
public static Vector128<T> Invoke(Vector128<T> x) => LogOperator<T>.Invoke(x) / Vector128.Create(T.CreateTruncating(s_log10));
public static Vector256<T> Invoke(Vector256<T> x) => LogOperator<T>.Invoke(x) / Vector256.Create(T.CreateTruncating(s_log10));
public static Vector512<T> Invoke(Vector512<T> x) => LogOperator<T>.Invoke(x) / Vector512.Create(T.CreateTruncating(s_log10));
}

/// <summary>T.LogP1(x)</summary>
Expand Down Expand Up @@ -14544,11 +14545,11 @@ public static Vector512<float> Invoke(Vector512<float> x)
internal readonly struct LogBaseOperator<T> : IBinaryOperator<T>
where T : ILogarithmicFunctions<T>
{
public static bool Vectorizable => false; // TODO: Vectorize
public static bool Vectorizable => LogOperator<T>.Vectorizable;
public static T Invoke(T x, T y) => T.Log(x, y);
public static Vector128<T> Invoke(Vector128<T> x, Vector128<T> y) => throw new NotSupportedException();
public static Vector256<T> Invoke(Vector256<T> x, Vector256<T> y) => throw new NotSupportedException();
public static Vector512<T> Invoke(Vector512<T> x, Vector512<T> y) => throw new NotSupportedException();
public static Vector128<T> Invoke(Vector128<T> x, Vector128<T> y) => LogOperator<T>.Invoke(x) / LogOperator<T>.Invoke(y);
public static Vector256<T> Invoke(Vector256<T> x, Vector256<T> y) => LogOperator<T>.Invoke(x) / LogOperator<T>.Invoke(y);
public static Vector512<T> Invoke(Vector512<T> x, Vector512<T> y) => LogOperator<T>.Invoke(x) / LogOperator<T>.Invoke(y);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down