public static double dotDense ( NumberVector v1 , NumberVector v2 ) { final int dim1 = v1 . getDimensionality ( ) , dim2 = v2 . getDimensionality ( ) ; final int mindim = ( dim1 <= dim2 ) ? dim1 : dim2 ; double dot = 0 ; for ( int k = 0 ; k < mindim ; k ++ ) { dot += v1 . doubleValue ( k ) * v2 . doubleValue ( k ) ; } return dot ; }
Compute the dot product of two dense vectors .