Skip to content

feat: add math/base/special/logitf #3367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
084c777
feat(math): add math/base/special/logitf
vivekmaurya001 Dec 7, 2024
fba8f2c
Merge branch 'logitf' of https://github.com/vivekmaurya001/stdlib int…
vivekmaurya001 Dec 7, 2024
92cc9c6
chore: update copyright years
stdlib-bot Dec 7, 2024
33ea60a
Merge branch 'stdlib-js:develop' into logitf
vivekmaurya001 Jan 18, 2025
501ef98
add math/base/special/logitf
vivekmaurya001 Jan 18, 2025
2e3dce0
chore: update copyright years
stdlib-bot Jan 18, 2025
1b0a660
add math/base/special/logitf
vivekmaurya001 Jan 18, 2025
30fe769
Merge branch 'logitf' of https://github.com/vivekmaurya001/stdlib int…
vivekmaurya001 Jan 18, 2025
5a0da6c
add math/base/special/logitf
vivekmaurya001 Jan 18, 2025
b600358
add math/base/special/logitf
vivekmaurya001 Jan 18, 2025
41a7874
Apply suggestions from code review
gunjjoshi Mar 7, 2025
4348720
Update lib/node_modules/@stdlib/math/base/special/logitf/docs/types/i…
gunjjoshi Mar 7, 2025
d4d2a4a
Merge branch 'stdlib-js:develop' into logitf
vivekmaurya001 Mar 7, 2025
04761f2
Merge branch 'stdlib-js:develop' into logitf
vivekmaurya001 Mar 8, 2025
7049e2f
feat: add math/base/special/logitf
vivekmaurya001 Mar 8, 2025
3327eed
chore: update copyright years
stdlib-bot Mar 8, 2025
a975a76
Merge remote-tracking branch 'upstream/develop' into logitf
stdlib-bot Apr 17, 2025
ae813a0
chore: clean-up
anandkaranubc Apr 17, 2025
abbfe91
docs: fix function descriptions
anandkaranubc Apr 17, 2025
cb908ea
bench: follow code conventions and fix function return types
anandkaranubc Apr 17, 2025
5c8a985
docs: replace manual for loop in examples
anandkaranubc Apr 17, 2025
ff84d08
chore: re-enable lint rule
anandkaranubc Apr 17, 2025
4d5d7aa
fix: use float64ToFloat32 to avoid elevated precision
anandkaranubc Apr 17, 2025
dc07f16
test: replace equal with strictEqual
anandkaranubc Apr 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Signed-off-by: Gunj Joshi <gunjjoshi8372@gmail.com>
  • Loading branch information
gunjjoshi authored Mar 7, 2025
commit 41a7874b74ee3e7f52136a9ddba93812cc75e42f
20 changes: 10 additions & 10 deletions lib/node_modules/@stdlib/math/base/special/logitf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.

# logitf

> Compute the [logit][logit] function for single precision-floating point number.
> Compute the [logit][logit] function for a single-precision floating-point number.

<section class="intro">

Expand Down Expand Up @@ -55,7 +55,7 @@ var logitf = require( '@stdlib/math/base/special/logitf' );

#### logitf( p )

Computes the [logit][logit] function for single precision-floating point number.
Computes the [logit][logit] function for a single-precision floating-point number.

```javascript
var v = logitf( 0.2 );
Expand Down Expand Up @@ -93,11 +93,11 @@ var len = 100;
var opts = {
'dtype': 'float32'
};
var p = uniform( len, 0, 1, opts );
var p = uniform( len, 0.0, 1.0, opts );
var i;

for ( i = 0; i < 100; i++ ) {
console.log( 'logitf(%f) = %f', p[ i ], logitf( p[ i ] ) );
console.log( 'logitf(%d) = %d', p[ i ], logitf( p[ i ] ) );
}
```

Expand Down Expand Up @@ -133,14 +133,14 @@ for ( i = 0; i < 100; i++ ) {

#### stdlib_base_logitf( p )

Computes the [logit][logit] function for single precision-floating point number.
Computes the [logit][logit] function for a single-precision floating-point number.

```c
float out = stdlib_base_logitf( 0.2 );
// returns ~-1.386
float out = stdlib_base_logitf( 0.2f );
// returns ~-1.386f

out = stdlib_base_logitf( 0.9 );
// returns ~2.197
out = stdlib_base_logitf( 0.9f );
// returns ~2.197f
```

The function accepts the following arguments:
Expand Down Expand Up @@ -180,7 +180,7 @@ int main( void ) {
int i;

for ( i = 0; i < 100; i++ ) {
x = ( float )rand() / ( float )RAND_MAX;
x = (float)rand() / (float)RAND_MAX;
v = stdlib_base_logitf( x );
printf( "logitf(%f) = %f\n", x, v );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bench( pkg, function benchmark( b ) {
};

len = 100;
x = uniform( len, 0, 1, opts );
x = uniform( len, 0.0, 1.0, opts );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
};

len = 100;
x = uniform( len, 0, 1, opts );
x = uniform( len, 0.0, 1.0, opts );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <time.h>
#include <sys/time.h>

#define NAME "logit"
#define NAME "logitf"
#define ITERATIONS 1000000
#define REPEATS 3

Expand Down Expand Up @@ -78,13 +78,13 @@ static double tic( void ) {
*
* @return random number
*/
static double rand_double( void ) {
static float rand_float( void ) {
int r = rand();
return (double)r / ( (double)RAND_MAX + 1.0 );
return (float)r / ( (float)RAND_MAX + 1.0f );
}

/**
* Evaluates the logit function.
* Computes the logit function for a single-precision floating-point number.
*
* @param x input value
* @return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ static float rand_float( void ) {
static double benchmark( void ) {
double elapsed;
float x[ 100 ];
float y;
double t;
float y;
int i;

for ( i = 0; i < 100; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

{{alias}}( p )
Evaluates the logit function for single precision-floating point number.
Evaluates the logit function for a single-precision floating-point number.

Let `p` be the probability of some event. The logit function is defined as
the logarithm of the odds `p / (1-p)`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ var len = 100;
var opts = {
'dtype': 'float32'
};
var p = uniform( len, 0, 1, opts );
var p = uniform( len, 0.0, 1.0, opts );
var i;

for ( i = 0; i < 100; i++ ) {
console.log( 'logitf(%f) = %f', p[ i ], logitf( p[ i ] ) );
console.log( 'logitf(%d) = %d', p[ i ], logitf( p[ i ] ) );
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C" {
#endif

/**
* Evaluates the logit function for single precision-floating point number.
* Evaluates the logit function for a single-precision floating-point number.
*/
float stdlib_base_logitf( const float p );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

/**
* Evaluate the logit function for single precision-floating point number.
* Evaluate the logit function for single-precision floating-point number.
*
* @module @stdlib/math/base/special/logitf
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var NINF = require( '@stdlib/constants/float32/ninf' );
// MAIN //

/**
* Evaluates the logit function for single precision-floating point number.
* Evaluates the logit function for a single-precision floating-point number.
*
* @param {Probability} p - input value
* @returns {number} function value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' );
// MAIN //

/**
* Evaluates the logit function for single precision-floating point number.
* Evaluates the logit function for a single-precision floating-point number.
*
* @private
* @param {Probability} p - input value
Expand Down
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/math/base/special/logitf/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
#include "stdlib/constants/float32/ninf.h"

/**
* Evaluates the logit function for single precision-floating point number.
* Evaluates the logit function for a single-precision floating-point number.
*
* @param x input value
* @return output value
* @return output value
*
* @example
* float out = stdlib_base_logitf( 0.2 );
* // returns ~-1.386
* float out = stdlib_base_logitf( 0.2f );
* // returns ~-1.386f
*/
float stdlib_base_logitf( const float p ) {
if ( stdlib_base_is_nanf( p ) ) {
Expand Down
Loading