Skip to content

Commit e86c07e

Browse files
committed
feat: add math/base/special/sinf
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent 8c4d311 commit e86c07e

File tree

33 files changed

+321
-619
lines changed

33 files changed

+321
-619
lines changed

lib/node_modules/@stdlib/math/base/special/sinf/README.md

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
@license Apache-2.0
44
5-
Copyright (c) 2018 The Stdlib Authors.
5+
Copyright (c) 2025 The Stdlib Authors.
66
77
Licensed under the Apache License, Version 2.0 (the "License");
88
you may not use this file except in compliance with the License.
@@ -20,28 +20,28 @@ limitations under the License.
2020

2121
# Sine
2222

23-
> Compute the [sine][sine] of a number.
23+
> Compute the [sine][sine] of a single-precision floating-point number (in radians).
2424
2525
<section class="usage">
2626

2727
## Usage
2828

2929
```javascript
30-
var sin = require( '@stdlib/math/base/special/sin' );
30+
var sinf = require( '@stdlib/math/base/special/sinf' );
3131
```
3232

33-
#### sin( x )
33+
#### sinf( x )
3434

35-
Computes the [sine][sine] of a `number` (in radians).
35+
Computes the [sine][sine] of a single-precision floating-point number (in radians).
3636

3737
```javascript
38-
var v = sin( 0.0 );
38+
var v = sinf( 0.0 );
3939
// returns ~0.0
4040

41-
v = sin( 3.141592653589793/2.0 );
41+
v = sinf( 3.141592653589793/2.0 );
4242
// returns ~1.0
4343

44-
v = sin( -3.141592653589793/6.0 );
44+
v = sinf( -3.141592653589793/6.0 );
4545
// returns ~-0.5
4646
```
4747

@@ -58,15 +58,15 @@ v = sin( -3.141592653589793/6.0 );
5858
```javascript
5959
var uniform = require( '@stdlib/random/array/uniform' );
6060
var logEachMap = require( '@stdlib/console/log-each-map' );
61-
var TWO_PI = require( '@stdlib/constants/float64/two-pi' );
62-
var sin = require( '@stdlib/math/base/special/sin' );
61+
var TWO_PI = require( '@stdlib/constants/float32/two-pi' );
62+
var sinf = require( '@stdlib/math/base/special/sinf' );
6363

6464
var opts = {
65-
'dtype': 'float64'
65+
'dtype': 'float32'
6666
};
6767
var x = uniform( 100, 0.0, TWO_PI, opts );
6868

69-
logEachMap( 'sin(%0.4f) = %0.4f', x, sin );
69+
logEachMap( 'sinf(%0.4f) = %0.4f', x, sinf );
7070
```
7171

7272
</section>
@@ -96,24 +96,24 @@ logEachMap( 'sin(%0.4f) = %0.4f', x, sin );
9696
### Usage
9797

9898
```c
99-
#include "stdlib/math/base/special/sin.h"
99+
#include "stdlib/math/base/special/sinf.h"
100100
```
101101

102-
#### stdlib_base_sin( x )
102+
#### stdlib_base_sinf( x )
103103

104-
Computes the [sine][sine] of a `number` (in radians).
104+
Computes the [sine][sine] of a single-precision floating-point number (in radians).
105105

106106
```c
107-
double y = stdlib_base_sin( 3.141592653589793 / 2.0 );
108-
// returns ~1.0
107+
float y = stdlib_base_sinf( 3.141592653589793f / 2.0f );
108+
// returns ~1.0f
109109
```
110110

111111
The function accepts the following arguments:
112112

113-
- **x**: `[in] double` input value.
113+
- **x**: `[in] float` input value.
114114

115115
```c
116-
double stdlib_base_sin( const double x );
116+
float stdlib_base_sinf( const float x );
117117
```
118118
119119
</section>
@@ -135,17 +135,17 @@ double stdlib_base_sin( const double x );
135135
### Examples
136136
137137
```c
138-
#include "stdlib/math/base/special/sin.h"
138+
#include "stdlib/math/base/special/sinf.h"
139139
#include <stdio.h>
140140
141141
int main( void ) {
142-
const double x[] = { 0.0, 0.523, 0.785, 1.047, 3.14 };
142+
const float x[] = { 0.0f, 0.523f, 0.785f, 1.047f, 3.14f };
143143
144-
double y;
144+
float y;
145145
int i;
146146
for ( i = 0; i < 5; i++ ) {
147-
y = stdlib_base_sin( x[ i ] );
148-
printf( "sin(%lf) = %lf\n", x[ i ], y );
147+
y = stdlib_base_sinf( x[ i ] );
148+
printf( "sinf(%f) = %f\n", x[ i ], y );
149149
}
150150
}
151151
```
@@ -162,14 +162,6 @@ int main( void ) {
162162

163163
<section class="related">
164164

165-
* * *
166-
167-
## See Also
168-
169-
- <span class="package-name">[`@stdlib/math/base/special/cos`][@stdlib/math/base/special/cos]</span><span class="delimiter">: </span><span class="description">compute the cosine of a number.</span>
170-
- <span class="package-name">[`@stdlib/math/base/special/sinpi`][@stdlib/math/base/special/sinpi]</span><span class="delimiter">: </span><span class="description">compute sin(πx).</span>
171-
- <span class="package-name">[`@stdlib/math/base/special/tan`][@stdlib/math/base/special/tan]</span><span class="delimiter">: </span><span class="description">evaluate the tangent of a number.</span>
172-
173165
</section>
174166

175167
<!-- /.related -->
@@ -182,12 +174,6 @@ int main( void ) {
182174

183175
<!-- <related-links> -->
184176

185-
[@stdlib/math/base/special/cos]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/cos
186-
187-
[@stdlib/math/base/special/sinpi]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/sinpi
188-
189-
[@stdlib/math/base/special/tan]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/tan
190-
191177
<!-- </related-links> -->
192178

193179
</section>

lib/node_modules/@stdlib/math/base/special/sinf/benchmark/benchmark.js

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -22,9 +22,9 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var uniform = require( '@stdlib/random/array/uniform' );
25-
var isnan = require( '@stdlib/math/base/assert/is-nan' );
25+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2626
var pkg = require( './../package.json' ).name;
27-
var sin = require( './../lib' );
27+
var sinf = require( './../lib' );
2828

2929

3030
// MAIN //
@@ -34,39 +34,19 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

37-
x = uniform( 100, -10.0, 10.0 );
37+
x = uniform( 100, -10.0, 10.0, {
38+
'dtype': 'float32'
39+
});
3840

3941
b.tic();
4042
for ( i = 0; i < b.iterations; i++ ) {
41-
y = sin( x[ i%x.length ] );
42-
if ( isnan( y ) ) {
43+
y = sinf( x[ i%x.length ] );
44+
if ( isnanf( y ) ) {
4345
b.fail( 'should not return NaN' );
4446
}
4547
}
4648
b.toc();
47-
if ( isnan( y ) ) {
48-
b.fail( 'should not return NaN' );
49-
}
50-
b.pass( 'benchmark finished' );
51-
b.end();
52-
});
53-
54-
bench( pkg+'::built-in', function benchmark( b ) {
55-
var x;
56-
var y;
57-
var i;
58-
59-
x = uniform( 100, -10.0, 10.0 );
60-
61-
b.tic();
62-
for ( i = 0; i < b.iterations; i++ ) {
63-
y = Math.sin( x[ i%x.length ] ); // eslint-disable-line stdlib/no-builtin-math
64-
if ( isnan( y ) ) {
65-
b.fail( 'should not return NaN' );
66-
}
67-
}
68-
b.toc();
69-
if ( isnan( y ) ) {
49+
if ( isnanf( y ) ) {
7050
b.fail( 'should not return NaN' );
7151
}
7252
b.pass( 'benchmark finished' );

lib/node_modules/@stdlib/math/base/special/sinf/benchmark/benchmark.native.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2024 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -23,16 +23,16 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var uniform = require( '@stdlib/random/array/uniform' );
26-
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2727
var tryRequire = require( '@stdlib/utils/try-require' );
2828
var pkg = require( './../package.json' ).name;
2929

3030

3131
// VARIABLES //
3232

33-
var sin = tryRequire( resolve( __dirname, './../lib/native.js' ) );
33+
var sinf = tryRequire( resolve( __dirname, './../lib/native.js' ) );
3434
var opts = {
35-
'skip': ( sin instanceof Error )
35+
'skip': ( sinf instanceof Error )
3636
};
3737

3838

@@ -43,17 +43,19 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4343
var y;
4444
var i;
4545

46-
x = uniform( 100, -10.0, 10.0 );
46+
x = uniform( 100, -10.0, 10.0, {
47+
'dtype': 'float32'
48+
});
4749

4850
b.tic();
4951
for ( i = 0; i < b.iterations; i++ ) {
50-
y = sin( x[ i%x.length ] );
51-
if ( isnan( y ) ) {
52+
y = sinf( x[ i%x.length ] );
53+
if ( isnanf( y ) ) {
5254
b.fail( 'should not return NaN' );
5355
}
5456
}
5557
b.toc();
56-
if ( isnan( y ) ) {
58+
if ( isnanf( y ) ) {
5759
b.fail( 'should not return NaN' );
5860
}
5961
b.pass( 'benchmark finished' );

lib/node_modules/@stdlib/math/base/special/sinf/benchmark/c/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#/
22
# @license Apache-2.0
33
#
4-
# Copyright (c) 2018 The Stdlib Authors.
4+
# Copyright (c) 2025 The Stdlib Authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
1616
# limitations under the License.
1717
#/
1818

19-
2019
# VARIABLES #
2120

2221
ifndef VERBOSE

lib/node_modules/@stdlib/math/base/special/sinf/benchmark/c/benchmark.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
2222
#include <time.h>
2323
#include <sys/time.h>
2424

25-
#define NAME "sin"
25+
#define NAME "sinf"
2626
#define ITERATIONS 1000000
2727
#define REPEATS 3
2828

@@ -78,9 +78,9 @@ static double tic( void ) {
7878
*
7979
* @return random number
8080
*/
81-
static double rand_double( void ) {
81+
static float rand_float( void ) {
8282
int r = rand();
83-
return (double)r / ( (double)RAND_MAX + 1.0 );
83+
return (float)r / ( (float)RAND_MAX + 1.0f );
8484
}
8585

8686
/**
@@ -89,19 +89,19 @@ static double rand_double( void ) {
8989
* @return elapsed time in seconds
9090
*/
9191
static double benchmark( void ) {
92-
double x[ 100 ];
92+
float x[ 100 ];
9393
double elapsed;
94-
double y;
9594
double t;
95+
float y;
9696
int i;
9797

9898
for ( i = 0; i < 100; i++ ) {
99-
x[ i ] = ( 20.0*rand_double() ) - 10.0;
99+
x[ i ] = ( 20.0f*rand_float() ) - 10.0f;
100100
}
101101

102102
t = tic();
103103
for ( i = 0; i < ITERATIONS; i++ ) {
104-
y = sin( x[ i%100 ] );
104+
y = sinf( x[ i%100 ] );
105105
if ( y != y ) {
106106
printf( "should not return NaN\n" );
107107
break;

0 commit comments

Comments
 (0)