DOUBLE PRECISION FUNCTION DOPBL3( SUBNAM, M, N, K ) * * -- LAPACK timing routine (version 3.0) -- * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., * Courant Institute, Argonne National Lab, and Rice University * June 30, 1999 * * .. Scalar Arguments .. CHARACTER*6 SUBNAM INTEGER K, M, N * .. * * Purpose * ======= * * DOPBL3 computes an approximation of the number of floating point * operations used by a subroutine SUBNAM with the given values * of the parameters M, N, and K. * * This version counts operations for the Level 3 BLAS. * * Arguments * ========= * * SUBNAM (input) CHARACTER*6 * The name of the subroutine. * * M (input) INTEGER * N (input) INTEGER * K (input) INTEGER * M, N, and K contain parameter values used by the Level 3 * BLAS. The output matrix is always M x N or N x N if * symmetric, but K has different uses in different * contexts. For example, in the matrix-matrix multiply * routine, we have * C = A * B * where C is M x N, A is M x K, and B is K x N. * In xSYMM, xTRMM, and xTRSM, K indicates whether the matrix * A is applied on the left or right. If K <= 0, the matrix * is applied on the left, if K > 0, on the right. * * ===================================================================== * * .. Local Scalars .. CHARACTER C1 CHARACTER*2 C2 CHARACTER*3 C3 DOUBLE PRECISION ADDS, EK, EM, EN, MULTS * .. * .. External Functions .. LOGICAL LSAME, LSAMEN EXTERNAL LSAME, LSAMEN * .. * .. Executable Statements .. * * Quick return if possible * IF( M.LE.0 .OR. .NOT.( LSAME( SUBNAM, 'S' ) .OR. LSAME( SUBNAM, $ 'D' ) .OR. LSAME( SUBNAM, 'C' ) .OR. LSAME( SUBNAM, 'Z' ) ) ) $ THEN DOPBL3 = 0 RETURN END IF * C1 = SUBNAM( 1: 1 ) C2 = SUBNAM( 2: 3 ) C3 = SUBNAM( 4: 6 ) MULTS = 0 ADDS = 0 EM = M EN = N EK = K * * ---------------------- * Matrix-matrix products * assume beta = 1 * ---------------------- * IF( LSAMEN( 3, C3, 'MM ' ) ) THEN * IF( LSAMEN( 2, C2, 'GE' ) ) THEN * MULTS = EM*EK*EN ADDS = EM*EK*EN * ELSE IF( LSAMEN( 2, C2, 'SY' ) .OR. $ LSAMEN( 3, SUBNAM, 'CHE' ) .OR. $ LSAMEN( 3, SUBNAM, 'ZHE' ) ) THEN * * IF K <= 0, assume A multiplies B on the left. * IF( K.LE.0 ) THEN MULTS = EM*EM*EN ADDS = EM*EM*EN ELSE MULTS = EM*EN*EN ADDS = EM*EN*EN END IF * ELSE IF( LSAMEN( 2, C2, 'TR' ) ) THEN * IF( K.LE.0 ) THEN MULTS = EN*EM*( EM+1.D0 ) / 2.D0 ADDS = EN*EM*( EM-1.D0 ) / 2.D0 ELSE MULTS = EM*EN*( EN+1.D0 ) / 2.D0 ADDS = EM*EN*( EN-1.D0 ) / 2.D0 END IF * END IF * * ------------------------------------------------ * Rank-K update of a symmetric or Hermitian matrix * ------------------------------------------------ * ELSE IF( LSAMEN( 3, C3, 'RK ' ) ) THEN * IF( LSAMEN( 2, C2, 'SY' ) .OR. LSAMEN( 3, SUBNAM, 'CHE' ) .OR. $ LSAMEN( 3, SUBNAM, 'ZHE' ) ) THEN * MULTS = EK*EM*( EM+1.D0 ) / 2.D0 ADDS = EK*EM*( EM+1.D0 ) / 2.D0 END IF * * ------------------------------------------------ * Rank-2K update of a symmetric or Hermitian matrix * ------------------------------------------------ * ELSE IF( LSAMEN( 3, C3, 'R2K' ) ) THEN * IF( LSAMEN( 2, C2, 'SY' ) .OR. LSAMEN( 3, SUBNAM, 'CHE' ) .OR. $ LSAMEN( 3, SUBNAM, 'ZHE' ) ) THEN * MULTS = EK*EM*EM ADDS = EK*EM*EM + EM END IF * * ----------------------------------------- * Solving system with many right hand sides * ----------------------------------------- * ELSE IF( LSAMEN( 5, SUBNAM( 2: 6 ), 'TRSM ' ) ) THEN * IF( K.LE.0 ) THEN MULTS = EN*EM*( EM+1.D0 ) / 2.D0 ADDS = EN*EM*( EM-1.D0 ) / 2.D0 ELSE MULTS = EM*EN*( EN+1.D0 ) / 2.D0 ADDS = EM*EN*( EN-1.D0 ) / 2.D0 END IF * END IF * * ------------------------------------------------ * Compute the total number of operations. * For real and double precision routines, count * 1 for each multiply and 1 for each add. * For complex and complex*16 routines, count * 6 for each multiply and 2 for each add. * ------------------------------------------------ * IF( LSAME( C1, 'S' ) .OR. LSAME( C1, 'D' ) ) THEN * DOPBL3 = MULTS + ADDS * ELSE * DOPBL3 = 6*MULTS + 2*ADDS * END IF * RETURN * * End of DOPBL3 * END