private static double dot ( double vector1 [ ] , double vector2 [ ] ) { double product = 0 ; assert vector1 . length == vector2 . length ; for ( int i = 0 ; i < vector1 . length ; i ++ ) { product += vector1 [ i ] * vector2 [ i ] ; } return product ; }
returns the dot product of two vectors