Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ private static bool AlwaysFinite<T>() =>
public static Vector128<T> Invoke(Vector128<T> x) => Vector128.IsFinite(x);
public static Vector256<T> Invoke(Vector256<T> x) => Vector256.IsFinite(x);
public static Vector512<T> Invoke(Vector512<T> x) => Vector512.IsFinite(x);

// A finite value is one whose absolute bit pattern lies below that of infinity.
public static bool HasThresholdForm => typeof(T) == typeof(float) || typeof(T) == typeof(double);
public static bool TrueBelowThreshold => true;
public static ulong ThresholdBits => PositiveInfinityBits<T>();
public static Vector128<T> Key(Vector128<T> x) => Vector128.Abs(x);
public static Vector256<T> Key(Vector256<T> x) => Vector256.Abs(x);
public static Vector512<T> Key(Vector512<T> x) => Vector512.Abs(x);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ private static bool MayBeNaN<T>() =>
public static Vector128<T> Invoke(Vector128<T> x) => Vector128.IsNaN<T>(x);
public static Vector256<T> Invoke(Vector256<T> x) => Vector256.IsNaN<T>(x);
public static Vector512<T> Invoke(Vector512<T> x) => Vector512.IsNaN<T>(x);

// A NaN is a value whose absolute bit pattern lies above that of infinity.
public static bool HasThresholdForm => typeof(T) == typeof(float) || typeof(T) == typeof(double);
public static bool TrueBelowThreshold => false;
public static ulong ThresholdBits => PositiveInfinityBits<T>();
public static Vector128<T> Key(Vector128<T> x) => Vector128.Abs(x);
public static Vector256<T> Key(Vector256<T> x) => Vector256.Abs(x);
public static Vector512<T> Key(Vector512<T> x) => Vector512.Abs(x);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ private static bool MayBeNegative<T>() =>
public static Vector128<T> Invoke(Vector128<T> x) => Vector128.IsNegative<T>(x);
public static Vector256<T> Invoke(Vector256<T> x) => Vector256.IsNegative<T>(x);
public static Vector512<T> Invoke(Vector512<T> x) => Vector512.IsNegative<T>(x);

// A negative value is one whose sign bit is set: whose bits lie above the values with the sign bit clear.
public static bool HasThresholdForm => MayBeNegative<T>() && (IsPrimitiveBinaryInteger<T>() || typeof(T) == typeof(float) || typeof(T) == typeof(double));
public static bool TrueBelowThreshold => false;
public static ulong ThresholdBits => SignBit<T>() - 1;
public static Vector128<T> Key(Vector128<T> x) => x;
public static Vector256<T> Key(Vector256<T> x) => x;
public static Vector512<T> Key(Vector512<T> x) => x;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ public static bool IsNormalAny<T>(ReadOnlySpan<T> x)
public static Vector256<T> Invoke(Vector256<T> x) => Vector256.IsNormal(x);

public static Vector512<T> Invoke(Vector512<T> x) => Vector512.IsNormal(x);

// A normal value is one whose absolute bit pattern lies between those of the smallest normal value (inclusive) and infinity (exclusive),
// the same range test as the operator's, which the subtraction turns into a single comparison: a smaller pattern wraps around.
public static bool HasThresholdForm => typeof(T) == typeof(float) || typeof(T) == typeof(double);
public static bool TrueBelowThreshold => true;
public static ulong ThresholdBits => PositiveInfinityBits<T>() - SmallestNormalBits<T>();
public static Vector128<T> Key(Vector128<T> x) => SubtractBits(Vector128.Abs(x), SmallestNormalBits<T>());
public static Vector256<T> Key(Vector256<T> x) => SubtractBits(Vector256.Abs(x), SmallestNormalBits<T>());
public static Vector512<T> Key(Vector512<T> x) => SubtractBits(Vector512.Abs(x), SmallestNormalBits<T>());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ public static bool IsPositiveAny<T>(ReadOnlySpan<T> x)
public static Vector128<T> Invoke(Vector128<T> x) => Vector128.IsPositive<T>(x);
public static Vector256<T> Invoke(Vector256<T> x) => Vector256.IsPositive<T>(x);
public static Vector512<T> Invoke(Vector512<T> x) => Vector512.IsPositive<T>(x);

// A positive value is one whose sign bit is clear: whose bits lie below the sign bit.
public static bool HasThresholdForm => MayBeNegative<T>() && (IsPrimitiveBinaryInteger<T>() || typeof(T) == typeof(float) || typeof(T) == typeof(double));
public static bool TrueBelowThreshold => true;
public static ulong ThresholdBits => SignBit<T>();
public static Vector128<T> Key(Vector128<T> x) => x;
public static Vector256<T> Key(Vector256<T> x) => x;
public static Vector512<T> Key(Vector512<T> x) => x;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ private static bool AlwaysReal<T>() =>
public static Vector128<T> Invoke(Vector128<T> x) => ~Vector128.IsNaN(x);
public static Vector256<T> Invoke(Vector256<T> x) => ~Vector256.IsNaN(x);
public static Vector512<T> Invoke(Vector512<T> x) => ~Vector512.IsNaN(x);

// A real number is any value but a NaN: one whose absolute bit pattern lies below that of the first NaN, the one after infinity.
public static bool HasThresholdForm => typeof(T) == typeof(float) || typeof(T) == typeof(double);
public static bool TrueBelowThreshold => true;
public static ulong ThresholdBits => PositiveInfinityBits<T>() + 1;
public static Vector128<T> Key(Vector128<T> x) => Vector128.Abs(x);
public static Vector256<T> Key(Vector256<T> x) => Vector256.Abs(x);
public static Vector512<T> Key(Vector512<T> x) => Vector512.Abs(x);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ private static bool MayBeSubnormal<T>() =>
public static Vector128<T> Invoke(Vector128<T> x) => Vector128.IsSubnormal(x);
public static Vector256<T> Invoke(Vector256<T> x) => Vector256.IsSubnormal(x);
public static Vector512<T> Invoke(Vector512<T> x) => Vector512.IsSubnormal(x);

// A subnormal value is one whose absolute bit pattern lies between one (inclusive) and that of the smallest normal value (exclusive),
// the same range test as the operator's, which the subtraction turns into a single comparison: zero wraps around.
public static bool HasThresholdForm => typeof(T) == typeof(float) || typeof(T) == typeof(double);
public static bool TrueBelowThreshold => true;
public static ulong ThresholdBits => SmallestNormalBits<T>() - 1;
public static Vector128<T> Key(Vector128<T> x) => SubtractBits(Vector128.Abs(x), 1);
public static Vector256<T> Key(Vector256<T> x) => SubtractBits(Vector256.Abs(x), 1);
public static Vector512<T> Key(Vector512<T> x) => SubtractBits(Vector512.Abs(x), 1);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ public static bool IsZeroAny<T>(ReadOnlySpan<T> x)
public static Vector128<T> Invoke(Vector128<T> x) => Vector128.Equals(x, Vector128<T>.Zero);
public static Vector256<T> Invoke(Vector256<T> x) => Vector256.Equals(x, Vector256<T>.Zero);
public static Vector512<T> Invoke(Vector512<T> x) => Vector512.Equals(x, Vector512<T>.Zero);

// Zero is the value whose bits, for the floating-point types apart from the sign, are below one.
public static bool HasThresholdForm => IsPrimitiveBinaryInteger<T>() || typeof(T) == typeof(float) || typeof(T) == typeof(double);
public static bool TrueBelowThreshold => true;
public static ulong ThresholdBits => 1;
public static Vector128<T> Key(Vector128<T> x) => typeof(T) == typeof(float) || typeof(T) == typeof(double) ? Vector128.Abs(x) : x;
public static Vector256<T> Key(Vector256<T> x) => typeof(T) == typeof(float) || typeof(T) == typeof(double) ? Vector256.Abs(x) : x;
public static Vector512<T> Key(Vector512<T> x) => typeof(T) == typeof(float) || typeof(T) == typeof(double) ? Vector512.Abs(x) : x;
}
}
}
Loading
Loading