Skip to content

Commit aded89d

Browse files
committed
feat: add math/base/special/cosm1f
--- 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: passed - 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 39b5c87 commit aded89d

File tree

24 files changed

+260
-540
lines changed

24 files changed

+260
-540
lines changed

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

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ var cosm1f = require( '@stdlib/math/base/special/cosm1f' );
3232

3333
#### cosm1f( x )
3434

35-
Computes `cos(x) - 1`, where `cos` is the [cosine][@stdlib/math/base/special/cos] of a `number` (in radians). This function should be used instead of manually calculating `cos(x) - 1` when the argument is near unity.
35+
Computes `cos(x) - 1`, where `cos` is the [cosine][cosine] of a single-precision floating-point number (in radians). This function should be used instead of manually calculating `cos(x) - 1` when the argument is near unity.
3636

3737
```javascript
38-
var PI = require( '@stdlib/constants/float64/pi' );
38+
var PI = require( '@stdlib/constants/float32/pi' );
3939

4040
var v = cosm1f( 0.0 );
4141
// returns 0.0
@@ -63,11 +63,11 @@ v = cosm1f( NaN );
6363
```javascript
6464
var uniform = require( '@stdlib/random/array/uniform' );
6565
var logEachMap = require( '@stdlib/console/log-each-map' );
66-
var PI = require( '@stdlib/constants/float64/pi' );
66+
var PI = require( '@stdlib/constants/float32/pi' );
6767
var cosm1f = require( '@stdlib/math/base/special/cosm1f' );
6868

6969
var opts = {
70-
'dtype': 'float64'
70+
'dtype': 'float32'
7171
};
7272
var x = uniform( 100, 0.0, 2.0*PI, opts );
7373

@@ -104,24 +104,24 @@ logEachMap( 'cos(%0.4f) - 1 = %0.4f', x, cosm1f );
104104
#include "stdlib/math/base/special/cosm1f.h"
105105
```
106106

107-
#### stdlib_base_cosm1( x )
107+
#### stdlib_base_cosm1f( x )
108108

109-
Computes `cos(x) - 1`, where `cos` is the [cosine][@stdlib/math/base/special/cos] of a `number` (in radians). This function should be used instead of manually calculating `cos(x) - 1` when the argument is near unity.
109+
Computes `cos(x) - 1`, where `cos` is the [cosine][cosine] of a single-precision floating-point number (in radians). This function should be used instead of manually calculating `cos(x) - 1` when the argument is near unity.
110110

111111
```c
112-
double out = stdlib_base_cosm1( 0.0 );
113-
// returns 0.0
112+
float out = stdlib_base_cosm1f( 0.0f );
113+
// returns 0.0f
114114

115-
out = stdlib_base_cosm1( 3.141592653589793238 / 4.0 );
116-
// returns ~-0.293
115+
out = stdlib_base_cosm1f( 3.141592653589793238f / 4.0f );
116+
// returns ~-0.293f
117117
```
118118

119119
The function accepts the following arguments:
120120

121-
- **x**: `[in] double` input value.
121+
- **x**: `[in] float` input value.
122122

123123
```c
124-
double stdlib_base_cosm1( const double x );
124+
float stdlib_base_cosm1f( const float x );
125125
```
126126
127127
</section>
@@ -147,13 +147,13 @@ double stdlib_base_cosm1( const double x );
147147
#include <stdio.h>
148148
149149
int main( void ) {
150-
const double x[] = { 0.0, 0.523, 0.785, 1.047, 3.14 };
150+
const float x[] = { 0.0f, 0.523f, 0.785f, 1.047f, 3.14f };
151151
152-
double y;
152+
float y;
153153
int i;
154154
for ( i = 0; i < 5; i++ ) {
155-
y = stdlib_base_cosm1( x[ i ] );
156-
printf( "cosm1f(%lf) = %lf\n", x[ i ], y );
155+
y = stdlib_base_cosm1f( x[ i ] );
156+
printf( "cosm1f(%f) = %f\n", x[ i ], y );
157157
}
158158
}
159159
```
@@ -170,12 +170,6 @@ int main( void ) {
170170

171171
<section class="related">
172172

173-
* * *
174-
175-
## See Also
176-
177-
- <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>
178-
179173
</section>
180174

181175
<!-- /.related -->
@@ -184,9 +178,9 @@ int main( void ) {
184178

185179
<section class="links">
186180

187-
<!-- <related-links> -->
181+
[cosine]: https://en.wikipedia.org/wiki/Cosine
188182

189-
[@stdlib/math/base/special/cos]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/cos
183+
<!-- <related-links> -->
190184

191185
<!-- </related-links> -->
192186

lib/node_modules/@stdlib/math/base/special/cosm1f/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 cosm1 = require( './../lib' );
27+
var cosm1f = 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, -2.0, 2.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 = cosm1( x[ i%x.length ] );
42-
if ( isnan( y ) ) {
43+
y = cosm1f( 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/cosm1f/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 cosm1 = tryRequire( resolve( __dirname, './../lib/native.js' ) );
33+
var cosm1f = tryRequire( resolve( __dirname, './../lib/native.js' ) );
3434
var opts = {
35-
'skip': ( cosm1 instanceof Error )
35+
'skip': ( cosm1f 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, -2.0, 2.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 = cosm1( x[ i%x.length ] );
51-
if ( isnan( y ) ) {
52+
y = cosm1f( 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/cosm1f/benchmark/c/cephes/Makefile

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)