home *** CD-ROM | disk | FTP | other *** search
- //-------------------------------------------------------------------//
-
- // Synopsis: A Hankel matrix with factorial elements.
-
- // Syntax: A = ipjfact ( N, K )
-
- // Description:
-
- // A.A is the matrix with
-
- // A[i;j] = (i+j)! (K = 0, default)
- // A[i;j] = 1/(i+j)! (K = 1)
-
- // Both are Hankel matrices.
- // The determinant and inverse are known explicitly.
-
- // A list is returned with elements `A' and `detA'
-
- // Suggested by P. R. Graves-Morris.
-
- // Reference:
- // M.J.C. Gover, The explicit inverse of factorial Hankel matrices,
- // Dept. of Mathematics, University of Bradford, 1993.
-
- // This file is a translation of ipjfact.m from version 2.0 of
- // "The Test Matrix Toolbox for Matlab", described in Numerical
- // Analysis Report No. 237, December 1993, by N. J. Higham.
-
- // Dependencies
- require hankel
-
- //-------------------------------------------------------------------//
-
- ipjfact = function ( n , k )
- {
- local (n, k)
-
- if (!exist (k)) { k = 0; }
-
- c = cumprod(2:n+1);
- d = cumprod(n+1:2*n) * c[n-1];
-
- A = hankel(c, d);
-
- if (k == 1)
- {
- A = ones(n, n)./A;
- }
-
- d = 1;
- if (k == 0)
- {
- for (i in 1:n-1)
- {
- d = d*prod(1:i+1)*prod(1:n-i);
- }
- d = d*prod(1:n+1);
- else
- for (i in 0:n-1)
- {
- d = d*prod(1:i)/prod(1:n+1+i);
- }
- if (mod(n*(n-1)/2,2)) { d = -d; }
- }
-
- return << A = A; detA = d >>;
- };
-