public static double [ ] normalize ( final double [ ] v1 ) { final double norm = 1. / euclideanLength ( v1 ) ; double [ ] re = new double [ v1 . length ] ; if ( norm < Double . POSITIVE_INFINITY ) { for ( int row = 0 ; row < v1 . length ; row ++ ) { re [ row ] = v1 [ row ] * norm ; } } return re ; }
Normalizes v1 to the length of 1 . 0 .