DataSharp/Mathematics/Vector.cs
/// <summary>
/// Returns a Vector that represents the correlation of 2 Vector.
/// </summary>
/// <param name="vector1">A Vector.</param>
/// <param name="vector2">The other Vector.</param>
/// <returns>A Vector that represents the correlation of 2 Vector.</returns>
Returns a Vector that represents the correlation of 2 Vector.
Returns a Vector that represents the correlation of 2 Vector .
public static Vector ComputeCorrelation(Vector vector1, Vector vector2)
        {
            if (vector1 == null)
                throw new ArgumentNullException("vector1", "The input Vector must not be null.");
            if (vector2 == null)
                throw new ArgumentNullException("vector2", "The input Vector must not be null.");
            Vector correlation = new Vector(vector1.Count + vector2.Count - 1);
            double[] extendedVector1 = new double[2 * (vector2.Count - 1) + vector1.Count];
            for (int i = 0; i < vector1.Count; i++)
                extendedVector1[i + vector2.Count - 1] = vector1[i];
            for (int i = 0; i < correlation.Count; i++)
            {
                for (int j = 0; j < vector2.Count; j++)
                    correlation[i] += extendedVector1[i + j] * vector2[j];
            }
            return correlation;
        }
public static Vector ComputeCorrelation ( Vector vector1 , Vector vector2 ) { if ( vector1 == null ) throw new ArgumentNullException ( " " , " " ) ; if ( vector2 == null ) throw new ArgumentNullException ( " " , " " ) ; Vector correlation = new Vector ( vector1 . Count + vector2 . Count - 1 ) ; double [ ] extendedVector1 = new double [ 2 * ( vector2 . Count - 1 ) + vector1 . Count ] ; for ( int i = 0 ; i < vector1 . Count ; i ++ ) extendedVector1 [ i + vector2 . Count - 1 ] = vector1 [ i ] ; for ( int i = 0 ; i < correlation . Count ; i ++ ) { for ( int j = 0 ; j < vector2 . Count ; j ++ ) correlation [ i ] += extendedVector1 [ i + j ] * vector2 [ j ] ; } return correlation ; }
Returns a Vector that represents the correlation of 2 Vector.
Returns a Vector that represents the correlation of 2 Vector .
// Throw ArgumentNullException if one of the input Vector is null. // Initialize the result vector with specified length. // Pad zeros for vector 1. // Compute and return the result of the correlation operation.
A Vector that represents the correlation of 2 Vector.
A Vector that represents the correlation of 2 Vector .
vector1
Vector
None
vector2
Vector
The other Vector.
The other Vector .