function A = frank_inv ( n )
%  function A = frank_inv ( n )
%  FRANK_INV returns the inverse of the Frank matrix.
%
%  Parameters:
%    Input, integer N, the order of the matrix.
%    Output, real A(N,N), the inverse Frank matrix.
%

% Author: John Burkardt
% Modified by M. M. Sussman
% $Date: 2007/12/24 22:33:37 $

  A = zeros ( n, n );

  for i = 1 : n
    for j = 1 : n
      if ( i == j-1 )
        A(i,j) = - 1.0;
      elseif ( i == j )
        if ( i == 1 )
          A(i,j) = 1.0;
        else
          A(i,j) = n + 2 - i;
        end
      elseif ( i > j )
        A(i,j) = - ( n + 1 - i ) * A(i-1,j);
      else
        A(i,j) = 0.0;
      end
    end
  end
