From 3d7f512461acd81dd7d0374018d38c38ea8aee55 Mon Sep 17 00:00:00 2001 From: igor175 Date: Fri, 2 Nov 2012 02:00:52 +0000 Subject: [PATCH] (s,d,c,z)lasyf.f: introduced from zlahef.f a more efficient version of the code that interchanges row and columns -- 1) for 'L' version: eliminated unnecessary copying to elemnents in cols. K (K and K+1 for 2x2 pivot) that later on will be overwritten by storing L(k) ( L(k) and L(k+1) for 2x2 pivot ) into these cols. 2) for 'U' version: eliminated unnecessary copying to elemnents in cols. K (K and K-1 for 2x2 pivot) that later on will be overwritten by storing L(k) ( L(k)and L(k-1) for 2x2 pivot ) into these cols. --- SRC/clasyf.f | 41 +++++++++++++++++++++++++++++------------ SRC/dlasyf.f | 41 +++++++++++++++++++++++++++++------------ SRC/slasyf.f | 41 +++++++++++++++++++++++++++++------------ SRC/zlasyf.f | 41 +++++++++++++++++++++++++++++------------ 4 files changed, 116 insertions(+), 48 deletions(-) diff --git a/SRC/clasyf.f b/SRC/clasyf.f index 3720f24..5c4e2bc 100644 --- a/SRC/clasyf.f +++ b/SRC/clasyf.f @@ -332,16 +332,25 @@ * IF( KP.NE.KK ) THEN * -* Copy non-updated column KK to column KP +* Copy non-updated column KK to column KP of submatrix A +* at step K. No need to copy element into column K +* (or K and K-1) of A, since these columns will be later +* overwritten. * - A( KP, K ) = A( KK, K ) - CALL CCOPY( K-1-KP, A( KP+1, KK ), 1, A( KP, KP+1 ), + A( KP, KP ) = A( KK, KK ) + CALL CCOPY( KK-1-KP, A( KP+1, KK ), 1, A( KP, KP+1 ), $ LDA ) - CALL CCOPY( KP, A( 1, KK ), 1, A( 1, KP ), 1 ) + IF( KP.GT.1 ) + $ CALL CCOPY( KP-1, A( 1, KK ), 1, A( 1, KP ), 1 ) * -* Interchange rows KK and KP in last KK columns of A and W +* Interchange rows KK and KP in last K+1 to N columns of A +* (columns K (or K and K-1) of A will be later overwritten) +* and interchange rows KK and KP in last KKW to NB columns +* of W * - CALL CSWAP( N-KK+1, A( KK, KK ), LDA, A( KP, KK ), LDA ) + IF( K.LT.N ) + $ CALL CSWAP( N-K, A( KK, K+1 ), LDA, A( KP, K+1 ), + $ LDA ) CALL CSWAP( N-KK+1, W( KK, KKW ), LDW, W( KP, KKW ), $ LDW ) END IF @@ -557,15 +566,23 @@ * IF( KP.NE.KK ) THEN * -* Copy non-updated column KK to column KP +* Copy non-updated column KK to column KP of submatrix A +* at step K. No need to copy element into column K +* (or K and K+1) of A, since these columns will be later +* overwritten. * - A( KP, K ) = A( KK, K ) - CALL CCOPY( KP-K-1, A( K+1, KK ), 1, A( KP, K+1 ), LDA ) - CALL CCOPY( N-KP+1, A( KP, KK ), 1, A( KP, KP ), 1 ) + A( KP, KP ) = A( KK, KK ) + CALL CCOPY( KP-KK-1, A( KK+1, KK ), 1, A( KP, KK+1 ), + $ LDA ) + IF( KP.LT.N ) + $ CALL CCOPY( N-KP, A( KP+1, KK ), 1, A( KP+1, KP ), 1 ) * -* Interchange rows KK and KP in first KK columns of A and W +* Interchange rows KK and KP in first K-1 columns of A +* (columns K (or K and K+1) of A will be later overwritten) +* and interchange rows KK and KP in first KK columns of W * - CALL CSWAP( KK, A( KK, 1 ), LDA, A( KP, 1 ), LDA ) + IF( K.GT.1 ) + $ CALL CSWAP( K-1, A( KK, 1 ), LDA, A( KP, 1 ), LDA ) CALL CSWAP( KK, W( KK, 1 ), LDW, W( KP, 1 ), LDW ) END IF * diff --git a/SRC/dlasyf.f b/SRC/dlasyf.f index 4e3f2ab..c02aa1d 100644 --- a/SRC/dlasyf.f +++ b/SRC/dlasyf.f @@ -323,16 +323,25 @@ * IF( KP.NE.KK ) THEN * -* Copy non-updated column KK to column KP +* Copy non-updated column KK to column KP of submatrix A +* at step K. No need to copy element into column K +* (or K and K-1) of A, since these columns will be later +* overwritten. * - A( KP, K ) = A( KK, K ) - CALL DCOPY( K-1-KP, A( KP+1, KK ), 1, A( KP, KP+1 ), + A( KP, KP ) = A( KK, KK ) + CALL DCOPY( KK-1-KP, A( KP+1, KK ), 1, A( KP, KP+1 ), $ LDA ) - CALL DCOPY( KP, A( 1, KK ), 1, A( 1, KP ), 1 ) + IF( KP.GT.1 ) + $ CALL DCOPY( KP-1, A( 1, KK ), 1, A( 1, KP ), 1 ) * -* Interchange rows KK and KP in last KK columns of A and W +* Interchange rows KK and KP in last K+1 to N columns of A +* (columns K (or K and K-1) of A will be later overwritten) +* and interchange rows KK and KP in last KKW to NB columns +* of W * - CALL DSWAP( N-KK+1, A( KK, KK ), LDA, A( KP, KK ), LDA ) + IF( K.LT.N ) + $ CALL DSWAP( N-K, A( KK, K+1 ), LDA, A( KP, K+1 ), + $ LDA ) CALL DSWAP( N-KK+1, W( KK, KKW ), LDW, W( KP, KKW ), $ LDW ) END IF @@ -547,15 +556,23 @@ * IF( KP.NE.KK ) THEN * -* Copy non-updated column KK to column KP +* Copy non-updated column KK to column KP of submatrix A +* at step K. No need to copy element into column K +* (or K and K+1) of A, since these columns will be later +* overwritten. * - A( KP, K ) = A( KK, K ) - CALL DCOPY( KP-K-1, A( K+1, KK ), 1, A( KP, K+1 ), LDA ) - CALL DCOPY( N-KP+1, A( KP, KK ), 1, A( KP, KP ), 1 ) + A( KP, KP ) = A( KK, KK ) + CALL DCOPY( KP-KK-1, A( KK+1, KK ), 1, A( KP, KK+1 ), + $ LDA ) + IF( KP.LT.N ) + $ CALL DCOPY( N-KP, A( KP+1, KK ), 1, A( KP+1, KP ), 1 ) * -* Interchange rows KK and KP in first KK columns of A and W +* Interchange rows KK and KP in first K-1 columns of A +* (columns K (or K and K+1) of A will be later overwritten) +* and interchange rows KK and KP in first KK columns of W * - CALL DSWAP( KK, A( KK, 1 ), LDA, A( KP, 1 ), LDA ) + IF( K.GT.1 ) + $ CALL DSWAP( K-1, A( KK, 1 ), LDA, A( KP, 1 ), LDA ) CALL DSWAP( KK, W( KK, 1 ), LDW, W( KP, 1 ), LDW ) END IF * diff --git a/SRC/slasyf.f b/SRC/slasyf.f index f25a1f3..7c0840f 100644 --- a/SRC/slasyf.f +++ b/SRC/slasyf.f @@ -323,16 +323,25 @@ * IF( KP.NE.KK ) THEN * -* Copy non-updated column KK to column KP +* Copy non-updated column KK to column KP of submatrix A +* at step K. No need to copy element into column K +* (or K and K-1) of A, since these columns will be later +* overwritten. * - A( KP, K ) = A( KK, K ) - CALL SCOPY( K-1-KP, A( KP+1, KK ), 1, A( KP, KP+1 ), + A( KP, KP ) = A( KK, KK ) + CALL SCOPY( KK-1-KP, A( KP+1, KK ), 1, A( KP, KP+1 ), $ LDA ) - CALL SCOPY( KP, A( 1, KK ), 1, A( 1, KP ), 1 ) + IF( KP.GT.1 ) + $ CALL SCOPY( KP-1, A( 1, KK ), 1, A( 1, KP ), 1 ) * -* Interchange rows KK and KP in last KK columns of A and W +* Interchange rows KK and KP in last K+1 to N columns of A +* (columns K (or K and K-1) of A will be later overwritten) +* and interchange rows KK and KP in last KKW to NB columns +* of W * - CALL SSWAP( N-KK+1, A( KK, KK ), LDA, A( KP, KK ), LDA ) + IF( K.LT.N ) + $ CALL SSWAP( N-K, A( KK, K+1 ), LDA, A( KP, K+1 ), + $ LDA ) CALL SSWAP( N-KK+1, W( KK, KKW ), LDW, W( KP, KKW ), $ LDW ) END IF @@ -547,15 +556,23 @@ * IF( KP.NE.KK ) THEN * -* Copy non-updated column KK to column KP +* Copy non-updated column KK to column KP of submatrix A +* at step K. No need to copy element into column K +* (or K and K+1) of A, since these columns will be later +* overwritten. * - A( KP, K ) = A( KK, K ) - CALL SCOPY( KP-K-1, A( K+1, KK ), 1, A( KP, K+1 ), LDA ) - CALL SCOPY( N-KP+1, A( KP, KK ), 1, A( KP, KP ), 1 ) + A( KP, KP ) = A( KK, KK ) + CALL SCOPY( KP-KK-1, A( KK+1, KK ), 1, A( KP, KK+1 ), + $ LDA ) + IF( KP.LT.N ) + $ CALL SCOPY( N-KP, A( KP+1, KK ), 1, A( KP+1, KP ), 1 ) * -* Interchange rows KK and KP in first KK columns of A and W +* Interchange rows KK and KP in first K-1 columns of A +* (columns K (or K and K+1) of A will be later overwritten) +* and interchange rows KK and KP in first KK columns of W * - CALL SSWAP( KK, A( KK, 1 ), LDA, A( KP, 1 ), LDA ) + IF( K.GT.1 ) + $ CALL SSWAP( K-1, A( KK, 1 ), LDA, A( KP, 1 ), LDA ) CALL SSWAP( KK, W( KK, 1 ), LDW, W( KP, 1 ), LDW ) END IF * diff --git a/SRC/zlasyf.f b/SRC/zlasyf.f index d41a575..3249e64 100644 --- a/SRC/zlasyf.f +++ b/SRC/zlasyf.f @@ -332,16 +332,25 @@ * IF( KP.NE.KK ) THEN * -* Copy non-updated column KK to column KP +* Copy non-updated column KK to column KP of submatrix A +* at step K. No need to copy element into column K +* (or K and K-1) of A, since these columns will be later +* overwritten. * - A( KP, K ) = A( KK, K ) - CALL ZCOPY( K-1-KP, A( KP+1, KK ), 1, A( KP, KP+1 ), + A( KP, KP ) = A( KK, KK ) + CALL ZCOPY( KK-1-KP, A( KP+1, KK ), 1, A( KP, KP+1 ), $ LDA ) - CALL ZCOPY( KP, A( 1, KK ), 1, A( 1, KP ), 1 ) + IF( KP.GT.1 ) + $ CALL ZCOPY( KP-1, A( 1, KK ), 1, A( 1, KP ), 1 ) * -* Interchange rows KK and KP in last KK columns of A and W +* Interchange rows KK and KP in last K+1 to N columns of A +* (columns K (or K and K-1) of A will be later overwritten) +* and interchange rows KK and KP in last KKW to NB columns +* of W * - CALL ZSWAP( N-KK+1, A( KK, KK ), LDA, A( KP, KK ), LDA ) + IF( K.LT.N ) + $ CALL ZSWAP( N-K, A( KK, K+1 ), LDA, A( KP, K+1 ), + $ LDA ) CALL ZSWAP( N-KK+1, W( KK, KKW ), LDW, W( KP, KKW ), $ LDW ) END IF @@ -557,15 +566,23 @@ * IF( KP.NE.KK ) THEN * -* Copy non-updated column KK to column KP +* Copy non-updated column KK to column KP of submatrix A +* at step K. No need to copy element into column K +* (or K and K+1) of A, since these columns will be later +* overwritten. * - A( KP, K ) = A( KK, K ) - CALL ZCOPY( KP-K-1, A( K+1, KK ), 1, A( KP, K+1 ), LDA ) - CALL ZCOPY( N-KP+1, A( KP, KK ), 1, A( KP, KP ), 1 ) + A( KP, KP ) = A( KK, KK ) + CALL ZCOPY( KP-KK-1, A( KK+1, KK ), 1, A( KP, KK+1 ), + $ LDA ) + IF( KP.LT.N ) + $ CALL ZCOPY( N-KP, A( KP+1, KK ), 1, A( KP+1, KP ), 1 ) * -* Interchange rows KK and KP in first KK columns of A and W +* Interchange rows KK and KP in first K-1 columns of A +* (columns K (or K and K+1) of A will be later overwritten) +* and interchange rows KK and KP in first KK columns of W * - CALL ZSWAP( KK, A( KK, 1 ), LDA, A( KP, 1 ), LDA ) + IF( K.GT.1 ) + $ CALL ZSWAP( K-1, A( KK, 1 ), LDA, A( KP, 1 ), LDA ) CALL ZSWAP( KK, W( KK, 1 ), LDW, W( KP, 1 ), LDW ) END IF * -- 2.7.4