From 4482278264e4eb7ff345281e80a093d0807a5892 Mon Sep 17 00:00:00 2001 From: yb175 Date: Fri, 9 Oct 2026 19:48:11 +0000 Subject: [PATCH 1/4] feat: add C implementation for blas/ext/base/ndarray/swhere --- .../blas/ext/base/ndarray/swhere/README.md | 60 +++ .../ndarray/swhere/benchmark/benchmark.js | 2 +- .../swhere/benchmark/benchmark.native.js | 121 +++++ .../base/ndarray/swhere/benchmark/c/Makefile | 146 ++++++ .../swhere/benchmark/c/benchmark.length.c | 159 +++++++ .../blas/ext/base/ndarray/swhere/binding.gyp | 170 +++++++ .../base/ndarray/swhere/examples/c/Makefile | 146 ++++++ .../base/ndarray/swhere/examples/c/example.c | 67 +++ .../blas/ext/base/ndarray/swhere/include.gypi | 53 +++ .../stdlib/blas/ext/base/ndarray/swhere.h | 40 ++ .../blas/ext/base/ndarray/swhere/lib/index.js | 16 +- .../ext/base/ndarray/swhere/lib/native.js | 50 ++ .../ext/base/ndarray/swhere/manifest.json | 109 +++++ .../blas/ext/base/ndarray/swhere/package.json | 4 + .../blas/ext/base/ndarray/swhere/src/Makefile | 70 +++ .../blas/ext/base/ndarray/swhere/src/addon.c | 70 +++ .../blas/ext/base/ndarray/swhere/src/main.c | 50 ++ .../blas/ext/base/ndarray/swhere/test/test.js | 53 ++- .../ext/base/ndarray/swhere/test/test.main.js | 412 ++++++++++++++++ .../base/ndarray/swhere/test/test.native.js | 444 ++++++++++++++++++ 20 files changed, 2235 insertions(+), 7 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/include/stdlib/blas/ext/base/ndarray/swhere.h create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/src/main.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/test/test.main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/test/test.native.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/README.md index fdfbb439580c..c5ff24332374 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/swhere/README.md @@ -111,6 +111,66 @@ console.log( ndarray2array( out ) ); +
+ +## C APIs + +
+ +
+ + + +
+ +### Usage + +```c +#include "stdlib/blas/ext/base/ndarray/swhere.h" +``` + +#### stdlib_blas_ext_swhere( arrays ) + +Takes elements from one of two one-dimensional single-precision floating-point ndarrays depending on a condition and assigns them to an output ndarray. + +```c +const struct ndarray *arrays[] = { condition, x, y, out }; +stdlib_blas_ext_swhere( arrays ); +// The output ndarray `out` now contains the selected values. +``` + +The function accepts the following argument: + +- **arrays**: `[in] struct ndarray**` list containing a one-dimensional boolean condition ndarray, two one-dimensional single-precision floating-point input ndarrays, and a one-dimensional single-precision floating-point output ndarray. + +```c +void stdlib_blas_ext_swhere( const struct ndarray *arrays[] ); +``` + +
+ + + +
+ +
+ + + +
+ +### Examples + +See the [C example](./examples/c/example.c) for a complete program constructing the ndarrays and calling this function. + +
+ + + +
+ + +