]> git.ipfire.org Git - thirdparty/man-pages.git/commit - man3/sincos.3
sincos.3: Note that sincos() is intended to be more efficient than sin() + cos()
authorMichael Kerrisk <mtk.manpages@gmail.com>
Sun, 10 Sep 2017 09:15:55 +0000 (11:15 +0200)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Mon, 11 Sep 2017 05:42:42 +0000 (07:42 +0200)
commit268bac1ffac0096a5e516f93dcd8ee426db8b94a
treebf1a90d1148ae9e6f533f4bec7c20607eb0c9245
parent31fa1fd2a6b211ea48c40e66e54e6bac24013909
sincos.3: Note that sincos() is intended to be more efficient than sin() + cos()

On a current x86-64 i7 system, sincos() is about 15% faster than
sin()+cos() according to the following test program.

/*
 * Build with: cc -O -lm -fno-fast-math -fno-builtin
 */

int
main(int argc, char *argv[])
{
    double arg, rsin, rcos;
    int loop, i;

    arg = strtod(argv[1], NULL);
    loop = 10000000;
    if (argc > 2)
        loop = atoi(argv[2]);

    if (argc > 3) {
        printf("sin + cos\n");
        for (i = 0; i < loop; i++) {
            rsin = sin(arg);
            rcos = cos(arg);
        }
    } else {
        printf("sincos\n");
        for (i = 0; i < loop; i++) {
            sincos(arg, &rsin, &rcos);
        }
    }
}

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
man3/sincos.3