Skip to content

Calculate CUNMLQ LWORK consistently when K=0#1225

Open
ndingle-arm wants to merge 1 commit intoReference-LAPACK:masterfrom
ndingle-arm:cumlq-workspace-patch
Open

Calculate CUNMLQ LWORK consistently when K=0#1225
ndingle-arm wants to merge 1 commit intoReference-LAPACK:masterfrom
ndingle-arm:cumlq-workspace-patch

Conversation

@ndingle-arm
Copy link
Copy Markdown
Contributor

Description

CUNMLQ's documentation says LWORK must be:

      If SIDE = 'L', LWORK >= max(1,N);
      if SIDE = 'R', LWORK >= max(1,M).

In the current implementation, however, when K=0 a workspace query will return LWORK=1 in WORK(1). This means a subsequent call to CUNMLQ with a workspace of that size will fail with INFO = -12.

The other ???MLQ routines return consistent values of LWORK when K=0 (that is, equal to or greater than NW) so this patch makes CUNMLQ's behaviour match theirs.

Checklist

  • The documentation has been updated. No docs update needed -- this makes the implementation match the documentation.
  • If the PR solves a specific issue, it is set to be closed on merge. No issue raised to close.

CUNMLQ's documentation says LWORK must be:

          If SIDE = 'L', LWORK >= max(1,N);
          if SIDE = 'R', LWORK >= max(1,M).

In the current implementation, however, when K=0 a workspace query
will return LWORK=1 in WORK(1). This means a subsequent call to CUNMLQ
with a workspace of that size will fail with INFO = -12.

The other ???MLQ routines return consistent values of LWORK when K=0
(that is, equal to or greater than NW) so this patch makes CUNMLQ's
behaviour match theirs.
@martin-frbg
Copy link
Copy Markdown
Collaborator

Assuming that the caller then goes ahead and allocates a large work array as told, wouldn't a more efficient alternative be to amend the LWORK size test in CUNMLQ with a special case for K=0 ? (Or simply IF M.EQ.0 .OR. N.EQ.0 .OR. K .EQ.0) NW=0)

@ndingle-arm
Copy link
Copy Markdown
Contributor Author

I was unsure why CUNMLQ handles workspace queries differently from ZUNMLQ and DORMLQ/SORMLQ when K=0. Those subroutines do not have the condition:

IF( m.EQ.0 .OR. n.EQ.0 .OR. k.EQ.0 ) THEN lwkopt = 1

so behave in accordance with the API specifications in their documentation (that is, they return a value of LWORK >= MAX(1,M) or MAX(1,N) regardless of the value of K).

Is there a need for CUNMLQ to have this special behaviour when K=0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants