Exemple #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);
        }
Exemple #2
0
 public static float CosineForNormalizedVectors(float[] lhs, float[] rhs)
 {
     return(1 - SIMD.DotProduct(ref lhs, ref rhs));
 }
Exemple #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
 }
Exemple #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))));
 }