@stdlib/math-base-special-kernel-sincos
v0.1.1
Published
Simultaneously compute the sine and cosine of an angle measured in radians on the interval [-π/4, π/4].
Downloads
60
Readme
kernelSincos
Simultaneously compute the sine and cosine of an angle measured in radians on the interval
[-π/4, π/4].
Installation
npm install @stdlib/math-base-special-kernel-sincosUsage
var kernelSincos = require( '@stdlib/math-base-special-kernel-sincos' );kernelSincos( x, y, out, stride, offset )
Simultaneously computes the sine and cosine of an angle measured in radians on the interval [-π/4, π/4].
var v = kernelSincos( 0.0, 0.0, [ 0.0, 0.0 ], 1, 0 );
// returns [ ~0.0, ~1.0 ]
v = kernelSincos( 3.141592653589793/2.0, 0.0, [ 0.0, 0.0 ], 1, 0 );
// returns [ ~1.0, ~0.0 ]
v = kernelSincos( -3.141592653589793/6.0, 0.0, [ 0.0, 0.0 ], 1, 0 );
// returns [ ~-0.5, ~0.866 ]
v = kernelSincos( NaN, 0.0, [ 0.0, 0.0 ], 1, 0 );
// returns [ NaN, NaN ]Examples
var linspace = require( '@stdlib/array-base-linspace' );
var PI = require( '@stdlib/constants-float64-pi' );
var kernelSincos = require( '@stdlib/math-base-special-kernel-sincos' );
var x = linspace( -PI/4.0, PI/4.0, 100 );
var y;
var i;
for ( i = 0; i < x.length; i++ ) {
y = kernelSincos( x[ i ], 0.0, [ 0.0, 0.0 ], 1, 0 );
console.log( 'kernelSincos(%d) = [ %d, %d ]', x[ i ], y[ 0 ], y[ 1 ] );
}C APIs
Usage
#include "stdlib/math/base/special/kernel_sincos.h"stdlib_base_kernel_sincos( x, y, &sine, &cosine )
Simultaneously computes the sine and cosine of an angle measured in radians on the interval [-π/4, π/4].
double cosine;
double sine;
stdlib_base_kernel_sincos( 0.0, 0.0, &sine, &cosine );The function accepts the following arguments:
- x:
[in] doubleinput value (in radians, assumed to be bounded by~pi/4in magnitude). - y:
[in] doubletail ofx. - sine:
[out] double*destination for the sine. - cosine:
[out] double*destination for the cosine.
void stdlib_base_kernel_sincos( const double x, const double y, double* sine, double* cosine );Examples
#include "stdlib/math/base/special/kernel_sincos.h"
#include <stdio.h>
int main( void ) {
const double x[] = { -0.7853981633974483, -0.6108652381980153, -0.4363323129985824, -0.26179938779914946, -0.08726646259971649, 0.08726646259971649, 0.26179938779914935, 0.43633231299858233, 0.6108652381980153, 0.7853981633974483 };
double cosine;
double sine;
int i;
for ( i = 0; i < 10; i++ ) {
stdlib_base_kernel_sincos( x[ i ], 0.0, &sine, &cosine );
printf( "x: %lf => sine: %lf, cosine: %lf\n", x[ i ], sine, cosine );
}
}Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
Copyright
Copyright © 2016-2026. The Stdlib Authors.
