Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Nov 17, 2024
1 parent 420bd1a commit a3e21d4
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 67 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<section class="release" id="unreleased">

## Unreleased (2024-11-11)
## Unreleased (2024-11-17)

<section class="features">

Expand All @@ -22,6 +22,7 @@

<details>

- [`163a3e7`](https://github.com/stdlib-js/stdlib/commit/163a3e7fa2c7429f88b2dd69df42572f9ff0af9d) - **refactor:** update benchmark, add `f` suffixes, missing spaces in `math/base/special/gcdf` [(#3121)](https://github.com/stdlib-js/stdlib/pull/3121) _(by Gunj Joshi, Athan Reines)_
- [`f8bcfd8`](https://github.com/stdlib-js/stdlib/commit/f8bcfd832483d46068c710b6854d5f97bcb778fd) - **feat:** add `math/base/special/gcdf` [(#2997)](https://github.com/stdlib-js/stdlib/pull/2997) _(by Aayush Khanna, Philipp Burckhardt)_

</details>
Expand All @@ -34,9 +35,11 @@

### Contributors

A total of 2 people contributed to this release. Thank you to the following contributors:
A total of 4 people contributed to this release. Thank you to the following contributors:

- Aayush Khanna
- Athan Reines
- Gunj Joshi
- Philipp Burckhardt

</section>
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Mohammad Kaif <98884589+Kaif987@users.noreply.github.com>
Momtchil Momtchev <momtchil@momtchev.com>
Muhammad Haris <harriskhan047@outlook.com>
Naresh Jagadeesan <naresh.naresh000@gmail.com>
Neeraj Pathak <neerajrpathak710@gmail.com>
NightKnight <Ahmedatwa866@yahoo.com>
Nithin Katta <88046362+nithinkatta@users.noreply.github.com>
Nourhan Hasan <109472010+TheNourhan@users.noreply.github.com>
Expand All @@ -69,6 +70,7 @@ Prajwal Kulkarni <prajwalkulkarni76@gmail.com>
Pranav Goswami <goswami.4@iitj.ac.in>
Praneki <97080887+PraneGIT@users.noreply.github.com>
Pratik <97464067+Pratik772846@users.noreply.github.com>
Pratyush Kumar Chouhan <pratyushkumar0308@gmail.com>
Priyansh <88396544+itsspriyansh@users.noreply.github.com>
Pushpendra Chandravanshi <pushpendrachandravanshi4@gmail.com>
RISHAV <115060907+rishav2404@users.noreply.github.com>
Expand All @@ -79,6 +81,7 @@ Ridam Garg <67867319+RidamGarg@users.noreply.github.com>
Robert Gislason <gztown2216@yahoo.com>
Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com>
Rutam <138517416+performant23@users.noreply.github.com>
Ruthwik Chikoti <145591715+ruthwikchikoti@users.noreply.github.com>
Ryan Seal <splrk@users.noreply.github.com>
Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com>
SarthakPaandey <145528240+SarthakPaandey@users.noreply.github.com>
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ limitations under the License.

[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->

> Compute the [greatest common divisor][gcd] (gcd) of two single-precision floating point numbers.
> Compute the [greatest common divisor][gcd] (gcd) of two single-precision floating-point numbers.
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

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

#### gcdf( a, b )

Computes the [greatest common divisor][gcd] (gcd).
Computes the [greatest common divisor][gcd] (gcd) of two single-precision floating-point numbers.

```javascript
var v = gcdf( 48, 18 );
Expand Down Expand Up @@ -172,7 +172,7 @@ for ( i = 0; i < a.length; i++ ) {

#### stdlib_base_gcdf( a, b )

Computes the greatest common divisor (gcd).
Computes the greatest common divisor (gcd) of two single-precision floating-point numbers.

```c
float v = stdlib_base_gcdf( 48.0f, 18.0f );
Expand Down
15 changes: 9 additions & 6 deletions benchmark/c/native/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,20 @@ static float rand_float( void ) {
*/
static double benchmark( void ) {
double elapsed;
float a;
float b;
float y;
float a[ 100 ];
float b[ 100 ];
double t;
float y;
int i;

for ( i = 0; i < 100; i++ ) {
a[ i ] = roundf( 500.0f * rand_float() );
b[ i ] = roundf( 500.0f * rand_float() );
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
a = round( 500.0f * rand_float() );
b = round( 500.0f * rand_float() );
y = stdlib_base_gcdf( a, b );
y = stdlib_base_gcdf( a[ i % 100 ], b[ i % 100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/repl.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

{{alias}}( a, b )
Computes the greatest common divisor (gcd) of two single-precision
floating point numbers.
floating-point numbers.

If both `a` and `b` are `0`, the function returns `0`.

Expand Down
2 changes: 1 addition & 1 deletion docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// TypeScript Version: 4.1

/**
* Computes the greatest common divisor (gcd) of two single-precision floating point numbers.
* Computes the greatest common divisor (gcd) of two single-precision floating-point numbers.
*
* ## Notes
*
Expand Down
2 changes: 1 addition & 1 deletion include/stdlib/math/base/special/gcdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C" {
#endif

/**
* Computes the greatest common divisor (gcd) of two single-precision floating point numbers.
* Computes the greatest common divisor (gcd) of two single-precision floating-point numbers.
*/
float stdlib_base_gcdf( const float a, const float b );

Expand Down
15 changes: 10 additions & 5 deletions lib/binary_gcd.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

/**
* Computes the greatest common divisor (gcd) of two single-precision floating point numbers using the binary GCD algorithm.
* Computes the greatest common divisor (gcd) of two single-precision floating-point numbers using the binary GCD algorithm.
*
* ## References
*
Expand All @@ -33,7 +33,7 @@
* @returns {integer} greatest common divisor
*
* @example
* var v = gcdf( 16777216.0, 65536.0 );
* var v = gcdf( 16777216, 65536 );
* // returns 65536
*/
function gcdf( a, b ) {
Expand All @@ -47,22 +47,26 @@ function gcdf( a, b ) {
if ( b === 0 ) {
return a;
}

// Reduce `a` and/or `b` to odd numbers and keep track of the greatest power of 2 dividing both `a` and `b`...
while ( a%2 === 0 && b%2 === 0 ) {
while ( a % 2 === 0 && b % 2 === 0 ) {
a /= 2; // right shift
b /= 2; // right shift
k *= 2; // left shift
}

// Reduce `a` to an odd number...
while ( a%2 === 0 ) {
while ( a % 2 === 0 ) {
a /= 2; // right shift
}

// Henceforth, `a` is always odd...
while ( b ) {
// Remove all factors of 2 in `b`, as they are not common...
while ( b%2 === 0 ) {
while ( b % 2 === 0 ) {
b /= 2; // right shift
}

// `a` and `b` are both odd. Swap values such that `b` is the larger of the two values, and then set `b` to the difference (which is even)...
if ( a > b ) {
t = b;
Expand All @@ -71,6 +75,7 @@ function gcdf( a, b ) {
}
b -= a; // b=0 iff b=a
}

// Restore common factors of 2...
return k * a;
}
Expand Down
13 changes: 9 additions & 4 deletions lib/bitwise_binary_gcd.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

/**
* Computes the greatest common divisor (gcd) of two single-precision floating point numbers using the binary GCD algorithm and bitwise operations.
* Computes the greatest common divisor (gcd) of two single-precision floating-point numbers using the binary GCD algorithm and bitwise operations.
*
* ## References
*
Expand Down Expand Up @@ -47,22 +47,26 @@ function gcdf( a, b ) {
if ( b === 0 ) {
return a;
}

// Reduce `a` and/or `b` to odd numbers and keep track of the greatest power of 2 dividing both `a` and `b`...
while ( (a & 1) === 0 && (b & 1) === 0 ) {
while ( ( a & 1 ) === 0 && ( b & 1 ) === 0 ) {
a >>>= 1; // right shift
b >>>= 1; // right shift
k += 1;
}

// Reduce `a` to an odd number...
while ( (a & 1) === 0 ) {
while ( ( a & 1 ) === 0 ) {
a >>>= 1; // right shift
}

// Henceforth, `a` is always odd...
while ( b ) {
// Remove all factors of 2 in `b`, as they are not common...
while ( (b & 1) === 0 ) {
while ( ( b & 1 ) === 0 ) {
b >>>= 1; // right shift
}

// `a` and `b` are both odd. Swap values such that `b` is the larger of the two values, and then set `b` to the difference (which is even)...
if ( a > b ) {
t = b;
Expand All @@ -71,6 +75,7 @@ function gcdf( a, b ) {
}
b -= a; // b=0 iff b=a
}

// Restore common factors of 2...
return a << k;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

/**
* Compute the greatest common divisor (gcd) of two single-precision floating point numbers.
* Compute the greatest common divisor (gcd) of two single-precision floating-point numbers.
*
* @module @stdlib/math-base-special-gcdf
*
Expand Down
2 changes: 1 addition & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var largeIntegersf = require( './binary_gcd.js' );
// MAIN //

/**
* Computes the greatest common divisor (gcd) of two single-precision floating point numbers.
* Computes the greatest common divisor (gcd) of two single-precision floating-point numbers.
*
* @param {integer} a - first number
* @param {integer} b - second number
Expand Down
2 changes: 1 addition & 1 deletion lib/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' );
// MAIN //

/**
* Computes the greatest common divisor (gcd) of two single-precision floating point numbers.
* Computes the greatest common divisor (gcd) of two single-precision floating-point numbers.
*
* @private
* @param {number} a - first number
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@stdlib/math-base-special-gcdf",
"version": "0.0.0",
"description": "Compute the greatest common divisor (gcd).",
"description": "Compute the greatest common divisor (gcd) of two single-precision floating-point numbers.",
"license": "Apache-2.0",
"author": {
"name": "The Stdlib Authors",
Expand Down Expand Up @@ -97,7 +97,7 @@
"scaffold": {
"$schema": "math/base@v1.0",
"base_alias": "gcd",
"alias": "gcd",
"alias": "gcdf",
"pkg_desc": "compute the greatest common divisor (gcd)",
"desc": "computes the greatest common divisor (gcd)",
"short_desc": "greatest common divisor (gcd)",
Expand All @@ -108,8 +108,8 @@
"type": {
"javascript": "integer",
"jsdoc": "integer",
"c": "double",
"dtype": "float64"
"c": "float",
"dtype": "float32"
},
"domain": [
{
Expand Down Expand Up @@ -153,8 +153,8 @@
"type": {
"javascript": "integer",
"jsdoc": "integer",
"c": "double",
"dtype": "float64"
"c": "float",
"dtype": "float32"
},
"domain": [
{
Expand Down Expand Up @@ -198,8 +198,8 @@
"type": {
"javascript": "number",
"jsdoc": "number",
"c": "double",
"dtype": "float64"
"c": "float",
"dtype": "float32"
}
},
"keywords": [
Expand Down
Loading

0 comments on commit a3e21d4

Please sign in to comment.