-
Notifications
You must be signed in to change notification settings - Fork 480
This a draft for dgecx.f. #1161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is both DGECX.f
(incorrect) and dgecx.f
(correct) file? This file should be removed.
*> Specifies how the factors of CX factorization | ||
*> are returned. | ||
*> | ||
*> = 'P' or 'p' : return only the column permutaion matrix P |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pedantic: LAPACK doesn't normally specify both Uppercase and lowercase. Cf.:
lapack/SRC> grep "^\*> += '\w'" lapack/SRC/zpotrf.f
*> = 'U': Upper triangle of A is stored;
*> = 'L': Lower triangle of A is stored.
lapack/SRC> grep "^\*> += '\w'" lapack/SRC/*.f`
*> matrix in the blocked step auxiliary subroutine DLAQP3RK ). | ||
*> \endverbatim | ||
*> | ||
*> \param[out] LIWORK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Input, right? \param[in]
*> The dimension of the array LIWORK. LIWORK >= N | ||
*> | ||
*> If LIWORK = -1, then a workspace query is assumed; the routine | ||
*> only calculates the optimal size of the WORK array, returns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: IWORK
array.
SRC/dgecx.f
Outdated
* | ||
* DGECX | ||
* | ||
END No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files should end with a newline. Notice ⊖ on Github.
NBOPT = ILAENV( INB, 'DGEQRF', ' ', M, N, -1, -1 ) | ||
LWKOPT = 1000 | ||
END IF | ||
WORK( 1 ) = DBLE( LWKOPT ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add:
LWORK( 1 ) = N
or whatever the formula is. Also elsewhere.
* | ||
END IF | ||
* | ||
WORK( 1 ) = DBLE( LWKOPT ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add:
LWORK( 1 ) = N
as above.
* MSUB. | ||
* | ||
INFO = -6 | ||
WORK( 1 ) = DBLE( LWKOPT ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add:
LWORK( 1 ) = N
or whatever the formula is. Also elsewhere.
by mistake 2 branches (one with dgecx.f and one with DGECX.f ) were joined
in a single pull request, the files are identical. DGECX.f can be removed.
…On Wed, Oct 15, 2025 at 11:15 AM Mark Gates ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Some initial comments.
------------------------------
On SRC/DGECX.f
<#1161 (comment)>
:
There is both DGECX.f (incorrect) and dgecx.f (correct) file? This file
should be removed.
------------------------------
In SRC/dgecx.f
<#1161 (comment)>
:
> +*> array as the first K elements.
+*> b) If the flag COMP_X is set, then the routine also explicitly
+*> computes and returns the factor X = pseudoinv(C) * A.
+*>
+*> \endverbatim
+*
+* Arguments:
+* ==========
+*
+*> \param[in] FACT
+*> \verbatim
+*> FACT is CHARACTER*1
+*> Specifies how the factors of CX factorization
+*> are returned.
+*>
+*> = 'P' or 'p' : return only the column permutaion matrix P
Pedantic: LAPACK doesn't normally specify both Uppercase and lowercase.
Cf.:
lapack/SRC> grep "^\*> += '\w'" lapack/SRC/zpotrf.f
*> = 'U': Upper triangle of A is stored;
*> = 'L': Lower triangle of A is stored.
lapack/SRC> grep "^\*> += '\w'" lapack/SRC/*.f`
------------------------------
In SRC/dgecx.f
<#1161 (comment)>
:
> +*>
+*> 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.
+*> \endverbatim
+*>
+*> \param[out] IWORK
+*> \verbatim
+*> IWORK is INTEGER array, dimension (N).
+*> Is a work array. ( IWORK is used by DGEQP3RK to store indices
+*> of "bad" columns for norm downdating in the residual
+*> matrix in the blocked step auxiliary subroutine DLAQP3RK ).
+*> \endverbatim
+*>
+*> \param[out] LIWORK
Input, right? \param[in]
------------------------------
In SRC/dgecx.f
<#1161 (comment)>
:
> +*>
+*> \param[out] IWORK
+*> \verbatim
+*> IWORK is INTEGER array, dimension (N).
+*> Is a work array. ( IWORK is used by DGEQP3RK to store indices
+*> of "bad" columns for norm downdating in the residual
+*> matrix in the blocked step auxiliary subroutine DLAQP3RK ).
+*> \endverbatim
+*>
+*> \param[out] LIWORK
+*> \verbatim
+*> LIWORK is INTEGER
+*> The dimension of the array LIWORK. LIWORK >= N
+*>
+*> If LIWORK = -1, then a workspace query is assumed; the routine
+*> only calculates the optimal size of the WORK array, returns
Typo: IWORK array.
------------------------------
In SRC/dgecx.f
<#1161 (comment)>
:
> +* Copy matrix C into work array WORK.
+*
+ CALL DLACPY( 'F', M, K, C, LDC, WORK, M )
+*
+ CALL DGELS( 'N', M, K, N, WORK, M, X, LDX,
+ $ WORK( M*K+1 ), LWORK,
+ $ IINFO )
+ INFO = IINFO
+*
+ END IF
+*
+ WORK( 1 ) = DBLE( LWKOPT )
+*
+* DGECX
+*
+ END
Files should end with a newline. Notice ⊖ on Github.
------------------------------
In SRC/dgecx.f
<#1161 (comment)>
:
> +* code.
+*
+ IF( INFO.EQ.0 ) THEN
+ MINMN = MIN( M, N )
+ IF( MINMN.EQ.0 ) THEN
+ LWKMIN = 1
+ LWKOPT = 1
+ ELSE
+ LWKMIN = 3*N + 1
+*
+* Assign to NBOPT optimal block size.
+*
+ NBOPT = ILAENV( INB, 'DGEQRF', ' ', M, N, -1, -1 )
+ LWKOPT = 1000
+ END IF
+ WORK( 1 ) = DBLE( LWKOPT )
Add:
LWORK( 1 ) = N
or whatever the formula is. Also elsewhere.
------------------------------
In SRC/dgecx.f
<#1161 (comment)>
:
> +* that uses QR factorization. For that purpose, we store C into
+* WORK array WORK(1:M*K), and the matrix A was copied into
+* the array X at the begining of the routine.
+*
+* Copy matrix C into work array WORK.
+*
+ CALL DLACPY( 'F', M, K, C, LDC, WORK, M )
+*
+ CALL DGELS( 'N', M, K, N, WORK, M, X, LDX,
+ $ WORK( M*K+1 ), LWORK,
+ $ IINFO )
+ INFO = IINFO
+*
+ END IF
+*
+ WORK( 1 ) = DBLE( LWKOPT )
Add:
LWORK( 1 ) = N
as above.
------------------------------
In SRC/dgecx.f
<#1161 (comment)>
:
> +*
+ MNSUB = MIN(MSUB, NSUB)
+ MRESID = MSUB-NSEL
+ NRESID = NSUB-NSEL
+ IF( NSEL.GT.0 ) THEN
+ IF( MSUB.LT.NSEL ) THEN
+* TODO: Move this part to the top of the routine.
+* a) Case MSUB < NSEL.
+* When the number of preselected columns
+* is larger than MSUB, hence the factorization of all NSEL
+* columns cannot be completed. Return from the routine with the
+* error of COL_SEL_DESEL parameter. NSEL cannot be larger than
+* MSUB.
+*
+ INFO = -6
+ WORK( 1 ) = DBLE( LWKOPT )
Add:
LWORK( 1 ) = N
or whatever the formula is. Also elsewhere.
—
Reply to this email directly, view it on GitHub
<#1161 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHYAZG2IG6CWKRVGDULGWT3X2FMPAVCNFSM6AAAAACJHEAYW6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTGNBRGUZDGMZSGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
changed the description of DGECX
*> | ||
*> A * P(K) = C*X + A_resid, where | ||
*> | ||
*> C is an M-by-K matrix which is a subset of K columns selected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think with "subset" you mean "spanning the same subspace" or "in the range of K columns of A" here. Is that right?
*> | ||
*> DGECX computes a CX factorization of a real M-by-N matrix A: | ||
*> | ||
*> A * P(K) = C*X + A_resid, where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think P(K)
notation is confusing here. It's not a function of K
but depends on K
parameter.
*> from the original matrix A, | ||
*> | ||
*> X is a K-by-N matrix that minimizes the Frobenius norm of the | ||
*> residual matrix A_resid, X = pseudoinv(C) * A, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just say "minimizes "|A - C*X|" in the Frobenius norm".
*> Column selection stage 1. | ||
*> ========================= | ||
*> | ||
*> The user can select N_sel columns and deselect N_desel columns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't I just supply a list of columns that I want and leave this deselect business out? Then it will be two options, "A" is all columns, "S" selected columns. If "A" then cols
array is not referenced otherwise it is read from cols
array.
I'm afraid this is getting a bit too complicated with explicit deselection. Same goes for the rows
his a draft for dgecx.f. to REVIEW and COMMENT