Skip to content

Commit c74b41c

Browse files
committed
feat: add math/base/special/hacovercosf
--- 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: na - 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 00614b6 commit c74b41c

File tree

24 files changed

+296
-281
lines changed

24 files changed

+296
-281
lines changed

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

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

2121
# Hacovercosine
2222

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

@@ -32,11 +32,6 @@ The half-value [coversed cosine][coversed-cosine] is defined as
3232
\mathop{\mathrm{hacovercos}}(\theta) = \frac{1 + \sin \theta}{2}
3333
```
3434

35-
<!-- <div class="equation" align="center" data-raw-text="\operatorname{hacovercos}(\theta) = \frac{1 + \sin \theta}{2}" data-equation="eq:hacovercosine">
36-
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/hacovercos/docs/img/equation_hacovercosine.svg" alt="Half-value coversed cosine.">
37-
<br>
38-
</div> -->
39-
4035
<!-- </equation> -->
4136

4237
</section>
@@ -48,21 +43,21 @@ The half-value [coversed cosine][coversed-cosine] is defined as
4843
## Usage
4944

5045
```javascript
51-
var hacovercos = require( '@stdlib/math/base/special/hacovercos' );
46+
var hacovercosf = require( '@stdlib/math/base/special/hacovercosf' );
5247
```
5348

54-
#### hacovercos( x )
49+
#### hacovercosf( x )
5550

56-
Computes the half-value [coversed cosine][coversed-cosine] (in radians).
51+
Computes the half-value [coversed cosine][coversed-cosine] of a single-precision floating-point number (in radians).
5752

5853
```javascript
59-
var v = hacovercos( 0.0 );
54+
var v = hacovercosf( 0.0 );
6055
// returns 0.5
6156

62-
v = hacovercos( 3.141592653589793/2.0 );
57+
v = hacovercosf( 3.141592653589793/2.0 );
6358
// returns 1.0
6459

65-
v = hacovercos( -3.141592653589793/6.0 );
60+
v = hacovercosf( -3.141592653589793/6.0 );
6661
// returns 0.25
6762
```
6863

@@ -79,15 +74,15 @@ v = hacovercos( -3.141592653589793/6.0 );
7974
```javascript
8075
var uniform = require( '@stdlib/random/array/uniform' );
8176
var logEachMap = require( '@stdlib/console/log-each-map' );
82-
var TWO_PI = require( '@stdlib/constants/float64/two-pi' );
83-
var hacovercos = require( '@stdlib/math/base/special/hacovercos' );
77+
var TWO_PI = require( '@stdlib/constants/float32/two-pi' );
78+
var hacovercosf = require( '@stdlib/math/base/special/hacovercosf' );
8479

8580
var opts = {
86-
'dtype': 'float64'
81+
'dtype': 'float32'
8782
};
8883
var x = uniform( 100, 0.0, TWO_PI, opts );
8984

90-
logEachMap( 'hacovercos(%0.4f) = %0.4f', x, hacovercos );
85+
logEachMap( 'hacovercosf(%0.4f) = %0.4f', x, hacovercosf );
9186
```
9287

9388
</section>
@@ -117,27 +112,27 @@ logEachMap( 'hacovercos(%0.4f) = %0.4f', x, hacovercos );
117112
### Usage
118113

119114
```c
120-
#include "stdlib/math/base/special/hacovercos.h"
115+
#include "stdlib/math/base/special/hacovercosf.h"
121116
```
122117

123-
#### stdlib_base_hacovercos( x )
118+
#### stdlib_base_hacovercosf( x )
124119

125-
Computes the half-value [coversed cosine][coversed-cosine] (in radians).
120+
Computes the half-value [coversed cosine][coversed-cosine] of a single-precision floating-point number (in radians).
126121

127122
```c
128-
double out = stdlib_base_hacovercos( 0.0 );
129-
// returns 0.5
123+
float out = stdlib_base_hacovercosf( 0.0f );
124+
// returns 0.5f
130125

131-
out = stdlib_base_hacovercos( 3.141592653589793 / 2.0 );
132-
// returns 1.0
126+
out = stdlib_base_hacovercosf( 3.141592653589793f / 2.0f );
127+
// returns 1.0f
133128
```
134129

135130
The function accepts the following arguments:
136131

137-
- **x**: `[in] double` input value.
132+
- **x**: `[in] float` input value (in radians).
138133

139134
```c
140-
double stdlib_base_hacovercos( const double x );
135+
float stdlib_base_hacovercosf( const float x );
141136
```
142137
143138
</section>
@@ -159,17 +154,17 @@ double stdlib_base_hacovercos( const double x );
159154
### Examples
160155
161156
```c
162-
#include "stdlib/math/base/special/hacovercos.h"
157+
#include "stdlib/math/base/special/hacovercosf.h"
163158
#include <stdio.h>
164159
165160
int main( void ) {
166-
const double x[] = { 0.0, 0.523, 0.785, 1.047, 3.14 };
161+
const float x[] = { 0.0f, 0.523f, 0.785f, 1.047f, 3.14f };
167162
168-
double y;
163+
float y;
169164
int i;
170165
for ( i = 0; i < 5; i++ ) {
171-
y = stdlib_base_hacovercos( x[ i ] );
172-
printf( "hacovercos(%lf) = %lf\n", x[ i ], y );
166+
y = stdlib_base_hacovercosf( x[ i ] );
167+
printf( "hacovercosf(%f) = %f\n", x[ i ], y );
173168
}
174169
}
175170
```
@@ -186,13 +181,6 @@ int main( void ) {
186181

187182
<section class="related">
188183

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

198186
<!-- /.related -->
@@ -205,10 +193,6 @@ int main( void ) {
205193

206194
<!-- <related-links> -->
207195

208-
[@stdlib/math/base/special/hacoversin]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/hacoversin
209-
210-
[@stdlib/math/base/special/havercos]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/havercos
211-
212196
<!-- </related-links> -->
213197

214198
</section>

lib/node_modules/@stdlib/math/base/special/hacovercosf/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 hacovercos = require( './../lib' );
27+
var hacovercosf = 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 = hacovercos( x[ i%x.length ] );
42-
if ( isnan( y ) ) {
43+
y = hacovercosf( 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/hacovercosf/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 hacovercos = tryRequire( resolve( __dirname, './../lib/native.js' ) );
33+
var hacovercosf = tryRequire( resolve( __dirname, './../lib/native.js' ) );
3434
var opts = {
35-
'skip': ( hacovercos instanceof Error )
35+
'skip': ( hacovercosf 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 = hacovercos( x[ i%x.length ] );
51-
if ( isnan( y ) ) {
52+
y = hacovercosf( 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/hacovercosf/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 "hacovercos"
25+
#define NAME "hacovercosf"
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 ] ) ) / 2.0;
106+
y = ( 1.0f + sinf( x[ i%100 ] ) ) / 2.0f;
105107
if ( y != y ) {
106108
printf( "should not return NaN\n" );
107109
break;

lib/node_modules/@stdlib/math/base/special/hacovercosf/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/hacovercos.h"
19+
#include "stdlib/math/base/special/hacovercosf.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 "hacovercos"
26+
#define NAME "hacovercosf"
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_hacovercos( x[ i%100 ] );
107+
y = stdlib_base_hacovercosf( x[ i%100 ] );
106108
if ( y != y ) {
107109
printf( "should not return NaN\n" );
108110
break;

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

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

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

56
The half-value coversed cosine is defined as `(1 + sin(x)) / 2`.
67

@@ -12,7 +13,7 @@
1213
Returns
1314
-------
1415
y: number
15-
Half-value coversed cosine of a single-precision floating-point number (in radians).
16+
Half-value coversed cosine.
1617

1718
Examples
1819
--------

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,24 @@
2929
* @returns half-value coversed cosine
3030
*
3131
* @example
32-
* var v = hacovercos( 0.0 );
32+
* var v = hacovercosf( 0.0 );
3333
* // returns 0.5
3434
*
3535
* @example
36-
* var v = hacovercos( 3.141592653589793/2.0 );
36+
* var v = hacovercosf( 3.141592653589793/2.0 );
3737
* // returns 1.0
3838
*
3939
* @example
40-
* var v = hacovercos( -3.141592653589793/6.0 );
40+
* var v = hacovercosf( -3.141592653589793/6.0 );
4141
* // returns 0.25
4242
*
4343
* @example
44-
* var v = hacovercos( NaN );
44+
* var v = hacovercosf( NaN );
4545
* // returns NaN
4646
*/
47-
declare function hacovercos( x: number ): number;
47+
declare function hacovercosf( x: number ): number;
4848

4949

5050
// EXPORTS //
5151

52-
export = hacovercos;
52+
export = hacovercosf;

0 commit comments

Comments
 (0)