Normalizes the columns of a matrix so each has Euclidean length of value one.
Matrix containing the normalized values of A . The output function value is an array of the same type and kind as A, where each column of each rank-2 principal section has Euclidean length of value one (Output)
A — Matrix to be normalized. The argument must be a rank-2 or rank-3 array of type single, double, complex, or double complex. (Input)
UNIT (A)
Normalizes the columns of a rank-2 or rank-3 array so each has Euclidean length of value one.
This function uses a rank-2 Euclidean length subroutine to compute the lengths of the nonzero columns, which are then normalized to have lengths of value one. The subroutine carefully avoids overflow or damaging underflow by rescaling the sums of squares as required.
use linear_operators
implicit none
! This is the equivalent of Example 4 (using operators) for LIN_EIG_SELF.
integer, parameter :: n=64
real(kind(1e0)), parameter :: one=1d0
real(kind(1e0)), dimension(n,n) :: A, B, C, D(n), lambda(n), &
S(n), vb_d, X, res
! Generate random self-adjoint matrices.
A = rand(A); A = A + .t.A
B = rand(B); B = B + .t.B
! Add a scalar matrix so B is positive definite.
B = B + norm(B)*EYE(n)
! Get the eigenvalues and eigenvectors for B.
S = EIG(B,V=vb_d)
! For full rank problems, convert to an ordinary self-adjoint
! problem. (All of these examples are full rank.)
if (S(n) > epsilon(one)) then
D = one/sqrt(S)
C = diag(D) .x. (vb_d .tx. A .x. vb_d) .x. diag(D)
C = (C + .t.C)/2
! Get the eigenvalues and eigenvectors for C.
lambda = EIG(C,v=X)
! Compute and normalize the generalized eigenvectors.
X = UNIT(vb_d .x. diag(D) .x. X)
res = (A .x. X) - (B .x. X .x. diag(lambda))
! Check the results.
if(norm(res)/(norm(A)+norm(B)) <= &
sqrt(epsilon(one))) then
write (*,*) 'Example 4 for LIN_EIG_SELF (operators) is correct.'
end if
end if
[1] The
operators .hx. and .xh. apply to sparse complex matrices
only. For real matrices use
the .tx. and .xt.
operators.
[2] SuperLU is used to support the defined operations .ix. and .xi., and the condition number function, cond(). SuperLU is well-tested. Distributed and threaded versions are available but these are not used here in our software at present. SuperLU was developed by James W. Demmel, Stanley C. Eisenstat, John R. Gilbert, Xiaoye S. Li, and Joseph W. H. Liu. Note that the authors do not support the package in the context used in the IMSL Libraries.
Visual Numerics, Inc. PHONE: 713.784.3131 FAX:713.781.9260 |