public static void fillHermitian ( ZMatrixRMaj A , double min , double max , Random rand ) { if ( A . numRows != A . numCols ) throw new IllegalArgumentException ( "A must be a square matrix" ) ; double range = max - min ; int length = A . numRows ; for ( int i = 0 ; i < length ; i ++ ) { A . set ( i , i , rand . nextDouble ( ) * range + min , 0 ) ; for ( int j = i + 1 ; j < length ; j ++ ) { double real = rand . nextDouble ( ) * range + min ; double imaginary = rand . nextDouble ( ) * range + min ; A . set ( i , j , real , imaginary ) ; A . set ( j , i , real , - imaginary ) ; } } }
Assigns the provided square matrix to be a random Hermitian matrix with elements from min to max value .