summaryrefslogtreecommitdiff
path: root/SRC/chb2st_kernels.f
blob: 8b0a4b28c40ac860ae702e0198ad43819e64073a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
*> \brief \b CHB2ST_KERNELS
*
*  @generated from zhb2st_kernels.f, fortran z -> c, Sun Nov  6 19:34:06 2016
*      
*  =========== DOCUMENTATION ===========
*
* Online html documentation available at 
*            http://www.netlib.org/lapack/explore-html/ 
*
*> \htmlonly
*> Download CHB2ST_KERNELS + dependencies 
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chb2st_kernels.f"> 
*> [TGZ]</a> 
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chb2st_kernels.f"> 
*> [ZIP]</a> 
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chb2st_kernels.f"> 
*> [TXT]</a>
*> \endhtmlonly 
*
*  Definition:
*  ===========
*
*       SUBROUTINE  CHB2ST_KERNELS( UPLO, WANTZ, TTYPE, 
*                                   ST, ED, SWEEP, N, NB, IB,
*                                   A, LDA, V, TAU, LDVT, WORK)
*
*       IMPLICIT NONE
*
*       .. Scalar Arguments ..
*       CHARACTER          UPLO
*       LOGICAL            WANTZ
*       INTEGER            TTYPE, ST, ED, SWEEP, N, NB, IB, LDA, LDVT
*       ..
*       .. Array Arguments ..
*       COMPLEX            A( LDA, * ), V( * ), 
*                          TAU( * ), WORK( * )
*  
*> \par Purpose:
*  =============
*>
*> \verbatim
*>
*> CHB2ST_KERNELS is an internal routine used by the CHETRD_HB2ST
*> subroutine.
*> \endverbatim
*
*  Arguments:
*  ==========
*
*> @param[in] n
*>          The order of the matrix A.
*>
*> @param[in] nb
*>          The size of the band.
*>
*> @param[in, out] A
*>          A pointer to the matrix A.
*>
*> @param[in] lda
*>          The leading dimension of the matrix A.
*>
*> @param[out] V
*>          COMPLEX array, dimension 2*n if eigenvalues only are
*>          requested or to be queried for vectors.
*>
*> @param[out] TAU
*>          COMPLEX array, dimension (2*n).
*>          The scalar factors of the Householder reflectors are stored
*>          in this array.
*>
*> @param[in] st
*>          internal parameter for indices.
*>
*> @param[in] ed
*>          internal parameter for indices.
*>
*> @param[in] sweep
*>          internal parameter for indices.
*>
*> @param[in] Vblksiz
*>          internal parameter for indices.
*>
*> @param[in] wantz
*>          logical which indicate if Eigenvalue are requested or both
*>          Eigenvalue/Eigenvectors.
*>
*> @param[in] work
*>          Workspace of size nb.
*>
*> \par Further Details:
*  =====================
*>
*> \verbatim
*>
*>  Implemented by Azzam Haidar.
*>
*>  All details are available on technical report, SC11, SC13 papers.
*>
*>  Azzam Haidar, Hatem Ltaief, and Jack Dongarra.
*>  Parallel reduction to condensed forms for symmetric eigenvalue problems
*>  using aggregated fine-grained and memory-aware kernels. In Proceedings
*>  of 2011 International Conference for High Performance Computing,
*>  Networking, Storage and Analysis (SC '11), New York, NY, USA,
*>  Article 8 , 11 pages.
*>  http://doi.acm.org/10.1145/2063384.2063394
*>
*>  A. Haidar, J. Kurzak, P. Luszczek, 2013.
*>  An improved parallel singular value algorithm and its implementation 
*>  for multicore hardware, In Proceedings of 2013 International Conference
*>  for High Performance Computing, Networking, Storage and Analysis (SC '13).
*>  Denver, Colorado, USA, 2013.
*>  Article 90, 12 pages.
*>  http://doi.acm.org/10.1145/2503210.2503292
*>
*>  A. Haidar, R. Solca, S. Tomov, T. Schulthess and J. Dongarra.
*>  A novel hybrid CPU-GPU generalized eigensolver for electronic structure 
*>  calculations based on fine-grained memory aware tasks.
*>  International Journal of High Performance Computing Applications.
*>  Volume 28 Issue 2, Pages 196-209, May 2014.
*>  http://hpc.sagepub.com/content/28/2/196 
*>
*> \endverbatim
*>
*  =====================================================================
      SUBROUTINE  CHB2ST_KERNELS( UPLO, WANTZ, TTYPE, 
     $                            ST, ED, SWEEP, N, NB, IB,
     $                            A, LDA, V, TAU, LDVT, WORK)
*
      IMPLICIT NONE
*
*  -- LAPACK computational routine (version 3.4.0) --
*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
*     November 2016
*
*     .. Scalar Arguments ..
      CHARACTER          UPLO
      LOGICAL            WANTZ
      INTEGER            TTYPE, ST, ED, SWEEP, N, NB, IB, LDA, LDVT
*     ..
*     .. Array Arguments ..
      COMPLEX            A( LDA, * ), V( * ), 
     $                   TAU( * ), WORK( * )
*     ..
*
*  =====================================================================
*
*     .. Parameters ..
      COMPLEX            ZERO, ONE
      PARAMETER          ( ZERO = ( 0.0E+0, 0.0E+0 ),
     $                   ONE = ( 1.0E+0, 0.0E+0 ) )
*     ..
*     .. Local Scalars ..
      LOGICAL            UPPER
      INTEGER            I, J1, J2, LM, LN, VPOS, TAUPOS,
     $                   DPOS, OFDPOS, AJETER 
      COMPLEX            CTMP 
*     ..
*     .. External Subroutines ..
      EXTERNAL           CLARFG, CLARFX, CLARFY
*     ..
*     .. Intrinsic Functions ..
      INTRINSIC          CONJG, MOD
*     .. External Functions ..
      LOGICAL            LSAME
      EXTERNAL           LSAME
*     ..
*     ..
*     .. Executable Statements ..
*      
      AJETER = IB + LDVT
      UPPER = LSAME( UPLO, 'U' )

      IF( UPPER ) THEN
          DPOS    = 2 * NB + 1
          OFDPOS  = 2 * NB
      ELSE
          DPOS    = 1
          OFDPOS  = 2
      ENDIF

*
*     Upper case
*  
      IF( UPPER ) THEN
*      
          IF( WANTZ ) THEN
              VPOS   = MOD( SWEEP-1, 2 ) * N + ST
              TAUPOS = MOD( SWEEP-1, 2 ) * N + ST
          ELSE
              VPOS   = MOD( SWEEP-1, 2 ) * N + ST
              TAUPOS = MOD( SWEEP-1, 2 ) * N + ST
          ENDIF
          GO TO ( 101, 102, 103 ) TTYPE
*
  101     CONTINUE
          LM = ED - ST + 1
*
          V( VPOS ) = ONE
          DO 10 I = 1, LM-1
              V( VPOS+I )         = CONJG( A( OFDPOS-I, ST+I ) )
              A( OFDPOS-I, ST+I ) = ZERO  
   10     CONTINUE
          CTMP = CONJG( A( OFDPOS, ST ) )
          CALL CLARFG( LM, CTMP, V( VPOS+1 ), 1, 
     $                                   TAU( TAUPOS ) )
          A( OFDPOS, ST ) = CTMP
* 
  103     CONTINUE
          LM = ED - ST + 1
          CALL CLARFY( UPLO, LM, V( VPOS ), 1, CONJG( TAU( TAUPOS ) ),
     $                             A( DPOS, ST ), LDA-1, WORK)
          GOTO 300
*
  102     CONTINUE
          J1 = ED+1
          J2 = MIN( ED+NB, N )
          LN = ED-ST+1
          LM = J2-J1+1
          IF( LM.GT.0) THEN
              CALL CLARFX( 'Left', LN, LM, V( VPOS ),
     $                     CONJG( TAU( TAUPOS ) ), A( DPOS-NB, J1 ),
     $                     LDA-1, WORK)
*
              IF( WANTZ ) THEN
                  VPOS   = MOD( SWEEP-1, 2 ) * N + J1
                  TAUPOS = MOD( SWEEP-1, 2 ) * N + J1
              ELSE
                  VPOS   = MOD( SWEEP-1, 2 ) * N + J1
                  TAUPOS = MOD( SWEEP-1, 2 ) * N + J1
              ENDIF
*
              V( VPOS ) = ONE
              DO 30 I = 1, LM-1
                  V( VPOS+I )          = CONJG( A( DPOS-NB-I, J1+I ) )
                  A( DPOS-NB-I, J1+I ) = ZERO
   30         CONTINUE
              CTMP = CONJG( A( DPOS-NB, J1 ) )
              CALL CLARFG( LM, CTMP, V( VPOS+1 ), 1, TAU( TAUPOS ) )
              A( DPOS-NB, J1 ) = CTMP
*             
              CALL CLARFX( 'Right', LN-1, LM, V( VPOS ), 
     $                     TAU( TAUPOS ),
     $                     A( DPOS-NB+1, J1 ), LDA-1, WORK)
          ENDIF
          GOTO 300
*
*     Lower case
*  
      ELSE
*      
          IF( WANTZ ) THEN
              VPOS   = MOD( SWEEP-1, 2 ) * N + ST
              TAUPOS = MOD( SWEEP-1, 2 ) * N + ST
          ELSE
              VPOS   = MOD( SWEEP-1, 2 ) * N + ST
              TAUPOS = MOD( SWEEP-1, 2 ) * N + ST
          ENDIF
          GO TO ( 201, 202, 203 ) TTYPE
*  
  201     CONTINUE
          LM = ED - ST + 1
*
          V( VPOS ) = ONE
          DO 20 I = 1, LM-1
              V( VPOS+I )         = A( OFDPOS+I, ST-1 )
              A( OFDPOS+I, ST-1 ) = ZERO  
   20     CONTINUE
          CALL CLARFG( LM, A( OFDPOS, ST-1 ), V( VPOS+1 ), 1, 
     $                                   TAU( TAUPOS ) )
*
  203     CONTINUE
          LM = ED - ST + 1
*
          CALL CLARFY( UPLO, LM, V( VPOS ), 1, CONJG( TAU( TAUPOS ) ),
     $                                      A( DPOS, ST ), LDA-1, WORK)

          GOTO 300
*
  202     CONTINUE
          J1 = ED+1
          J2 = MIN( ED+NB, N )
          LN = ED-ST+1
          LM = J2-J1+1
*
          IF( LM.GT.0) THEN
              CALL CLARFX( 'Right', LM, LN, V( VPOS ), 
     $                     TAU( TAUPOS ), A( DPOS+NB, ST ),
     $                     LDA-1, WORK)
*
              IF( WANTZ ) THEN
                  VPOS   = MOD( SWEEP-1, 2 ) * N + J1
                  TAUPOS = MOD( SWEEP-1, 2 ) * N + J1
              ELSE
                  VPOS   = MOD( SWEEP-1, 2 ) * N + J1
                  TAUPOS = MOD( SWEEP-1, 2 ) * N + J1
              ENDIF
*              
              V( VPOS ) = ONE
              DO 40 I = 1, LM-1
                  V( VPOS+I )        = A( DPOS+NB+I, ST )
                  A( DPOS+NB+I, ST ) = ZERO
   40         CONTINUE
              CALL CLARFG( LM, A( DPOS+NB, ST ), V( VPOS+1 ), 1, 
     $                                    TAU( TAUPOS ) )
*                  
              CALL CLARFX( 'Left', LM, LN-1, V( VPOS ), 
     $                     CONJG( TAU( TAUPOS ) ),
     $                     A( DPOS+NB-1, ST+1 ), LDA-1, WORK)

          ENDIF
          GOTO 300
      ENDIF

  300 CONTINUE    
      RETURN
*
*     END OF CHB2ST_KERNELS
*
      END