From e899eb4c208f40d6bc433556500cb2368a35523d Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 23 Jan 2023 09:34:24 +0530 Subject: [PATCH 01/15] update readme --- .../@stdlib/blas/base/sdsdot/README.md | 38 ++++++------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/README.md b/lib/node_modules/@stdlib/blas/base/sdsdot/README.md index fe8a4f966e9e..bdb16eb28f64 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/README.md +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2020 The Stdlib Authors. +Copyright (c) 2023 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -70,18 +70,15 @@ The function has the following parameters: - **y**: input [`Float32Array`][@stdlib/array/float32]. - **strideY**: index increment for `y`. -The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to calculate the dot product of every other value in `x` and the first `N` elements of `y` in reverse order, +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to calculate the dot product of every other value in `x` and the first `N` elements of `y` in reverse order, ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var y = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); -var N = floor( x.length / 2 ); - -var z = sdsdot( N, 0.0, x, 2, y, -1 ); +var z = sdsdot( 3, 0.0, x, 2, y, -1 ); // returns 9.0 ``` @@ -101,9 +98,7 @@ var y0 = new Float32Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // start at 4th element -var N = floor( x0.length / 2 ); - -var z = sdsdot( N, 0.0, x1, -2, y1, 1 ); +var z = sdsdot( 3, 0.0, x1, -2, y1, 1 ); // returns 128.0 ``` @@ -126,18 +121,15 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. - **offsetY**: starting index for `y`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offsetX` and `offsetY` parameters support indexing semantics based on starting indices. For example, to calculate the dot product of every other value in `x` starting from the second value with the last 3 elements in `y` in reverse order +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the offset parameters support indexing semantics based on starting indices. For example, to calculate the dot product of every other value in `x` starting from the second value with the last 3 elements in `y` in reverse order ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var y = new Float32Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -var N = floor( x.length / 2 ); - -var z = sdsdot.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ); +var z = sdsdot.ndarray( 3, 0.0, x, 2, 1, y, -1, y.length-1 ); // returns 128.0 ``` @@ -163,22 +155,14 @@ var z = sdsdot.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var sdsdot = require( '@stdlib/blas/base/sdsdot' ); -var x; -var y; -var i; - -x = new Float32Array( 10 ); -y = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu() * 100.0 ); - y[ i ] = round( randu() * 10.0 ); -} +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); console.log( x ); + +var y = filledarrayBy( x.length, 'float32', discreteUniform( 0, 10 ) ); console.log( y ); var z = sdsdot( x.length, 0.0, x, 1, y, -1 ); From ad854c3a669427c9f5d920c57eb1406b479a732e Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 23 Jan 2023 09:41:36 +0530 Subject: [PATCH 02/15] refactor src/ --- .../@stdlib/blas/base/sdsdot/src/addon.c | 54 ++++++ .../@stdlib/blas/base/sdsdot/src/addon.cpp | 166 ------------------ .../@stdlib/blas/base/sdsdot/src/sdsdot.c | 6 +- .../@stdlib/blas/base/sdsdot/src/sdsdot.f | 8 +- .../blas/base/sdsdot/src/sdsdot_cblas.c | 6 +- .../@stdlib/blas/base/sdsdot/src/sdsdot_f.c | 6 +- .../@stdlib/blas/base/sdsdot/src/sdsdotsub.f | 6 +- 7 files changed, 70 insertions(+), 182 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c delete mode 100644 lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.cpp diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c new file mode 100644 index 000000000000..8f14f80f5ec9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/sdsdot.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_double.h" +#include "stdlib/napi/argv_strided_float32array.h" +#include + + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + napi_status status; + + STDLIB_NAPI_ARGV( env, info, argv, argc, 6 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_DOUBLE( env, scalar, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 4 ); + + napi_value v; + status = napi_create_double( env, (double)c_sdsdot( N, (float)scalar, (float *)X, strideX, (float *)Y, strideY ), &v ); + assert( status == napi_ok ); + + return v; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.cpp b/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.cpp deleted file mode 100644 index 995a362e0cf2..000000000000 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/blas/base/sdsdot.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_base_sdsdot { - - /** - * Computes the dot product of two single-precision floating-point vectors with extended accumulation. - * - * ## Notes - * - * - When called from JavaScript, the function expects six arguments: - * - * - `N`: number of indexed elements - * - `scalar`: scalar constant to add to dot product - * - `X`: input array - * - `strideX`: `X` stride length - * - `Y`: destination array - * - `strideY`: `Y` stride length - */ - napi_value node_sdsdot( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 6; - napi_value argv[ 6 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 6 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 6 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a number." ); - return nullptr; - } - - bool res2; - status = napi_is_typedarray( env, argv[ 2 ], &res2 ); - assert( status == napi_ok ); - if ( res2 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype3; - status = napi_typeof( env, argv[ 3 ], &vtype3 ); - assert( status == napi_ok ); - if ( vtype3 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a number." ); - return nullptr; - } - - bool res4; - status = napi_is_typedarray( env, argv[ 4 ], &res4 ); - assert( status == napi_ok ); - if ( res4 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype5; - status = napi_typeof( env, argv[ 5 ], &vtype5 ); - assert( status == napi_ok ); - if ( vtype5 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Sixth argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - double scalar; - status = napi_get_value_double( env, argv[ 1 ], &scalar ); - assert( status == napi_ok ); - - int64_t strideX; - status = napi_get_value_int64( env, argv[ 3 ], &strideX ); - assert( status == napi_ok ); - - int64_t strideY; - status = napi_get_value_int64( env, argv[ 5 ], &strideY ); - assert( status == napi_ok ); - - napi_typedarray_type vtype2; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 2 ], &vtype2, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype2 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideX) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Third argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_typedarray_type vtype4; - size_t ylen; - void *Y; - status = napi_get_typedarray_info( env, argv[ 4 ], &vtype4, &ylen, &Y, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype4 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideY) >= (int64_t)ylen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Fifth argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_value v; - status = napi_create_double( env, (double)c_sdsdot( N, (float)scalar, (float *)X, strideX, (float *)Y, strideY ), &v ); - assert( status == napi_ok ); - - return v; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_sdsdot, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_base_sdsdot diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c index feff0991e0a8..d00477191e37 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,13 +26,13 @@ /** * Computes the dot product of two single-precision floating-point vectors with extended accumulation. * -* @param N number of values over which to compute the dot product +* @param N number of values * @param scalar scalar constant added to the dot product * @param X first array * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product of X and Y +* @returns output array */ float c_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY ) { double dot; diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.f b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.f index 5c97236df726..2f78de8b7130 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.f +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.f @@ -1,7 +1,7 @@ !> ! @license Apache-2.0 ! -! Copyright (c) 2020 The Stdlib Authors. +! Copyright (c) 2023 The Stdlib Authors. ! ! Licensed under the Apache License, Version 2.0 (the "License"); ! you may not use this file except in compliance with the License. @@ -60,13 +60,13 @@ ! > ! > * We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support. ! -! @param {integer} N - number of values over which to compute the dot product +! @param {integer} N - number of values ! @param {real} sb - scalar constant added to the dot product ! @param {Array} sx - first array ! @param {integer} strideX - `sx` stride length ! @param {Array} sy - second array ! @param {integer} strideY - `sy` stride length -! @returns {real} the dot product of `sx` and `sy` +! @returns {real} output array !< real function sdsdot( N, sb, sx, strideX, sy, strideY ) implicit none @@ -134,4 +134,4 @@ real function sdsdot( N, sb, sx, strideX, sy, strideY ) endif sdsdot = real( dtemp ) return -end function sdsdot \ No newline at end of file +end function sdsdot diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c index ffad84648be3..4e77ee699edb 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,13 +22,13 @@ /** * Computes the dot product of two single-precision floating-point vectors with extended accumulation. * -* @param N number of values over which to compute the dot product +* @param N number of values * @param scalar scalar constant added to the dot product * @param X first array * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product of X and Y +* @returns output array */ float c_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY ) { return cblas_sdsdot( N, scalar, X, strideX, Y, strideY ); diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c index 15fd5b99c894..23ce29273ee2 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,13 +29,13 @@ * * Arguments are passed by reference to a Fortran subroutine implementing `sdsdot`. * -* @param N number of values over which to compute the dot product +* @param N number of values * @param scalar scalar constant added to the dot product * @param X first array * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns the dot product of X and Y +* @returns output array */ float c_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY ) { float dot; diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f index de33074654d1..86169183128b 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f @@ -18,13 +18,13 @@ !> Wraps `sdsdot` as a subroutine. ! -! @param {integer} N - number of values over which to compute the dot product +! @param {integer} N - number of values ! @param {real} sb - scalar constant added to the dot product ! @param {Array} sx - first array ! @param {integer} strideX - `sx` stride length ! @param {Array} sy - second array ! @param {integer} strideY - `sy` stride length -! @param {real} dot - output variable reference +! @param {real} dot - output array !< subroutine sdsdotsub( N, sb, sx, strideX, sy, strideY, dot ) implicit none @@ -47,4 +47,4 @@ end function sdsdot ! Compute the dot product: dot = sdsdot( N, sb, sx, strideX, sy, strideY ) return -end subroutine sdsdotsub \ No newline at end of file +end subroutine sdsdotsub From 3c008f082a9366b3c214851d87cdfdc971921d22 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 23 Jan 2023 10:19:54 +0530 Subject: [PATCH 03/15] update include.gypi --- lib/node_modules/@stdlib/blas/base/sdsdot/include.gypi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/include.gypi b/lib/node_modules/@stdlib/blas/base/sdsdot/include.gypi index 22e6289c74db..f8b01bfb52cb 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/include.gypi +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2018 The Stdlib Authors. +# Copyright (c) 2023 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' Date: Mon, 23 Jan 2023 10:21:16 +0530 Subject: [PATCH 04/15] update manifest and package.json --- .../@stdlib/blas/base/sdsdot/manifest.json | 48 ++++++++++++++++--- .../@stdlib/blas/base/sdsdot/package.json | 5 +- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/manifest.json b/lib/node_modules/@stdlib/blas/base/sdsdot/manifest.json index cb5f9e296702..28fa220955a2 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/manifest.json @@ -39,7 +39,13 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-double" + ] }, { "os": "linux", @@ -55,7 +61,13 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-double" + ] }, { "os": "mac", @@ -70,7 +82,13 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-double" + ] }, { "os": "mac", @@ -85,7 +103,13 @@ "-lblas" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-double" + ] }, { "os": "mac", @@ -101,7 +125,13 @@ "-lpthread" ], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-double" + ] }, { "os": "win", @@ -114,7 +144,13 @@ ], "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-double" + ] } ] } diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/package.json b/lib/node_modules/@stdlib/blas/base/sdsdot/package.json index a20937e8a62a..a7915023dbfe 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/package.json +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/package.json @@ -79,5 +79,8 @@ "float32array", "extended", "precision" - ] + ], + "__stdlib__": { + "wasm": false + } } From 5e0e9f3acbe44c5cefba624f25eaf122ff330eba Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 23 Jan 2023 10:23:45 +0530 Subject: [PATCH 05/15] refactor lib/ --- .../@stdlib/blas/base/sdsdot/lib/ndarray.js | 6 ++--- .../blas/base/sdsdot/lib/ndarray.native.js | 24 +++++++++---------- .../@stdlib/blas/base/sdsdot/lib/sdsdot.js | 6 ++--- .../blas/base/sdsdot/lib/sdsdot.native.js | 6 ++--- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.js index 86f68b5813c9..2baa08946334 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ var M = 5; /** * Computes the dot product of two single-precision floating-point vectors with extended accumulation. * -* @param {integer} N - number of values over which to compute the dot product +* @param {integer} N - number of values * @param {number} scalar - scalar constant to add to dot product * @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length @@ -41,7 +41,7 @@ var M = 5; * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length * @param {NonNegativeInteger} offsetY - starting index for `y` -* @returns {number} dot product of `x` and `y` +* @returns {number} output array * * @example * var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.native.js index 4e53f1daf1e6..4869fc738eb1 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,8 @@ // MODULES // -var Float32Array = require( '@stdlib/array/float32' ); +var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); +var offsetView = require( '@stdlib/strided/base/offset-view' ); var addon = require( './sdsdot.native.js' ); @@ -29,7 +30,7 @@ var addon = require( './sdsdot.native.js' ); /** * Computes the dot product of two single-precision floating-point vectors with extended accumulation. * -* @param {integer} N - number of values over which to compute the dot product +* @param {integer} N - number of values * @param {number} scalar - scalar constant to add to dot product * @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length @@ -37,7 +38,7 @@ var addon = require( './sdsdot.native.js' ); * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length * @param {NonNegativeInteger} offsetY - starting index for `y` -* @returns {number} dot product of `x` and `y` +* @returns {number} output array * * @example * var Float32Array = require( '@stdlib/array/float32' ); @@ -51,14 +52,13 @@ var addon = require( './sdsdot.native.js' ); function sdsdot( N, scalar, x, strideX, offsetX, y, strideY, offsetY ) { var viewX; var viewY; - if ( strideX < 0 ) { - offsetX += (N-1) * strideX; - } - if ( strideY < 0 ) { - offsetY += (N-1) * strideY; - } - viewX = new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offsetX), x.length-offsetX ); // eslint-disable-line max-len - viewY = new Float32Array( y.buffer, y.byteOffset+(y.BYTES_PER_ELEMENT*offsetY), y.length-offsetY ); // eslint-disable-line max-len + + offsetX = minViewBufferIndex( N, strideX, offsetX ); + offsetY = minViewBufferIndex( N, strideY, offsetY ); + + viewX = offsetView( x, offsetX ); + viewY = offsetView( y, offsetY ); + return addon( N, scalar, viewX, strideX, viewY, strideY ); } diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.js b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.js index 3f95d9c61017..b37b680b09d9 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,13 +33,13 @@ var M = 5; /** * Computes the dot product of two single-precision floating-point vectors with extended accumulation. * -* @param {PositiveInteger} N - number of values over which to compute the dot product +* @param {PositiveInteger} N - number of values * @param {number} scalar - scalar constant to add to dot product * @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length -* @returns {number} dot product of `x` and `y` +* @returns {number} output array * * @example * var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.native.js b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.native.js index 386cb8945734..82f124b7460f 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.native.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,13 +28,13 @@ var addon = require( './../src/addon.node' ); /** * Computes the dot product of two single-precision floating-point vectors with extended accumulation. * -* @param {PositiveInteger} N - number of values over which to compute the dot product +* @param {PositiveInteger} N - number of values * @param {number} scalar - scalar constant to add to dot product * @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length -* @returns {number} dot product of `x` and `y` +* @returns {number} output array * * @example * var Float32Array = require( '@stdlib/array/float32' ); From ff1c7f2a279454a5ba299804ffa91bf534a6a30e Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 23 Jan 2023 10:25:29 +0530 Subject: [PATCH 06/15] refactor index.js --- .../blas/base/sdsdot/examples/index.js | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/examples/index.js b/lib/node_modules/@stdlib/blas/base/sdsdot/examples/index.js index ec4247262248..1467f690b392 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,23 +18,15 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); -var sdsdot = require( './../lib' ).ndarray; +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var sdsdot = require( '@stdlib/blas/base/sdsdot' ); -var x; -var y; -var i; - -x = new Float32Array( 10 ); -y = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); - y[ i ] = round( randu()*10.0 ); -} +var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); console.log( x ); + +var y = filledarrayBy( x.length, 'float32', discreteUniform( 0, 10 ) ); console.log( y ); -var dot = sdsdot( x.length, 0.0, x, 1, 0, y, -1, y.length-1 ); +var dot = sdsdot( x.length, 0.0, x, 1, y, -1 ); console.log( dot ); From 1f9ef34a8336a9b4e7b1df13ca5c3fca71f4817c Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 23 Jan 2023 10:39:19 +0530 Subject: [PATCH 07/15] refactor benchmark/ --- .../blas/base/sdsdot/benchmark/benchmark.js | 23 ++++++++----------- .../base/sdsdot/benchmark/benchmark.native.js | 19 +++++---------- .../sdsdot/benchmark/benchmark.ndarray.js | 23 ++++++++----------- .../benchmark/benchmark.ndarray.native.js | 19 +++++---------- 4 files changed, 32 insertions(+), 52 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.js index 75cebf81195b..e9d17a118198 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var sdsdot = require( './../lib/sdsdot.js' ); +// VARIABLES // + +var rand = uniform( -100.0, 100.0 ); + + // FUNCTIONS // /** @@ -39,16 +44,8 @@ var sdsdot = require( './../lib/sdsdot.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - y[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); + var y = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.native.js index d70aaa377ff1..0527a93d9603 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var sdsdot = tryRequire( resolve( __dirname, './../lib/sdsdot.native.js' ) ); var opts = { 'skip': ( sdsdot instanceof Error ) }; +var rand = uniform( -100.0, 100.0 ); // FUNCTIONS // @@ -48,16 +49,8 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - y[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); + var y = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.ndarray.js index 52a84b24fb24..a3015e89c4e6 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var sdsdot = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -100.0, 100.0 ); + + // FUNCTIONS // /** @@ -39,16 +44,8 @@ var sdsdot = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - y[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); + var y = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.ndarray.native.js index 5d4af456b36d..8d194eace8b2 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/benchmark/benchmark.ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var sdsdot = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( sdsdot instanceof Error ) }; +var rand = uniform( -100.0, 100.0 ); // FUNCTIONS // @@ -48,16 +49,8 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float32Array( len ); - y = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - y[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float32', rand ); + var y = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { From f27c2ca5ce7eb58e3a8a0cf391a12e9a536aeb3a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 23 Jan 2023 10:43:14 +0530 Subject: [PATCH 08/15] update docs --- .../@stdlib/blas/base/sdsdot/docs/repl.txt | 20 ++++++++----------- .../blas/base/sdsdot/docs/types/index.d.ts | 14 ++++++------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt index 8505b469dbeb..85f76c00b5ca 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt @@ -3,8 +3,8 @@ Computes the dot product of two single-precision floating-point vectors with extended accumulation. - The `N`, `strideX`, and `strideY` parameters determine which elements in `x` - and `y` are accessed at runtime. + The `N`, stride parameters determine which elements in the strided arrays + are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -34,7 +34,7 @@ Returns ------- dot: number - The dot product of `x` and `y`. + The dot product. Examples -------- @@ -47,8 +47,7 @@ // Strides: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > dot = {{alias}}( N, 0.0, x, 2, y, -1 ) + > dot = {{alias}}( 3, 0.0, x, 2, y, -1 ) 9.0 // Using view offsets: @@ -56,8 +55,7 @@ > y = new {{alias:@stdlib/array/float32}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x.buffer, x.BYTES_PER_ELEMENT*1 ); > var y1 = new {{alias:@stdlib/array/float32}}( y.buffer, y.BYTES_PER_ELEMENT*3 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > dot = {{alias}}( N, 0.0, x1, -2, y1, 1 ) + > dot = {{alias}}( 3, 0.0, x1, -2, y1, 1 ) 128.0 {{alias}}.ndarray( N, scalar, x, strideX, offsetX, y, strideY, offsetY ) @@ -97,7 +95,7 @@ Returns ------- dot: number - The dot product of `x` and `y`. + The dot product. Examples -------- @@ -110,15 +108,13 @@ // Strides: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > dot = {{alias}}.ndarray( N, 0.0, x, 2, 0, y, 2, 0 ) + > dot = {{alias}}.ndarray( 3, 0.0, x, 2, 0, y, 2, 0 ) 9.0 // Using offset indices: > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > y = new {{alias:@stdlib/array/float32}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - > N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > dot = {{alias}}.ndarray( N, 0.0, x, -2, x.length-1, y, 1, 3 ) + > dot = {{alias}}.ndarray( 3, 0.0, x, -2, x.length-1, y, 1, 3 ) 128.0 References diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/sdsdot/docs/types/index.d.ts index a88e8a975f6b..a38854fc6441 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2023 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,13 +25,13 @@ interface Routine { /** * Computes the dot product of two single-precision floating-point vectors with extended accumulation. * - * @param N - number of values over which to compute the dot product + * @param N - number of values * @param scalar - scalar constant added to dot product * @param x - first input array * @param strideX - `x` stride length * @param y - second input array * @param strideY - `y` stride length - * @returns dot product of `x` and `y` + * @returns dot product * * @example * var Float32Array = require( `@stdlib/array/float32` ); @@ -47,7 +47,7 @@ interface Routine { /** * Computes the dot product of two single-precision floating-point vectors using alternative indexing semantics and with extended accumulation. * - * @param N - number of values over which to compute the dot product + * @param N - number of values * @param scalar - scalar constant added to dot product * @param x - first input array * @param strideX - `x` stride length @@ -55,7 +55,7 @@ interface Routine { * @param y - second input array * @param strideY - `y` stride length * @param offsetY - starting index for `y` - * @returns dot product of `x` and `y` + * @returns dot product * * @example * var Float32Array = require( `@stdlib/array/float32` ); @@ -72,13 +72,13 @@ interface Routine { /** * Computes the dot product of two single-precision floating-point vectors with extended accumulation. * -* @param N - number of values over which to compute the dot product +* @param N - number of values * @param scalar - scalar constant added to dot product * @param x - first input array * @param strideX - `x` stride length * @param y - second input array * @param strideY - `y` stride length -* @returns dot product of `x` and `y` +* @returns dot product * * @example * var Float32Array = require( `@stdlib/array/float32` ); From eac632149bad1188d5a9160c8fe243fe2311319e Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 23 Jan 2023 10:44:49 +0530 Subject: [PATCH 09/15] change output array to dot product --- lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.js | 2 +- lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.native.js | 2 +- lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.js | 2 +- lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.native.js | 2 +- lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c | 2 +- lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.f | 2 +- lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c | 2 +- lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c | 2 +- lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.js index 2baa08946334..1466cfa5ec6b 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.js @@ -41,7 +41,7 @@ var M = 5; * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length * @param {NonNegativeInteger} offsetY - starting index for `y` -* @returns {number} output array +* @returns {number} dot product * * @example * var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.native.js index 4869fc738eb1..14c89a12c958 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/ndarray.native.js @@ -38,7 +38,7 @@ var addon = require( './sdsdot.native.js' ); * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length * @param {NonNegativeInteger} offsetY - starting index for `y` -* @returns {number} output array +* @returns {number} dot product * * @example * var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.js b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.js index b37b680b09d9..9f41b9f5052c 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.js @@ -39,7 +39,7 @@ var M = 5; * @param {integer} strideX - `x` stride length * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length -* @returns {number} output array +* @returns {number} dot product * * @example * var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.native.js b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.native.js index 82f124b7460f..09e230e4fd01 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.native.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/lib/sdsdot.native.js @@ -34,7 +34,7 @@ var addon = require( './../src/addon.node' ); * @param {integer} strideX - `x` stride length * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length -* @returns {number} output array +* @returns {number} dot product * * @example * var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c index d00477191e37..358c9e12edc4 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.c @@ -32,7 +32,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns output array +* @returns dot product */ float c_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY ) { double dot; diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.f b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.f index 2f78de8b7130..bfc197ea0555 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.f +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot.f @@ -66,7 +66,7 @@ ! @param {integer} strideX - `sx` stride length ! @param {Array} sy - second array ! @param {integer} strideY - `sy` stride length -! @returns {real} output array +! @returns {real} dot product !< real function sdsdot( N, sb, sx, strideX, sy, strideY ) implicit none diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c index 4e77ee699edb..62fcf288604f 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_cblas.c @@ -28,7 +28,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns output array +* @returns dot product */ float c_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY ) { return cblas_sdsdot( N, scalar, X, strideX, Y, strideY ); diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c index 23ce29273ee2..e2bccefeb228 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdot_f.c @@ -35,7 +35,7 @@ * @param strideX X stride length * @param Y second array * @param strideY Y stride length -* @returns output array +* @returns dot product */ float c_sdsdot( const int N, const float scalar, const float *X, const int strideX, const float *Y, const int strideY ) { float dot; diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f index 86169183128b..4bc283fbfb95 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f @@ -24,7 +24,7 @@ ! @param {integer} strideX - `sx` stride length ! @param {Array} sy - second array ! @param {integer} strideY - `sy` stride length -! @param {real} dot - output array +! @param {real} dot - dot product !< subroutine sdsdotsub( N, sb, sx, strideX, sy, strideY, dot ) implicit none From 8efd8412cd32819c5ea9c43a607d825bbb5b471f Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 23 Jan 2023 10:46:58 +0530 Subject: [PATCH 10/15] fix indenting in addon.c --- lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c index 8f14f80f5ec9..8d133269803d 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c @@ -38,17 +38,17 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 6 ); STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); - STDLIB_NAPI_ARGV_DOUBLE( env, scalar, argv, 1 ); + STDLIB_NAPI_ARGV_DOUBLE( env, scalar, argv, 1 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 4 ); - napi_value v; - status = napi_create_double( env, (double)c_sdsdot( N, (float)scalar, (float *)X, strideX, (float *)Y, strideY ), &v ); - assert( status == napi_ok ); + napi_value v; + status = napi_create_double( env, (double)c_sdsdot( N, (float)scalar, (float *)X, strideX, (float *)Y, strideY ), &v ); + assert( status == napi_ok ); - return v; + return v; } STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) From 03496782dd08f0cba15947fb6479567ecaced1b8 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 31 Jan 2023 02:08:32 -0800 Subject: [PATCH 11/15] Apply suggestions from code review --- lib/node_modules/@stdlib/blas/base/sdsdot/examples/index.js | 2 +- lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/examples/index.js b/lib/node_modules/@stdlib/blas/base/sdsdot/examples/index.js index 1467f690b392..202780c8682d 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/examples/index.js @@ -20,7 +20,7 @@ var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; var filledarrayBy = require( '@stdlib/array/filled-by' ); -var sdsdot = require( '@stdlib/blas/base/sdsdot' ); +var sdsdot = require( './../lib' ); var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) ); console.log( x ); diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f index 4bc283fbfb95..2f414c47af4f 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/sdsdotsub.f @@ -24,7 +24,7 @@ ! @param {integer} strideX - `sx` stride length ! @param {Array} sy - second array ! @param {integer} strideY - `sy` stride length -! @param {real} dot - dot product +! @param {real} dot - output variable reference !< subroutine sdsdotsub( N, sb, sx, strideX, sy, strideY, dot ) implicit none From d79f710f1793f50bd844ea522520be166d4ee807 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 31 Jan 2023 02:08:48 -0800 Subject: [PATCH 12/15] Fix grammar --- lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt index 85f76c00b5ca..7e39af3211d6 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt @@ -3,7 +3,7 @@ Computes the dot product of two single-precision floating-point vectors with extended accumulation. - The `N`, stride parameters determine which elements in the strided arrays + The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed From fe02500f1920def861151fc75cc0f460a6c09847 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sun, 26 Feb 2023 14:30:44 +0530 Subject: [PATCH 13/15] swap macro in addon.c and update manifest.json --- .../@stdlib/blas/base/sdsdot/manifest.json | 12 ++++++------ .../@stdlib/blas/base/sdsdot/src/addon.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/manifest.json b/lib/node_modules/@stdlib/blas/base/sdsdot/manifest.json index 28fa220955a2..eaf268dc4e0d 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/manifest.json @@ -44,7 +44,7 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-float" ] }, { @@ -66,7 +66,7 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-float" ] }, { @@ -87,7 +87,7 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-float" ] }, { @@ -108,7 +108,7 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-float" ] }, { @@ -130,7 +130,7 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-float" ] }, { @@ -149,7 +149,7 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-float" ] } ] diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c index 8d133269803d..3d8140dec3ce 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c @@ -20,7 +20,7 @@ #include "stdlib/napi/export.h" #include "stdlib/napi/argv.h" #include "stdlib/napi/argv_int64.h" -#include "stdlib/napi/argv_double.h" +#include "stdlib/napi/argv_float.h" #include "stdlib/napi/argv_strided_float32array.h" #include @@ -38,7 +38,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 6 ); STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); - STDLIB_NAPI_ARGV_DOUBLE( env, scalar, argv, 1 ); + STDLIB_NAPI_ARGV_FLOAT( env, scalar, argv, 1 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 ); From 0634779aa814950bb454dccf068aa5a291195477 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sun, 26 Feb 2023 14:36:21 +0530 Subject: [PATCH 14/15] add new line in repl.txt --- lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt index 7e39af3211d6..859b2a1b49c2 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/docs/repl.txt @@ -58,6 +58,7 @@ > dot = {{alias}}( 3, 0.0, x1, -2, y1, 1 ) 128.0 + {{alias}}.ndarray( N, scalar, x, strideX, offsetX, y, strideY, offsetY ) Computes the dot product of two single-precision floating-point vectors using alternative indexing semantics and with extended accumulation. From 39b2187b695ea7d96915a141d455c6cc8638ba66 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 1 Mar 2023 15:24:55 -0800 Subject: [PATCH 15/15] Apply suggestions from code review --- lib/node_modules/@stdlib/blas/base/sdsdot/README.md | 2 +- lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/README.md b/lib/node_modules/@stdlib/blas/base/sdsdot/README.md index bdb16eb28f64..7238f2236d34 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/README.md +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/README.md @@ -70,7 +70,7 @@ The function has the following parameters: - **y**: input [`Float32Array`][@stdlib/array/float32]. - **strideY**: index increment for `y`. -The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to calculate the dot product of every other value in `x` and the first `N` elements of `y` in reverse order, +The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to calculate the dot product of every other value in `x` and the first `N` elements of `y` in reverse order, ```javascript var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c b/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c index 3d8140dec3ce..712d9ed3da04 100644 --- a/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/sdsdot/src/addon.c @@ -24,7 +24,6 @@ #include "stdlib/napi/argv_strided_float32array.h" #include - /** * Receives JavaScript callback invocation data. * @@ -34,8 +33,6 @@ * @return Node-API value */ static napi_value addon( napi_env env, napi_callback_info info ) { - napi_status status; - STDLIB_NAPI_ARGV( env, info, argv, argc, 6 ); STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); STDLIB_NAPI_ARGV_FLOAT( env, scalar, argv, 1 ); @@ -45,7 +42,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 4 ); napi_value v; - status = napi_create_double( env, (double)c_sdsdot( N, (float)scalar, (float *)X, strideX, (float *)Y, strideY ), &v ); + napi_status status = napi_create_double( env, (double)c_sdsdot( N, scalar, (float *)X, strideX, (float *)Y, strideY ), &v ); assert( status == napi_ok ); return v;