Exemplo n.º 1
0
        /// <summary>
        /// Perform an operation
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="operation"></param>
        /// <returns></returns>
        public static float[] ElementWiseOperation(float[] a, float[] b, ElementWiseOperation operation)
        {
            if (!VectorCompare.SameLength(a, b))
            {
                throw new ArgumentException("Vectors are not of same length.");
            }

            float[] y = new float[a.Length];

            for (int i = 0; i < y.Length; i++)
            {
                y[i] = operation.Invoke(a[i], b[i]);
            }

            return(y);
        }
Exemplo n.º 2
0
        public static float Dot(float[] a, float[] b)
        {
            if (!VectorCompare.SameLength(a, b))
            {
                throw new ArgumentException("Vectors are not of same length.");
            }

            float y = 0;

            for (int l = 0; l < a.Length; l++)
            {
                y += a[l] * b[l];
            }

            return(y);
        }