Hilbert Matrix | C ++ program for Hilbert Matrix ; Function that generates a Hilbert matrix ; using the formula to generate hilbert matrix ; driver function
#include <bits/stdc++.h> NEW_LINE using namespace std ; void printMatrix ( int n ) { float H [ 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 ) - 1.0 ) ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) cout << H [ i ] [ j ] << " ▁ " ; cout << endl ; } } int main ( ) { int n = 3 ; printMatrix ( n ) ; return 0 ; }