Skip to content

Commit 2f47ba6

Browse files
committed
feat: add math/base/special/coversinf
--- 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 148b72a commit 2f47ba6

File tree

27 files changed

+220
-296
lines changed

27 files changed

+220
-296
lines changed

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

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# Coversine
2222

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

@@ -48,21 +48,21 @@ The [coversed sine][coversed-sine] is defined as
4848
## Usage
4949

5050
```javascript
51-
var coversin = require( '@stdlib/math/base/special/coversin' );
51+
var coversinf = require( '@stdlib/math/base/special/coversinf' );
5252
```
5353

54-
#### coversin( x )
54+
#### coversinf( x )
5555

56-
Computes the [coversed sine][coversed-sine] (in radians).
56+
Computes the [coversed sine][coversed-sine] of a single-precision floating-point number (in radians).
5757

5858
```javascript
59-
var v = coversin( 0.0 );
59+
var v = coversinf( 0.0 );
6060
// returns 1.0
6161

62-
v = coversin( 3.141592653589793/2.0 );
62+
v = coversinf( 3.141592653589793/2.0 );
6363
// returns 0.0
6464

65-
v = coversin( -3.141592653589793/6.0 );
65+
v = coversinf( -3.141592653589793/6.0 );
6666
// returns 1.5
6767
```
6868

@@ -79,15 +79,15 @@ v = coversin( -3.141592653589793/6.0 );
7979
```javascript
8080
var uniform = require( '@stdlib/random/array/uniform' );
8181
var logEachMap = require( '@stdlib/console/log-each-map' );
82-
var TWO_PI = require( '@stdlib/constants/float64/two-pi' );
83-
var coversin = require( '@stdlib/math/base/special/coversin' );
82+
var TWO_PI = require( '@stdlib/constants/float32/two-pi' );
83+
var coversinf = require( '@stdlib/math/base/special/coversinf' );
8484

8585
var opts = {
86-
'dtype': 'float64'
86+
'dtype': 'float32'
8787
};
8888
var x = uniform( 100, 0.0, TWO_PI, opts );
8989

90-
logEachMap( 'coversin(%0.4f) = %0.4f', x, coversin );
90+
logEachMap( 'coversinf(%0.4f) = %0.4f', x, coversinf );
9191
```
9292

9393
</section>
@@ -117,27 +117,27 @@ logEachMap( 'coversin(%0.4f) = %0.4f', x, coversin );
117117
### Usage
118118

119119
```c
120-
#include "stdlib/math/base/special/coversin.h"
120+
#include "stdlib/math/base/special/coversinf.h"
121121
```
122122

123-
#### stdlib_base_coversin( x )
123+
#### stdlib_base_coversinf( x )
124124

125-
Computes the [coversed sine][coversed-sine] (in radians).
125+
Computes the [coversed sine][coversed-sine] of a single-precision floating-point number (in radians).
126126

127127
```c
128-
double out = stdlib_base_coversin( 0.0 );
129-
// returns 1.0
128+
float out = stdlib_base_coversinf( 0.0f );
129+
// returns 1.0f
130130

131-
out = stdlib_base_coversin( 3.141592653589793 / 2.0 );
132-
// returns 0.0
131+
out = stdlib_base_coversinf( 3.141592653589793f / 2.0f );
132+
// returns 0.0f
133133
```
134134

135135
The function accepts the following arguments:
136136

137-
- **x**: `[in] double` input value.
137+
- **x**: `[in] float` input value.
138138

139139
```c
140-
double stdlib_base_coversin( const double x );
140+
float stdlib_base_coversinf( const float x );
141141
```
142142
143143
</section>
@@ -159,17 +159,17 @@ double stdlib_base_coversin( const double x );
159159
### Examples
160160
161161
```c
162-
#include "stdlib/math/base/special/coversin.h"
162+
#include "stdlib/math/base/special/coversinf.h"
163163
#include <stdio.h>
164164
165165
int main( void ) {
166-
const double x[] = { 0.0, 0.523, 0.785, 1.047, 3.14 };
166+
const float x[] = { 0.0f, 0.523f, 0.785f, 1.047f, 3.14f };
167167
168-
double y;
168+
float y;
169169
int i;
170170
for ( i = 0; i < 5; i++ ) {
171-
y = stdlib_base_coversin( x[ i ] );
172-
printf( "coversin(%lf) = %lf\n", x[ i ], y );
171+
y = stdlib_base_coversinf( x[ i ] );
172+
printf( "coversinf(%f) = %f\n", x[ i ], y );
173173
}
174174
}
175175
```
@@ -186,13 +186,6 @@ int main( void ) {
186186

187187
<section class="related">
188188

189-
* * *
190-
191-
## See Also
192-
193-
- <span class="package-name">[`@stdlib/math/base/special/covercos`][@stdlib/math/base/special/covercos]</span><span class="delimiter">: </span><span class="description">compute the coversed cosine.</span>
194-
- <span class="package-name">[`@stdlib/math/base/special/versin`][@stdlib/math/base/special/versin]</span><span class="delimiter">: </span><span class="description">compute the versed sine.</span>
195-
196189
</section>
197190

198191
<!-- /.related -->
@@ -205,10 +198,6 @@ int main( void ) {
205198

206199
<!-- <related-links> -->
207200

208-
[@stdlib/math/base/special/covercos]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/covercos
209-
210-
[@stdlib/math/base/special/versin]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/versin
211-
212201
<!-- </related-links> -->
213202

214203
</section>

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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 coversin = require( './../lib' );
27+
var coversinf = require( './../lib' );
2828

2929

3030
// MAIN //
@@ -34,17 +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 = coversin( x[ i%x.length ] );
42-
if ( isnan( y ) ) {
43+
y = coversinf( x[ i%x.length ] );
44+
if ( isnanf( y ) ) {
4345
b.fail( 'should not return NaN' );
4446
}
4547
}
4648
b.toc();
47-
if ( isnan( y ) ) {
49+
if ( isnanf( y ) ) {
4850
b.fail( 'should not return NaN' );
4951
}
5052
b.pass( 'benchmark finished' );

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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 coversin = tryRequire( resolve( __dirname, './../lib/native.js' ) );
33+
var coversinf = tryRequire( resolve( __dirname, './../lib/native.js' ) );
3434
var opts = {
35-
'skip': ( coversin instanceof Error )
35+
'skip': ( coversinf 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 = coversin( x[ i%x.length ] );
51-
if ( isnan( y ) ) {
52+
y = coversinf( 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/coversinf/benchmark/c/benchmark.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <time.h>
2323
#include <sys/time.h>
2424

25-
#define NAME "coversin"
25+
#define NAME "coversinf"
2626
#define ITERATIONS 1000000
2727
#define REPEATS 3
2828

@@ -74,13 +74,15 @@ static double tic( void ) {
7474
}
7575

7676
/**
77-
* Generates a random number on the interval [0,1).
77+
* Generates a random number on the interval [min,max).
7878
*
79-
* @return random number
79+
* @param min minimum value (inclusive)
80+
* @param max maximum value (exclusive)
81+
* @return random number
8082
*/
81-
static double rand_double( void ) {
82-
int r = rand();
83-
return (double)r / ( (double)RAND_MAX + 1.0 );
83+
static float random_uniform( const float min, const float max ) {
84+
float v = (float)rand() / ( (float)RAND_MAX + 1.0f );
85+
return min + ( v*(max-min) );
8486
}
8587

8688
/**
@@ -89,19 +91,19 @@ static double rand_double( void ) {
8991
* @return elapsed time in seconds
9092
*/
9193
static double benchmark( void ) {
94+
float x[ 100 ];
9295
double elapsed;
93-
double x[ 100 ];
94-
double y;
9596
double t;
97+
float y;
9698
int i;
9799

98100
for ( i = 0; i < 100; i++ ) {
99-
x[ i ] = ( 20.0*rand_double() ) - 10.0;
101+
x[ i ] = random_uniform( -10.0f, 10.0f );
100102
}
101103

102104
t = tic();
103105
for ( i = 0; i < ITERATIONS; i++ ) {
104-
y = 1.0 - sin( x[ i%100 ] );
106+
y = 1.0f - sinf( x[ i%100 ] );
105107
if ( y != y ) {
106108
printf( "should not return NaN\n" );
107109
break;

lib/node_modules/@stdlib/math/base/special/coversinf/benchmark/c/native/benchmark.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "stdlib/math/base/special/coversin.h"
19+
#include "stdlib/math/base/special/coversinf.h"
2020
#include <stdlib.h>
2121
#include <stdio.h>
2222
#include <math.h>
2323
#include <time.h>
2424
#include <sys/time.h>
2525

26-
#define NAME "coversin"
26+
#define NAME "coversinf"
2727
#define ITERATIONS 1000000
2828
#define REPEATS 3
2929

@@ -75,13 +75,15 @@ static double tic( void ) {
7575
}
7676

7777
/**
78-
* Generates a random number on the interval [0,1).
78+
* Generates a random number on the interval [min,max).
7979
*
80-
* @return random number
80+
* @param min minimum value (inclusive)
81+
* @param max maximum value (exclusive)
82+
* @return random number
8183
*/
82-
static double rand_double( void ) {
83-
int r = rand();
84-
return (double)r / ( (double)RAND_MAX + 1.0 );
84+
static float random_uniform( const float min, const float max ) {
85+
float v = (float)rand() / ( (float)RAND_MAX + 1.0f );
86+
return min + ( v*(max-min) );
8587
}
8688

8789
/**
@@ -90,19 +92,19 @@ static double rand_double( void ) {
9092
* @return elapsed time in seconds
9193
*/
9294
static double benchmark( void ) {
95+
float x[ 100 ];
9396
double elapsed;
94-
double x[ 100 ];
95-
double y;
9697
double t;
98+
float y;
9799
int i;
98100

99101
for ( i = 0; i < 100; i++ ) {
100-
x[ i ] = ( 20.0 * rand_double() ) - 10.0;
102+
x[ i ] = random_uniform( -10.0f, 10.0f );
101103
}
102104

103105
t = tic();
104106
for ( i = 0; i < ITERATIONS; i++ ) {
105-
y = stdlib_base_coversin( x[ i%100 ] );
107+
y = stdlib_base_coversinf( x[ i%100 ] );
106108
if ( y != y ) {
107109
printf( "should not return NaN\n" );
108110
break;

lib/node_modules/@stdlib/math/base/special/coversinf/docs/repl.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
{{alias}}( x )
3-
Computes the coversed sine of a single-precision floating-point number (in radians).
3+
Computes the coversed sine of a single-precision floating-point number
4+
(in radians).
45

56
The coversed sine is defined as `1 - sin(x)`.
67

lib/node_modules/@stdlib/math/base/special/coversinf/docs/types/index.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@
2525
* @returns coversed sine
2626
*
2727
* @example
28-
* var v = coversin( 0.0 );
28+
* var v = coversinf( 0.0 );
2929
* // returns 1.0
3030
*
3131
* @example
32-
* var v = coversin( 3.141592653589793/2.0 );
32+
* var v = coversinf( 3.141592653589793/2.0 );
3333
* // returns 0.0
3434
*
3535
* @example
36-
* var v = coversin( -3.141592653589793/6.0 );
36+
* var v = coversinf( -3.141592653589793/6.0 );
3737
* // returns 1.5
3838
*
3939
* @example
40-
* var v = coversin( NaN );
40+
* var v = coversinf( NaN );
4141
* // returns NaN
4242
*/
43-
declare function coversin( x: number ): number;
43+
declare function coversinf( x: number ): number;
4444

4545

4646
// EXPORTS //
4747

48-
export = coversin;
48+
export = coversinf;

0 commit comments

Comments
 (0)