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

◆ sorgtsqr_row()

subroutine sorgtsqr_row ( integer m,
integer n,
integer mb,
integer nb,
real, dimension( lda, * ) a,
integer lda,
real, dimension( ldt, * ) t,
integer ldt,
real, dimension( * ) work,
integer lwork,
integer info )

SORGTSQR_ROW

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

Purpose:
!>
!> SORGTSQR_ROW generates an M-by-N real matrix Q_out with
!> orthonormal columns from the output of SLATSQR. These N orthonormal
!> columns are the first N columns of a product of complex unitary
!> matrices Q(k)_in of order M, which are returned by SLATSQR in
!> a special format.
!>
!>      Q_out = first_N_columns_of( Q(1)_in * Q(2)_in * ... * Q(k)_in ).
!>
!> The input matrices Q(k)_in are stored in row and column blocks in A.
!> See the documentation of SLATSQR for more details on the format of
!> Q(k)_in, where each Q(k)_in is represented by block Householder
!> transformations. This routine calls an auxiliary routine SLARFB_GETT,
!> where the computation is performed on each individual block. The
!> algorithm first sweeps NB-sized column blocks from the right to left
!> starting in the bottom row block and continues to the top row block
!> (hence _ROW in the routine name). This sweep is in reverse order of
!> the order in which SLATSQR generates the output blocks.
!> 
Parameters
[in]M
!>          M is INTEGER
!>          The number of rows of the matrix A.  M >= 0.
!> 
[in]N
!>          N is INTEGER
!>          The number of columns of the matrix A. M >= N >= 0.
!> 
[in]MB
!>          MB is INTEGER
!>          The row block size used by SLATSQR to return
!>          arrays A and T. MB > N.
!>          (Note that if MB > M, then M is used instead of MB
!>          as the row block size).
!> 
[in]NB
!>          NB is INTEGER
!>          The column block size used by SLATSQR to return
!>          arrays A and T. NB >= 1.
!>          (Note that if NB > N, then N is used instead of NB
!>          as the column block size).
!> 
[in,out]A
!>          A is REAL array, dimension (LDA,N)
!>
!>          On entry:
!>
!>             The elements on and above the diagonal are not used as
!>             input. The elements below the diagonal represent the unit
!>             lower-trapezoidal blocked matrix V computed by SLATSQR
!>             that defines the input matrices Q_in(k) (ones on the
!>             diagonal are not stored). See SLATSQR for more details.
!>
!>          On exit:
!>
!>             The array A contains an M-by-N orthonormal matrix Q_out,
!>             i.e the columns of A are orthogonal unit vectors.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max(1,M).
!> 
[in]T
!>          T is REAL array,
!>          dimension (LDT, N * NIRB)
!>          where NIRB = Number_of_input_row_blocks
!>                     = MAX( 1, CEIL((M-N)/(MB-N)) )
!>          Let NICB = Number_of_input_col_blocks
!>                   = CEIL(N/NB)
!>
!>          The upper-triangular block reflectors used to define the
!>          input matrices Q_in(k), k=(1:NIRB*NICB). The block
!>          reflectors are stored in compact form in NIRB block
!>          reflector sequences. Each of the NIRB block reflector
!>          sequences is stored in a larger NB-by-N column block of T
!>          and consists of NICB smaller NB-by-NB upper-triangular
!>          column blocks. See SLATSQR for more details on the format
!>          of T.
!> 
[in]LDT
!>          LDT is INTEGER
!>          The leading dimension of the array T.
!>          LDT >= max(1,min(NB,N)).
!> 
[out]WORK
!>          (workspace) REAL array, dimension (MAX(1,LWORK))
!>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
!> 
[in]LWORK
!>          LWORK is INTEGER
!>          The dimension of the array WORK.
!>          LWORK >= NBLOCAL * MAX(NBLOCAL,(N-NBLOCAL)),
!>          where NBLOCAL=MIN(NB,N).
!>          If LWORK = -1, then a workspace query is assumed.
!>          The routine only calculates the optimal size of the WORK
!>          array, returns this value as the first entry of the WORK
!>          array, and no error message related to LWORK is issued
!>          by XERBLA.
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Contributors:
!>
!> November 2020, Igor Kozachenko,
!>                Computer Science Division,
!>                University of California, Berkeley
!>
!> 

Definition at line 185 of file sorgtsqr_row.f.

187 IMPLICIT NONE
188*
189* -- LAPACK computational routine --
190* -- LAPACK is a software package provided by Univ. of Tennessee, --
191* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
192*
193* .. Scalar Arguments ..
194 INTEGER INFO, LDA, LDT, LWORK, M, N, MB, NB
195* ..
196* .. Array Arguments ..
197 REAL A( LDA, * ), T( LDT, * ), WORK( * )
198* ..
199*
200* =====================================================================
201*
202* .. Parameters ..
203 REAL ONE, ZERO
204 parameter( one = 1.0e+0, zero = 0.0e+0 )
205* ..
206* .. Local Scalars ..
207 LOGICAL LQUERY
208 INTEGER NBLOCAL, MB2, M_PLUS_ONE, ITMP, IB_BOTTOM,
209 $ LWORKOPT, NUM_ALL_ROW_BLOCKS, JB_T, IB, IMB,
210 $ KB, KB_LAST, KNB, MB1
211* ..
212* .. Local Arrays ..
213 REAL DUMMY( 1, 1 )
214* ..
215* .. External Functions ..
216 REAL SROUNDUP_LWORK
217 EXTERNAL sroundup_lwork
218* ..
219* .. External Subroutines ..
220 EXTERNAL slarfb_gett, slaset, xerbla
221* ..
222* .. Intrinsic Functions ..
223 INTRINSIC max, min
224* ..
225* .. Executable Statements ..
226*
227* Test the input parameters
228*
229 info = 0
230 lquery = lwork.EQ.-1
231 IF( m.LT.0 ) THEN
232 info = -1
233 ELSE IF( n.LT.0 .OR. m.LT.n ) THEN
234 info = -2
235 ELSE IF( mb.LE.n ) THEN
236 info = -3
237 ELSE IF( nb.LT.1 ) THEN
238 info = -4
239 ELSE IF( lda.LT.max( 1, m ) ) THEN
240 info = -6
241 ELSE IF( ldt.LT.max( 1, min( nb, n ) ) ) THEN
242 info = -8
243 ELSE IF( lwork.LT.1 .AND. .NOT.lquery ) THEN
244 info = -10
245 END IF
246*
247 nblocal = min( nb, n )
248*
249* Determine the workspace size.
250*
251 IF( info.EQ.0 ) THEN
252 lworkopt = nblocal * max( nblocal, ( n - nblocal ) )
253 END IF
254*
255* Handle error in the input parameters and handle the workspace query.
256*
257 IF( info.NE.0 ) THEN
258 CALL xerbla( 'SORGTSQR_ROW', -info )
259 RETURN
260 ELSE IF ( lquery ) THEN
261 work( 1 ) = sroundup_lwork( lworkopt )
262 RETURN
263 END IF
264*
265* Quick return if possible
266*
267 IF( min( m, n ).EQ.0 ) THEN
268 work( 1 ) = sroundup_lwork( lworkopt )
269 RETURN
270 END IF
271*
272* (0) Set the upper-triangular part of the matrix A to zero and
273* its diagonal elements to one.
274*
275 CALL slaset('U', m, n, zero, one, a, lda )
276*
277* KB_LAST is the column index of the last column block reflector
278* in the matrices T and V.
279*
280 kb_last = ( ( n-1 ) / nblocal ) * nblocal + 1
281*
282*
283* (1) Bottom-up loop over row blocks of A, except the top row block.
284* NOTE: If MB>=M, then the loop is never executed.
285*
286 IF ( mb.LT.m ) THEN
287*
288* MB2 is the row blocking size for the row blocks before the
289* first top row block in the matrix A. IB is the row index for
290* the row blocks in the matrix A before the first top row block.
291* IB_BOTTOM is the row index for the last bottom row block
292* in the matrix A. JB_T is the column index of the corresponding
293* column block in the matrix T.
294*
295* Initialize variables.
296*
297* NUM_ALL_ROW_BLOCKS is the number of row blocks in the matrix A
298* including the first row block.
299*
300 mb2 = mb - n
301 m_plus_one = m + 1
302 itmp = ( m - mb - 1 ) / mb2
303 ib_bottom = itmp * mb2 + mb + 1
304 num_all_row_blocks = itmp + 2
305 jb_t = num_all_row_blocks * n + 1
306*
307 DO ib = ib_bottom, mb+1, -mb2
308*
309* Determine the block size IMB for the current row block
310* in the matrix A.
311*
312 imb = min( m_plus_one - ib, mb2 )
313*
314* Determine the column index JB_T for the current column block
315* in the matrix T.
316*
317 jb_t = jb_t - n
318*
319* Apply column blocks of H in the row block from right to left.
320*
321* KB is the column index of the current column block reflector
322* in the matrices T and V.
323*
324 DO kb = kb_last, 1, -nblocal
325*
326* Determine the size of the current column block KNB in
327* the matrices T and V.
328*
329 knb = min( nblocal, n - kb + 1 )
330*
331 CALL slarfb_gett( 'I', imb, n-kb+1, knb,
332 $ t( 1, jb_t+kb-1 ), ldt, a( kb, kb ), lda,
333 $ a( ib, kb ), lda, work, knb )
334*
335 END DO
336*
337 END DO
338*
339 END IF
340*
341* (2) Top row block of A.
342* NOTE: If MB>=M, then we have only one row block of A of size M
343* and we work on the entire matrix A.
344*
345 mb1 = min( mb, m )
346*
347* Apply column blocks of H in the top row block from right to left.
348*
349* KB is the column index of the current block reflector in
350* the matrices T and V.
351*
352 DO kb = kb_last, 1, -nblocal
353*
354* Determine the size of the current column block KNB in
355* the matrices T and V.
356*
357 knb = min( nblocal, n - kb + 1 )
358*
359 IF( mb1-kb-knb+1.EQ.0 ) THEN
360*
361* In SLARFB_GETT parameters, when M=0, then the matrix B
362* does not exist, hence we need to pass a dummy array
363* reference DUMMY(1,1) to B with LDDUMMY=1.
364*
365 CALL slarfb_gett( 'N', 0, n-kb+1, knb,
366 $ t( 1, kb ), ldt, a( kb, kb ), lda,
367 $ dummy( 1, 1 ), 1, work, knb )
368 ELSE
369 CALL slarfb_gett( 'N', mb1-kb-knb+1, n-kb+1, knb,
370 $ t( 1, kb ), ldt, a( kb, kb ), lda,
371 $ a( kb+knb, kb), lda, work, knb )
372
373 END IF
374*
375 END DO
376*
377 work( 1 ) = sroundup_lwork( lworkopt )
378 RETURN
379*
380* End of SORGTSQR_ROW
381*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine slarfb_gett(ident, m, n, k, t, ldt, a, lda, b, ldb, work, ldwork)
SLARFB_GETT
subroutine slaset(uplo, m, n, alpha, beta, a, lda)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition slaset.f:108
real function sroundup_lwork(lwork)
SROUNDUP_LWORK
Here is the call graph for this function:
Here is the caller graph for this function: