question: public Matrix correlation ( ) { final Matrix corr = covariance ( ) ; final Array v = corr . diagonal ( ) ; for ( int i = 0 ; i < dimension_ ; i ++ ) { for ( int j = 0 ; j < dimension_ ; j ++ ) { if ( i == j ) { if ( v . $ [ v . _ ( i ) ] == 0.0 ) { corr . $ [ corr . _ ( i , j ) ] = 1.0 ; } else { corr . $ [ corr . _ ( i , j ) ] *= 1.0 / Math . sqrt ( v . $ [ v . _ ( i ) ] * v . $ [ v . _ ( j ) ] ) ; } } else { if ( v . $ [ v . _ ( i ) ] == 0.0 && v . $ [ v . _ ( j ) ] == 0 ) { corr . $ [ corr . _ ( i , j ) ] = 1.0 ; } else if ( v . $ [ v . _ ( i ) ] == 0.0 || v . $ [ v . _ ( j ) ] == 0.0 ) { corr . $ [ corr . _ ( i , j ) ] = 0.0 ; } else { corr . $ [ corr . _ ( i , j ) ] *= 1.0 / Math . sqrt ( v . $ [ v . _ ( i ) ] * v . $ [ v . _ ( j ) ] ) ; } } } } return corr ; }
target:  returns the correlation Matrix