Code Monkey home page Code Monkey logo

Comments (1)

christoph-conrads avatar christoph-conrads commented on June 6, 2024

Minimum example (compile with gcc -Wextra -Wall -std=c99 -pedantic -llapack):

#include <complex.h>
#include <stdio.h>

typedef int lapack_int;

void clarfgp_(
    lapack_int* n, float complex* alpha, float complex* x, lapack_int* incx,
    float complex* tau
);

int main()
{
    lapack_int n = 1;
    float complex x[1] = { 2.073921727e-43f + 3.082856622e-44f * I };
    lapack_int incx = 1;
    float complex tau = -1.0f;

    clarfgp_(&n, x, x + 1, &incx, &tau);

    float complex tau_expected = 1.086842348e-02 - 1.470330722e-01 * I;

    printf("computed tau: %.6e%+.6ej\n", crealf(tau), cimagf(tau));
    printf(
        "expected tau: %.6e%+.6ej\n", crealf(tau_expected), cimagf(tau_expected)
    );
}

Output on my machine:

$ ./a.out 
computed tau: 1.333332e-02-1.466667e-01j
expected tau: 1.086842e-02-1.470331e-01j

The expected value was computed with the help of Python NumPy by the expression

xnorm = np.abs(alpha)
(1 - alpha.real / xnorm) - (alpha.imag / xnorm) * 1j

in double-precision arithmetic.

from lapack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.