@stdlib/math-base-special-kernel-sincosf
v0.1.1
Published
Simultaneously compute the sine and cosine of an angle measured in radians on [-π/4, π/4] in single-precision floating-point format.
Readme
kernelSincosf
Simultaneously compute the sine and cosine of an angle measured in radians on
[-π/4, π/4]in single-precision floating-point format.
Installation
npm install @stdlib/math-base-special-kernel-sincosfUsage
var kernelSincosf = require( '@stdlib/math-base-special-kernel-sincosf' );kernelSincosf( x )
Simultaneously computes the sine and cosine of an angle measured in radians on [-π/4, π/4] in single-precision floating-point format.
var sc = kernelSincosf( 0.0 );
// returns [ ~0.0, ~1.0 ]
sc = kernelSincosf( 3.141592653589793/2.0 );
// returns [ ~1.0, ~0.0 ]
sc = kernelSincosf( -3.141592653589793/6.0 );
// returns [ ~-0.5, ~0.866 ]
sc = kernelSincosf( NaN );
// returns [ NaN, NaN ]kernelSincosf.assign( x, out, stride, offset )
Simultaneously computes the sine and cosine of an angle measured in radians on [-π/4, π/4] in single-precision floating-point format, and stores the results in a provided output array.
var Float32Array = require( '@stdlib/array-float32' );
var out = new Float32Array( 2 );
var sc = kernelSincosf.assign( 0.0, out, 1, 0 );
// returns <Float32Array>[ ~0.0, ~1.0 ]
var bool = ( sc === out );
// returns trueExamples
var linspace = require( '@stdlib/array-base-linspace' );
var PI = require( '@stdlib/constants-float64-pi' );
var kernelSincosf = require( '@stdlib/math-base-special-kernel-sincosf' );
var x = linspace( -PI/4.0, PI/4.0, 100 );
var y;
var i;
for ( i = 0; i < x.length; i++ ) {
y = kernelSincosf( x[ i ] );
console.log( 'kernelSincosf(%d) = [ %d, %d ]', x[ i ], y[ 0 ], y[ 1 ] );
}C APIs
Usage
#include "stdlib/math/base/special/kernel_sincosf.h"stdlib_base_kernel_sincosf( x, &sine, &cosine )
Simultaneously computes the sine and cosine of an angle measured in radians on [-π/4, π/4] in single-precision floating-point format.
float cosine;
float sine;
stdlib_base_kernel_sincosf( 0.0, &sine, &cosine );The function accepts the following arguments:
- x:
[in] doubleinput value (in radians, assumed to be bounded by~pi/4in magnitude). - sine:
[out] float*destination for the sine. - cosine:
[out] float*destination for the cosine.
void stdlib_base_kernel_sincosf( const double x, float* sine, float* cosine );Examples
#include "stdlib/math/base/special/kernel_sincosf.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 };
float cosine;
float sine;
int i;
for ( i = 0; i < 10; i++ ) {
stdlib_base_kernel_sincosf( x[ i ], &sine, &cosine );
printf( "kernelSincosf(%lf) = [ %f, %f ]\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.
