From 8d34450ad531ebed04dac6b241b9fcc106f9f5d9 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Tue, 29 Sep 2026 22:47:23 +0500 Subject: [PATCH] refactor: delegate to dfill and dcopy in blas/ext/base/dleft-pad-edge --- .../blas/ext/base/dleft-pad-edge/binding.gyp | 95 +++++++++++++++++++ .../ext/base/dleft-pad-edge/lib/ndarray.js | 25 ++--- .../ext/base/dleft-pad-edge/manifest.json | 44 +++++++-- .../blas/ext/base/dleft-pad-edge/src/main.c | 21 +--- 4 files changed, 143 insertions(+), 42 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/binding.gyp b/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/binding.gyp index 0d6508a12e99..60dce9d0b31a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/binding.gyp +++ b/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/binding.gyp @@ -29,6 +29,39 @@ # Target name should match the add-on export name: 'addon_target_name%': 'addon', + # Fortran compiler (to override -Dfortran_compiler=): + 'fortran_compiler%': 'gfortran', + + # Fortran compiler flags: + 'fflags': [ + # Specify the Fortran standard to which a program is expected to conform: + '-std=f95', + + # Indicate that the layout is free-form source code: + '-ffree-form', + + # Aggressive optimization: + '-O3', + + # Enable commonly used warning options: + '-Wall', + + # Warn if source code contains problematic language features: + '-Wextra', + + # Warn if a procedure is called without an explicit interface: + '-Wimplicit-interface', + + # Do not transform names of entities specified in Fortran source files by appending underscores (i.e., don't mangle names, thus allowing easier usage in C wrappers): + '-fno-underscoring', + + # Warn if source code contains Fortran 95 extensions and C-language constructs: + '-pedantic', + + # Compile but do not link (output is an object file): + '-c', + ], + # Set variables based on the host OS: 'conditions': [ [ @@ -128,6 +161,68 @@ }, ], # end condition (OS!="win") ], # end conditions + + # Define custom build actions for particular inputs: + 'rules': [ + { + # Define a rule for processing Fortran files: + 'extension': 'f', + + # Define the pathnames to be used as inputs when performing processing: + 'inputs': [ + # Full path of the current input: + '<(RULE_INPUT_PATH)' + ], + + # Define the outputs produced during processing: + 'outputs': [ + # Store an output object file in a directory for placing intermediate results (only accessible within a single target): + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).<(obj)' + ], + + # Define the rule for compiling Fortran based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + + # Rule to compile Fortran on Windows: + { + 'rule_name': 'compile_fortran_windows', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Windows...', + + 'process_outputs_as_sources': 0, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + }, + + # Rule to compile Fortran on non-Windows: + { + 'rule_name': 'compile_fortran_linux', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Linux...', + + 'process_outputs_as_sources': 1, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '-fPIC', # generate platform-independent code + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + } + ], # end condition (OS=="win") + ], # end conditions + }, # end rule (extension=="f") + ], # end rules }, # end target <(addon_target_name) # Target to copy a generated add-on to a standard location: diff --git a/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/lib/ndarray.js index b5e500bf0734..aa714210a297 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/lib/ndarray.js @@ -18,6 +18,12 @@ 'use strict'; +// MODULES // + +var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray; +var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; + + // MAIN // /** @@ -43,29 +49,14 @@ * // y => [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 4.0 ] */ function dleftPadEdge( N, k, x, strideX, offsetX, y, strideY, offsetY ) { - var ix; - var iy; - var v; - var i; - if ( N <= 0 ) { return y; } if ( k < 0 ) { k = 0; } - v = x[ offsetX ]; - iy = offsetY; - for ( i = 0; i < k; i++ ) { - y[ iy ] = v; - iy += strideY; - } - ix = offsetX; - for ( i = 0; i < N; i++ ) { - y[ iy ] = x[ ix ]; - iy += strideY; - ix += strideX; - } + dfill( k, x[ offsetX ], y, strideY, offsetY ); + dcopy( N, x, strideX, offsetX, y, strideY, offsetY + ( strideY * k ) ); return y; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/manifest.json index 2f3a082413bf..fb276ebd654d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/manifest.json @@ -1,6 +1,7 @@ { "options": { - "task": "build" + "task": "build", + "wasm": false }, "fields": [ { @@ -27,6 +28,7 @@ "confs": [ { "task": "build", + "wasm": false, "src": [ "./src/main.c" ], @@ -36,16 +38,19 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/dcopy", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float64array", - "@stdlib/strided/base/stride2offset", - "@stdlib/blas/base/shared" + "@stdlib/napi/argv-strided-float64array" ] }, { "task": "benchmark", + "wasm": false, "src": [ "./src/main.c" ], @@ -55,12 +60,15 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/strided/base/stride2offset", - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/blas/base/dcopy", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset" ] }, { "task": "examples", + "wasm": false, "src": [ "./src/main.c" ], @@ -70,8 +78,28 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/strided/base/stride2offset", - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/blas/base/dcopy", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "build", + "wasm": true, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/dcopy", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset" ] } ] diff --git a/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/src/main.c index ea6b71a817a8..3aaf98f1692e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dleft-pad-edge/src/main.c @@ -17,6 +17,8 @@ */ #include "stdlib/blas/ext/base/dleft_pad_edge.h" +#include "stdlib/blas/ext/base/dfill.h" +#include "stdlib/blas/base/dcopy.h" #include "stdlib/strided/base/stride2offset.h" #include "stdlib/blas/base/shared.h" @@ -55,27 +57,12 @@ void API_SUFFIX(stdlib_strided_dleft_pad_edge)( const CBLAS_INT N, CBLAS_INT k, * @param offsetY starting index for `Y` */ void API_SUFFIX(stdlib_strided_dleft_pad_edge_ndarray)( const CBLAS_INT N, CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { - CBLAS_INT ix; - CBLAS_INT iy; - double v; - CBLAS_INT i; - if ( N <= 0 ) { return; } if ( k < 0 ) { k = 0; } - v = X[ offsetX ]; - iy = offsetY; - for ( i = 0; i < k; i++ ) { - Y[ iy ] = v; - iy += strideY; - } - ix = offsetX; - for ( i = 0; i < N; i++ ) { - Y[ iy ] = X[ ix ]; - iy += strideY; - ix += strideX; - } + API_SUFFIX(stdlib_strided_dfill_ndarray)( k, X[ offsetX ], Y, strideY, offsetY ); + API_SUFFIX(c_dcopy_ndarray)( N, X, strideX, offsetX, Y, strideY, offsetY + ( strideY * k ) ); }