Skip to content

Commit e60279a

Browse files
fix: update according to code review
Co-authored-by: Athan <kgryte@gmail.com> Signed-off-by: Nakul Krishnakumar <nakulkrishnakumar86@gmail.com>
1 parent c3c6734 commit e60279a

11 files changed

Lines changed: 23 additions & 23 deletions

File tree

lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function main() {
103103
for ( j = min; j <= max; j++ ) {
104104
len = pow( 10, i );
105105
f = createBenchmark( len, p[ i ] );
106-
bench( format( '%s:len=%d:p=%.2f', pkg, len, p[ i ] ), f );
106+
bench( format( '%s:len=%d,p=%.2f', pkg, len, p[ i ] ), f );
107107
}
108108
}
109109
}

lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/benchmark.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function main() {
108108
for ( j = min; j <= max; j++ ) {
109109
len = pow( 10, i );
110110
f = createBenchmark( len, p[ i ] );
111-
bench( format( '%s::native:len=%d:p=%.2f', pkg, len, p[ i ] ), opts, f );
111+
bench( format( '%s::native:len=%d,p=%.2f', pkg, len, p[ i ] ), opts, f );
112112
}
113113
}
114114
}

lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/benchmark.ndarray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function main() {
103103
for ( j = min; j <= max; j++ ) {
104104
len = pow( 10, i );
105105
f = createBenchmark( len, p[ i ] );
106-
bench( format( '%s:ndarray:len=%d:p=%.2f', pkg, len, p[ i ] ), f );
106+
bench( format( '%s:ndarray:len=%d,p=%.2f', pkg, len, p[ i ] ), f );
107107
}
108108
}
109109
}

lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/benchmark.ndarray.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function main() {
108108
for ( j = min; j <= max; j++ ) {
109109
len = pow( 10, i );
110110
f = createBenchmark( len, p[ i ] );
111-
bench( format( '%s::native:ndarray:len=%d:p=%.2f', pkg, len, p[ i ] ), opts, f );
111+
bench( format( '%s::native:ndarray:len=%d,p=%.2f', pkg, len, p[ i ] ), opts, f );
112112
}
113113
}
114114
}

lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/c/benchmark.length.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static double random_uniform( const double min, const double max ) {
9494
*
9595
* @param iterations number of iterations
9696
* @param len array length
97-
* @param p power
97+
* @param p power
9898
* @return elapsed time in seconds
9999
*/
100100
static double benchmark1( int iterations, int len, double p ) {
@@ -134,7 +134,7 @@ static double benchmark1( int iterations, int len, double p ) {
134134
*
135135
* @param iterations number of iterations
136136
* @param len array length
137-
* @param p power
137+
* @param p power
138138
* @return elapsed time in seconds
139139
*/
140140
static double benchmark2( int iterations, int len, double p ) {
@@ -194,14 +194,14 @@ int main( void ) {
194194
for ( p = 0; p < 4; p++ ) {
195195
for ( j = 0; j < REPEATS; j++ ) {
196196
count += 1;
197-
printf( "# c::%s:len=%d:p=%.2f\n", NAME, len, powers[ p ] );
197+
printf( "# c::%s:len=%d,p=%.2f\n", NAME, len, powers[ p ] );
198198
elapsed = benchmark1( iter, len, powers[ p ] );
199199
print_results( iter, elapsed );
200200
printf( "ok %d benchmark finished\n", count );
201201
}
202202
for ( j = 0; j < REPEATS; j++ ) {
203203
count += 1;
204-
printf( "# c::%s:ndarray:len=%d:p=%.2f\n", NAME, len, powers[ p ] );
204+
printf( "# c::%s:ndarray:len=%d,p=%.2f\n", NAME, len, powers[ p ] );
205205
elapsed = benchmark2( iter, len, powers[ p ] );
206206
print_results( iter, elapsed );
207207
printf( "ok %d benchmark finished\n", count );

lib/node_modules/@stdlib/stats/strided/distances/dminkowski/docs/types/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ import dminkowski = require( './index' );
246246
dminkowski.ndarray( x.length, 3, x, 1, 0, y, ( x: number ): number => x, 0 ); // $ExpectError
247247
}
248248

249-
// The compiler throws an error if the `ndarray` method is provided a eighth argument which is not a number...
249+
// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number...
250250
{
251251
const x = new Float64Array( 10 );
252252
const y = new Float64Array( 10 );

lib/node_modules/@stdlib/stats/strided/distances/dminkowski/examples/c/example.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ int main( void ) {
2727
// Specify the number of elements:
2828
const int N = 8;
2929

30-
// Specify strides:
30+
// Specify the order of the Minkowski norm:
3131
const double p = 3.0;
32+
33+
// Specify strides:
3234
const int strideX = 1;
3335
const int strideY = -1;
3436

lib/node_modules/@stdlib/stats/strided/distances/dminkowski/lib/dminkowski.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var ndarray = require( './ndarray.js' );
3030
* Computes the Minkowski distance between two double-precision floating-point strided arrays.
3131
*
3232
* @param {NonNegativeInteger} N - number of indexed elements
33-
* @param {PositiveInteger} p - order of the Minkowski norm
33+
* @param {number} p - order of the Minkowski norm
3434
* @param {Float64Array} x - first input array
3535
* @param {integer} strideX - stride length of `x`
3636
* @param {Float64Array} y - second input array

lib/node_modules/@stdlib/stats/strided/distances/dminkowski/lib/dminkowski.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var addon = require( './../src/addon.node' );
2929
* Computes the Minkowski distance between two double-precision floating-point strided arrays.
3030
*
3131
* @param {NonNegativeInteger} N - number of indexed elements
32-
* @param {PositiveInteger} p - order of the Minkowski norm
32+
* @param {number} p - order of the Minkowski norm
3333
* @param {Float64Array} x - first input array
3434
* @param {integer} strideX - stride length of `x`
3535
* @param {Float64Array} y - second input array

lib/node_modules/@stdlib/stats/strided/distances/dminkowski/lib/ndarray.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var pow = require( '@stdlib/math/base/special/pow' );
2525
var dcityblock = require( '@stdlib/stats/strided/distances/dcityblock' ).ndarray;
2626
var deuclidean = require( '@stdlib/stats/strided/distances/deuclidean' ).ndarray;
2727
var dchebyshev = require( '@stdlib/stats/strided/distances/dchebyshev' ).ndarray;
28+
var PINF = require( '@stdlib/constants/float64/pinf' );
2829

2930

3031
// MAIN //
@@ -33,7 +34,7 @@ var dchebyshev = require( '@stdlib/stats/strided/distances/dchebyshev' ).ndarray
3334
* Computes the Minkowski distance between two double-precision floating-point strided arrays using alternative indexing semantics.
3435
*
3536
* @param {NonNegativeInteger} N - number of indexed elements
36-
* @param {PositiveInteger} p - order of the Minkowski norm
37+
* @param {number} p - order of the Minkowski norm
3738
* @param {Float64Array} x - first input array
3839
* @param {integer} strideX - stride length of `x`
3940
* @param {NonNegativeInteger} offsetX - starting index for `x`
@@ -61,29 +62,26 @@ function dminkowski( N, p, x, strideX, offsetX, y, strideY, offsetY ) {
6162
if ( N <= 0 ) {
6263
return NaN;
6364
}
64-
if ( p === 1 ) {
65+
if ( p === 1.0 ) {
6566
return dcityblock( N, x, strideX, offsetX, y, strideY, offsetY );
6667
}
67-
if ( p === 2 ) {
68+
if ( p === 2.0 ) {
6869
return deuclidean( N, x, strideX, offsetX, y, strideY, offsetY );
6970
}
70-
if ( p === Infinity ) {
71+
if ( p === PINF ) {
7172
return dchebyshev( N, x, strideX, offsetX, y, strideY, offsetY );
7273
}
7374
ox = offsetX;
7475
oy = offsetY;
7576

76-
s = abs( x[ ox ] - y[ oy ] );
77-
d = pow( s, p );
78-
ox += strideX;
79-
oy += strideY;
80-
for ( i = 1; i < N; i++ ) {
77+
d = 0.0;
78+
for ( i = 0; i < N; i++ ) {
8179
s = abs( x[ ox ] - y[ oy ] );
8280
d += pow( s, p );
8381
ox += strideX;
8482
oy += strideY;
8583
}
86-
return pow( d, 1/p );
84+
return pow( d, 1.0/p );
8785
}
8886

8987

0 commit comments

Comments
 (0)