public static void symmetric ( DMatrixRMaj 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 ++ ) { for ( int j = i ; j < length ; j ++ ) { double val = rand . nextDouble ( ) * range + min ; A . set ( i , j , val ) ; A . set ( j , i , val ) ; } } }
Sets the provided square matrix to be a random symmetric matrix whose values are selected from an uniform distribution from min to max inclusive .