Simultaneously compute the sine and cosine of an angle measured in radians on the interval
[-π/4, π/4]
.
var kernelSincos = require( '@stdlib/math/base/special/kernel-sincos' );
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 ]
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 ] );
}
#include "stdlib/math/base/special/kernel_sincos.h"
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] double
input value (in radians, assumed to be bounded by~pi/4
in magnitude). - y:
[in] double
tail 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 );
#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 );
}
}