Skip to content

Commit

Permalink
feat!: fix function name and update docs
Browse files Browse the repository at this point in the history
BREAKING CHANGE: update C API name

This commit changes the name of the C API from `stdlib_base_j1` to `stdlib_base_besselj1`. This ensures that the C function name more closely matches the global namespace name and helps protect against future naming collisions. To migrate, users should update their call signatures accordingly.

PR-URL: stdlib-js#2777
Ref: stdlib-js@18bd1b5#r145258015
Ref: stdlib-js@18bd1b5#r145258035
Reviewed-by: Athan Reines <[email protected]>
  • Loading branch information
gunjjoshi authored Aug 12, 2024
1 parent 09afa7c commit 0ae49fb
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
16 changes: 8 additions & 8 deletions lib/node_modules/@stdlib/math/base/special/besselj1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@ for ( i = 0; i < 100; i++ ) {
### Usage

```c
#include "stdlib/math/base/special/j1.h"
#include "stdlib/math/base/special/besselj1.h"
```

#### stdlib_base_j1( x )
#### stdlib_base_besselj1( x )

Computes the [Bessel function of the first kind][bessel-first-kind] of order one at `x`.

```c
double out = stdlib_base_j1( 0.0 );
double out = stdlib_base_besselj1( 0.0 );
// returns 0.0

out = stdlib_base_j1( 1.0 );
out = stdlib_base_besselj1( 1.0 );
// returns ~0.440
```

Expand All @@ -142,7 +142,7 @@ The function accepts the following arguments:
- **x**: `[in] double` input value.

```c
double stdlib_base_j1( const double x );
double stdlib_base_besselj1( const double x );
```
</section>
Expand All @@ -164,7 +164,7 @@ double stdlib_base_j1( const double x );
### Examples
```c
#include "stdlib/math/base/special/j1.h"
#include "stdlib/math/base/special/besselj1.h"
#include <stdio.h>
int main( void ) {
Expand All @@ -173,8 +173,8 @@ int main( void ) {
int i;
for ( i = 0; i < 7; i++ ) {
v = stdlib_base_j1( x[ i ] );
printf( "j1(%lf) = %lf\n", x[ i ], v );
v = stdlib_base_besselj1( x[ i ] );
printf( "besselj1(%lf) = %lf\n", x[ i ], v );
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

#include "stdlib/math/base/special/j1.h"
#include "stdlib/math/base/special/besselj1.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
Expand Down Expand Up @@ -99,7 +99,7 @@ static double benchmark( void ) {
t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 100000.0 * rand_double() ) - 0.0;
y = stdlib_base_j1( x );
y = stdlib_base_besselj1( x );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

#include "stdlib/math/base/special/j1.h"
#include "stdlib/math/base/special/besselj1.h"
#include <stdio.h>

int main( void ) {
Expand All @@ -25,7 +25,7 @@ int main( void ) {
int i;

for ( i = 0; i < 7; i++ ) {
v = stdlib_base_j1( x[ i ] );
printf( "j1(%lf) = %lf\n", x[ i ], v );
v = stdlib_base_besselj1( x[ i ] );
printf( "besselj1(%lf) = %lf\n", x[ i ], v );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* limitations under the License.
*/

#ifndef STDLIB_MATH_BASE_SPECIAL_J1_H
#define STDLIB_MATH_BASE_SPECIAL_J1_H
#ifndef STDLIB_MATH_BASE_SPECIAL_BESSELJ1_H
#define STDLIB_MATH_BASE_SPECIAL_BESSELJ1_H

/*
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
Expand All @@ -29,10 +29,10 @@ extern "C" {
/**
* Computes the Bessel function of the first kind of order one.
*/
double stdlib_base_j1( const double x );
double stdlib_base_besselj1( const double x );

#ifdef __cplusplus
}
#endif

#endif // !STDLIB_MATH_BASE_SPECIAL_J1_H
#endif // !STDLIB_MATH_BASE_SPECIAL_BESSELJ1_H
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* ## Notice
*
* The original C++ code and copyright notice are from the [Boost library]{@link https://github.com/boostorg/math/blob/develop/include/boost/math/special_functions/detail/bessel_j1.hpp}. The implementation has been modified for JavaScript.
* The original C++ code and copyright notice are from the [Boost library]{@link https://www.boost.org/doc/libs/1_85_0/boost/math/special_functions/detail/bessel_j1.hpp}. The implementation has been modified for JavaScript.
*
* ```text
* Copyright Xiaogang Zhang, 2006.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* limitations under the License.
*/

#include "stdlib/math/base/special/j1.h"
#include "stdlib/math/base/special/besselj1.h"
#include "stdlib/math/base/napi/unary.h"

// cppcheck-suppress shadowFunction
STDLIB_MATH_BASE_NAPI_MODULE_D_D( stdlib_base_j1 )
STDLIB_MATH_BASE_NAPI_MODULE_D_D( stdlib_base_besselj1 )
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* ## Notice
*
* The original C++ code and copyright notice are from the [Boost library]{@link https://github.com/boostorg/math/blob/develop/include/boost/math/special_functions/detail/bessel_j1.hpp}. The implementation has been modified for use in stdlib.
* The original C++ code and copyright notice are from the [Boost library]{@link https://www.boost.org/doc/libs/1_85_0/boost/math/special_functions/detail/bessel_j1.hpp}. The implementation has been modified for use in stdlib.
*
* ```text
* Copyright Xiaogang Zhang, 2006.
Expand All @@ -29,7 +29,7 @@
* ```
*/

#include "stdlib/math/base/special/j1.h"
#include "stdlib/math/base/special/besselj1.h"
#include "stdlib/math/base/special/sqrt.h"
#include "stdlib/math/base/special/abs.h"
#include "stdlib/math/base/special/sincos.h"
Expand Down Expand Up @@ -222,10 +222,10 @@ static double rational_psqs( const double x ) {
* @return evaluated Bessel function
*
* @example
* double out = stdlib_base_j1( 1.0 );
* double out = stdlib_base_besselj1( 1.0 );
* // returns ~0.440
*/
double stdlib_base_j1( const double x ) {
double stdlib_base_besselj1( const double x ) {
double value;
double rc;
double rs;
Expand Down

0 comments on commit 0ae49fb

Please sign in to comment.