@stdlib/math-base-special-sincosf
v0.1.1
Published
Simultaneously compute the sine and cosine of a single-precision floating-point number (in radians).
Readme
sincosf
Simultaneously compute the sine and cosine of a single-precision floating-point number (in radians).
Installation
npm install @stdlib/math-base-special-sincosfUsage
var sincosf = require( '@stdlib/math-base-special-sincosf' );sincosf( x )
Simultaneously computes the sine and cosine of a single-precision floating-point number (in radians).
var v = sincosf( 0.0 );
// returns [ ~0.0, ~1.0 ]
v = sincosf( 3.141592653589793/2.0 );
// returns [ ~1.0, ~0.0 ]
v = sincosf( -3.141592653589793/6.0 );
// returns [ ~-0.5, ~0.866 ]sincosf.assign( x, out, stride, offset )
Simultaneously computes the sine and cosine of a single-precision floating-point number (in radians) and assigns the results to a provided output array.
var Float32Array = require( '@stdlib/array-float32' );
var out = new Float32Array( 2 );
var v = sincosf.assign( 0.0, out, 1, 0 );
// returns <Float32Array>[ ~0.0, ~1.0 ]
var bool = ( v === out );
// returns trueExamples
var uniform = require( '@stdlib/random-array-uniform' );
var TWO_PI = require( '@stdlib/constants-float32-two-pi' );
var sincosf = require( '@stdlib/math-base-special-sincosf' );
var opts = {
'dtype': 'float32'
};
var x = uniform( 100, 0.0, TWO_PI, opts );
var y;
var i;
for ( i = 0; i < x.length; i++ ) {
y = sincosf( x[ i ] );
console.log( 'sincosf(%d) = [ %d, %d ]', x[ i ], y[ 0 ], y[ 1 ] );
}C APIs
Usage
#include "stdlib/math/base/special/sincosf.h"stdlib_base_sincosf( x, &sine, &cosine )
Simultaneously computes the sine and cosine of a single-precision floating-point number (in radians).
float cosine;
float sine;
stdlib_base_sincosf( 4.0f, &sine, &cosine );The function accepts the following arguments:
- x:
[in] floatinput value. - sine:
[out] float*destination for the sine. - cosine:
[out] float*destination for the cosine.
void stdlib_base_sincosf( const float x, float *sine, float *cosine );Examples
#include "stdlib/math/base/special/sincosf.h"
#include <stdio.h>
int main( void ) {
const float x[] = { 0.0f, 1.57f, 3.14f, 6.28f };
float cosine;
float sine;
int i;
for ( i = 0; i < 4; i++ ) {
stdlib_base_sincosf( x[ i ], &sine, &cosine );
printf( "sincosf(%f) = [ %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.
