LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ slapmr()

subroutine slapmr ( logical forwrd,
integer m,
integer n,
real, dimension( ldx, * ) x,
integer ldx,
integer, dimension( * ) k )

SLAPMR rearranges rows of a matrix as specified by a permutation vector.

Download SLAPMR + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> SLAPMR rearranges the rows of the M by N matrix X as specified
!> by the permutation K(1),K(2),...,K(M) of the integers 1,...,M.
!> If FORWRD = .TRUE.,  forward permutation:
!>
!>      X(K(I),*) is moved X(I,*) for I = 1,2,...,M.
!>
!> If FORWRD = .FALSE., backward permutation:
!>
!>      X(I,*) is moved to X(K(I),*) for I = 1,2,...,M.
!> 
Parameters
[in]FORWRD
!>          FORWRD is LOGICAL
!>          = .TRUE., forward permutation
!>          = .FALSE., backward permutation
!> 
[in]M
!>          M is INTEGER
!>          The number of rows of the matrix X. M >= 0.
!> 
[in]N
!>          N is INTEGER
!>          The number of columns of the matrix X. N >= 0.
!> 
[in,out]X
!>          X is REAL array, dimension (LDX,N)
!>          On entry, the M by N matrix X.
!>          On exit, X contains the permuted matrix X.
!> 
[in]LDX
!>          LDX is INTEGER
!>          The leading dimension of the array X, LDX >= MAX(1,M).
!> 
[in,out]K
!>          K is INTEGER array, dimension (M)
!>          On entry, K contains the permutation vector. K is used as
!>          internal workspace, but reset to its original value on
!>          output.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 101 of file slapmr.f.

102*
103* -- LAPACK auxiliary routine --
104* -- LAPACK is a software package provided by Univ. of Tennessee, --
105* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
106*
107* .. Scalar Arguments ..
108 LOGICAL FORWRD
109 INTEGER LDX, M, N
110* ..
111* .. Array Arguments ..
112 INTEGER K( * )
113 REAL X( LDX, * )
114* ..
115*
116* =====================================================================
117*
118* .. Local Scalars ..
119 INTEGER I, IN, J, JJ
120 REAL TEMP
121* ..
122* .. Executable Statements ..
123*
124 IF( m.LE.1 )
125 $ RETURN
126*
127 DO 10 i = 1, m
128 k( i ) = -k( i )
129 10 CONTINUE
130*
131 IF( forwrd ) THEN
132*
133* Forward permutation
134*
135 DO 50 i = 1, m
136*
137 IF( k( i ).GT.0 )
138 $ GO TO 40
139*
140 j = i
141 k( j ) = -k( j )
142 in = k( j )
143*
144 20 CONTINUE
145 IF( k( in ).GT.0 )
146 $ GO TO 40
147*
148 DO 30 jj = 1, n
149 temp = x( j, jj )
150 x( j, jj ) = x( in, jj )
151 x( in, jj ) = temp
152 30 CONTINUE
153*
154 k( in ) = -k( in )
155 j = in
156 in = k( in )
157 GO TO 20
158*
159 40 CONTINUE
160*
161 50 CONTINUE
162*
163 ELSE
164*
165* Backward permutation
166*
167 DO 90 i = 1, m
168*
169 IF( k( i ).GT.0 )
170 $ GO TO 80
171*
172 k( i ) = -k( i )
173 j = k( i )
174 60 CONTINUE
175 IF( j.EQ.i )
176 $ GO TO 80
177*
178 DO 70 jj = 1, n
179 temp = x( i, jj )
180 x( i, jj ) = x( j, jj )
181 x( j, jj ) = temp
182 70 CONTINUE
183*
184 k( j ) = -k( j )
185 j = k( j )
186 GO TO 60
187*
188 80 CONTINUE
189*
190 90 CONTINUE
191*
192 END IF
193*
194 RETURN
195*
196* End of SLAPMR
197*
Here is the caller graph for this function: