165
166
167
168
169
170
171 REAL ALPHA, BETA
172 INTEGER K, LDA, N
173 CHARACTER TRANS, TRANSR, UPLO
174
175
176 REAL A( LDA, * ), C( * )
177
178
179
180
181
182 REAL ONE, ZERO
183 parameter( one = 1.0e+0, zero = 0.0e+0 )
184
185
186 LOGICAL LOWER, NORMALTRANSR, NISODD, NOTRANS
187 INTEGER INFO, NROWA, J, NK, N1, N2
188
189
190 LOGICAL LSAME
192
193
195
196
197 INTRINSIC max
198
199
200
201
202
203 info = 0
204 normaltransr =
lsame( transr,
'N' )
205 lower =
lsame( uplo,
'L' )
206 notrans =
lsame( trans,
'N' )
207
208 IF( notrans ) THEN
209 nrowa = n
210 ELSE
211 nrowa = k
212 END IF
213
214 IF( .NOT.normaltransr .AND. .NOT.
lsame( transr,
'T' ) )
THEN
215 info = -1
216 ELSE IF( .NOT.lower .AND. .NOT.
lsame( uplo,
'U' ) )
THEN
217 info = -2
218 ELSE IF( .NOT.notrans .AND. .NOT.
lsame( trans,
'T' ) )
THEN
219 info = -3
220 ELSE IF( n.LT.0 ) THEN
221 info = -4
222 ELSE IF( k.LT.0 ) THEN
223 info = -5
224 ELSE IF( lda.LT.max( 1, nrowa ) ) THEN
225 info = -8
226 END IF
227 IF( info.NE.0 ) THEN
228 CALL xerbla(
'SSFRK ', -info )
229 RETURN
230 END IF
231
232
233
234
235
236
237 IF( ( n.EQ.0 ) .OR. ( ( ( alpha.EQ.zero ) .OR. ( k.EQ.0 ) ) .AND.
238 $ ( beta.EQ.one ) ) )RETURN
239
240 IF( ( alpha.EQ.zero ) .AND. ( beta.EQ.zero ) ) THEN
241 DO j = 1, ( ( n*( n+1 ) ) / 2 )
242 c( j ) = zero
243 END DO
244 RETURN
245 END IF
246
247
248
249
250
251 IF( mod( n, 2 ).EQ.0 ) THEN
252 nisodd = .false.
253 nk = n / 2
254 ELSE
255 nisodd = .true.
256 IF( lower ) THEN
257 n2 = n / 2
258 n1 = n - n2
259 ELSE
260 n1 = n / 2
261 n2 = n - n1
262 END IF
263 END IF
264
265 IF( nisodd ) THEN
266
267
268
269 IF( normaltransr ) THEN
270
271
272
273 IF( lower ) THEN
274
275
276
277 IF( notrans ) THEN
278
279
280
281 CALL ssyrk(
'L',
'N', n1, k, alpha, a( 1, 1 ), lda,
282 $ beta, c( 1 ), n )
283 CALL ssyrk(
'U',
'N', n2, k, alpha, a( n1+1, 1 ),
284 $ lda,
285 $ beta, c( n+1 ), n )
286 CALL sgemm(
'N',
'T', n2, n1, k, alpha, a( n1+1,
287 $ 1 ),
288 $ lda, a( 1, 1 ), lda, beta, c( n1+1 ), n )
289
290 ELSE
291
292
293
294 CALL ssyrk(
'L',
'T', n1, k, alpha, a( 1, 1 ), lda,
295 $ beta, c( 1 ), n )
296 CALL ssyrk(
'U',
'T', n2, k, alpha, a( 1, n1+1 ),
297 $ lda,
298 $ beta, c( n+1 ), n )
299 CALL sgemm(
'T',
'N', n2, n1, k, alpha, a( 1,
300 $ n1+1 ),
301 $ lda, a( 1, 1 ), lda, beta, c( n1+1 ), n )
302
303 END IF
304
305 ELSE
306
307
308
309 IF( notrans ) THEN
310
311
312
313 CALL ssyrk(
'L',
'N', n1, k, alpha, a( 1, 1 ), lda,
314 $ beta, c( n2+1 ), n )
315 CALL ssyrk(
'U',
'N', n2, k, alpha, a( n2, 1 ),
316 $ lda,
317 $ beta, c( n1+1 ), n )
318 CALL sgemm(
'N',
'T', n1, n2, k, alpha, a( 1, 1 ),
319 $ lda, a( n2, 1 ), lda, beta, c( 1 ), n )
320
321 ELSE
322
323
324
325 CALL ssyrk(
'L',
'T', n1, k, alpha, a( 1, 1 ), lda,
326 $ beta, c( n2+1 ), n )
327 CALL ssyrk(
'U',
'T', n2, k, alpha, a( 1, n2 ),
328 $ lda,
329 $ beta, c( n1+1 ), n )
330 CALL sgemm(
'T',
'N', n1, n2, k, alpha, a( 1, 1 ),
331 $ lda, a( 1, n2 ), lda, beta, c( 1 ), n )
332
333 END IF
334
335 END IF
336
337 ELSE
338
339
340
341 IF( lower ) THEN
342
343
344
345 IF( notrans ) THEN
346
347
348
349 CALL ssyrk(
'U',
'N', n1, k, alpha, a( 1, 1 ), lda,
350 $ beta, c( 1 ), n1 )
351 CALL ssyrk(
'L',
'N', n2, k, alpha, a( n1+1, 1 ),
352 $ lda,
353 $ beta, c( 2 ), n1 )
354 CALL sgemm(
'N',
'T', n1, n2, k, alpha, a( 1, 1 ),
355 $ lda, a( n1+1, 1 ), lda, beta,
356 $ c( n1*n1+1 ), n1 )
357
358 ELSE
359
360
361
362 CALL ssyrk(
'U',
'T', n1, k, alpha, a( 1, 1 ), lda,
363 $ beta, c( 1 ), n1 )
364 CALL ssyrk(
'L',
'T', n2, k, alpha, a( 1, n1+1 ),
365 $ lda,
366 $ beta, c( 2 ), n1 )
367 CALL sgemm(
'T',
'N', n1, n2, k, alpha, a( 1, 1 ),
368 $ lda, a( 1, n1+1 ), lda, beta,
369 $ c( n1*n1+1 ), n1 )
370
371 END IF
372
373 ELSE
374
375
376
377 IF( notrans ) THEN
378
379
380
381 CALL ssyrk(
'U',
'N', n1, k, alpha, a( 1, 1 ), lda,
382 $ beta, c( n2*n2+1 ), n2 )
383 CALL ssyrk(
'L',
'N', n2, k, alpha, a( n1+1, 1 ),
384 $ lda,
385 $ beta, c( n1*n2+1 ), n2 )
386 CALL sgemm(
'N',
'T', n2, n1, k, alpha, a( n1+1,
387 $ 1 ),
388 $ lda, a( 1, 1 ), lda, beta, c( 1 ), n2 )
389
390 ELSE
391
392
393
394 CALL ssyrk(
'U',
'T', n1, k, alpha, a( 1, 1 ), lda,
395 $ beta, c( n2*n2+1 ), n2 )
396 CALL ssyrk(
'L',
'T', n2, k, alpha, a( 1, n1+1 ),
397 $ lda,
398 $ beta, c( n1*n2+1 ), n2 )
399 CALL sgemm(
'T',
'N', n2, n1, k, alpha, a( 1,
400 $ n1+1 ),
401 $ lda, a( 1, 1 ), lda, beta, c( 1 ), n2 )
402
403 END IF
404
405 END IF
406
407 END IF
408
409 ELSE
410
411
412
413 IF( normaltransr ) THEN
414
415
416
417 IF( lower ) THEN
418
419
420
421 IF( notrans ) THEN
422
423
424
425 CALL ssyrk(
'L',
'N', nk, k, alpha, a( 1, 1 ), lda,
426 $ beta, c( 2 ), n+1 )
427 CALL ssyrk(
'U',
'N', nk, k, alpha, a( nk+1, 1 ),
428 $ lda,
429 $ beta, c( 1 ), n+1 )
430 CALL sgemm(
'N',
'T', nk, nk, k, alpha, a( nk+1,
431 $ 1 ),
432 $ lda, a( 1, 1 ), lda, beta, c( nk+2 ),
433 $ n+1 )
434
435 ELSE
436
437
438
439 CALL ssyrk(
'L',
'T', nk, k, alpha, a( 1, 1 ), lda,
440 $ beta, c( 2 ), n+1 )
441 CALL ssyrk(
'U',
'T', nk, k, alpha, a( 1, nk+1 ),
442 $ lda,
443 $ beta, c( 1 ), n+1 )
444 CALL sgemm(
'T',
'N', nk, nk, k, alpha, a( 1,
445 $ nk+1 ),
446 $ lda, a( 1, 1 ), lda, beta, c( nk+2 ),
447 $ n+1 )
448
449 END IF
450
451 ELSE
452
453
454
455 IF( notrans ) THEN
456
457
458
459 CALL ssyrk(
'L',
'N', nk, k, alpha, a( 1, 1 ), lda,
460 $ beta, c( nk+2 ), n+1 )
461 CALL ssyrk(
'U',
'N', nk, k, alpha, a( nk+1, 1 ),
462 $ lda,
463 $ beta, c( nk+1 ), n+1 )
464 CALL sgemm(
'N',
'T', nk, nk, k, alpha, a( 1, 1 ),
465 $ lda, a( nk+1, 1 ), lda, beta, c( 1 ),
466 $ n+1 )
467
468 ELSE
469
470
471
472 CALL ssyrk(
'L',
'T', nk, k, alpha, a( 1, 1 ), lda,
473 $ beta, c( nk+2 ), n+1 )
474 CALL ssyrk(
'U',
'T', nk, k, alpha, a( 1, nk+1 ),
475 $ lda,
476 $ beta, c( nk+1 ), n+1 )
477 CALL sgemm(
'T',
'N', nk, nk, k, alpha, a( 1, 1 ),
478 $ lda, a( 1, nk+1 ), lda, beta, c( 1 ),
479 $ n+1 )
480
481 END IF
482
483 END IF
484
485 ELSE
486
487
488
489 IF( lower ) THEN
490
491
492
493 IF( notrans ) THEN
494
495
496
497 CALL ssyrk(
'U',
'N', nk, k, alpha, a( 1, 1 ), lda,
498 $ beta, c( nk+1 ), nk )
499 CALL ssyrk(
'L',
'N', nk, k, alpha, a( nk+1, 1 ),
500 $ lda,
501 $ beta, c( 1 ), nk )
502 CALL sgemm(
'N',
'T', nk, nk, k, alpha, a( 1, 1 ),
503 $ lda, a( nk+1, 1 ), lda, beta,
504 $ c( ( ( nk+1 )*nk )+1 ), nk )
505
506 ELSE
507
508
509
510 CALL ssyrk(
'U',
'T', nk, k, alpha, a( 1, 1 ), lda,
511 $ beta, c( nk+1 ), nk )
512 CALL ssyrk(
'L',
'T', nk, k, alpha, a( 1, nk+1 ),
513 $ lda,
514 $ beta, c( 1 ), nk )
515 CALL sgemm(
'T',
'N', nk, nk, k, alpha, a( 1, 1 ),
516 $ lda, a( 1, nk+1 ), lda, beta,
517 $ c( ( ( nk+1 )*nk )+1 ), nk )
518
519 END IF
520
521 ELSE
522
523
524
525 IF( notrans ) THEN
526
527
528
529 CALL ssyrk(
'U',
'N', nk, k, alpha, a( 1, 1 ), lda,
530 $ beta, c( nk*( nk+1 )+1 ), nk )
531 CALL ssyrk(
'L',
'N', nk, k, alpha, a( nk+1, 1 ),
532 $ lda,
533 $ beta, c( nk*nk+1 ), nk )
534 CALL sgemm(
'N',
'T', nk, nk, k, alpha, a( nk+1,
535 $ 1 ),
536 $ lda, a( 1, 1 ), lda, beta, c( 1 ), nk )
537
538 ELSE
539
540
541
542 CALL ssyrk(
'U',
'T', nk, k, alpha, a( 1, 1 ), lda,
543 $ beta, c( nk*( nk+1 )+1 ), nk )
544 CALL ssyrk(
'L',
'T', nk, k, alpha, a( 1, nk+1 ),
545 $ lda,
546 $ beta, c( nk*nk+1 ), nk )
547 CALL sgemm(
'T',
'N', nk, nk, k, alpha, a( 1,
548 $ nk+1 ),
549 $ lda, a( 1, 1 ), lda, beta, c( 1 ), nk )
550
551 END IF
552
553 END IF
554
555 END IF
556
557 END IF
558
559 RETURN
560
561
562
subroutine xerbla(srname, info)
subroutine sgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
SGEMM
subroutine ssyrk(uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
SSYRK
logical function lsame(ca, cb)
LSAME