public static void Uniform(ref float[] data, float a, IProvideRandomValues random) { float a2 = 2 * a; float an = -a; random.NextFloats(data); SIMD.Multiply(ref data, a2); SIMD.Add(ref data, an); }
public static float CosineForNormalizedVectors(float[] lhs, float[] rhs) { return(1 - SIMD.DotProduct(ref lhs, ref rhs)); }
public static float Euclidean(float[] lhs, float[] rhs) { return((float)Math.Sqrt(SIMD.Euclidean(ref lhs, ref rhs))); // TODO: Replace with netcore3 MathF class when the framework is available }
public static float Cosine(float[] lhs, float[] rhs) { return(1 - (SIMD.DotProduct(ref lhs, ref rhs) / (SIMD.Magnitude(ref lhs) * SIMD.Magnitude(ref rhs)))); }