From 4ffeb2ac09c11d8dc8ebe3d2201c5ba49e223b4c Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Sat, 11 Jan 2025 09:56:43 +0000
Subject: [PATCH 1/7] feat: add C ndarray API and refactor
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: passed
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: missing_dependencies
- task: lint_c_examples
status: missing_dependencies
- task: lint_c_benchmarks
status: missing_dependencies
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
- task: run_javascript_examples
status: na
- task: run_c_examples
status: na
- task: run_cpp_examples
status: na
- task: run_javascript_readme_examples
status: na
- task: run_c_benchmarks
status: na
- task: run_cpp_benchmarks
status: na
- task: run_fortran_benchmarks
status: na
- task: run_javascript_benchmarks
status: na
- task: run_julia_benchmarks
status: na
- task: run_python_benchmarks
status: na
- task: run_r_benchmarks
status: na
- task: run_javascript_tests
status: na
---
---
.../@stdlib/blas/ext/base/sapx/README.md | 146 ++++++++++++++++--
.../blas/ext/base/sapx/benchmark/benchmark.js | 9 +-
.../base/sapx/benchmark/benchmark.native.js | 9 +-
.../base/sapx/benchmark/benchmark.ndarray.js | 9 +-
.../benchmark/benchmark.ndarray.native.js | 9 +-
.../base/sapx/benchmark/c/benchmark.length.c | 50 +++++-
.../@stdlib/blas/ext/base/sapx/docs/repl.txt | 30 ++--
.../blas/ext/base/sapx/docs/types/index.d.ts | 24 +--
.../blas/ext/base/sapx/examples/c/example.c | 12 +-
.../blas/ext/base/sapx/examples/index.js | 8 +-
.../sapx/include/stdlib/blas/ext/base/sapx.h | 11 +-
.../@stdlib/blas/ext/base/sapx/lib/index.js | 2 +-
.../@stdlib/blas/ext/base/sapx/lib/ndarray.js | 21 ++-
.../blas/ext/base/sapx/lib/ndarray.native.js | 24 ++-
.../@stdlib/blas/ext/base/sapx/lib/sapx.js | 53 +------
.../blas/ext/base/sapx/lib/sapx.native.js | 10 +-
.../@stdlib/blas/ext/base/sapx/manifest.json | 32 ++--
.../@stdlib/blas/ext/base/sapx/package.json | 2 +-
.../@stdlib/blas/ext/base/sapx/src/addon.c | 27 +++-
.../@stdlib/blas/ext/base/sapx/src/main.c | 84 ++++++++++
.../@stdlib/blas/ext/base/sapx/src/sapx.c | 70 ---------
21 files changed, 403 insertions(+), 239 deletions(-)
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/sapx/src/main.c
delete mode 100644 lib/node_modules/@stdlib/blas/ext/base/sapx/src/sapx.c
diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/README.md b/lib/node_modules/@stdlib/blas/ext/base/sapx/README.md
index d5021571d5ea..67df0782e950 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/sapx/README.md
+++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/README.md
@@ -20,7 +20,7 @@ limitations under the License.
# sapx
-> Add a constant to each element in a single-precision floating-point strided array.
+> Add a scalar constant to each element in a single-precision floating-point strided array.
@@ -30,9 +30,9 @@ limitations under the License.
var sapx = require( '@stdlib/blas/ext/base/sapx' );
```
-#### sapx( N, alpha, x, stride )
+#### sapx( N, alpha, x, strideX )
-Adds a constant `alpha` to each element in a single-precision floating-point strided array `x`.
+Adds a scalar constant to each element in a single-precision floating-point strided array.
```javascript
var Float32Array = require( '@stdlib/array/float32' );
@@ -48,9 +48,9 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **alpha**: scalar constant.
- **x**: input [`Float32Array`][@stdlib/array/float32].
-- **stride**: index increment.
+- **strideX**: stride length.
-The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to add a constant to every other element
+The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to add a constant to every other element:
```javascript
var Float32Array = require( '@stdlib/array/float32' );
@@ -77,9 +77,9 @@ sapx( 3, 5.0, x1, 2 );
// x0 => [ 1.0, 3.0, 3.0, 1.0, 5.0, -1.0 ]
```
-#### sapx.ndarray( N, alpha, x, stride, offset )
+#### sapx.ndarray( N, alpha, x, strideX, offsetX )
-Adds a constant `alpha` to each element in a single-precision floating-point strided array `x` using alternative indexing semantics.
+Adds a scalar constant to each element in a single-precision floating-point strided array using alternative indexing semantics.
```javascript
var Float32Array = require( '@stdlib/array/float32' );
@@ -92,9 +92,9 @@ sapx.ndarray( x.length, 5.0, x, 1, 0 );
The function has the following additional parameters:
-- **offset**: starting index.
+- **offsetX**: starting index.
-While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array
+While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of the strided array:
```javascript
var Float32Array = require( '@stdlib/array/float32' );
@@ -102,7 +102,7 @@ var Float32Array = require( '@stdlib/array/float32' );
var x = new Float32Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
sapx.ndarray( 3, 5.0, x, 1, x.length-3 );
-// x => [ 1.0, -2.0, 3.0, 1.0, 10.0, -1.0 ]
+// x => [ 6.0, 3.0, 8.0, -4.0, 5.0, -6.0 ]
```
@@ -126,11 +126,12 @@ sapx.ndarray( 3, 5.0, x, 1, x.length-3 );
```javascript
-var uniform = require( '@stdlib/random/base/uniform' ).factory;
-var filledarrayBy = require( '@stdlib/array/filled-by' );
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var sapx = require( '@stdlib/blas/ext/base/sapx' );
-var x = filledarrayBy( 10, 'float32', uniform( -100.0, 100.0 ) );
+var x = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float32'
+});
console.log( x );
sapx( x.length, 5.0, x, 1 );
@@ -141,6 +142,125 @@ console.log( x );
+
+
+* * *
+
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/blas/ext/base/sapx.h"
+```
+
+#### stdlib_strided_sapx( N, alpha, \*X, strideX )
+
+Adds a scalar constant to each element in a single-precision floating-point strided array.
+
+```c
+float x[] = { 1.0f, 2.0f, 3.0f, 4.0f };
+
+stdlib_strided_sapx( 4, 5.0f, x, 1 );
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **alpha**: `[in] float` scalar constant.
+- **X**: `[inout] float*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length.
+
+```c
+void stdlib_strided_sapx( const CBLAS_INT N, const float alpha, float *X, const CBLAS_INT strideX );
+```
+
+#### stdlib_strided_sapx_ndarray( N, alpha, \*X, strideX, offsetX )
+
+Adds a scalar constant to each element in a single-precision floating-point strided array using alternative indexing semantics.
+
+```c
+float x[] = { 1.0f, 2.0f, 3.0f, 4.0f };
+
+stdlib_strided_sapx_ndarray( 4, 5.0f, x, 1, 0 );
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **alpha**: `[in] float` scalar constant.
+- **X**: `[inout] float*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length.
+- **offsetX**: `[in] CBLAS_INT` starting index.
+
+```c
+void stdlib_strided_sapx_ndarray( const CBLAS_INT N, const float alpha, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/blas/ext/base/sapx.h"
+#include
+
+int main( void ) {
+ // Create a strided array:
+ float x[] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f };
+
+ // Specify the number of indexed elements:
+ const int N = 8;
+
+ // Specify a stride:
+ const int strideX = 1;
+
+ // Fill the array:
+ stdlib_strided_sapx( N, 5.0f, x, strideX );
+
+ // Print the result:
+ for ( int i = 0; i < 8; i++ ) {
+ printf( "x[ %i ] = %f\n", i, x[ i ] );
+ }
+}
+```
+
+
+
+
+
+
+
+
+
From 17a4133a3530f0a89c0a730eb54d4f69ef6ef5cc Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Sat, 11 Jan 2025 16:02:19 +0500
Subject: [PATCH 3/7] docs: apply review suggestion
Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
---
.../@stdlib/blas/ext/base/sapx/lib/ndarray.native.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/sapx/lib/ndarray.native.js
index 04d67006a13b..efaff76ccd2d 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/sapx/lib/ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/lib/ndarray.native.js
@@ -41,7 +41,7 @@ var addon = require( './../src/addon.node' );
* var x = new Float32Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
*
* sapx( 3, 5.0, x, 1, x.length-3 );
-* // x => [ 6.0, 3.0, 8.0, -4.0, 5.0, -6.0 ]
+* // x => [ 1.0, -2.0, 3.0, 1.0, 10.0, -1.0 ]
*/
function sapx( N, alpha, x, strideX, offsetX ) {
addon.ndarray( N, alpha, x, strideX, offsetX );
From f9f9425e6deb4dcf12fa493641488e726ff8ef73 Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Sun, 12 Jan 2025 11:48:07 +0500
Subject: [PATCH 4/7] docs: apply review suggestion
Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
---
.../@stdlib/blas/ext/base/sapx/examples/c/example.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/sapx/examples/c/example.c
index c6c9679bb227..b1e0e48c8206 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/sapx/examples/c/example.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/examples/c/example.c
@@ -29,7 +29,7 @@ int main( void ) {
// Specify a stride:
const int strideX = 1;
- // Fill the array:
+ // Add a constant to each element:
stdlib_strided_sapx( N, 5.0f, x, strideX );
// Print the result:
From fd1a294fe3adc821d3edbff737f6706b038b9434 Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Sun, 19 Jan 2025 05:59:44 +0000
Subject: [PATCH 5/7] fix: apply code review suggestion
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: missing_dependencies
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: na
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
- task: run_javascript_examples
status: na
- task: run_c_examples
status: na
- task: run_cpp_examples
status: na
- task: run_javascript_readme_examples
status: na
- task: run_c_benchmarks
status: na
- task: run_cpp_benchmarks
status: na
- task: run_fortran_benchmarks
status: na
- task: run_javascript_benchmarks
status: na
- task: run_julia_benchmarks
status: na
- task: run_python_benchmarks
status: na
- task: run_r_benchmarks
status: na
- task: run_javascript_tests
status: na
---
---
lib/node_modules/@stdlib/blas/ext/base/sapx/src/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/sapx/src/main.c
index ce75bb7963d5..9a1d3480fac7 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/sapx/src/main.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/src/main.c
@@ -59,7 +59,7 @@ void API_SUFFIX(stdlib_strided_sapx_ndarray)( const CBLAS_INT N, const float alp
// If we have a remainder, run a clean-up loop...
if ( m > 0 ) {
for ( i = 0; i < m; i++ ) {
- X[ i ] += alpha;
+ X[ ix ] += alpha;
ix += strideX;
}
}
From 7d2e6f2f9f2a1764744bec35e1cbcdbbd0e64d29 Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Sun, 19 Jan 2025 07:44:22 +0000
Subject: [PATCH 6/7] docs: wrap repl line
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: na
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
- task: run_javascript_examples
status: na
- task: run_c_examples
status: na
- task: run_cpp_examples
status: na
- task: run_javascript_readme_examples
status: na
- task: run_c_benchmarks
status: na
- task: run_cpp_benchmarks
status: na
- task: run_fortran_benchmarks
status: na
- task: run_javascript_benchmarks
status: na
- task: run_julia_benchmarks
status: na
- task: run_python_benchmarks
status: na
- task: run_r_benchmarks
status: na
- task: run_javascript_tests
status: na
---
---
lib/node_modules/@stdlib/blas/ext/base/sapx/docs/repl.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/sapx/docs/repl.txt
index 0332d2195c70..f62676a59287 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/sapx/docs/repl.txt
+++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/docs/repl.txt
@@ -56,8 +56,8 @@
strided array using alternative indexing semantics.
While typed array views mandate a view offset based on the underlying
- buffer, the offset parameter supports indexing semantics based on a
- starting index.
+ buffer, the offset parameter supports indexing semantics based on a starting
+ index.
Parameters
----------
From ad2a2a0a5a84a813c78ea712cb35b3cf7a173352 Mon Sep 17 00:00:00 2001
From: Athan
Date: Sun, 19 Jan 2025 00:40:01 -0800
Subject: [PATCH 7/7] docs: update comment
Signed-off-by: Athan
---
lib/node_modules/@stdlib/blas/ext/base/sapx/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/blas/ext/base/sapx/README.md b/lib/node_modules/@stdlib/blas/ext/base/sapx/README.md
index be302d1e661b..438f5be61036 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/sapx/README.md
+++ b/lib/node_modules/@stdlib/blas/ext/base/sapx/README.md
@@ -243,7 +243,7 @@ int main( void ) {
// Specify a stride:
const int strideX = 1;
- // Fill the array:
+ // Add a constant to each element:
stdlib_strided_sapx( N, 5.0f, x, strideX );
// Print the result: