@stdlib/math-base-special-powm1
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -1,6 +0,6 @@ | ||
"use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var n=f(function(m,a){ | ||
var u=require('@stdlib/math-base-assert-is-nan/dist'),t=require('@stdlib/math-base-special-abs/dist'),s=require('@stdlib/math-base-special-expm1/dist'),v=require('@stdlib/math-base-special-ln/dist'),q=require('@stdlib/math-base-special-pow/dist'),o=require('@stdlib/math-base-special-trunc/dist');function p(e,r){var i;if(u(e)||u(r))return NaN;if(r===0)return 0;if(e===0)return-1;if(e<0&&r%2===0&&(e=-e),e>0){if((t(r*(e-1))<.5||t(r)<.2)&&(i=v(e)*r,i<.5))return s(i)}else if(o(r)!==r)return NaN;return q(e,r)-1}a.exports=p | ||
});var c=n();module.exports=c; | ||
"use strict";var s=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var f=s(function(w,a){ | ||
var t=require('@stdlib/math-base-assert-is-nan/dist'),v=require('@stdlib/math-base-assert-is-infinite/dist'),n=require('@stdlib/math-base-special-abs/dist'),q=require('@stdlib/math-base-special-expm1/dist'),o=require('@stdlib/math-base-special-ln/dist'),p=require('@stdlib/math-base-special-pow/dist'),c=require('@stdlib/math-base-special-trunc/dist');function N(e,r){var i,u;if(t(e)||t(r))return NaN;if(r===0)return 0;if(e===0)return-1;if(e<0&&r%2===0&&(e=-e),e>0){if((n(r*(e-1))<.5||n(r)<.2)&&(u=o(e)*r,u<.5))return q(u)}else if(c(r)!==r)return NaN;return i=p(e,r)-1,v(i)||t(i)?NaN:i}a.exports=N | ||
});var l=f();module.exports=l; | ||
/** @license Apache-2.0 */ | ||
/** @license Apache-2.0 */ | ||
//# sourceMappingURL=index.js.map |
@@ -21,3 +21,3 @@ /** | ||
* | ||
* The original C++ code and copyright notice are from the [Boost library]{@link http://www.boost.org/doc/libs/1_60_0/boost/math/special_functions/powm1.hpp}. The implementation follows the original, but has been modified for JavaScript. | ||
* The original C++ code and copyright notice are from the [Boost library]{@link http://www.boost.org/doc/libs/1_85_0/boost/math/special_functions/powm1.hpp}. The implementation follows the original, but has been modified for JavaScript. | ||
* | ||
@@ -38,2 +38,3 @@ * ```text | ||
var isnan = require( '@stdlib/math-base-assert-is-nan' ); | ||
var isinfinite = require( '@stdlib/math-base-assert-is-infinite' ); | ||
var abs = require( '@stdlib/math-base-special-abs' ); | ||
@@ -88,2 +89,3 @@ var expm1 = require( '@stdlib/math-base-special-expm1' ); | ||
function powm1( b, x ) { | ||
var result; | ||
var y; | ||
@@ -123,3 +125,7 @@ if ( | ||
} | ||
return pow( b, x ) - 1.0; | ||
result = pow( b, x ) - 1.0; | ||
if ( isinfinite( result ) || isnan( result ) ) { | ||
return 0.0 / 0.0; // NaN | ||
} | ||
return result; | ||
} | ||
@@ -126,0 +132,0 @@ |
{ | ||
"name": "@stdlib/math-base-special-powm1", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Evaluate bˣ - 1.", | ||
@@ -33,8 +33,12 @@ "license": "Apache-2.0 AND BSL-1.0", | ||
"dependencies": { | ||
"@stdlib/math-base-assert-is-nan": "^0.2.1", | ||
"@stdlib/math-base-special-abs": "^0.2.1", | ||
"@stdlib/math-base-special-expm1": "^0.2.1", | ||
"@stdlib/math-base-special-ln": "^0.2.1", | ||
"@stdlib/math-base-special-pow": "^0.2.1", | ||
"@stdlib/math-base-special-trunc": "^0.2.1" | ||
"@stdlib/math-base-assert-is-infinite": "^0.2.2", | ||
"@stdlib/math-base-assert-is-nan": "^0.2.2", | ||
"@stdlib/math-base-napi-binary": "^0.3.0", | ||
"@stdlib/math-base-special-abs": "^0.2.2", | ||
"@stdlib/math-base-special-expm1": "^0.2.3", | ||
"@stdlib/math-base-special-fmod": "^0.1.0", | ||
"@stdlib/math-base-special-ln": "^0.2.4", | ||
"@stdlib/math-base-special-pow": "^0.3.0", | ||
"@stdlib/math-base-special-trunc": "^0.2.2", | ||
"@stdlib/utils-library-manifest": "^0.2.2" | ||
}, | ||
@@ -41,0 +45,0 @@ "devDependencies": {}, |
@@ -135,2 +135,95 @@ <!-- | ||
<!-- C interface documentation. --> | ||
* * * | ||
<section class="c"> | ||
## C APIs | ||
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> | ||
<section class="intro"> | ||
</section> | ||
<!-- /.intro --> | ||
<!-- C usage documentation. --> | ||
<section class="usage"> | ||
### Usage | ||
```c | ||
#include "stdlib/math/base/special/powm1.h" | ||
``` | ||
#### stdlib_base_powm1( base, exponent ) | ||
Evaluates `bˣ - 1`. | ||
```c | ||
double out = stdlib_base_powm1( 3.141592653589793, 5.0 ); | ||
// returns ~305.0197 | ||
out = stdlib_base_powm1( 4.0, 0.5 ); | ||
// returns 1.0 | ||
``` | ||
The function accepts the following arguments: | ||
- **base**: `[in] double` base. | ||
- **exponent**: `[in] double` exponent. | ||
```c | ||
double stdlib_base_powm1( const double base, const double exponent ); | ||
``` | ||
</section> | ||
<!-- /.usage --> | ||
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
<section class="notes"> | ||
</section> | ||
<!-- /.notes --> | ||
<!-- C API usage examples. --> | ||
<section class="examples"> | ||
### Examples | ||
```c | ||
#include "stdlib/math/base/special/powm1.h" | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
int main( void ) { | ||
double out; | ||
double b; | ||
double x; | ||
int i; | ||
for ( i = 0; i < 100; i++ ) { | ||
b = ( ( (double)rand() / (double)RAND_MAX ) * 10.0 ); | ||
x = ( ( (double)rand() / (double)RAND_MAX ) * 10.0 ) - 5.0; | ||
out = stdlib_base_powm1( b, x ); | ||
printf( "powm1(%lf, %lf) = %lf\n", b, x, out ); | ||
} | ||
} | ||
``` | ||
</section> | ||
<!-- /.examples --> | ||
</section> | ||
<!-- /.c --> | ||
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> | ||
@@ -184,4 +277,4 @@ | ||
[test-image]: https://github.com/stdlib-js/math-base-special-powm1/actions/workflows/test.yml/badge.svg?branch=v0.2.1 | ||
[test-url]: https://github.com/stdlib-js/math-base-special-powm1/actions/workflows/test.yml?query=branch:v0.2.1 | ||
[test-image]: https://github.com/stdlib-js/math-base-special-powm1/actions/workflows/test.yml/badge.svg?branch=v0.3.0 | ||
[test-url]: https://github.com/stdlib-js/math-base-special-powm1/actions/workflows/test.yml?query=branch:v0.3.0 | ||
@@ -188,0 +281,0 @@ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-special-powm1/main.svg |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
46570
17
410
316
10
+ Added@stdlib/constants-float64-min-base2-exponent@0.2.2(transitive)
+ Added@stdlib/math-base-assert-is-odd@0.3.0(transitive)
+ Added@stdlib/math-base-special-fmod@0.1.0(transitive)
+ Added@stdlib/math-base-special-pow@0.3.0(transitive)
- Removed@stdlib/math-base-assert-is-odd@0.2.1(transitive)
- Removed@stdlib/math-base-special-pow@0.2.1(transitive)