test_invh Subroutine

subroutine test_invh()

Arguments

None

Contents

Source Code


Source Code

subroutine test_invh ()
   call lala( 'display(ones(80,1)''*61)')
   call lala( 'help invh')
   call lala( 'tally=[0];')
   call lala( [ character(len=256) :: &
 & '                                                                         ', &
 & '// generate the Hilbert matrix of order N.                               ', &
 & 'N=5                                                                      ', &
 & 'for i = 1:N, for j = 1:N, A(i,j) = 1/(i+j-1);                            ', &
 & '// generate the inverse Hilbert matrix                                   ', &
 & 'C=invh(N);                                                               ', &
 & 'expected=[                                                               ', &
 & '   25     -300     1050    -1400      630;                               ', &
 & ' -300     4800   -18900    26880   -12600;                               ', &
 & ' 1050   -18900    79380  -117600    56700;                               ', &
 & '-1400    26880  -117600   179200   -88200;                               ', &
 & '  630   -12600    56700   -88200    44100;                               ', &
 & '];                                                                       ', &
 & '                                                                         ', &
 & 'if C=expected, tally=[tally,0];display(''inverse Hilbert PASSED'');else,tally=[tally,1];display(''inverse Hilbert FAILED'');', &
 & 'if sum(tally)=0,display(''invh PASSED'');else,display(''invh FAILED'');tally ', &
 & ''])
end subroutine test_invh