Skip to content

C/ZLARFGP must re-scale when ALPHA is not real #980

@christoph-conrads

Description

@christoph-conrads

Description

When a vector x with a single nonzero entry x_1 sufficiently small in modulus is passed to CLARFGP or ZLARFGP and if the imaginary part of x_1 is nonzero, then the computed scalar τ is inaccurate. Specifically if either the real of the imaginary part of x_1 (or both) is denormalized, then the the modulus computed by xLARFGP does not possess a small relative error (see SRC/clarfgp.f, line 172 for example).

The problem does not occur with xLARFG (note the missing "P" in the function) name because it scales the vector before computing the modulus of ALPHA when at least one of the following two conditions holds (see SRC/clarfg.f):

  • the norm of the vector entries (x_2, x_3, ..., x_n) is nonzero or
  • the imaginary part of x_1 is nonzero.

xlarfgP does not check for the second condition.

The issue was found while working on #406. If inaccurate factors τ computed by xlarfgP are passed to xUNGQR, then the matrices calculated by the latter function are far from being unitary (‖U^* U - I‖ is noticeably different from zero).

Checklist

  • I've included a minimal example to reproduce the issue
  • I'd be willing to make a PR to solve this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions