458 INTEGER i, j, k, l, m, n, ii, i1, kk, k1, ll, l1, mn, nu, nv, nb,
460 REAL*8 w(1), u(nu,1), v(nv,1), b(nb,irhs), rv1(1)
461 REAL*8 c, f, g, h, s, x, y, z, eps, scale,
srelpr, dummy
462 REAL*8 dsqrt, dmax1, dabs, dsign
465 c this
SUBROUTINE is a translation of the algol procedure svd,
466 c num. math. 14, 403-420(1970) by golub and reinsch.
467 c handbook for auto. comp., vol ii-linear algebra, 134-151(1971).
469 c this
SUBROUTINE determines the singular value decomposition
471 c a=usv of a
REAL m by n rectangular matrix. householder
472 c bidiagonalization and a variant of the qr algorithm are used.
473 c
grsvd assumes that a copy of the matrix a is in the array u. it
474 c also assumes m .GE. n.
IF m .LT. n,
THEN compute the singular
476 c
VALUE decomposition of a .
IF a =uwv ,
THEN a=vwu .
478 c
grsvd can also be used to compute the minimal length least squares
479 c solution to the overdetermined linear system a*x=b.
483 c nu must be set to the row dimension of two-dimensional
484 c array parameters u as declared in the calling
PROGRAM 485 c dimension statement. note that nu must be at least
488 c nv must be set to the row dimension of the two-dimensional
489 c array
PARAMETER v as declared in the calling
PROGRAM 490 c dimension statement. nv must be at least as large as n,
492 c nb must be set to the row dimension of two-dimensional
493 c array parameters b as declared in the calling
PROGRAM 494 c dimension statement. note that nb must be at least
497 c m is the number of rows of a(and u),
499 c n is the number of columns of a(and u) and the order of v,
501 c a
CONTAINS the rectangular input matrix to be decomposed,
503 c b
CONTAINS the irhs right-hand-sides of the overdetermined
504 c linear system a*x=b.
IF irhs .GT. 0,
THEN on output,
505 c the first n components of these irhs columns of b
507 c will contain u b. thus, to compute the minimal length least
509 c squares solution, one must compute v*w times the columns of
511 c b,
WHERE w is a diagonal matrix, w(i)=0
IF w(i) is
512 c negligible, otherwise is 1/w(i).
IF irhs=0, b may coincide
513 c with a or u and will not be referenced,
515 c irhs is the number of right-hand-sides of the overdetermined
516 c system a*x=b. irhs should be set to zero
IF only the singula
517 c
VALUE decomposition of a is desired,
519 c matu should be set to .true.
IF the u matrix in the
520 c decomposition is desired, and to .false. otherwise,
522 c matv should be set to .true.
IF the v matrix in the
523 c decomposition is desired, and to .false. otherwise.
527 c w
CONTAINS the n(non-negative) singular values of a(the
528 c diagonal
elements of s). they are unordered.
IF an
529 c error
EXIT is made, the singular values should be correct
530 c for indices ierr+1,ierr+2,...,n,
532 c u
CONTAINS the matrix u(orthogonal column vectors) of the
533 c decomposition
IF matu has been set to .true. otherwise
534 c u is used as a temporary array.
535 c
IF an error
EXIT is made, the columns of u corresponding
536 c to indices of correct singular values should be correct,
538 c v
CONTAINS the matrix v(orthogonal) of the decomposition
IF 539 c matv has been set to .true. otherwise v is not referenced.
540 c
IF an error
EXIT is made, the columns of v corresponding to
541 c indices of correct singular values should be correct,
544 c zero for normal
RETURN,
545 c k
IF the k-th singular
VALUE has not been
546 c determined after 30 iterations,
547 c -1
IF irhs .LT. 0 ,
549 c -3
IF nu .LT. m .OR. nb .LT. m,
552 c rv1 is a temporary storage array.
554 c this
SUBROUTINE has been checked by the pfort verifier
555 c(ryder, b.g.
'THE PFORT VERIFIER', software - practice and
556 c experience, vol.4, 359-377, 1974) for adherence to a large,
557 c carefully defined, portable subset of american national standar
558 c fortran called pfort.
560 c original version of this code is
SUBROUTINE svd in release 2 of
563 c modified by tony f. chan,
564 c comp. sci. dept, yale univ.,
565 c box 2158, yale station,
567 c last modified : january, 1982.
569 c ------------------------------------------------------------------
571 c **********
srelpr is a machine-dependent
FUNCTION specifying
572 c the relative precision of floating point arithmetic.
577 IF (irhs.GE.0)
GO TO 10
580 10
IF (m.GE.n)
GO TO 20
583 20
IF (nu.GE.m .AND. nb.GE.m)
GO TO 30
586 30
IF (nv.GE.n)
GO TO 40
591 c ********** householder reduction to bidiagonal form **********
603 c compute left transformations that zero the subdiagonal
elements 604 c of the i-th column.
607 scale = scale + dabs(u(k,i))
610 IF (scale.EQ.0.d0)
GO TO 160
613 u(k,i) = u(k,i)/scale
618 g = -dsign(dsqrt(s),f)
621 IF (i.EQ.n)
GO TO 100
623 c apply left transformations to remaining columns of a.
629 s = s + u(k,i)*u(k,j)
635 u(k,j) = u(k,j) + f*u(k,i)
639 c apply left transformations to the columns of b
IF irhs .GT. 0
641 100
IF (irhs.EQ.0)
GO TO 140
645 s = s + u(k,i)*b(k,j)
649 b(k,j) = b(k,j) + f*u(k,i)
653 c compute right transformations.
656 u(k,i) = scale*u(k,i)
663 IF (i.GT.m .OR. i.EQ.n)
GO TO 250
666 scale = scale + dabs(u(i,k))
669 IF (scale.EQ.0.d0)
GO TO 250
672 u(i,k) = u(i,k)/scale
677 g = -dsign(dsqrt(s),f)
685 IF (i.EQ.m)
GO TO 230
691 s = s + u(j,k)*u(i,k)
695 u(j,k) = u(j,k) + s*rv1(k)
700 u(i,k) = scale*u(i,k)
703 250 x = dmax1(x,dabs(w(i))+dabs(rv1(i)))
705 c ********** accumulation of right-hand transformations **********
706 IF (.NOT.matv)
GO TO 350
707 c ********** for i=n step -1 until 1
DO -- **********
710 IF (i.EQ.n)
GO TO 330
711 IF (g.EQ.0.d0)
GO TO 310
714 c ********** double division avoids possible underflow **********
715 v(j,i) = (u(i,j)/u(i,l))/g
722 s = s + u(i,k)*v(k,j)
726 v(k,j) = v(k,j) + s*v(k,i)
739 c ********** accumulation of left-hand transformations **********
740 350
IF (.NOT.matu)
GO TO 470
741 c **********for i=
min(m,n) step -1 until 1
DO -- **********
749 IF (i.EQ.n)
GO TO 370
755 370
IF (g.EQ.0.d0)
GO TO 430
756 IF (i.EQ.mn)
GO TO 410
762 s = s + u(k,i)*u(k,j)
764 c ********** double division avoids possible underflow **********
768 u(k,j) = u(k,j) + f*u(k,i)
782 450 u(i,i) = u(i,i) + 1.d0
784 c ********** diagonalization of the bidiagonal form **********
786 c ********** for k=n step -1 until 1
DO -- **********
791 c ********** test for splitting.
792 c for l=k step -1 until 1
DO -- **********
796 IF (dabs(rv1(l)).LE.eps)
GO TO 550
797 c ********** rv1(1) is always zero, so there is no
EXIT 798 c through the bottom of the loop **********
799 IF (dabs(w(l1)).LE.eps)
GO TO 500
801 c ********** cancellation of rv1(l)
IF l greater than 1 **********
808 IF (dabs(f).LE.eps)
GO TO 550
815 c apply left transformations to b
IF irhs .GT. 0
817 IF (irhs.EQ.0)
GO TO 520
826 IF (.NOT.matu)
GO TO 540
836 c ********** test for convergence **********
838 IF (l.EQ.k)
GO TO 630
839 c ********** shift from bottom 2 by 2 minor **********
840 IF (its.EQ.30)
GO TO 660
846 f = ((y-z)*(y+z)+(g-h)*(g+h))/(2.d0*h*y)
848 f = ((x-z)*(x+z)+h*(y/(f+dsign(g,f))-h))/x
849 c ********** next qr transformation **********
867 IF (.NOT.matv)
GO TO 570
876 570 z = dsqrt(f*f+h*h)
878 c ********** rotation can be arbitrary
IF z is zero **********
879 IF (z.EQ.0.d0)
GO TO 580
885 c apply left transformations to b
IF irhs .GT. 0
887 IF (irhs.EQ.0)
GO TO 600
896 IF (.NOT.matu)
GO TO 620
911 c ********** convergence **********
912 630
IF (z.GE.0.d0)
GO TO 650
913 c ********** w(k) is made non-negative **********
915 IF (.NOT.matv)
GO TO 650
924 c ********** set error -- no convergence to a
925 c singular
VALUE after 30 iterations **********
928 c ********** last card of
grsvd **********
real *8 function srelpr(DUMMY)
Definition: hybsvd.f:986
#define min(a, b)
Definition: cascade.c:31
subroutine grsvd(NU, NV, NB, M, N, W, MATU, U, MATV, V, B, IRHS,
Definition: hybsvd.f:456
subroutine elements(inpc, textpart, kon, ipkon, lakon, nkon, ne, ne_, set, istartset, iendset, ialset, nset, nset_, nalset, nalset_, mi, ixfree, iponor, xnor, istep, istat, n, iline, ipol, inl, ipoinp, inp, iaxial, ipoinpc, solid, cfd, network, filab, nlabel, out3d, iuel, nuel_)
Definition: elements.f:24