예제 #1
0
        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);
        }
예제 #2
0
 public static float CosineForNormalizedVectors(float[] lhs, float[] rhs)
 {
     return(1 - SIMD.DotProduct(ref lhs, ref rhs));
 }
예제 #3
0
 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
 }
예제 #4
0
 public static float Cosine(float[] lhs, float[] rhs)
 {
     return(1 - (SIMD.DotProduct(ref lhs, ref rhs) / (SIMD.Magnitude(ref lhs) * SIMD.Magnitude(ref rhs))));
 }