Hilbert Matrix | Java program for Hilbert Matrix ; Function that generates a Hilbert matrix ; using the formula to generate hilbert matrix ; Driver code
import java . io . * ; class GFG { static void printMatrix ( int n ) { float H [ ] [ ] = new float [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { H [ i ] [ j ] = ( float ) 1.0 / ( ( i + 1 ) + ( j + 1 ) - ( float ) 1.0 ) ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) System . out . print ( H [ i ] [ j ] + " ▁ " ) ; System . out . println ( ) ; } } public static void main ( String [ ] args ) { int n = 3 ; printMatrix ( n ) ; } }