1 subroutine r1mpyq
(m
,n
,a
,lda
,v
,w
)
3 double precision a
(lda
,n
),v
(n
),w
(n
)
8 c given an m by n matrix a, this subroutine computes a*q where
9 c q is the product of 2*(n - 1) transformations
11 c gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1)
13 c and gv(i), gw(i) are givens rotations in the (i,n) plane which
14 c eliminate elements in the i-th and n-th planes, respectively.
15 c q itself is not given, rather the information to recover the
16 c gv, gw rotations is supplied.
18 c the subroutine statement is
20 c subroutine r1mpyq(m,n,a,lda,v,w)
24 c m is a positive integer input variable set to the number
27 c n is a positive integer input variable set to the number
30 c a is an m by n array. on input a must contain the matrix
31 c to be postmultiplied by the orthogonal matrix q
32 c described above. on output a*q has replaced a.
34 c lda is a positive integer input variable not less than m
35 c which specifies the leading dimension of the array a.
37 c v is an input array of length n. v(i) must contain the
38 c information necessary to recover the givens rotation gv(i)
41 c w is an input array of length n. w(i) must contain the
42 c information necessary to recover the givens rotation gw(i)
47 c fortran-supplied ... dabs,dsqrt
49 c argonne national laboratory. minpack project. march 1980.
50 c burton s. garbow, kenneth e. hillstrom, jorge j. more
54 double precision cos
,one
,sin
,temp
57 c apply the first set of givens rotations to a.
60 if (nm1
.lt
. 1) go to 50
63 if (dabs
(v
(j
)) .gt
. one
) cos
= one
/v
(j
)
64 if (dabs
(v
(j
)) .gt
. one
) sin
= dsqrt
(one
-cos**2
)
65 if (dabs
(v
(j
)) .le
. one
) sin
= v
(j
)
66 if (dabs
(v
(j
)) .le
. one
) cos
= dsqrt
(one
-sin**2
)
68 temp
= cos*a
(i
,j
) - sin*a
(i
,n
)
69 a
(i
,n
) = sin*a
(i
,j
) + cos*a
(i
,n
)
74 c apply the second set of givens rotations to a.
77 if (dabs
(w
(j
)) .gt
. one
) cos
= one
/w
(j
)
78 if (dabs
(w
(j
)) .gt
. one
) sin
= dsqrt
(one
-cos**2
)
79 if (dabs
(w
(j
)) .le
. one
) sin
= w
(j
)
80 if (dabs
(w
(j
)) .le
. one
) cos
= dsqrt
(one
-sin**2
)
82 temp
= cos*a
(i
,j
) + sin*a
(i
,n
)
83 a
(i
,n
) = -sin*a
(i
,j
) + cos*a
(i
,n
)
90 c last card of subroutine r1mpyq.