From 6ed9bff478a1be1f1339c7ce30b5e571b02a18a1 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 11 May 2025 23:24:20 +0530 Subject: [PATCH 01/21] feat: add c implementation for blas/base/sgemv --- 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: passed - 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: missing_dependencies - 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 --- --- .../@stdlib/blas/base/sgemv/binding.gyp | 265 ++++++++++++++ .../blas/base/sgemv/examples/c/Makefile | 146 ++++++++ .../blas/base/sgemv/examples/c/example.c | 48 +++ .../@stdlib/blas/base/sgemv/include.gypi | 70 ++++ .../sgemv/include/stdlib/blas/base/sgemv.h | 48 +++ .../include/stdlib/blas/base/sgemv_cblas.h | 43 +++ .../@stdlib/blas/base/sgemv/lib/native.js | 35 ++ .../blas/base/sgemv/lib/ndarray.native.js | 71 ++++ .../blas/base/sgemv/lib/sgemv.native.js | 71 ++++ .../@stdlib/blas/base/sgemv/manifest.json | 330 ++++++++++++++++++ .../@stdlib/blas/base/sgemv/src/Makefile | 70 ++++ .../@stdlib/blas/base/sgemv/src/addon.c | 96 +++++ .../@stdlib/blas/base/sgemv/src/sgemv.c | 60 ++++ .../@stdlib/blas/base/sgemv/src/sgemv_cblas.c | 89 +++++ .../blas/base/sgemv/src/sgemv_ndarray.c | 126 +++++++ 15 files changed, 1568 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv.h create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/binding.gyp b/lib/node_modules/@stdlib/blas/base/sgemv/binding.gyp new file mode 100644 index 000000000000..864d9109e892 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/binding.gyp @@ -0,0 +1,265 @@ +# @license Apache-2.0 +# +# Copyright (c) 2018 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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # 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': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # 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: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/Makefile new file mode 100644 index 000000000000..ff5293d3059f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c new file mode 100644 index 000000000000..aa5e6df32fe1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c @@ -0,0 +1,48 @@ +/** +* @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/sgemv.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Create a strided array: + const float A[] = { 1.0f, 0.0f, 0.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f }; + const float x[] = { 1.0f, 2.0f, 3.0f }; + float y[] = { 1.0f, 2.0f, 3.0f }; + + // Specify the number of elements along each dimension of `A`: + const int M = 3; + const int N = 3; + + // Perform the matrix-vector operations `y = α*A*x + β*y`: + c_sgemv( CblasRowMajor, CblasNoTrans, M, N, 1.0f, A, 1, x, 1, 1.0f, y, 1 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "y[ %i ] = %f\n", i, y[ i ] ); + } + + // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`: + c_sgemv_ndarray( CblasNoTrans, M, N, 1.0f, A, 1, 1, 0, x, 1, 0, 1.0f, y, 1, 0 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "y[ %i ] = %f\n", i, y[ i ] ); + } +} diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/include.gypi b/lib/node_modules/@stdlib/blas/base/sgemv/include.gypi new file mode 100644 index 000000000000..f8b01bfb52cb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/include.gypi @@ -0,0 +1,70 @@ +# @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. + +# A GYP include file for building a Node.js native add-on. +# +# Note that nesting variables is required due to how GYP processes a configuration. Any variables defined within a nested 'variables' section is defined in the outer scope. Thus, conditions in the outer variable scope are free to use these variables without running into "variable undefined" errors. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +# +# Variable nesting hacks: +# +# [3]: https://chromium.googlesource.com/external/skia/gyp/+/master/common_variables.gypi +# [4]: https://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004 +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + 'variables': { + # Host BLAS library (to override -Dblas=): + 'blas%': '', + + # Path to BLAS library (to override -Dblas_dir=): + 'blas_dir%': '', + }, # end variables + + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '<@(blas_dir)', + ' [ 6.0, 8.0, 1.0 ] +*/ +function sgemv( trans, M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, offsetX, beta, y, strideY, offsetY ) { // eslint-disable-line max-params, max-len + return addon.ndarray( resolveTrans( trans ), M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, offsetX, beta, y, strideY, offsetY ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = sgemv; diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js new file mode 100644 index 000000000000..27aea07c2980 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js @@ -0,0 +1,71 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var resolveOrder = require( '@stdlib/blas/base/layout-resolve-enum' ); +var resolveTrans = require( '@stdlib/blas/base/transpose-operation-resolve-enum' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. +* +* @param {string} order - storage layout +* @param {string} trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param {NonNegativeInteger} M - number of rows in the matrix `A` +* @param {NonNegativeInteger} N - number of columns in the matrix `A` +* @param {number} alpha - scalar constant +* @param {Float32Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float32Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {number} beta - scalar constant +* @param {Float32Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must be a valid transpose operation +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} fourth argument must be a nonnegative integer +* @throws {RangeError} seventh argument must be greater than or equal to max(1,M) +* @throws {RangeError} ninth argument must be non-zero +* @throws {RangeError} twelfth argument must be non-zero +* @returns {Float32Array} `y` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sgemv( 'row-major', 'no-transpose', 2, 3, 1.0, A, 3, x, 1, 1.0, y, 1 ); +* // y => [ 6.0, 8.0, 1.0 ] +*/ +function sgemv( order, trans, M, N, alpha, A, LDA, x, strideX, beta, y, strideY ) { // eslint-disable-line max-params, max-len + return addon( resolveOrder( order ), resolveTrans( trans ), M, N, alpha, A, LDA, x, strideX, beta, y, strideY ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = sgemv; diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json b/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json new file mode 100644 index 000000000000..22b19d864bcb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json @@ -0,0 +1,330 @@ +{ + "options": { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "os": "win", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sgemv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-strided-float32array2d", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sgemv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sgemv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/sgemv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-strided-float32array2d", + "@stdlib/napi/argv-double" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/sgemv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/sgemv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sgemv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-strided-float32array2d", + "@stdlib/napi/argv-double" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sgemv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/sgemv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/sgemv.c", + "./src/sgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-strided-float32array2d", + "@stdlib/napi/argv-double", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/sgemv.c", + "./src/sgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/math/base/special/floorf", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/sgemv.c", + "./src/sgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/sgemv.c", + "./src/sgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/Makefile b/lib/node_modules/@stdlib/blas/base/sgemv/src/Makefile new file mode 100644 index 000000000000..dd720a3de8f2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c new file mode 100644 index 000000000000..d65803c60096 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/sgemv.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_int32.h" +#include "stdlib/napi/argv_float.h" +#include "stdlib/napi/argv_strided_float32array.h" +#include "stdlib/napi/argv_strided_float32array2d.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @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 ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 12 ); + + STDLIB_NAPI_ARGV_INT32( env, order, argv, 0 ); + STDLIB_NAPI_ARGV_INT32( env, trans, argv, 1 ); + + STDLIB_NAPI_ARGV_INT64( env, M, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 8 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 11 ); + STDLIB_NAPI_ARGV_INT64( env, LDA, argv, 6 ); + + STDLIB_NAPI_ARGV_FLOAT( env, alpha, argv, 4 ); + STDLIB_NAPI_ARGV_FLOAT( env, beta, argv, 9 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 7 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 10 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( env, A, M, N, LDA, 1, argv, 5 ); + + API_SUFFIX(c_sgemv)( order, trans, M, N, alpha, A, LDA, X, strideX, beta, Y, strideY ); + + return NULL; +} + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 15 ); + + STDLIB_NAPI_ARGV_INT32( env, trans, argv, 0 ); + + STDLIB_NAPI_ARGV_INT64( env, M, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 9 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 10 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 13 ); + STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 14 ); + STDLIB_NAPI_ARGV_INT64( env, strideA1, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, strideA2, argv, 6 ); + STDLIB_NAPI_ARGV_INT64( env, offsetA, argv, 7 ); + + STDLIB_NAPI_ARGV_FLOAT( env, alpha, argv, 3 ); + STDLIB_NAPI_ARGV_FLOAT( env, beta, argv, 11 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 8 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 12 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( env, A, M, N, strideA1, strideA2, argv, 4 ); + + API_SUFFIX(c_sgemv_ndarray)( trans, M, N, alpha, A, strideA1, strideA2, offsetA, X, strideX, offsetX, beta, Y, strideY, offsetY ); + + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) + diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c new file mode 100644 index 000000000000..3c705a719ed9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c @@ -0,0 +1,60 @@ +/** +* @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/sgemv.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" + +/** +* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. +* +* @param order storage layout +* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param M number of rows in the matrix `A` +* @param N number of columns in the matrix `A` +* @param alpha scalar constant +* @param A input matrix +* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param x first input vector +* @param strideX `x` stride length +* @param beta scalar constant +* @param y second input vector +* @param strideY `y` stride length +* @return output value +*/ +void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *x, const CBLAS_INT strideX, const float beta, float *y, const CBLAS_INT strideY ) { + CBLAS_INT sa1; + CBLAS_INT sa2; + CBLAS_INT ox; + CBLAS_INT oy; + + if ( M == 0 || N == 0 || ( alpha == 0.0f && beta == 1.0f ) ) { + return; + } + if ( order == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + ox = stdlib_strided_stride2offset( N, strideX ); + oy = stdlib_strided_stride2offset( N, strideY ); + API_SUFFIX(c_sgemv_ndarray)( trans, M, N, alpha, A, sa1, sa2, 0, x, strideX, ox, beta, y, strideY, oy ); + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c new file mode 100644 index 000000000000..ca19d29dd43a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c @@ -0,0 +1,89 @@ +/** +* @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/sgemv.h" +#include "stdlib/blas/base/sgemv_cblas.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/min_view_buffer_index.h" +#include "stdlib/ndarray/base/min_view_buffer_index.h" + +/** +* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. +* +* @param order storage layout +* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param M number of rows in the matrix `A` +* @param N number of columns in the matrix `A` +* @param alpha scalar constant +* @param A input matrix +* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param x first input vector +* @param strideX `x` stride length +* @param beta scalar constant +* @param y second input vector +* @param strideY `y` stride length +* @return output value +*/ +float API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *x, const CBLAS_INT strideX, const float beta, const float *y, const CBLAS_INT strideY ) { + CBLAS_INT sx = strideX; + CBLAS_INT sy = strideY; + if ( sx < 0 ) { + sx = -sx; + } + if ( sy < 0 ) { + sy = -sy; + } + return API_SUFFIX(cblas_sgemv)( order, trans, M, N, alpha, A, LDA, x, sx, beta, y, sy ); +} + +/** +* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` using alternative indexing semantics, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. +* +* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param M number of rows in the matrix `A` +* @param N number of columns in the matrix `A` +* @param alpha scalar constant +* @param A input matrix +* @param strideA1 stride of the first dimension of `A` +* @param strideA1 stride of the second dimension of `A` +* @param offsetA starting index for `A` +* @param x first input vector +* @param strideX `x` stride length +* @param offsetX starting index for `x` +* @param beta scalar constant +* @param y second input vector +* @param strideY `y` stride length +* @param offsetY starting index for `Y` +* @return output value +*/ +float API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, const float *y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { + CBLAS_INT sx = strideX; + CBLAS_INT sy = strideY; + if ( sx < 0 ) { + sx = -sx; + } + if ( sy < 0 ) { + sy = -sy; + } + x += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer + y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer + const int64_t shape[] = { M, N }; + const int64_t strides[] = { strideA1, strideA2 }; + A += stdlib_ndarray_min_view_buffer_index( 2, shape, strides, offsetA ); // adjust array pointer + return API_SUFFIX(cblas_sgemv)( order, trans, M, N, alpha, A, LDA, x, sx, beta, y, sy ); +} diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c new file mode 100644 index 000000000000..6560a243c810 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c @@ -0,0 +1,126 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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/sgemv.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/sscal.h" +#include "stdlib/blas/ext/base/sfill.h" +#include "stdlib/ndarray/base/assert/is_row_major.h" + +/** +* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` using alternative indexing semantics, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. +* +* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param M number of rows in the matrix `A` +* @param N number of columns in the matrix `A` +* @param alpha scalar constant +* @param A input matrix +* @param strideA1 stride of the first dimension of `A` +* @param strideA1 stride of the second dimension of `A` +* @param offsetA starting index for `A` +* @param x first input vector +* @param strideX `x` stride length +* @param offsetX starting index for `x` +* @param beta scalar constant +* @param y second input vector +* @param strideY `y` stride length +* @param offsetY starting index for `Y` +* @return output value +*/ +void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, float *y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { + CBLAS_INT isrm; + CBLAS_INT xlen; + CBLAS_INT ylen; + CBLAS_INT ix1; + CBLAS_INT iy1; + CBLAS_INT sa0; + CBLAS_INT sa1; + CBLAS_INT i0; + CBLAS_INT i1; + CBLAS_INT oa; + float tmp; + + // Note on variable naming convention: sa#, ix#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + int64_t strides[] = { strideA1, strideA2 }; + if ( M == 0 || N == 0 || ( alpha == 0.0f && beta == 1.0f ) ) { + return; + } + isrm = stdlib_ndarray_is_row_major( 2, strides ); + if ( isrm ) { + // For row-major matrices, the last dimension has the fastest changing index... + sa0 = strideA2; // stride for innermost loop + sa1 = strideA1; // stride for outermost loop + } else { // isColMajor + // For column-major matrices, the first dimension has the fastest changing index... + sa0 = strideA1; // stride for innermost loop + sa1 = strideA2; // stride for outermost loop + } + if ( CblasNoTrans ) { + xlen = N; + ylen = M; + } else { + xlen = M; + ylen = N; + } + // y = beta*y + if ( beta != 1.0f ) { + if ( beta == 0.0f ) { + stdlib_strided_sfill_ndarray( ylen, 0.0f, y, strideY, offsetY ); + } else { + c_sscal_ndarray( ylen, beta, y, strideY, offsetY ); + } + } + if ( alpha == 0.0f ) { + return; + } + // Form: y = α*A*x + y + if ( + ( isrm && CblasNoTrans ) || + ( !isrm && CblasTrans ) + ) { + ix1 = offsetX; + for ( i1 = 0; i1 < xlen; i1++ ) { + tmp = alpha * x[ ix1 ]; + oa = offsetA + (sa1*i1); + iy1 = offsetY; + for ( i0 = 0; i0 < ylen; i0++ ) { + y[ iy1 ] += A[ oa+(sa0*i0) ] * tmp; + iy1 += strideY; + } + ix1 += strideX; + } + return; + } + // Form: y = α*A^T*x + y + + // ( !isrm && trans !== 'no-transpose' ) || ( isrm && trans === 'no-transpose' ) + iy1 = offsetY; + for ( i1 = 0; i1 < ylen; i1++ ) { + tmp = 0.0f; + ix1 = offsetX; + oa = offsetA + (sa1*i1); + for ( i0 = 0; i0 < xlen; i0++ ) { + tmp += A[ oa+(sa0*i0) ] * x[ ix1 ]; + ix1 += strideX; + } + y[ iy1 ] += alpha * tmp; + iy1 += strideY; + } + return; +} From 1220dd4a1a09a7f2f693f329754800dcb5f38262 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 12 May 2025 12:03:28 +0530 Subject: [PATCH 02/21] chore: add benchmark --- 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: passed - 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: missing_dependencies - 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 --- --- .../base/sgemv/benchmark/benchmark.native.js | 104 +++++++++ .../benchmark/benchmark.ndarray.native.js | 104 +++++++++ .../blas/base/sgemv/benchmark/c/Makefile | 146 +++++++++++++ .../base/sgemv/benchmark/c/benchmark.length.c | 197 ++++++++++++++++++ 4 files changed, 551 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.native.js new file mode 100644 index 000000000000..fa47355955af --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.native.js @@ -0,0 +1,104 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var ones = require( '@stdlib/array/ones' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floorf = require( '@stdlib/math/base/special/floorf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var sgemv = tryRequire( resolve( __dirname, './../lib/sgemv.native.js' ) ); +var opts = { + 'skip': ( sgemv instanceof Error ) +}; +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = ones( len, options.dtype ); + var y = ones( len, options.dtype ); + var A = ones( len*len, options.dtype ); + return benchmark; + + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = sgemv( 'row-major', 'no-transpose', len, len, 1.0, A, len, x, 1, 1.0, y, 1 ); + if ( isnanf( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var len; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floorf( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+':size='+(len*len), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..96a44b72f5b1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,104 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var ones = require( '@stdlib/array/ones' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floorf = require( '@stdlib/math/base/special/floorf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var sgemv = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( sgemv instanceof Error ) +}; +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = ones( len, options.dtype ); + var y = ones( len, options.dtype ); + var A = ones( len*len, options.dtype ); + return benchmark; + + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = sgemv( 'no-transpose', len, len, 1.0, A, len, 1, 0, x, 1, 0, 1.0, y, 1, 0 ); + if ( isnanf( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var len; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floorf( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+':size='+(len*len), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/Makefile new file mode 100644 index 000000000000..7280962b4c4d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..23263e0d4ada --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c @@ -0,0 +1,197 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/sgemv.h" +#include "stdlib/blas/ext/base/sfill.h" +#include "stdlib/math/base/special/floorf.h" +#include +#include +#include +#include +#include + +#define NAME "sgemv" +#define ITERATIONS 10000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param iterations number of iterations +* @param elapsed elapsed time in seconds +*/ +static void print_results( int iterations, double elapsed ) { + double rate = (double)iterations / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", iterations ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark1( int iterations, int len ) { + double elapsed; + float A[ len*len ]; + float x[ len ]; + float y[ len ]; + double t; + int i; + + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_float()*1.0f ) - 0.5f; + y[ i ] = ( rand_float()*1.0f ) - 0.5f; + } + stdlib_strided_sfill( len*len, 1.0f, A, 1 ); + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_sgemv( CblasRowMajor, CblasNoTrans, len, len, 1.0, A, len, x, 1, 1.0, y, 1 ); + if ( y[ 0 ] != y[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y[ 0 ] != y[ 0 ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int len ) { + double elapsed; + float A[ len*len ]; + float x[ len ]; + float y[ len ]; + double t; + int i; + + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_float()*1.0f ) - 0.5f; + y[ i ] = ( rand_float()*1.0f ) - 0.5f; + } + stdlib_strided_sfill( len*len, 1.0f, A, 1 ); + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_sgemv_ndarray( CblasNoTrans, len, len, 1.0, A, len, 1, 0, x, 1, 0, 1.0, y, 1, 0 ); + if ( y[ 0 ] != y[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y[ 0 ] != y[ 0 ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int len; + int i; + int j; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + for ( i = MIN; i <= MAX; i++ ) { + len = stdlib_base_floorf( pow( pow( 10, i ), 1.0/2.0 ) ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:len=%d\n", NAME, len ); + elapsed = benchmark1( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:ndarray:len=%d\n", NAME, len ); + elapsed = benchmark2( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} From f90d065a86a6466d3caa11f68bcb6376be8ec06c Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 16 May 2025 13:04:45 +0530 Subject: [PATCH 03/21] chore: add implementation --- 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: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - 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: missing_dependencies - 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 --- --- .../@stdlib/blas/base/sgemv/README.md | 98 ++- .../blas/base/sgemv/examples/c/example.c | 4 +- .../@stdlib/blas/base/sgemv/examples/index.js | 5 +- .../blas/base/sgemv/lib/ndarray.native.js | 7 +- .../blas/base/sgemv/lib/sgemv.native.js | 7 +- .../@stdlib/blas/base/sgemv/src/addon.c | 41 +- .../@stdlib/blas/base/sgemv/src/sgemv.c | 14 +- .../blas/base/sgemv/src/sgemv_ndarray.c | 33 +- .../base/sgemv/test/test.ndarray.native.js | 813 ++++++++++++++++++ .../blas/base/sgemv/test/test.sgemv.native.js | 519 +++++++++++ 10 files changed, 1499 insertions(+), 42 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.native.js diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/README.md b/lib/node_modules/@stdlib/blas/base/sgemv/README.md index 3a65df1b86d8..bdeca07c48d6 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/README.md +++ b/lib/node_modules/@stdlib/blas/base/sgemv/README.md @@ -93,6 +93,8 @@ sgemv( 'row-major', 'no-transpose', 2, 2, 1.0, A, 2, x1, -1, 1.0, y1, -1 ); // y0 => [ 0.0, 8.0, 4.0 ] ``` + + #### sgemv.ndarray( trans, M, N, α, A, sa1, sa2, oa, x, sx, ox, β, y, sy, oy ) Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, using alternative indexing semantics and where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. @@ -199,18 +201,73 @@ console.log( y ); #include "stdlib/blas/base/sgemv.h" ``` -#### TODO +#### c_sgemv( order, trans, M, N, alpha, \*A, LDA, \*X, strideX, beta, \*Y, strideY ) + +Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. + +```c +#include "stdlib/blas/base/shared.h" + +float A[] = { 1.0f, 0.0f, 0.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f }; +const float x[] = { 1.0f, 2.0f, 3.0f }; +const float y[] = { 1.0f, 2.0f, 3.0f }; + +c_sgemv( CblasColMajor, CblasNoTrans, 3, 3, 1.0f, A, 3, x, 1, 1.0f, y, 1 ); +``` + +The function accepts the following arguments: + +- **order**: `[in] CBLAS_LAYOUT` storage layout. +- **trans**: `[in] CBLAS_TRANSPOSE` specifies whether `A` should be transposed, conjugate-transposed, or not transposed. +- **M**: `[in] CBLAS_INT` number of rows in the matrix `A`. +- **N**: `[in] CBLAS_INT` number of columns in the matrix `A`. +- **alpha**: `[in] float` scalar. +- **A**: `[inout] float*` input matrix. +- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **X**: `[in] float*` first input vector. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **beta**: `[in] float` scalar. +- **Y**: `[in] float*` second input vector. +- **strideY**: `[in] CBLAS_INT` index increment for `Y`. + +```c +void c_sgemv( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *x, const CBLAS_INT strideX, const float beta, float *y, const CBLAS_INT strideY ) +``` + +#### c_sgemv_ndarray( trans, M, N, alpha, \*A, sa1, sa2, oa, \*X, sx, ox, beta, \*Y, sy, oy ) -TODO. +Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix using indexing alternative semantics. ```c -TODO +#include "stdlib/blas/base/shared.h" + +float A[] = { 1.0f, 0.0f, 0.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f }; +const float x[] = { 1.0f, 2.0f, 3.0f }; +const float y[] = { 1.0f, 2.0f, 3.0f }; + +c_sgemv_ndarray( CblasNoTrans, 3, 3, 1.0f, A, 1, 3, 0, x, 1, 0, 1.0f, y, 1, 0 ); ``` -TODO +The function accepts the following arguments: + +- **trans**: `[in] CBLAS_TRANSPOSE` specifies whether `A` should be transposed, conjugate-transposed, or not transposed. +- **M**: `[in] CBLAS_INT` number of rows in the matrix `A`. +- **N**: `[in] CBLAS_INT` number of columns in the matrix `A`. +- **alpha**: `[in] float` scalar. +- **A**: `[inout] float*` input matrix. +- **sa1**: `[in] CBLAS_INT` stride of the first dimension of `A`. +- **sa2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **oa**: `[in] CBLAS_INT` starting index for `A`. +- **X**: `[in] float*` first input vector. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **beta**: `[in] float` scalar. +- **Y**: `[in] float*` second input vector. +- **strideY**: `[in] CBLAS_INT` index increment for `Y`. +- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. ```c -TODO +void c_sgemv_ndarray( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, float *y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) ``` @@ -232,7 +289,36 @@ TODO ### Examples ```c -TODO +#include "stdlib/blas/base/sgemv.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Create a strided array: + const float A[] = { 1.0f, 0.0f, 0.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f }; + const float x[] = { 1.0f, 2.0f, 3.0f }; + float y[] = { 1.0f, 2.0f, 3.0f }; + + // Specify the number of elements along each dimension of `A`: + const int M = 3; + const int N = 3; + + // Perform the matrix-vector operations `y = α*A*x + β*y`: + c_sgemv( CblasRowMajor, CblasNoTrans, M, N, 1.0f, A, M, x, 1, 1.0f, y, 1 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "y[ %i ] = %f\n", i, y[ i ] ); + } + + // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`: + c_sgemv_ndarray( CblasNoTrans, 3, 3, 1.0f, A, 3, 1, 0, x, 1, 0, 1.0f, y, 1, 0 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "y[ %i ] = %f\n", i, y[ i ] ); + } +} ``` diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c index aa5e6df32fe1..8968c90f03c7 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c @@ -31,7 +31,7 @@ int main( void ) { const int N = 3; // Perform the matrix-vector operations `y = α*A*x + β*y`: - c_sgemv( CblasRowMajor, CblasNoTrans, M, N, 1.0f, A, 1, x, 1, 1.0f, y, 1 ); + c_sgemv( CblasRowMajor, CblasNoTrans, M, N, 1.0f, A, M, x, 1, 1.0f, y, 1 ); // Print the result: for ( int i = 0; i < N; i++ ) { @@ -39,7 +39,7 @@ int main( void ) { } // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`: - c_sgemv_ndarray( CblasNoTrans, M, N, 1.0f, A, 1, 1, 0, x, 1, 0, 1.0f, y, 1, 0 ); + c_sgemv_ndarray( CblasNoTrans, 3, 3, 1.0f, A, 3, 1, 0, x, 1, 0, 1.0f, y, 1, 0 ); // Print the result: for ( int i = 0; i < N; i++ ) { diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/examples/index.js b/lib/node_modules/@stdlib/blas/base/sgemv/examples/index.js index b41a65b29369..945cea832499 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/examples/index.js @@ -32,5 +32,8 @@ var A = discreteUniform( M*N, 0, 255, opts ); var x = discreteUniform( N, 0, 255, opts ); var y = discreteUniform( M, 0, 255, opts ); -sgemv( 'row-major', 'no-transpose', M, N, 1.0, A, N, x, -1, 1.0, y, -1 ); +sgemv( 'row-major', 'no-transpose', M, N, 1.0, A, N, x, 1, 1.0, y, 1 ); +console.log( y ); + +sgemv.ndarray( 'no-transpose', M, N, 1.0, A, N, 1, 0, x, 1, 0, 1.0, y, 1, 0 ); console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js index a33645f33518..90d2a6c84195 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js @@ -56,13 +56,14 @@ var addon = require( './../src/addon.node' ); * * var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); -* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0 ] ); * * sgemv( 'no-transpose', 2, 3, 1.0, A, 3, 1, 0, x, 1, 0, 1.0, y, 1, 0 ); -* // y => [ 6.0, 8.0, 1.0 ] +* // y => [ 7.0, 16.0 ] */ function sgemv( trans, M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, offsetX, beta, y, strideY, offsetY ) { // eslint-disable-line max-params, max-len - return addon.ndarray( resolveTrans( trans ), M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, offsetX, beta, y, strideY, offsetY ); // eslint-disable-line max-len + addon.ndarray( resolveTrans( trans ), M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, offsetX, beta, y, strideY, offsetY ); // eslint-disable-line max-len + return y; } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js index 27aea07c2980..e19a8c48303d 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js @@ -56,13 +56,14 @@ var addon = require( './../src/addon.node' ); * * var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); -* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0 ] ); * * sgemv( 'row-major', 'no-transpose', 2, 3, 1.0, A, 3, x, 1, 1.0, y, 1 ); -* // y => [ 6.0, 8.0, 1.0 ] +* // y => [ 7.0, 16.0 ] */ function sgemv( order, trans, M, N, alpha, A, LDA, x, strideX, beta, y, strideY ) { // eslint-disable-line max-params, max-len - return addon( resolveOrder( order ), resolveTrans( trans ), M, N, alpha, A, LDA, x, strideX, beta, y, strideY ); // eslint-disable-line max-len + addon( resolveOrder( order ), resolveTrans( trans ), M, N, alpha, A, LDA, x, strideX, beta, y, strideY ); // eslint-disable-line max-len + return y; } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c index d65803c60096..4947d365a509 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c @@ -49,9 +49,29 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_FLOAT( env, alpha, argv, 4 ); STDLIB_NAPI_ARGV_FLOAT( env, beta, argv, 9 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 7 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 10 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( env, A, M, N, LDA, 1, argv, 5 ); + CBLAS_INT xlen; + CBLAS_INT ylen; + CBLAS_INT sa1; + CBLAS_INT sa2; + + if ( trans == CblasNoTrans ) { + xlen = N; + ylen = M; + } else { + xlen = M; + ylen = N; + } + if ( order == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, xlen, strideX, argv, 7 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, ylen, strideY, argv, 10 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( env, A, M, N, sa1, sa2, argv, 5 ); API_SUFFIX(c_sgemv)( order, trans, M, N, alpha, A, LDA, X, strideX, beta, Y, strideY ); @@ -83,8 +103,19 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_FLOAT( env, alpha, argv, 3 ); STDLIB_NAPI_ARGV_FLOAT( env, beta, argv, 11 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 8 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 12 ); + CBLAS_INT xlen; + CBLAS_INT ylen; + + if ( trans == CblasNoTrans ) { + xlen = N; + ylen = M; + } else { + xlen = M; + ylen = N; + } + + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, xlen, strideX, argv, 8 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, ylen, strideY, argv, 12 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( env, A, M, N, strideA1, strideA2, argv, 4 ); API_SUFFIX(c_sgemv_ndarray)( trans, M, N, alpha, A, strideA1, strideA2, offsetA, X, strideX, offsetX, beta, Y, strideY, offsetY ); diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c index 3c705a719ed9..0febcdc7a737 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c @@ -38,13 +38,19 @@ * @return output value */ void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *x, const CBLAS_INT strideX, const float beta, float *y, const CBLAS_INT strideY ) { + CBLAS_INT xlen; + CBLAS_INT ylen; CBLAS_INT sa1; CBLAS_INT sa2; CBLAS_INT ox; CBLAS_INT oy; - if ( M == 0 || N == 0 || ( alpha == 0.0f && beta == 1.0f ) ) { - return; + if ( trans == CblasNoTrans ) { + xlen = N; + ylen = M; + } else { + xlen = M; + ylen = N; } if ( order == CblasColMajor ) { sa1 = 1; @@ -53,8 +59,8 @@ void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, sa1 = LDA; sa2 = 1; } - ox = stdlib_strided_stride2offset( N, strideX ); - oy = stdlib_strided_stride2offset( N, strideY ); + ox = stdlib_strided_stride2offset( xlen, strideX ); + oy = stdlib_strided_stride2offset( ylen, strideY ); API_SUFFIX(c_sgemv_ndarray)( trans, M, N, alpha, A, sa1, sa2, 0, x, strideX, ox, beta, y, strideY, oy ); return; } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c index 6560a243c810..b3444439793b 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c @@ -58,27 +58,27 @@ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M // Note on variable naming convention: sa#, ix#, i# where # corresponds to the loop number, with `0` being the innermost loop... int64_t strides[] = { strideA1, strideA2 }; + isrm = stdlib_ndarray_is_row_major( 2, strides ); if ( M == 0 || N == 0 || ( alpha == 0.0f && beta == 1.0f ) ) { return; } - isrm = stdlib_ndarray_is_row_major( 2, strides ); if ( isrm ) { - // For row-major matrices, the last dimension has the fastest changing index... - sa0 = strideA2; // stride for innermost loop - sa1 = strideA1; // stride for outermost loop - } else { // isColMajor - // For column-major matrices, the first dimension has the fastest changing index... - sa0 = strideA1; // stride for innermost loop - sa1 = strideA2; // stride for outermost loop + sa0 = strideA2; + sa1 = strideA1; + } else { + sa0 = strideA1; + sa1 = strideA2; } - if ( CblasNoTrans ) { + + if ( trans == CblasNoTrans ) { xlen = N; ylen = M; } else { xlen = M; ylen = N; } - // y = beta*y + + // y = beta * y if ( beta != 1.0f ) { if ( beta == 0.0f ) { stdlib_strided_sfill_ndarray( ylen, 0.0f, y, strideY, offsetY ); @@ -90,17 +90,14 @@ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M return; } // Form: y = α*A*x + y - if ( - ( isrm && CblasNoTrans ) || - ( !isrm && CblasTrans ) - ) { + if ( ( !isrm && trans == CblasNoTrans ) || ( isrm && trans != CblasNoTrans ) ) { ix1 = offsetX; for ( i1 = 0; i1 < xlen; i1++ ) { tmp = alpha * x[ ix1 ]; - oa = offsetA + (sa1*i1); + oa = offsetA + sa1 * i1; iy1 = offsetY; for ( i0 = 0; i0 < ylen; i0++ ) { - y[ iy1 ] += A[ oa+(sa0*i0) ] * tmp; + y[ iy1 ] += A[ oa + sa0 * i0 ] * tmp; iy1 += strideY; } ix1 += strideX; @@ -114,9 +111,9 @@ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M for ( i1 = 0; i1 < ylen; i1++ ) { tmp = 0.0f; ix1 = offsetX; - oa = offsetA + (sa1*i1); + oa = offsetA + sa1 * i1; for ( i0 = 0; i0 < xlen; i0++ ) { - tmp += A[ oa+(sa0*i0) ] * x[ ix1 ]; + tmp += A[ oa + sa0 * i0 ] * x[ ix1 ]; ix1 += strideX; } y[ iy1 ] += alpha * tmp; diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js new file mode 100644 index 000000000000..2884db758c17 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js @@ -0,0 +1,813 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// FIXTURES // + +var cap = require( './fixtures/column_major_complex_access_pattern.json' ); +var cnt = require( './fixtures/column_major_nt.json' ); +var ct = require( './fixtures/column_major_t.json' ); +var coa = require( './fixtures/column_major_oa.json' ); +var csa1sa2 = require( './fixtures/column_major_sa1_sa2.json' ); +var csa1nsa2 = require( './fixtures/column_major_sa1n_sa2.json' ); +var csa1sa2n = require( './fixtures/column_major_sa1_sa2n.json' ); +var csa1nsa2n = require( './fixtures/column_major_sa1n_sa2n.json' ); +var cxnyn = require( './fixtures/column_major_xnyn.json' ); +var cxpyn = require( './fixtures/column_major_xpyn.json' ); +var cxnyp = require( './fixtures/column_major_xnyp.json' ); +var cxpyp = require( './fixtures/column_major_xpyp.json' ); + +var rap = require( './fixtures/row_major_complex_access_pattern.json' ); +var rnt = require( './fixtures/row_major_nt.json' ); +var rt = require( './fixtures/row_major_t.json' ); +var roa = require( './fixtures/row_major_oa.json' ); +var rsa1sa2 = require( './fixtures/row_major_sa1_sa2.json' ); +var rsa1nsa2 = require( './fixtures/row_major_sa1n_sa2.json' ); +var rsa1sa2n = require( './fixtures/row_major_sa1_sa2n.json' ); +var rsa1nsa2n = require( './fixtures/row_major_sa1n_sa2n.json' ); +var rxnyn = require( './fixtures/row_major_xnyn.json' ); +var rxpyn = require( './fixtures/row_major_xpyn.json' ); +var rxnyp = require( './fixtures/row_major_xnyp.json' ); +var rxpyp = require( './fixtures/row_major_xpyp.json' ); + + +// VARIABLES // + +var sgemv = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( sgemv instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sgemv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 15', opts, function test( t ) { + t.strictEqual( sgemv.length, 15, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` (row-major, no-transpose)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rnt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` (column-major, no-transpose)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cnt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` (row-major, transpose)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` (column-major, transpose)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ct; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the second input vector (row-major)', opts, function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = rt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the second input vector (column-major)', opts, function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = ct; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + + t.end(); +}); + +tape( 'if either `M` or `N` is `0`, the function returns the second input vector unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y ); + + out = sgemv( data.trans, 0, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sgemv( data.trans, data.M, 0, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if either `M` or `N` is `0`, the function returns the second input vector unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ct; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y ); + + out = sgemv( data.trans, 0, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sgemv( data.trans, data.M, 0, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0` and `β` is `1`, the function returns the second input vector unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y ); + + out = sgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 1.0, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0` and `β` is `1`, the function returns the second input vector unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ct; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y ); + + out = sgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 1.0, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0`, the function scales the second input vector by `β` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y.length ); + + out = sgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 0.0, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0`, the function scales the second input vector by `β` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ct; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y.length ); + + out = sgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 0.0, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the strides of the first and second dimensions of `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1sa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the strides of the first and second dimensions of `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1sa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative stride for the first dimension of `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1nsa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative stride for the first dimension of `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1nsa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative stride for the second dimension of `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1sa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative stride for the second dimension of `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1sa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides for `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1nsa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides for `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1nsa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an offset parameter for `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = roa; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an offset parameter for `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = coa; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying negative strides for `x` and `y` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying negative strides for `x` and `y` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rap; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cap; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.native.js new file mode 100644 index 000000000000..7a6303e641d5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.native.js @@ -0,0 +1,519 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// FIXTURES // + +var cnt = require( './fixtures/column_major_nt.json' ); +var ct = require( './fixtures/column_major_t.json' ); +var cxnyn = require( './fixtures/column_major_xnyn.json' ); +var cxpyn = require( './fixtures/column_major_xpyn.json' ); +var cxnyp = require( './fixtures/column_major_xnyp.json' ); +var cxpyp = require( './fixtures/column_major_xpyp.json' ); + +var rnt = require( './fixtures/row_major_nt.json' ); +var rt = require( './fixtures/row_major_t.json' ); +var rxnyn = require( './fixtures/row_major_xnyn.json' ); +var rxpyn = require( './fixtures/row_major_xpyn.json' ); +var rxnyp = require( './fixtures/row_major_xnyp.json' ); +var rxpyp = require( './fixtures/row_major_xpyp.json' ); + + +// VARIABLES // + +var sgemv = tryRequire( resolve( __dirname, './../lib/sgemv.native.js' ) ); +var opts = { + 'skip': ( sgemv instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sgemv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 12', opts, function test( t ) { + t.strictEqual( sgemv.length, 12, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` (row-major, no-transpose)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rnt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` (column-major, no-transpose)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cnt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` (row-major, transpose)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` (column-major, transpose)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ct; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the second input vector (row-major)', opts, function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = rt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the second input vector (column-major)', opts, function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = ct; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'if either `M` or `N` is `0`, the function returns the second input vector unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y ); + + out = sgemv( data.order, data.trans, 0, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sgemv( data.order, data.trans, data.M, 0, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if either `M` or `N` is `0`, the function returns the second input vector unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ct; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y ); + + out = sgemv( data.order, data.trans, 0, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + out = sgemv( data.order, data.trans, data.M, 0, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0` and `β` is `1`, the function returns the second input vector unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y ); + + out = sgemv( data.order, data.trans, data.M, data.N, 0.0, a, data.lda, x, data.strideX, 1.0, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0` and `β` is `1`, the function returns the second input vector unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ct; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y ); + + out = sgemv( data.order, data.trans, data.M, data.N, 0.0, a, data.lda, x, data.strideX, 1.0, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0`, the function scales the second input vector by `β` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rt; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y.length ); + + out = sgemv( data.order, data.trans, data.M, data.N, 0.0, a, data.lda, x, data.strideX, 0.0, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `α` is `0`, the function scales the second input vector by `β` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ct; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y.length ); + + out = sgemv( data.order, data.trans, data.M, data.N, 0.0, a, data.lda, x, data.strideX, 0.0, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); From fc3895769c574fa58b5dcdca020fe271712ad9e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Fri, 16 May 2025 07:38:07 +0000 Subject: [PATCH 04/21] chore: update copyright years --- .../@stdlib/blas/base/sgemv/benchmark/benchmark.native.js | 2 +- .../blas/base/sgemv/benchmark/benchmark.ndarray.native.js | 2 +- lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/Makefile | 2 +- .../@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c | 2 +- lib/node_modules/@stdlib/blas/base/sgemv/binding.gyp | 2 +- lib/node_modules/@stdlib/blas/base/sgemv/examples/c/Makefile | 2 +- lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c | 2 +- lib/node_modules/@stdlib/blas/base/sgemv/include.gypi | 2 +- lib/node_modules/@stdlib/blas/base/sgemv/lib/native.js | 2 +- lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js | 2 +- lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js | 2 +- lib/node_modules/@stdlib/blas/base/sgemv/src/Makefile | 2 +- lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c | 2 +- lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c | 2 +- lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c | 2 +- .../@stdlib/blas/base/sgemv/test/test.ndarray.native.js | 2 +- .../@stdlib/blas/base/sgemv/test/test.sgemv.native.js | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.native.js index fa47355955af..38d6230aa482 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.native.js index 96a44b72f5b1..b337700ce44d 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/Makefile index 7280962b4c4d..cce2c865d7ad 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2020 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c index 23263e0d4ada..bcdcf66753f2 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/binding.gyp b/lib/node_modules/@stdlib/blas/base/sgemv/binding.gyp index 864d9109e892..08de71a2020e 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/binding.gyp +++ b/lib/node_modules/@stdlib/blas/base/sgemv/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2018 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/Makefile index ff5293d3059f..25ced822f96a 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/Makefile +++ b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2020 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c index 8968c90f03c7..a9d828b3849b 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/include.gypi b/lib/node_modules/@stdlib/blas/base/sgemv/include.gypi index f8b01bfb52cb..4217944b5d20 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/include.gypi +++ b/lib/node_modules/@stdlib/blas/base/sgemv/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2023 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/native.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/native.js index 426fa6b37a9e..f55cec5dd156 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js index 90d2a6c84195..53f3bcad0188 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js index e19a8c48303d..b571cbe2ba26 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/Makefile b/lib/node_modules/@stdlib/blas/base/sgemv/src/Makefile index dd720a3de8f2..7733b6180cb4 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/Makefile +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2020 The Stdlib Authors. +# Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c index 4947d365a509..624b4617614d 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c index 0febcdc7a737..ea78a35899c5 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c index ca19d29dd43a..e7010c83b2a0 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js index 2884db758c17..e75ac4cfa22b 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.native.js index 7a6303e641d5..f1f24cfd837e 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* Copyright (c) 2025 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. From a863ebe34fb20c0a94711bdaeeb2622a479d39fc Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 16 May 2025 13:19:09 +0530 Subject: [PATCH 05/21] chore: update package.json --- 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: passed - 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: 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 --- --- lib/node_modules/@stdlib/blas/base/sgemv/package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/package.json b/lib/node_modules/@stdlib/blas/base/sgemv/package.json index 78283b0e6817..9820518e416f 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/package.json +++ b/lib/node_modules/@stdlib/blas/base/sgemv/package.json @@ -14,11 +14,15 @@ } ], "main": "./lib", + "browser": "./lib/main.js", + "gypfile": true, "directories": { "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", + "include": "./include", "lib": "./lib", + "src": "./src", "test": "./test" }, "types": "./docs/types", From e2cdf0497e20b4742678b7acbfabd7c0f3424535 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Fri, 16 May 2025 13:36:40 +0530 Subject: [PATCH 06/21] chore: update benchmark --- 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: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: missing_dependencies - 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 --- --- .../blas/base/sgemv/benchmark/c/benchmark.length.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c index bcdcf66753f2..b79d52183f5b 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c @@ -104,10 +104,8 @@ static double benchmark1( int iterations, int len ) { double t; int i; - for ( i = 0; i < len; i++ ) { - x[ i ] = ( rand_float()*1.0f ) - 0.5f; - y[ i ] = ( rand_float()*1.0f ) - 0.5f; - } + stdlib_strided_sfill( len, 1.0f, x, 1 ); + stdlib_strided_sfill( len, 1.0f, y, 1 ); stdlib_strided_sfill( len*len, 1.0f, A, 1 ); t = tic(); for ( i = 0; i < iterations; i++ ) { @@ -139,10 +137,8 @@ static double benchmark2( int iterations, int len ) { double t; int i; - for ( i = 0; i < len; i++ ) { - x[ i ] = ( rand_float()*1.0f ) - 0.5f; - y[ i ] = ( rand_float()*1.0f ) - 0.5f; - } + stdlib_strided_sfill( len, 1.0f, x, 1 ); + stdlib_strided_sfill( len, 1.0f, y, 1 ); stdlib_strided_sfill( len*len, 1.0f, A, 1 ); t = tic(); for ( i = 0; i < iterations; i++ ) { From 893662b380505a5f26241bcdb08e3cb38f5f3638 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Fri, 16 May 2025 16:35:22 +0530 Subject: [PATCH 07/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c index ea78a35899c5..74a09e5653b9 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c @@ -35,7 +35,7 @@ * @param beta scalar constant * @param y second input vector * @param strideY `y` stride length -* @return output value +* @return output value */ void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *x, const CBLAS_INT strideX, const float beta, float *y, const CBLAS_INT strideY ) { CBLAS_INT xlen; From f65d213d2db182e06d20ca2606882893cb9f522f Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Fri, 16 May 2025 16:36:05 +0530 Subject: [PATCH 08/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c index b3444439793b..bec6742ea416 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c @@ -40,7 +40,7 @@ * @param y second input vector * @param strideY `y` stride length * @param offsetY starting index for `Y` -* @return output value +* @return output value */ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, float *y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { CBLAS_INT isrm; @@ -59,6 +59,7 @@ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M int64_t strides[] = { strideA1, strideA2 }; isrm = stdlib_ndarray_is_row_major( 2, strides ); + if ( M == 0 || N == 0 || ( alpha == 0.0f && beta == 1.0f ) ) { return; } From e1c0588aba8c7bec577600b10ed79073897c2d5f Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Fri, 16 May 2025 17:33:49 +0530 Subject: [PATCH 09/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/sgemv/lib/sgemv.native.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js index b571cbe2ba26..cbfd023eb1a0 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js @@ -42,13 +42,6 @@ var addon = require( './../src/addon.node' ); * @param {number} beta - scalar constant * @param {Float32Array} y - second input vector * @param {integer} strideY - `y` stride length -* @throws {TypeError} first argument must be a valid order -* @throws {TypeError} second argument must be a valid transpose operation -* @throws {RangeError} third argument must be a nonnegative integer -* @throws {RangeError} fourth argument must be a nonnegative integer -* @throws {RangeError} seventh argument must be greater than or equal to max(1,M) -* @throws {RangeError} ninth argument must be non-zero -* @throws {RangeError} twelfth argument must be non-zero * @returns {Float32Array} `y` * * @example From 68fdeaff29fda3f93f9be13047d44eba82a428b2 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Fri, 16 May 2025 17:34:17 +0530 Subject: [PATCH 10/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/sgemv/lib/ndarray.native.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js index 53f3bcad0188..97079c5d5e4f 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js @@ -44,11 +44,6 @@ var addon = require( './../src/addon.node' ); * @param {Float32Array} y - second input vector * @param {integer} strideY - `y` stride length * @param {NonNegativeInteger} offsetY - starting index for `y` -* @throws {TypeError} first argument must be a valid transpose operation -* @throws {RangeError} second argument must be a nonnegative integer -* @throws {RangeError} third argument must be a nonnegative integer -* @throws {RangeError} tenth argument must be non-zero -* @throws {RangeError} fourteenth argument must be non-zero * @returns {Float32Array} `y` * * @example From 01e5b66beb4e703036cd06e5cb4923cd0d64cc2b Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Fri, 16 May 2025 18:24:03 +0530 Subject: [PATCH 11/21] chore: remove whitespace Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c index bec6742ea416..350658ef6db2 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c @@ -59,7 +59,7 @@ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M int64_t strides[] = { strideA1, strideA2 }; isrm = stdlib_ndarray_is_row_major( 2, strides ); - + if ( M == 0 || N == 0 || ( alpha == 0.0f && beta == 1.0f ) ) { return; } From 54e6470a5181847959487a0ba27aeb7f9f2a37a4 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sat, 17 May 2025 00:12:46 +0530 Subject: [PATCH 12/21] chore: update parameter naming Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/sgemv/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/README.md b/lib/node_modules/@stdlib/blas/base/sgemv/README.md index bdeca07c48d6..a1b660b00c96 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/README.md +++ b/lib/node_modules/@stdlib/blas/base/sgemv/README.md @@ -234,7 +234,7 @@ The function accepts the following arguments: void c_sgemv( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *x, const CBLAS_INT strideX, const float beta, float *y, const CBLAS_INT strideY ) ``` -#### c_sgemv_ndarray( trans, M, N, alpha, \*A, sa1, sa2, oa, \*X, sx, ox, beta, \*Y, sy, oy ) +#### c_sgemv_ndarray( trans, M, N, alpha, \*A, strideA1, strideA2, offsetA, \*X, strideX, offsetX, beta, \*Y, strideY, offsetY ) Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix using indexing alternative semantics. @@ -255,9 +255,9 @@ The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of columns in the matrix `A`. - **alpha**: `[in] float` scalar. - **A**: `[inout] float*` input matrix. -- **sa1**: `[in] CBLAS_INT` stride of the first dimension of `A`. -- **sa2**: `[in] CBLAS_INT` stride of the second dimension of `A`. -- **oa**: `[in] CBLAS_INT` starting index for `A`. +- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A`. +- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **offsetA**: `[in] CBLAS_INT` starting index for `A`. - **X**: `[in] float*` first input vector. - **strideX**: `[in] CBLAS_INT` index increment for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. From 279a643b5b7452331353089624be7bdb697c002b Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 31 May 2025 14:02:53 +0530 Subject: [PATCH 13/21] chore: update implementation --- 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: 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../base/sgemv/benchmark/c/benchmark.length.c | 28 +- .../blas/base/sgemv/examples/c/example.c | 16 +- .../@stdlib/blas/base/sgemv/manifest.json | 258 +++++++++++++++--- .../@stdlib/blas/base/sgemv/src/sgemv.c | 14 +- .../@stdlib/blas/base/sgemv/src/sgemv_cblas.c | 34 +-- .../blas/base/sgemv/src/sgemv_ndarray.c | 32 +-- 6 files changed, 278 insertions(+), 104 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c index b79d52183f5b..5b4a247746d6 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c @@ -99,24 +99,24 @@ static float rand_float( void ) { static double benchmark1( int iterations, int len ) { double elapsed; float A[ len*len ]; - float x[ len ]; - float y[ len ]; + float X[ len ]; + float Y[ len ]; double t; int i; - stdlib_strided_sfill( len, 1.0f, x, 1 ); - stdlib_strided_sfill( len, 1.0f, y, 1 ); + stdlib_strided_sfill( len, 1.0f, X, 1 ); + stdlib_strided_sfill( len, 1.0f, Y, 1 ); stdlib_strided_sfill( len*len, 1.0f, A, 1 ); t = tic(); for ( i = 0; i < iterations; i++ ) { - c_sgemv( CblasRowMajor, CblasNoTrans, len, len, 1.0, A, len, x, 1, 1.0, y, 1 ); - if ( y[ 0 ] != y[ 0 ] ) { + c_sgemv( CblasRowMajor, CblasNoTrans, len, len, 1.0, A, len, X, 1, 1.0, Y, 1 ); + if ( Y[ 0 ] != Y[ 0 ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( y[ 0 ] != y[ 0 ] ) { + if ( Y[ 0 ] != Y[ 0 ] ) { printf( "should not return NaN\n" ); } return elapsed; @@ -132,24 +132,24 @@ static double benchmark1( int iterations, int len ) { static double benchmark2( int iterations, int len ) { double elapsed; float A[ len*len ]; - float x[ len ]; - float y[ len ]; + float X[ len ]; + float Y[ len ]; double t; int i; - stdlib_strided_sfill( len, 1.0f, x, 1 ); - stdlib_strided_sfill( len, 1.0f, y, 1 ); + stdlib_strided_sfill( len, 1.0f, X, 1 ); + stdlib_strided_sfill( len, 1.0f, Y, 1 ); stdlib_strided_sfill( len*len, 1.0f, A, 1 ); t = tic(); for ( i = 0; i < iterations; i++ ) { - c_sgemv_ndarray( CblasNoTrans, len, len, 1.0, A, len, 1, 0, x, 1, 0, 1.0, y, 1, 0 ); - if ( y[ 0 ] != y[ 0 ] ) { + c_sgemv_ndarray( CblasNoTrans, len, len, 1.0, A, len, 1, 0, X, 1, 0, 1.0, Y, 1, 0 ); + if ( Y[ 0 ] != Y[ 0 ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( y[ 0 ] != y[ 0 ] ) { + if ( Y[ 0 ] != Y[ 0 ] ) { printf( "should not return NaN\n" ); } return elapsed; diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c index a9d828b3849b..4a826a166eb3 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c @@ -23,26 +23,26 @@ int main( void ) { // Create a strided array: const float A[] = { 1.0f, 0.0f, 0.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f }; - const float x[] = { 1.0f, 2.0f, 3.0f }; - float y[] = { 1.0f, 2.0f, 3.0f }; + const float X[] = { 1.0f, 2.0f, 3.0f }; + float Y[] = { 1.0f, 2.0f, 3.0f }; // Specify the number of elements along each dimension of `A`: const int M = 3; const int N = 3; - // Perform the matrix-vector operations `y = α*A*x + β*y`: - c_sgemv( CblasRowMajor, CblasNoTrans, M, N, 1.0f, A, M, x, 1, 1.0f, y, 1 ); + // Perform the matrix-vector operations `Y = α*A*X + β*Y`: + c_sgemv( CblasRowMajor, CblasNoTrans, M, N, 1.0f, A, M, X, 1, 1.0f, Y, 1 ); // Print the result: for ( int i = 0; i < N; i++ ) { - printf( "y[ %i ] = %f\n", i, y[ i ] ); + printf( "Y[ %i ] = %f\n", i, Y[ i ] ); } - // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`: - c_sgemv_ndarray( CblasNoTrans, 3, 3, 1.0f, A, 3, 1, 0, x, 1, 0, 1.0f, y, 1, 0 ); + // Perform the symmetric rank 2 operation `A = α*X*Y^T + α*Y*X^T + A`: + c_sgemv_ndarray( CblasNoTrans, 3, 3, 1.0f, A, 3, 1, 0, X, 1, 0, 1.0f, Y, 1, 0 ); // Print the result: for ( int i = 0; i < N; i++ ) { - printf( "y[ %i ] = %f\n", i, y[ i ] ); + printf( "Y[ %i ] = %f\n", i, Y[ i ] ); } } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json b/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json index 22b19d864bcb..b33f04be73d6 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json @@ -30,11 +30,86 @@ "confs": [ { "task": "build", - "os": "win", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/ssyr.c", + "./src/ssyr_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-strided-float32array2d" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/ssyr.c", + "./src/ssyr_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/math/base/special/floorf" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/ssyr.c", + "./src/ssyr_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "linux", "blas": "openblas", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/ssyr_cblas.c" ], "include": [ "./include" @@ -46,22 +121,24 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-float", "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-strided-float32array2d", - "@stdlib/ndarray/base/assert/is-row-major" + "@stdlib/napi/argv-strided-float32array2d" ] }, { "task": "benchmark", - "os": "win", + "os": "linux", "blas": "openblas", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/ssyr_cblas.c" ], "include": [ "./include" @@ -72,16 +149,20 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/ext/base/sfill", + "@stdlib/math/base/special/floorf" ] }, { "task": "examples", - "os": "win", + "os": "linux", "blas": "openblas", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/ssyr_cblas.c" ], "include": [ "./include" @@ -92,7 +173,84 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/ssyr.c", + "./src/ssyr_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-strided-float32array2d" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/ssyr.c", + "./src/ssyr_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/math/base/special/floorf" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/ssyr.c", + "./src/ssyr_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, @@ -102,7 +260,7 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/ssyr_cblas.c" ], "include": [ "./include" @@ -113,13 +271,15 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-float", "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-strided-float32array2d", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-strided-float32array2d" ] }, { @@ -128,7 +288,7 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/ssyr_cblas.c" ], "include": [ "./include" @@ -138,16 +298,20 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/ext/base/sfill", + "@stdlib/math/base/special/floorf" ] }, { - "task": "examples", + "task": "examples", "os": "mac", "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/ssyr_cblas.c" ], "include": [ "./include" @@ -157,7 +321,9 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index" ] }, @@ -167,7 +333,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/ssyr_cblas.c" ], "include": [ "./include" @@ -179,13 +345,15 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-float", "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-strided-float32array2d", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-strided-float32array2d" ] }, { @@ -194,7 +362,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/ssyr_cblas.c" ], "include": [ "./include" @@ -205,7 +373,11 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/ext/base/sfill", + "@stdlib/math/base/special/floorf" ] }, { @@ -214,7 +386,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/ssyr_cblas.c" ], "include": [ "./include" @@ -225,18 +397,20 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index" ] }, { "task": "build", - "os": "linux", + "os": "win", "blas": "", "wasm": false, "src": [ - "./src/sgemv.c", - "./src/sgemv_ndarray.c" + "./src/ssyr.c", + "./src/ssyr_ndarray.c" ], "include": [ "./include" @@ -247,25 +421,25 @@ "@stdlib/blas/base/shared", "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-float", "@stdlib/napi/argv-strided-float32array", - "@stdlib/napi/argv-strided-float32array2d", - "@stdlib/napi/argv-double", - "@stdlib/strided/base/stride2offset", - "@stdlib/ndarray/base/assert/is-row-major" + "@stdlib/napi/argv-strided-float32array2d" ] }, { "task": "benchmark", - "os": "linux", + "os": "win", "blas": "", "wasm": false, "src": [ - "./src/sgemv.c", - "./src/sgemv_ndarray.c" + "./src/ssyr.c", + "./src/ssyr_ndarray.c" ], "include": [ "./include" @@ -276,19 +450,19 @@ "@stdlib/blas/base/shared", "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", - "@stdlib/math/base/special/floorf", "@stdlib/strided/base/stride2offset", - "@stdlib/ndarray/base/assert/is-row-major" + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/math/base/special/floorf" ] }, { "task": "examples", - "os": "linux", + "os": "win", "blas": "", "wasm": false, "src": [ - "./src/sgemv.c", - "./src/sgemv_ndarray.c" + "./src/ssyr.c", + "./src/ssyr_ndarray.c" ], "include": [ "./include" @@ -310,8 +484,8 @@ "blas": "", "wasm": true, "src": [ - "./src/sgemv.c", - "./src/sgemv_ndarray.c" + "./src/ssyr.c", + "./src/ssyr_ndarray.c" ], "include": [ "./include" diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c index 74a09e5653b9..3fee682cc4d7 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c @@ -21,7 +21,7 @@ #include "stdlib/strided/base/stride2offset.h" /** -* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. +* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. * * @param order storage layout * @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed @@ -30,14 +30,14 @@ * @param alpha scalar constant * @param A input matrix * @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param x first input vector -* @param strideX `x` stride length +* @param X first input vector +* @param strideX `X` stride length * @param beta scalar constant -* @param y second input vector -* @param strideY `y` stride length +* @param Y second input vector +* @param strideY `Y` stride length * @return output value */ -void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *x, const CBLAS_INT strideX, const float beta, float *y, const CBLAS_INT strideY ) { +void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, float *Y, const CBLAS_INT strideY ) { CBLAS_INT xlen; CBLAS_INT ylen; CBLAS_INT sa1; @@ -61,6 +61,6 @@ void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, } ox = stdlib_strided_stride2offset( xlen, strideX ); oy = stdlib_strided_stride2offset( ylen, strideY ); - API_SUFFIX(c_sgemv_ndarray)( trans, M, N, alpha, A, sa1, sa2, 0, x, strideX, ox, beta, y, strideY, oy ); + API_SUFFIX(c_sgemv_ndarray)( trans, M, N, alpha, A, sa1, sa2, 0, X, strideX, ox, beta, Y, strideY, oy ); return; } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c index e7010c83b2a0..ba484ab74e19 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c @@ -23,7 +23,7 @@ #include "stdlib/ndarray/base/min_view_buffer_index.h" /** -* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. +* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. * * @param order storage layout * @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed @@ -32,14 +32,14 @@ * @param alpha scalar constant * @param A input matrix * @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param x first input vector -* @param strideX `x` stride length +* @param X first input vector +* @param strideX `X` stride length * @param beta scalar constant -* @param y second input vector -* @param strideY `y` stride length +* @param Y second input vector +* @param strideY `Y` stride length * @return output value */ -float API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *x, const CBLAS_INT strideX, const float beta, const float *y, const CBLAS_INT strideY ) { +float API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, const float *Y, const CBLAS_INT strideY ) { CBLAS_INT sx = strideX; CBLAS_INT sy = strideY; if ( sx < 0 ) { @@ -48,11 +48,11 @@ float API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans if ( sy < 0 ) { sy = -sy; } - return API_SUFFIX(cblas_sgemv)( order, trans, M, N, alpha, A, LDA, x, sx, beta, y, sy ); + return API_SUFFIX(cblas_sgemv)( order, trans, M, N, alpha, A, LDA, X, sx, beta, Y, sy ); } /** -* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` using alternative indexing semantics, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. +* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y` using alternative indexing semantics, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. * * @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed * @param M number of rows in the matrix `A` @@ -62,16 +62,16 @@ float API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans * @param strideA1 stride of the first dimension of `A` * @param strideA1 stride of the second dimension of `A` * @param offsetA starting index for `A` -* @param x first input vector -* @param strideX `x` stride length -* @param offsetX starting index for `x` +* @param X first input vector +* @param strideX `X` stride length +* @param offsetX starting index for `X` * @param beta scalar constant -* @param y second input vector -* @param strideY `y` stride length +* @param Y second input vector +* @param strideY `Y` stride length * @param offsetY starting index for `Y` * @return output value */ -float API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, const float *y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { +float API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, const float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { CBLAS_INT sx = strideX; CBLAS_INT sy = strideY; if ( sx < 0 ) { @@ -80,10 +80,10 @@ float API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT if ( sy < 0 ) { sy = -sy; } - x += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer - y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer + X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer + Y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer const int64_t shape[] = { M, N }; const int64_t strides[] = { strideA1, strideA2 }; A += stdlib_ndarray_min_view_buffer_index( 2, shape, strides, offsetA ); // adjust array pointer - return API_SUFFIX(cblas_sgemv)( order, trans, M, N, alpha, A, LDA, x, sx, beta, y, sy ); + return API_SUFFIX(cblas_sgemv)( order, trans, M, N, alpha, A, LDA, X, sx, beta, Y, sy ); } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c index 350658ef6db2..1095017832f1 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c @@ -23,7 +23,7 @@ #include "stdlib/ndarray/base/assert/is_row_major.h" /** -* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` using alternative indexing semantics, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. +* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y` using alternative indexing semantics, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. * * @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed * @param M number of rows in the matrix `A` @@ -33,16 +33,16 @@ * @param strideA1 stride of the first dimension of `A` * @param strideA1 stride of the second dimension of `A` * @param offsetA starting index for `A` -* @param x first input vector -* @param strideX `x` stride length -* @param offsetX starting index for `x` +* @param X first input vector +* @param strideX `X` stride length +* @param offsetX starting index for `X` * @param beta scalar constant -* @param y second input vector -* @param strideY `y` stride length +* @param Y second input vector +* @param strideY `Y` stride length * @param offsetY starting index for `Y` * @return output value */ -void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, float *y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { +void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { CBLAS_INT isrm; CBLAS_INT xlen; CBLAS_INT ylen; @@ -79,33 +79,33 @@ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M ylen = N; } - // y = beta * y + // Y = beta * Y if ( beta != 1.0f ) { if ( beta == 0.0f ) { - stdlib_strided_sfill_ndarray( ylen, 0.0f, y, strideY, offsetY ); + stdlib_strided_sfill_ndarray( ylen, 0.0f, Y, strideY, offsetY ); } else { - c_sscal_ndarray( ylen, beta, y, strideY, offsetY ); + c_sscal_ndarray( ylen, beta, Y, strideY, offsetY ); } } if ( alpha == 0.0f ) { return; } - // Form: y = α*A*x + y + // Form: Y = α*A*X + Y if ( ( !isrm && trans == CblasNoTrans ) || ( isrm && trans != CblasNoTrans ) ) { ix1 = offsetX; for ( i1 = 0; i1 < xlen; i1++ ) { - tmp = alpha * x[ ix1 ]; + tmp = alpha * X[ ix1 ]; oa = offsetA + sa1 * i1; iy1 = offsetY; for ( i0 = 0; i0 < ylen; i0++ ) { - y[ iy1 ] += A[ oa + sa0 * i0 ] * tmp; + Y[ iy1 ] += A[ oa + sa0 * i0 ] * tmp; iy1 += strideY; } ix1 += strideX; } return; } - // Form: y = α*A^T*x + y + // Form: Y = α*A^T*X + Y // ( !isrm && trans !== 'no-transpose' ) || ( isrm && trans === 'no-transpose' ) iy1 = offsetY; @@ -114,10 +114,10 @@ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M ix1 = offsetX; oa = offsetA + sa1 * i1; for ( i0 = 0; i0 < xlen; i0++ ) { - tmp += A[ oa + sa0 * i0 ] * x[ ix1 ]; + tmp += A[ oa + sa0 * i0 ] * X[ ix1 ]; ix1 += strideX; } - y[ iy1 ] += alpha * tmp; + Y[ iy1 ] += alpha * tmp; iy1 += strideY; } return; From f300de5ddfab4659cc0bb1c5ca365820ce00b276 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 31 May 2025 14:04:26 +0530 Subject: [PATCH 14/21] chore: update implementation --- 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: 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 --- --- .../@stdlib/blas/base/sgemv/manifest.json | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json b/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json index b33f04be73d6..51e9c5162efd 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json @@ -34,8 +34,8 @@ "blas": "", "wasm": false, "src": [ - "./src/ssyr.c", - "./src/ssyr_ndarray.c" + "./src/sgemv.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -63,8 +63,8 @@ "blas": "", "wasm": false, "src": [ - "./src/ssyr.c", - "./src/ssyr_ndarray.c" + "./src/sgemv.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -86,8 +86,8 @@ "blas": "", "wasm": false, "src": [ - "./src/ssyr.c", - "./src/ssyr_ndarray.c" + "./src/sgemv.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -109,7 +109,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/ssyr_cblas.c" + "./src/sgemv_cblas.c" ], "include": [ "./include" @@ -138,7 +138,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/ssyr_cblas.c" + "./src/sgemv_cblas.c" ], "include": [ "./include" @@ -162,7 +162,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/ssyr_cblas.c" + "./src/sgemv_cblas.c" ], "include": [ "./include" @@ -185,8 +185,8 @@ "blas": "", "wasm": false, "src": [ - "./src/ssyr.c", - "./src/ssyr_ndarray.c" + "./src/sgemv.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -214,8 +214,8 @@ "blas": "", "wasm": false, "src": [ - "./src/ssyr.c", - "./src/ssyr_ndarray.c" + "./src/sgemv.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -237,8 +237,8 @@ "blas": "", "wasm": false, "src": [ - "./src/ssyr.c", - "./src/ssyr_ndarray.c" + "./src/sgemv.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -260,7 +260,7 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/ssyr_cblas.c" + "./src/sgemv_cblas.c" ], "include": [ "./include" @@ -288,7 +288,7 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/ssyr_cblas.c" + "./src/sgemv_cblas.c" ], "include": [ "./include" @@ -311,7 +311,7 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/ssyr_cblas.c" + "./src/sgemv_cblas.c" ], "include": [ "./include" @@ -333,7 +333,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/ssyr_cblas.c" + "./src/sgemv_cblas.c" ], "include": [ "./include" @@ -362,7 +362,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/ssyr_cblas.c" + "./src/sgemv_cblas.c" ], "include": [ "./include" @@ -386,7 +386,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/ssyr_cblas.c" + "./src/sgemv_cblas.c" ], "include": [ "./include" @@ -409,8 +409,8 @@ "blas": "", "wasm": false, "src": [ - "./src/ssyr.c", - "./src/ssyr_ndarray.c" + "./src/sgemv.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -438,8 +438,8 @@ "blas": "", "wasm": false, "src": [ - "./src/ssyr.c", - "./src/ssyr_ndarray.c" + "./src/sgemv.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -461,8 +461,8 @@ "blas": "", "wasm": false, "src": [ - "./src/ssyr.c", - "./src/ssyr_ndarray.c" + "./src/sgemv.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -484,8 +484,8 @@ "blas": "", "wasm": true, "src": [ - "./src/ssyr.c", - "./src/ssyr_ndarray.c" + "./src/sgemv.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" From 05da6e8a27fe98d512a61a0eefe1d3f6abe1a90c Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 31 May 2025 14:05:10 +0530 Subject: [PATCH 15/21] chore: update implementation --- 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: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: missing_dependencies - 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 --- --- .../blas/base/sgemv/benchmark/c/benchmark.length.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c index 5b4a247746d6..a74fee5f2b5d 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c @@ -79,16 +79,6 @@ static double tic( void ) { return (double)now.tv_sec + (double)now.tv_usec/1.0e6; } -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static float rand_float( void ) { - int r = rand(); - return (float)r / ( (float)RAND_MAX + 1.0f ); -} - /** * Runs a benchmark. * From fb6c27d4e25ebfffbceb6cbbf1eb5057af47877b Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 31 May 2025 15:48:15 +0530 Subject: [PATCH 16/21] chore: minor clean-up --- 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: 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 --- --- .../blas/base/sgemv/include/stdlib/blas/base/sgemv.h | 8 ++++---- .../base/sgemv/include/stdlib/blas/base/sgemv_cblas.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv.h b/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv.h index b8e1fb845b1f..594edcdc778d 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv.h +++ b/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv.h @@ -32,14 +32,14 @@ extern "C" { #endif /** -* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. +* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. */ -void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *x, const CBLAS_INT strideX, const float beta, float *y, const CBLAS_INT strideY ); +void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, float *Y, const CBLAS_INT strideY ); /** -* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix using alternative indexing semantics. +* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix using alternative indexing semantics. */ -void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, float *y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); +void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv_cblas.h b/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv_cblas.h index feeb28ec3fb9..6a2ebfe6c89e 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv_cblas.h @@ -32,9 +32,9 @@ extern "C" { #endif /** -* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. +* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. */ -void API_SUFFIX(cblas_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *x, const CBLAS_INT strideX, const float beta, float *y, const CBLAS_INT strideY ); +void API_SUFFIX(cblas_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, float *Y, const CBLAS_INT strideY ); #ifdef __cplusplus } From 5e5ae0d5a664a20d687dcf96e3914179839da313 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sat, 31 May 2025 16:41:46 +0530 Subject: [PATCH 17/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c index 4a826a166eb3..6d96cd5da54e 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c @@ -38,7 +38,7 @@ int main( void ) { printf( "Y[ %i ] = %f\n", i, Y[ i ] ); } - // Perform the symmetric rank 2 operation `A = α*X*Y^T + α*Y*X^T + A`: + // Perform the matrix-vector operations `Y = α*A*X + β*Y`: c_sgemv_ndarray( CblasNoTrans, 3, 3, 1.0f, A, 3, 1, 0, X, 1, 0, 1.0f, Y, 1, 0 ); // Print the result: From eadaa49673795cc367e3c986f9236daf713a54db Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 30 Jun 2025 18:26:54 +0530 Subject: [PATCH 18/21] chore: update implementation --- 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: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/sgemv/README.md | 104 +++--- .../blas/base/sgemv/benchmark/benchmark.js | 10 +- .../base/sgemv/benchmark/benchmark.native.js | 24 +- .../base/sgemv/benchmark/benchmark.ndarray.js | 11 +- .../benchmark/benchmark.ndarray.native.js | 24 +- .../base/sgemv/benchmark/c/benchmark.length.c | 78 +++-- .../@stdlib/blas/base/sgemv/docs/repl.txt | 12 +- .../blas/base/sgemv/examples/c/example.c | 26 +- .../sgemv/include/stdlib/blas/base/sgemv.h | 2 +- .../include/stdlib/blas/base/sgemv_cblas.h | 9 +- .../@stdlib/blas/base/sgemv/lib/base.js | 132 +++++--- .../blas/base/sgemv/lib/ndarray.native.js | 26 ++ .../@stdlib/blas/base/sgemv/lib/sgemv.js | 13 +- .../blas/base/sgemv/lib/sgemv.native.js | 43 +++ .../@stdlib/blas/base/sgemv/manifest.json | 109 ++++--- .../@stdlib/blas/base/sgemv/src/addon.c | 27 +- .../@stdlib/blas/base/sgemv/src/sgemv.c | 55 +++- .../@stdlib/blas/base/sgemv/src/sgemv_cblas.c | 63 +--- .../blas/base/sgemv/src/sgemv_ndarray.c | 131 +++++--- .../fixtures/column_major_alpha_zero.json | 20 ++ .../test/fixtures/column_major_x_zeros.json | 20 ++ .../column_major_x_zeros_beta_one.json | 20 ++ .../test/fixtures/row_major_alpha_zero.json | 20 ++ .../test/fixtures/row_major_x_zeros.json | 20 ++ .../fixtures/row_major_x_zeros_beta_one.json | 20 ++ .../blas/base/sgemv/test/test.ndarray.js | 110 ++++++- .../base/sgemv/test/test.ndarray.native.js | 306 +++++++++++++++--- .../blas/base/sgemv/test/test.sgemv.js | 116 ++++++- .../blas/base/sgemv/test/test.sgemv.native.js | 294 ++++++++++++++++- 29 files changed, 1447 insertions(+), 398 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/column_major_alpha_zero.json create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/column_major_x_zeros.json create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/column_major_x_zeros_beta_one.json create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/row_major_alpha_zero.json create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/row_major_x_zeros.json create mode 100644 lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/row_major_x_zeros_beta_one.json diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/README.md b/lib/node_modules/@stdlib/blas/base/sgemv/README.md index a1b660b00c96..5a90e93c2b62 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/README.md +++ b/lib/node_modules/@stdlib/blas/base/sgemv/README.md @@ -20,7 +20,7 @@ limitations under the License. # sgemv -> Perform one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`. +> Perform one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A**T*x + β*y`.
@@ -30,9 +30,9 @@ limitations under the License. var sgemv = require( '@stdlib/blas/base/sgemv' ); ``` -#### sgemv( ord, trans, M, N, α, A, LDA, x, sx, β, y, sy ) +#### sgemv( order, trans, M, N, α, A, LDA, x, sx, β, y, sy ) -Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. +Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A**T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -47,7 +47,7 @@ sgemv( 'row-major', 'no-transpose', 2, 3, 1.0, A, 3, x, 1, 1.0, y, 1 ); The function has the following parameters: -- **ord**: storage layout. +- **order**: storage layout. - **trans**: specifies whether `A` should be transposed, conjugate-transposed, or not transposed. - **M**: number of rows in the matrix `A`. - **N**: number of columns in the matrix `A`. @@ -55,10 +55,10 @@ The function has the following parameters: - **A**: input matrix stored in linear memory as a [`Float32Array`][mdn-float32array]. - **lda**: stride of the first dimension of `A` (leading dimension of `A`). - **x**: input [`Float32Array`][mdn-float32array]. -- **sx**: index increment for `x`. +- **sx**: stride length for `x`. - **β**: scalar constant. - **y**: output [`Float32Array`][mdn-float32array]. -- **sy**: index increment for `y`. +- **sy**: stride length for `y`. The stride parameters determine how operations are performed. For example, to iterate over every other element in `x` and `y`, @@ -97,7 +97,7 @@ sgemv( 'row-major', 'no-transpose', 2, 2, 1.0, A, 2, x1, -1, 1.0, y1, -1 ); #### sgemv.ndarray( trans, M, N, α, A, sa1, sa2, oa, x, sx, ox, β, y, sy, oy ) -Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, using alternative indexing semantics and where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. +Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A**T*x + β*y`, using alternative indexing semantics and where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -201,51 +201,51 @@ console.log( y ); #include "stdlib/blas/base/sgemv.h" ``` -#### c_sgemv( order, trans, M, N, alpha, \*A, LDA, \*X, strideX, beta, \*Y, strideY ) +#### c_sgemv( layout, trans, M, N, alpha, \*A, LDA, \*X, strideX, beta, \*Y, strideY ) Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. ```c #include "stdlib/blas/base/shared.h" -float A[] = { 1.0f, 0.0f, 0.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f }; -const float x[] = { 1.0f, 2.0f, 3.0f }; -const float y[] = { 1.0f, 2.0f, 3.0f }; +const float A[] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; +const float x[] = { 1.0, 2.0, 3.0 }; +float y[] = { 1.0, 2.0, 3.0 }; -c_sgemv( CblasColMajor, CblasNoTrans, 3, 3, 1.0f, A, 3, x, 1, 1.0f, y, 1 ); +c_sgemv( CblasColMajor, CblasNoTrans, 3, 3, 1.0, A, 3, x, 1, 1.0, y, 1 ); ``` The function accepts the following arguments: -- **order**: `[in] CBLAS_LAYOUT` storage layout. +- **layout**: `[in] CBLAS_LAYOUT` storage layout. - **trans**: `[in] CBLAS_TRANSPOSE` specifies whether `A` should be transposed, conjugate-transposed, or not transposed. - **M**: `[in] CBLAS_INT` number of rows in the matrix `A`. - **N**: `[in] CBLAS_INT` number of columns in the matrix `A`. -- **alpha**: `[in] float` scalar. -- **A**: `[inout] float*` input matrix. +- **alpha**: `[in] float` scalar constant. +- **A**: `[in] float*` input matrix. - **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **X**: `[in] float*` first input vector. -- **strideX**: `[in] CBLAS_INT` index increment for `X`. -- **beta**: `[in] float` scalar. -- **Y**: `[in] float*` second input vector. -- **strideY**: `[in] CBLAS_INT` index increment for `Y`. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **beta**: `[in] float` scalar constant. +- **Y**: `[inout] float*` second input vector. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. ```c -void c_sgemv( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *x, const CBLAS_INT strideX, const float beta, float *y, const CBLAS_INT strideY ) +void c_sgemv( const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, float *Y, const CBLAS_INT strideY ) ``` -#### c_sgemv_ndarray( trans, M, N, alpha, \*A, strideA1, strideA2, offsetA, \*X, strideX, offsetX, beta, \*Y, strideY, offsetY ) +#### c_sgemv_ndarray( trans, M, N, alpha, \*A, sa1, sa2, oa, \*X, sx, ox, beta, \*Y, sy, oy ) -Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix using indexing alternative semantics. +Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, using indexing alternative semantics and where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. ```c #include "stdlib/blas/base/shared.h" -float A[] = { 1.0f, 0.0f, 0.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f }; -const float x[] = { 1.0f, 2.0f, 3.0f }; -const float y[] = { 1.0f, 2.0f, 3.0f }; +const float A[] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; +const float x[] = { 1.0, 2.0, 3.0 }; +float y[] = { 1.0, 2.0, 3.0 }; -c_sgemv_ndarray( CblasNoTrans, 3, 3, 1.0f, A, 1, 3, 0, x, 1, 0, 1.0f, y, 1, 0 ); +c_sgemv_ndarray( CblasNoTrans, 3, 3, 1.0, A, 1, 3, 0, x, 1, 0, 1.0, y, 1, 0 ); ``` The function accepts the following arguments: @@ -253,21 +253,21 @@ The function accepts the following arguments: - **trans**: `[in] CBLAS_TRANSPOSE` specifies whether `A` should be transposed, conjugate-transposed, or not transposed. - **M**: `[in] CBLAS_INT` number of rows in the matrix `A`. - **N**: `[in] CBLAS_INT` number of columns in the matrix `A`. -- **alpha**: `[in] float` scalar. -- **A**: `[inout] float*` input matrix. -- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A`. -- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A`. -- **offsetA**: `[in] CBLAS_INT` starting index for `A`. +- **alpha**: `[in] float` scalar constant. +- **A**: `[in] float*` input matrix. +- **sa1**: `[in] CBLAS_INT` stride of the first dimension of `A`. +- **sa2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **oa**: `[in] CBLAS_INT` starting index for `A`. - **X**: `[in] float*` first input vector. -- **strideX**: `[in] CBLAS_INT` index increment for `X`. -- **offsetX**: `[in] CBLAS_INT` starting index for `X`. -- **beta**: `[in] float` scalar. -- **Y**: `[in] float*` second input vector. -- **strideY**: `[in] CBLAS_INT` index increment for `Y`. -- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. +- **sx**: `[in] CBLAS_INT` stride length for `X`. +- **ox**: `[in] CBLAS_INT` starting index for `X`. +- **beta**: `[in] float` scalar constant. +- **Y**: `[inout] float*` second input vector. +- **sy**: `[in] CBLAS_INT` stride length for `Y`. +- **oy**: `[in] CBLAS_INT` starting index for `Y`. ```c -void c_sgemv_ndarray( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, float *y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) +void c_sgemv_ndarray( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) ```
@@ -294,29 +294,35 @@ void c_sgemv_ndarray( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLA #include int main( void ) { - // Create a strided array: - const float A[] = { 1.0f, 0.0f, 0.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f }; - const float x[] = { 1.0f, 2.0f, 3.0f }; - float y[] = { 1.0f, 2.0f, 3.0f }; + // Define a 3x3 matrix stored in row-major order: + const float A[ 3*3 ] = { + 1.0, 2.0, 3.0, + 4.0, 5.0, 6.0, + 7.0, 8.0, 9.0 + }; + + // Define `x` and `y` vectors: + const float x[ 3 ] = { 1.0, 2.0, 3.0 }; + float y[ 3 ] = { 1.0, 2.0, 3.0 }; // Specify the number of elements along each dimension of `A`: const int M = 3; const int N = 3; - // Perform the matrix-vector operations `y = α*A*x + β*y`: - c_sgemv( CblasRowMajor, CblasNoTrans, M, N, 1.0f, A, M, x, 1, 1.0f, y, 1 ); + // Perform the matrix-vector operation `y = α*A*x + β*y`: + c_sgemv( CblasRowMajor, CblasNoTrans, M, N, 1.0, A, M, x, 1, 1.0, y, 1 ); // Print the result: for ( int i = 0; i < N; i++ ) { - printf( "y[ %i ] = %f\n", i, y[ i ] ); + printf( "y[ %i ] = %lf\n", i, y[ i ] ); } - // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`: - c_sgemv_ndarray( CblasNoTrans, 3, 3, 1.0f, A, 3, 1, 0, x, 1, 0, 1.0f, y, 1, 0 ); + // Perform the matrix-vector operation `y = α*A*x + β*y` using alternative indexing semantics: + c_sgemv_ndarray( CblasNoTrans, M, N, 1.0, A, N, 1, 0, x, 1, 0, 1.0, y, 1, 0 ); // Print the result: for ( int i = 0; i < N; i++ ) { - printf( "y[ %i ] = %f\n", i, y[ i ] ); + printf( "y[ %i ] = %lf\n", i, y[ i ] ); } } ``` @@ -343,7 +349,7 @@ int main( void ) { [blas]: http://www.netlib.org/blas -[blas-sgemv]: https://www.netlib.org/lapack/explore-html/d7/dda/group__gemv_ga0d35d880b663ad18204bb23bd186e380.html#ga0d35d880b663ad18204bb23bd186e380 +[blas-sgemv]: https://www.netlib.org/lapack/explore-html-3.6.1/d6/d30/group__single__blas__level2_gafc92361b74c6d41c7e5afa0aa5d13ec9.html [mdn-float32array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.js index 7a9017dbbb55..fe66a4027c88 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.js @@ -42,7 +42,7 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - array dimension size +* @param {PositiveInteger} N - array length * @returns {Function} benchmark function */ function createBenchmark( N ) { @@ -86,9 +86,9 @@ function createBenchmark( N ) { * @private */ function main() { - var len; var min; var max; + var N; var f; var i; @@ -96,9 +96,9 @@ function main() { max = 6; // 10^max for ( i = min; i <= max; i++ ) { - len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - f = createBenchmark( len ); - bench( pkg+':size='+(len*len), f ); + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':size='+(N*N), f ); } } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.native.js index 38d6230aa482..65f6c5d4e4e0 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var ones = require( '@stdlib/array/ones' ); var pow = require( '@stdlib/math/base/special/pow' ); -var floorf = require( '@stdlib/math/base/special/floorf' ); +var floor = require( '@stdlib/math/base/special/floor' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -47,13 +47,13 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} len - array length +* @param {PositiveInteger} N - array length * @returns {Function} benchmark function */ -function createBenchmark( len ) { - var x = ones( len, options.dtype ); - var y = ones( len, options.dtype ); - var A = ones( len*len, options.dtype ); +function createBenchmark( N ) { + var x = uniform( N, -10.0, 10.0, options ); + var y = uniform( N, -10.0, 10.0, options ); + var A = uniform( N*N, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { @@ -62,7 +62,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = sgemv( 'row-major', 'no-transpose', len, len, 1.0, A, len, x, 1, 1.0, y, 1 ); + z = sgemv( 'row-major', 'no-transpose', N, N, 1.0, A, N, x, 1, 1.0, y, 1 ); if ( isnanf( z ) ) { b.fail( 'should not return NaN' ); } @@ -87,7 +87,7 @@ function createBenchmark( len ) { function main() { var min; var max; - var len; + var N; var f; var i; @@ -95,9 +95,9 @@ function main() { max = 6; // 10^max for ( i = min; i <= max; i++ ) { - len = floorf( pow( pow( 10, i ), 1.0/2.0 ) ); - f = createBenchmark( len ); - bench( pkg+':size='+(len*len), opts, f ); + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+'::native:size='+(N*N), opts, f ); } } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.js index a456289dc424..65b56fc9010b 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.js @@ -1,3 +1,4 @@ + /** * @license Apache-2.0 * @@ -42,7 +43,7 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - array dimension size +* @param {PositiveInteger} N - array length * @returns {Function} benchmark function */ function createBenchmark( N ) { @@ -86,9 +87,9 @@ function createBenchmark( N ) { * @private */ function main() { - var len; var min; var max; + var N; var f; var i; @@ -96,9 +97,9 @@ function main() { max = 6; // 10^max for ( i = min; i <= max; i++ ) { - len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - f = createBenchmark( len ); - bench( pkg+':ndarray:size='+(len*len), f ); + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':ndarray:size='+(N*N), f ); } } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.native.js index b337700ce44d..22013d83bd58 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/benchmark.ndarray.native.js @@ -22,10 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var ones = require( '@stdlib/array/ones' ); var pow = require( '@stdlib/math/base/special/pow' ); -var floorf = require( '@stdlib/math/base/special/floorf' ); +var floor = require( '@stdlib/math/base/special/floor' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -47,13 +47,13 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} len - array length +* @param {PositiveInteger} N - array length * @returns {Function} benchmark function */ -function createBenchmark( len ) { - var x = ones( len, options.dtype ); - var y = ones( len, options.dtype ); - var A = ones( len*len, options.dtype ); +function createBenchmark( N ) { + var x = uniform( N, -10.0, 10.0, options ); + var y = uniform( N, -10.0, 10.0, options ); + var A = uniform( N*N, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { @@ -62,7 +62,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = sgemv( 'no-transpose', len, len, 1.0, A, len, 1, 0, x, 1, 0, 1.0, y, 1, 0 ); + z = sgemv( 'no-transpose', N, N, 1.0, A, N, 1, 0, x, 1, 0, 1.0, y, 1, 0 ); if ( isnanf( z ) ) { b.fail( 'should not return NaN' ); } @@ -87,7 +87,7 @@ function createBenchmark( len ) { function main() { var min; var max; - var len; + var N; var f; var i; @@ -95,9 +95,9 @@ function main() { max = 6; // 10^max for ( i = min; i <= max; i++ ) { - len = floorf( pow( pow( 10, i ), 1.0/2.0 ) ); - f = createBenchmark( len ); - bench( pkg+':size='+(len*len), opts, f ); + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+'::native:ndarray:size='+(N*N), opts, f ); } } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c index a74fee5f2b5d..59a3d32b0d0a 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/benchmark/c/benchmark.length.c @@ -17,8 +17,6 @@ */ #include "stdlib/blas/base/sgemv.h" -#include "stdlib/blas/ext/base/sfill.h" -#include "stdlib/math/base/special/floorf.h" #include #include #include @@ -79,34 +77,49 @@ static double tic( void ) { return (double)now.tv_sec + (double)now.tv_usec/1.0e6; } +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + /** * Runs a benchmark. * * @param iterations number of iterations -* @param len array length +* @param N array dimension size * @return elapsed time in seconds */ -static double benchmark1( int iterations, int len ) { +static double benchmark1( int iterations, int N ) { double elapsed; - float A[ len*len ]; - float X[ len ]; - float Y[ len ]; + float A[ N*N ]; + float x[ N ]; + float y[ N ]; double t; int i; + int j; - stdlib_strided_sfill( len, 1.0f, X, 1 ); - stdlib_strided_sfill( len, 1.0f, Y, 1 ); - stdlib_strided_sfill( len*len, 1.0f, A, 1 ); + for ( i = 0, j = 0; i < N; i++, j += 2 ) { + x[ i ] = ( rand_float()*20.0f ) - 10.0f; + y[ i ] = ( rand_float()*20.0f ) - 10.0f; + A[ j ] = ( rand_float()*20.0f ) - 10.0f; + A[ j+1 ] = ( rand_float()*20.0f ) - 10.0f; + } t = tic(); for ( i = 0; i < iterations; i++ ) { - c_sgemv( CblasRowMajor, CblasNoTrans, len, len, 1.0, A, len, X, 1, 1.0, Y, 1 ); - if ( Y[ 0 ] != Y[ 0 ] ) { + // cppcheck-suppress uninitvar + c_sgemv( CblasRowMajor, CblasNoTrans, N, N, 1.0f, A, N, x, 1, 1.0f, y, 1 ); + if ( y[ i%N ] != y[ i%N ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( Y[ 0 ] != Y[ 0 ] ) { + if ( y[ i%N ] != y[ i%N ] ) { printf( "should not return NaN\n" ); } return elapsed; @@ -116,30 +129,35 @@ static double benchmark1( int iterations, int len ) { * Runs a benchmark. * * @param iterations number of iterations -* @param len array length +* @param N array dimension size * @return elapsed time in seconds */ -static double benchmark2( int iterations, int len ) { +static double benchmark2( int iterations, int N ) { double elapsed; - float A[ len*len ]; - float X[ len ]; - float Y[ len ]; + float A[ N*N ]; + float x[ N ]; + float y[ N ]; double t; int i; + int j; - stdlib_strided_sfill( len, 1.0f, X, 1 ); - stdlib_strided_sfill( len, 1.0f, Y, 1 ); - stdlib_strided_sfill( len*len, 1.0f, A, 1 ); + for ( i = 0, j = 0; i < N; i++, j += 2 ) { + x[ i ] = ( rand_float()*20.0f ) - 10.0f; + y[ i ] = ( rand_float()*20.0f ) - 10.0f; + A[ j ] = ( rand_float()*20.0f ) - 10.0f; + A[ j+1 ] = ( rand_float()*20.0f ) - 10.0f; + } t = tic(); for ( i = 0; i < iterations; i++ ) { - c_sgemv_ndarray( CblasNoTrans, len, len, 1.0, A, len, 1, 0, X, 1, 0, 1.0, Y, 1, 0 ); - if ( Y[ 0 ] != Y[ 0 ] ) { + // cppcheck-suppress uninitvar + c_sgemv_ndarray( CblasNoTrans, N, N, 1.0f, A, N, 1, 0, x, 1, 0, 1.0f, y, 1, 0 ); + if ( y[ i%N ] != y[ i%N ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( Y[ 0 ] != Y[ 0 ] ) { + if ( y[ i%N ] != y[ i%N ] ){ printf( "should not return NaN\n" ); } return elapsed; @@ -152,7 +170,7 @@ int main( void ) { double elapsed; int count; int iter; - int len; + int N; int i; int j; @@ -162,19 +180,19 @@ int main( void ) { print_version(); count = 0; for ( i = MIN; i <= MAX; i++ ) { - len = stdlib_base_floorf( pow( pow( 10, i ), 1.0/2.0 ) ); + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); iter = ITERATIONS / pow( 10, i-1 ); for ( j = 0; j < REPEATS; j++ ) { count += 1; - printf( "# c::%s:len=%d\n", NAME, len ); - elapsed = benchmark1( iter, len ); + printf( "# c::%s:size=%d\n", NAME, N*N ); + elapsed = benchmark1( iter, N ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } for ( j = 0; j < REPEATS; j++ ) { count += 1; - printf( "# c::%s:ndarray:len=%d\n", NAME, len ); - elapsed = benchmark2( iter, len ); + printf( "# c::%s:ndarray:size=%d\n", NAME, N*N ); + elapsed = benchmark2( iter, N ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/sgemv/docs/repl.txt index 3e76116055fa..e80069e02432 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/sgemv/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( ord, trans, M, N, α, A, lda, x, sx, β, y, sy ) +{{alias}}( order, trans, M, N, α, A, lda, x, sx, β, y, sy ) Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A**T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. @@ -9,11 +9,11 @@ If `M` or `N` is equal to `0`, the function returns `y` unchanged. - If `α` equals `0` and β equals `1`, the function returns `y` unchanged. + If `α` equals `0` and `β` equals `1`, the function returns `y` unchanged. Parameters ---------- - ord: string + order: string Row-major (C-style) or column-major (Fortran-style) order. trans: string @@ -75,14 +75,14 @@ [ 8.0, 4.0 ] // Using typed array views: - > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0, 1.0 ] ); - > var y0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var x0 = new {{alias:@stdlib/array/float32}}( [ 0.0, 1.0, 1.0 ] ); + > var y0 = new {{alias:@stdlib/array/float32}}( [ 0.0, 1.0, 1.0 ] ); > A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var y1 = new {{alias:@stdlib/array/float32}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); > {{alias}}( ord, trans, 2, 2, 1.0, A, 2, x1, -1, 1.0, y1, -1 ); > y0 - [ 1.0, 8.0 ] + [ 0.0, 8.0, 4.0 ] {{alias}}.ndarray( trans, M, N, α, A, sa1, sa2, oa, x, sx, ox, β, y, sy, oy ) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c index 6d96cd5da54e..7bd04d4a398f 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/examples/c/example.c @@ -21,28 +21,34 @@ #include int main( void ) { - // Create a strided array: - const float A[] = { 1.0f, 0.0f, 0.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f }; - const float X[] = { 1.0f, 2.0f, 3.0f }; - float Y[] = { 1.0f, 2.0f, 3.0f }; + // Define a 3x3 matrix stored in row-major order: + const float A[ 3*3 ] = { + 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f + }; + + // Define `x` and `y` vectors: + const float x[ 3 ] = { 1.0f, 2.0f, 3.0f }; + float y[ 3 ] = { 1.0f, 2.0f, 3.0f }; // Specify the number of elements along each dimension of `A`: const int M = 3; const int N = 3; - // Perform the matrix-vector operations `Y = α*A*X + β*Y`: - c_sgemv( CblasRowMajor, CblasNoTrans, M, N, 1.0f, A, M, X, 1, 1.0f, Y, 1 ); + // Perform the matrix-vector operation `y = α*A*x + β*y`: + c_sgemv( CblasRowMajor, CblasNoTrans, M, N, 1.0f, A, M, x, 1, 1.0f, y, 1 ); // Print the result: for ( int i = 0; i < N; i++ ) { - printf( "Y[ %i ] = %f\n", i, Y[ i ] ); + printf( "y[ %i ] = %f\n", i, y[ i ] ); } - // Perform the matrix-vector operations `Y = α*A*X + β*Y`: - c_sgemv_ndarray( CblasNoTrans, 3, 3, 1.0f, A, 3, 1, 0, X, 1, 0, 1.0f, Y, 1, 0 ); + // Perform the matrix-vector operation `y = α*A*x + β*y` using alternative indexing semantics: + c_sgemv_ndarray( CblasNoTrans, M, N, 1.0f, A, N, 1, 0, x, 1, 0, 1.0f, y, 1, 0 ); // Print the result: for ( int i = 0; i < N; i++ ) { - printf( "Y[ %i ] = %f\n", i, Y[ i ] ); + printf( "y[ %i ] = %f\n", i, y[ i ] ); } } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv.h b/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv.h index 594edcdc778d..3eebebdf1322 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv.h +++ b/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv.h @@ -34,7 +34,7 @@ extern "C" { /** * Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. */ -void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, float *Y, const CBLAS_INT strideY ); +void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, float *Y, const CBLAS_INT strideY ); /** * Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix using alternative indexing semantics. diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv_cblas.h b/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv_cblas.h index 6a2ebfe6c89e..fefa1347ca06 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/sgemv/include/stdlib/blas/base/sgemv_cblas.h @@ -17,7 +17,7 @@ */ /** -* Header file containing function declarations for the C interface to the CBLAS Level 2 routine `cblas_sgemv`. +* Header file containing function declarations for the C interface to the BLAS Level 2 routine `sgemv`. */ #ifndef SGEMV_CBLAS_H #define SGEMV_CBLAS_H @@ -34,7 +34,12 @@ extern "C" { /** * Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. */ -void API_SUFFIX(cblas_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, float *Y, const CBLAS_INT strideY ); +void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, float *Y, const CBLAS_INT strideY ); + +/** +* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix using alternative indexing semantics. +*/ +void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/base.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/base.js index aa81ed849fa4..a941c7a171f5 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/base.js @@ -21,9 +21,34 @@ // MODULES // var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); -var sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; -var sscal = require( '@stdlib/blas/base/sscal' ).ndarray; -var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; +var dscal = require( '@stdlib/blas/base/dscal' ).ndarray; + + +// FUNCTIONS // + +/** +* Tests whether a provided string indicates to transpose a matrix. +* +* @private +* @param {string} str - input string +* @returns {boolean} boolean indicating whether to transpose a matrix +* +* @example +* var bool = isTransposed( 'transpose' ); +* // returns true +* +* @example +* var bool = isTransposed( 'conjugate-transpose' ); +* // returns true +* +* @example +* var bool = isTransposed( 'no-transpose' ); +* // returns false +*/ +function isTransposed( str ) { // TODO: consider moving to a separate helper utility package + return ( str !== 'no-transpose' ); +} // MAIN // @@ -64,76 +89,91 @@ function sgemv( trans, M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, var xlen; var ylen; var tmp; - var ix1; - var iy1; - var sa0; - var sa1; + var da0; + var da1; + var ix; + var iy; + var ia; var i1; var i0; - var oa; - // Note on variable naming convention: sa#, ix#, i# where # corresponds to the loop number, with `0` being the innermost loop... + // Note on variable naming convention: da#, i# where # corresponds to the loop number, with `0` being the innermost loop... isrm = isRowMajor( [ strideA1, strideA2 ] ); - if ( isrm ) { - // For row-major matrices, the last dimension has the fastest changing index... - sa0 = strideA2; // stride for innermost loop - sa1 = strideA1; // stride for outermost loop - } else { // isColMajor - // For column-major matrices, the first dimension has the fastest changing index... - sa0 = strideA1; // stride for innermost loop - sa1 = strideA2; // stride for outermost loop - } - if ( trans === 'no-transpose' ) { - xlen = N; - ylen = M; - } else { + if ( isTransposed( trans ) ) { xlen = M; ylen = N; + } else { + xlen = N; + ylen = M; } // y = beta*y - if ( beta !== 1.0 ) { - if ( beta === 0.0 ) { - sfill( ylen, 0.0, y, strideY, offsetY ); - } else { - sscal( ylen, beta, y, strideY, offsetY ); - } + if ( beta === 0.0 ) { + dfill( ylen, 0.0, y, strideY, offsetY ); + } else if ( beta !== 1.0 ) { + dscal( ylen, beta, y, strideY, offsetY ); } if ( alpha === 0.0 ) { return y; } // Form: y = α*A*x + y if ( - ( !isrm && trans === 'no-transpose' ) || - ( isrm && trans !== 'no-transpose' ) + ( !isrm && !isTransposed( trans ) ) || + ( isrm && isTransposed( trans ) ) ) { - ix1 = offsetX; + if ( isrm ) { + // For row-major matrices, the last dimension has the fastest changing index... + da0 = strideA2; // offset increment for innermost loop + da1 = strideA1 - ( ylen*strideA2 ); // offset increment for outermost loop + } else { // isColMajor + // For column-major matrices, the first dimension has the fastest changing index... + da0 = strideA1; // offset increment for innermost loop + da1 = strideA2 - ( ylen*strideA1 ); // offset increment for outermost loop + } + ia = offsetA; + ix = offsetX; for ( i1 = 0; i1 < xlen; i1++ ) { - tmp = f32( alpha * x[ ix1 ] ); - oa = offsetA + (sa1*i1); - iy1 = offsetY; - for ( i0 = 0; i0 < ylen; i0++ ) { - y[ iy1 ] += f32( A[ oa+(sa0*i0) ] * tmp ); - iy1 += strideY; + tmp = alpha * x[ ix ]; + if ( tmp === 0.0 ) { + ia += da0 * ylen; + } else { + iy = offsetY; + for ( i0 = 0; i0 < ylen; i0++ ) { + y[ iy ] += A[ ia ] * tmp; + iy += strideY; + ia += da0; + } } - ix1 += strideX; + ix += strideX; + ia += da1; } return y; } // Form: y = α*A^T*x + y - // ( !isrm && trans !== 'no-transpose' ) || ( isrm && trans === 'no-transpose' ) - iy1 = offsetY; + // ( !isrm && isTransposed( trans ) ) || ( isrm && !isTransposed( trans ) ) + if ( isrm ) { + // For row-major matrices, the last dimension has the fastest changing index... + da0 = strideA2; // offset increment for innermost loop + da1 = strideA1 - ( xlen*strideA2 ); // offset increment for outermost loop + } else { // isColMajor + // For column-major matrices, the first dimension has the fastest changing index... + da0 = strideA1; // offset increment for innermost loop + da1 = strideA2 - ( xlen*strideA1 ); // offset increment for outermost loop + } + ia = offsetA; + iy = offsetY; for ( i1 = 0; i1 < ylen; i1++ ) { tmp = 0.0; - ix1 = offsetX; - oa = offsetA + (sa1*i1); + ix = offsetX; for ( i0 = 0; i0 < xlen; i0++ ) { - tmp += f32( A[ oa+(sa0*i0) ] * x[ ix1 ] ); - ix1 += strideX; + tmp += A[ ia ] * x[ ix ]; + ix += strideX; + ia += da0; } - y[ iy1 ] += f32( alpha * tmp ); - iy1 += strideY; + y[ iy ] += alpha * tmp; + iy += strideY; + ia += da1; } return y; } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js index 97079c5d5e4f..5174e7339ac8 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/ndarray.native.js @@ -20,7 +20,9 @@ // MODULES // +var isMatrixTranspose = require( '@stdlib/blas/base/assert/is-transpose-operation' ); var resolveTrans = require( '@stdlib/blas/base/transpose-operation-resolve-enum' ); +var format = require( '@stdlib/string/format' ); var addon = require( './../src/addon.node' ); @@ -44,6 +46,11 @@ var addon = require( './../src/addon.node' ); * @param {Float32Array} y - second input vector * @param {integer} strideY - `y` stride length * @param {NonNegativeInteger} offsetY - starting index for `y` +* @throws {TypeError} first argument must be a valid transpose operation +* @throws {RangeError} second argument must be a nonnegative integer +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} tenth argument must be non-zero +* @throws {RangeError} fourteenth argument must be non-zero * @returns {Float32Array} `y` * * @example @@ -57,6 +64,25 @@ var addon = require( './../src/addon.node' ); * // y => [ 7.0, 16.0 ] */ function sgemv( trans, M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, offsetX, beta, y, strideY, offsetY ) { // eslint-disable-line max-params, max-len + if ( !isMatrixTranspose( trans ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid transpose operation. Value: `%s`.', trans ) ); + } + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Tenth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( strideY === 0 ) { + throw new RangeError( format( 'invalid argument. Fourteenth argument must be non-zero. Value: `%d`.', strideY ) ); + } + // Check if we can early return... + if ( M === 0 || N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { + return y; + } addon.ndarray( resolveTrans( trans ), M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, offsetX, beta, y, strideY, offsetY ); // eslint-disable-line max-len return y; } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.js index 2b963fbb3a96..b0fc88cdf8f7 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.js @@ -1,3 +1,4 @@ + /** * @license Apache-2.0 * @@ -20,11 +21,11 @@ // MODULES // -var max = require( '@stdlib/math/base/special/fast/max' ); -var stride2offset = require( '@stdlib/strided/base/stride2offset' ); var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var isMatrixTranspose = require( '@stdlib/blas/base/assert/is-transpose-operation' ); var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var max = require( '@stdlib/math/base/special/fast/max' ); var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); @@ -50,7 +51,7 @@ var base = require( './base.js' ); * @throws {TypeError} second argument must be a valid transpose operation * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} fourth argument must be a nonnegative integer -* @throws {RangeError} seventh argument must be greater than or equal to max(1,M) +* @throws {RangeError} seventh argument must be a valid stride * @throws {RangeError} ninth argument must be non-zero * @throws {RangeError} twelfth argument must be non-zero * @returns {Float32Array} `y` @@ -75,7 +76,6 @@ function sgemv( order, trans, M, N, alpha, A, LDA, x, strideX, beta, y, strideY var ox; var oy; - iscm = isColumnMajor( order ); if ( !isLayout( order ) ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } @@ -88,6 +88,7 @@ function sgemv( order, trans, M, N, alpha, A, LDA, x, strideX, beta, y, strideY if ( N < 0 ) { throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) ); } + iscm = isColumnMajor( order ); if ( iscm ) { vala = M; } else { @@ -97,10 +98,10 @@ function sgemv( order, trans, M, N, alpha, A, LDA, x, strideX, beta, y, strideY throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to max(1,%d). Value: `%d`.', vala, LDA ) ); } if ( strideX === 0 ) { - throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero.' ) ); + throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) ); } if ( strideY === 0 ) { - throw new RangeError( format( 'invalid argument. Twelfth argument must be non-zero.' ) ); + throw new RangeError( format( 'invalid argument. Twelfth argument must be non-zero. Value: `%d`.', strideY ) ); } // Check if we can early return... if ( M === 0 || N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js index cbfd023eb1a0..772646b2d089 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/sgemv.native.js @@ -20,8 +20,13 @@ // MODULES // +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTranspose = require( '@stdlib/blas/base/assert/is-transpose-operation' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var max = require( '@stdlib/math/base/special/fast/max' ); var resolveOrder = require( '@stdlib/blas/base/layout-resolve-enum' ); var resolveTrans = require( '@stdlib/blas/base/transpose-operation-resolve-enum' ); +var format = require( '@stdlib/string/format' ); var addon = require( './../src/addon.node' ); @@ -42,6 +47,13 @@ var addon = require( './../src/addon.node' ); * @param {number} beta - scalar constant * @param {Float32Array} y - second input vector * @param {integer} strideY - `y` stride length +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must be a valid transpose operation +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} fourth argument must be a nonnegative integer +* @throws {RangeError} seventh argument must be a valid stride +* @throws {RangeError} ninth argument must be non-zero +* @throws {RangeError} twelfth argument must be non-zero * @returns {Float32Array} `y` * * @example @@ -55,6 +67,37 @@ var addon = require( './../src/addon.node' ); * // y => [ 7.0, 16.0 ] */ function sgemv( order, trans, M, N, alpha, A, LDA, x, strideX, beta, y, strideY ) { // eslint-disable-line max-params, max-len + var vala; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isMatrixTranspose( trans ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a valid transpose operation. Value: `%s`.', trans ) ); + } + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( strideY === 0 ) { + throw new RangeError( format( 'invalid argument. Twelfth argument must be non-zero. Value: `%d`.', strideY ) ); + } + if ( isColumnMajor( order ) ) { + vala = M; + } else { + vala = N; + } + if ( LDA < max( 1, vala ) ) { + throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to max(1,%d). Value: `%d`.', vala, LDA ) ); + } + // Check if we can early return... + if ( M === 0 || N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { + return y; + } addon( resolveOrder( order ), resolveTrans( trans ), M, N, alpha, A, LDA, x, strideX, beta, y, strideY ); // eslint-disable-line max-len return y; } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json b/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json index 51e9c5162efd..93305f7c2bc9 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/sgemv/manifest.json @@ -44,6 +44,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", "@stdlib/strided/base/stride2offset", @@ -73,11 +74,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", "@stdlib/strided/base/stride2offset", - "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/math/base/special/floorf" + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -96,6 +97,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", "@stdlib/strided/base/stride2offset", @@ -109,7 +111,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/sgemv_cblas.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -121,8 +124,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -138,7 +144,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/sgemv_cblas.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -150,10 +157,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", - "@stdlib/math/base/special/floorf" + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -162,7 +170,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/sgemv_cblas.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -174,8 +183,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index" + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, @@ -195,6 +207,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", "@stdlib/strided/base/stride2offset", @@ -224,11 +237,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", "@stdlib/strided/base/stride2offset", - "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/math/base/special/floorf" + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -247,6 +260,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", "@stdlib/strided/base/stride2offset", @@ -260,7 +274,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/sgemv_cblas.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -271,8 +286,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -288,7 +306,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/sgemv_cblas.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -299,10 +318,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", - "@stdlib/math/base/special/floorf" + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -311,7 +331,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/sgemv_cblas.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -322,8 +343,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index" + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, @@ -333,7 +357,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/sgemv_cblas.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -345,8 +370,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -362,7 +390,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/sgemv_cblas.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -374,10 +403,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", - "@stdlib/math/base/special/floorf" + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -386,7 +416,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/sgemv_cblas.c" + "./src/sgemv_cblas.c", + "./src/sgemv_ndarray.c" ], "include": [ "./include" @@ -398,8 +429,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index" + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/sscal", + "@stdlib/blas/ext/base/sfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, @@ -419,6 +453,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", "@stdlib/strided/base/stride2offset", @@ -448,11 +483,11 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", "@stdlib/strided/base/stride2offset", - "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/math/base/special/floorf" + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -471,6 +506,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", "@stdlib/strided/base/stride2offset", @@ -494,6 +530,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/base/sscal", "@stdlib/blas/ext/base/sfill", "@stdlib/strided/base/stride2offset", diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c index 624b4617614d..02eefc748e3b 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/addon.c @@ -35,9 +35,14 @@ * @return Node-API value */ static napi_value addon( napi_env env, napi_callback_info info ) { + CBLAS_INT xlen; + CBLAS_INT ylen; + CBLAS_INT sa1; + CBLAS_INT sa2; + STDLIB_NAPI_ARGV( env, info, argv, argc, 12 ); - STDLIB_NAPI_ARGV_INT32( env, order, argv, 0 ); + STDLIB_NAPI_ARGV_INT32( env, layout, argv, 0 ); STDLIB_NAPI_ARGV_INT32( env, trans, argv, 1 ); STDLIB_NAPI_ARGV_INT64( env, M, argv, 2 ); @@ -49,11 +54,6 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_FLOAT( env, alpha, argv, 4 ); STDLIB_NAPI_ARGV_FLOAT( env, beta, argv, 9 ); - CBLAS_INT xlen; - CBLAS_INT ylen; - CBLAS_INT sa1; - CBLAS_INT sa2; - if ( trans == CblasNoTrans ) { xlen = N; ylen = M; @@ -61,19 +61,18 @@ static napi_value addon( napi_env env, napi_callback_info info ) { xlen = M; ylen = N; } - if ( order == CblasColMajor ) { + if ( layout == CblasColMajor ) { sa1 = 1; sa2 = LDA; - } else { // order === 'row-major' + } else { // layout === CblasRowMajor sa1 = LDA; sa2 = 1; } - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, xlen, strideX, argv, 7 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, ylen, strideY, argv, 10 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( env, A, M, N, sa1, sa2, argv, 5 ); - API_SUFFIX(c_sgemv)( order, trans, M, N, alpha, A, LDA, X, strideX, beta, Y, strideY ); + API_SUFFIX(c_sgemv)( layout, trans, M, N, alpha, A, LDA, X, strideX, beta, Y, strideY ); return NULL; } @@ -86,6 +85,9 @@ static napi_value addon( napi_env env, napi_callback_info info ) { * @return Node-API value */ static napi_value addon_method( napi_env env, napi_callback_info info ) { + CBLAS_INT xlen; + CBLAS_INT ylen; + STDLIB_NAPI_ARGV( env, info, argv, argc, 15 ); STDLIB_NAPI_ARGV_INT32( env, trans, argv, 0 ); @@ -103,9 +105,6 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_FLOAT( env, alpha, argv, 3 ); STDLIB_NAPI_ARGV_FLOAT( env, beta, argv, 11 ); - CBLAS_INT xlen; - CBLAS_INT ylen; - if ( trans == CblasNoTrans ) { xlen = N; ylen = M; @@ -113,7 +112,6 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { xlen = M; ylen = N; } - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, xlen, strideX, argv, 8 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, ylen, strideY, argv, 12 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( env, A, M, N, strideA1, strideA2, argv, 4 ); @@ -124,4 +122,3 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { } STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) - diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c index 3fee682cc4d7..3d56bd4a2d3a 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c @@ -18,12 +18,13 @@ #include "stdlib/blas/base/sgemv.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/xerbla.h" #include "stdlib/strided/base/stride2offset.h" /** * Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. * -* @param order storage layout +* @param layout storage layout * @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed * @param M number of rows in the matrix `A` * @param N number of columns in the matrix `A` @@ -37,14 +38,60 @@ * @param strideY `Y` stride length * @return output value */ -void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, float *Y, const CBLAS_INT strideY ) { +void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, float *Y, const CBLAS_INT strideY ) { + CBLAS_INT vala; CBLAS_INT xlen; CBLAS_INT ylen; CBLAS_INT sa1; CBLAS_INT sa2; CBLAS_INT ox; CBLAS_INT oy; + CBLAS_INT v; + // Perform input argument validation... + if ( layout != CblasRowMajor && layout != CblasColMajor ) { + c_xerbla( 1, "c_sgemv", "Error: invalid argument. First argument must be a valid storage layout. Value: `%d`.", layout ); + return; + } + if ( trans != CblasTrans && trans != CblasConjTrans && trans != CblasNoTrans ) { + c_xerbla( 2, "c_sgemv", "Error: invalid argument. Second argument must be a valid transpose operation. Value: `%d`.", trans ); + return; + } + if ( M < 0 ) { + c_xerbla( 3, "c_sgemv", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", M ); + return; + } + if ( N < 0 ) { + c_xerbla( 4, "c_sgemv", "Error: invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 9, "c_sgemv", "Error: invalid argument. Ninth argument must be a nonzero. Value: `%d`.", strideX ); + return; + } + if ( strideY == 0 ) { + c_xerbla( 12, "c_sgemv", "Error: invalid argument. Twelfth argument must be a nonzero. Value: `%d`.", strideY ); + return; + } + if ( layout == CblasColMajor ) { + v = M; + } else { + v = N; + } + // max(1, v) + if ( v < 1 ) { + vala = 1; + } else { + vala = v; + } + if ( LDA < v ) { + c_xerbla( 10, "c_sgemv", "Error: invalid argument. Seventh argument must be greater than or equal to max(1,%d). Value: `%d`.", vala, LDA ); + return; + } + // Check if we can early return... + if ( M == 0 || N == 0 || ( alpha == 0.0 && beta == 1.0 ) ) { + return; + } if ( trans == CblasNoTrans ) { xlen = N; ylen = M; @@ -52,10 +99,10 @@ void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, xlen = M; ylen = N; } - if ( order == CblasColMajor ) { + if ( layout == CblasColMajor ) { sa1 = 1; sa2 = LDA; - } else { // order === 'row-major' + } else { // layout === CblasRowMajor sa1 = LDA; sa2 = 1; } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c index ba484ab74e19..1cf00d2eac19 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c @@ -19,71 +19,24 @@ #include "stdlib/blas/base/sgemv.h" #include "stdlib/blas/base/sgemv_cblas.h" #include "stdlib/blas/base/shared.h" -#include "stdlib/strided/base/min_view_buffer_index.h" -#include "stdlib/ndarray/base/min_view_buffer_index.h" /** -* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. +* Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. * -* @param order storage layout +* @param layout storage layout * @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed * @param M number of rows in the matrix `A` * @param N number of columns in the matrix `A` * @param alpha scalar constant * @param A input matrix * @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param X first input vector -* @param strideX `X` stride length +* @param x first input vector +* @param strideX `x` stride length * @param beta scalar constant -* @param Y second input vector -* @param strideY `Y` stride length +* @param y second input vector +* @param strideY `y` stride length * @return output value */ -float API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT order, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, const float *Y, const CBLAS_INT strideY ) { - CBLAS_INT sx = strideX; - CBLAS_INT sy = strideY; - if ( sx < 0 ) { - sx = -sx; - } - if ( sy < 0 ) { - sy = -sy; - } - return API_SUFFIX(cblas_sgemv)( order, trans, M, N, alpha, A, LDA, X, sx, beta, Y, sy ); -} - -/** -* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y` using alternative indexing semantics, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. -* -* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed -* @param M number of rows in the matrix `A` -* @param N number of columns in the matrix `A` -* @param alpha scalar constant -* @param A input matrix -* @param strideA1 stride of the first dimension of `A` -* @param strideA1 stride of the second dimension of `A` -* @param offsetA starting index for `A` -* @param X first input vector -* @param strideX `X` stride length -* @param offsetX starting index for `X` -* @param beta scalar constant -* @param Y second input vector -* @param strideY `Y` stride length -* @param offsetY starting index for `Y` -* @return output value -*/ -float API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, const float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { - CBLAS_INT sx = strideX; - CBLAS_INT sy = strideY; - if ( sx < 0 ) { - sx = -sx; - } - if ( sy < 0 ) { - sy = -sy; - } - X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer - Y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer - const int64_t shape[] = { M, N }; - const int64_t strides[] = { strideA1, strideA2 }; - A += stdlib_ndarray_min_view_buffer_index( 2, shape, strides, offsetA ); // adjust array pointer - return API_SUFFIX(cblas_sgemv)( order, trans, M, N, alpha, A, LDA, X, sx, beta, Y, sy ); +void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, const float *Y, const CBLAS_INT strideY ) { + API_SUFFIX(cblas_sgemv)( layout, trans, M, N, alpha, A, LDA, X, strideX, beta, Y, strideY ); } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c index 1095017832f1..01d33828ee1c 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c @@ -18,12 +18,13 @@ #include "stdlib/blas/base/sgemv.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/xerbla.h" #include "stdlib/blas/base/sscal.h" #include "stdlib/blas/ext/base/sfill.h" #include "stdlib/ndarray/base/assert/is_row_major.h" /** -* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y` using alternative indexing semantics, where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. +* Performs one of the matrix-vector operations `Y = α*A*X + β*Y` or `Y = α*A^T*X + β*Y`, using alternative indexing semantics and where `α` and `β` are scalars, `X` and `Y` are vectors, and `A` is an `M` by `N` matrix. * * @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed * @param M number of rows in the matrix `A` @@ -43,34 +44,50 @@ * @return output value */ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float beta, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { + int64_t sa[ 2 ]; CBLAS_INT isrm; CBLAS_INT xlen; CBLAS_INT ylen; - CBLAS_INT ix1; - CBLAS_INT iy1; - CBLAS_INT sa0; - CBLAS_INT sa1; + CBLAS_INT da0; + CBLAS_INT da1; + CBLAS_INT ix; + CBLAS_INT iy; + CBLAS_INT ia; CBLAS_INT i0; CBLAS_INT i1; - CBLAS_INT oa; float tmp; - // Note on variable naming convention: sa#, ix#, i# where # corresponds to the loop number, with `0` being the innermost loop... + // Note on variable naming convention: da#, i# where # corresponds to the loop number, with `0` being the innermost loop... - int64_t strides[] = { strideA1, strideA2 }; - isrm = stdlib_ndarray_is_row_major( 2, strides ); - - if ( M == 0 || N == 0 || ( alpha == 0.0f && beta == 1.0f ) ) { + // Perform input argument validation... + if ( trans != CblasTrans && trans != CblasConjTrans && trans != CblasNoTrans ) { + c_xerbla( 1, "c_sgemv_ndarray", "Error: invalid argument. First argument must be a valid transpose operation. Value: `%d`.", trans ); return; } - if ( isrm ) { - sa0 = strideA2; - sa1 = strideA1; - } else { - sa0 = strideA1; - sa1 = strideA2; + if ( M < 0 ) { + c_xerbla( 2, "c_sgemv_ndarray", "Error: invalid argument. Second argument must be a nonnegative integer. Value: `%d`.", M ); + return; } - + if ( N < 0 ) { + c_xerbla( 3, "c_sgemv_ndarray", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 10, "c_sgemv_ndarray", "Error: invalid argument. Tenth argument must be a nonzero. Value: `%d`.", strideX ); + return; + } + if ( strideY == 0 ) { + c_xerbla( 14, "c_sgemv_ndarray", "Error: invalid argument. Fourteenth argument must be a nonzero. Value: `%d`.", strideY ); + return; + } + // Check whether we can avoid computation altogether... + if ( M == 0 || N == 0 || ( alpha == 0.0 && beta == 1.0 ) ) { + return; + } + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sa[ 0 ] = strideA1; + sa[ 1 ] = strideA2; + isrm = stdlib_ndarray_is_row_major( 2, sa ); if ( trans == CblasNoTrans ) { xlen = N; ylen = M; @@ -78,47 +95,73 @@ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M xlen = M; ylen = N; } - // Y = beta * Y - if ( beta != 1.0f ) { - if ( beta == 0.0f ) { - stdlib_strided_sfill_ndarray( ylen, 0.0f, Y, strideY, offsetY ); - } else { - c_sscal_ndarray( ylen, beta, Y, strideY, offsetY ); - } + if ( beta == 0.0 ) { + API_SUFFIX(stdlib_strided_sfill_ndarray)( ylen, 0.0, Y, strideY, offsetY ); + } else if ( beta != 1.0 ) { + API_SUFFIX(c_sscal_ndarray)( ylen, beta, Y, strideY, offsetY ); } - if ( alpha == 0.0f ) { + if ( alpha == 0.0 ) { return; } // Form: Y = α*A*X + Y - if ( ( !isrm && trans == CblasNoTrans ) || ( isrm && trans != CblasNoTrans ) ) { - ix1 = offsetX; + if ( + ( !isrm && trans == CblasNoTrans ) || + ( isrm && trans != CblasNoTrans ) + ) { + if ( isrm ) { + // For row-major matrices, the last dimension has the fastest changing index... + da0 = strideA2; // offset increment for innermost loop + da1 = strideA1 - ( ylen*strideA2 ); // offset increment for outermost loop + } else { // isColMajor + // For column-major matrices, the first dimension has the fastest changing index... + da0 = strideA1; // offset increment for innermost loop + da1 = strideA2 - ( ylen*strideA1 ); // offset increment for outermost loop + } + ia = offsetA; + ix = offsetX; for ( i1 = 0; i1 < xlen; i1++ ) { - tmp = alpha * X[ ix1 ]; - oa = offsetA + sa1 * i1; - iy1 = offsetY; - for ( i0 = 0; i0 < ylen; i0++ ) { - Y[ iy1 ] += A[ oa + sa0 * i0 ] * tmp; - iy1 += strideY; + tmp = alpha * X[ ix ]; + if ( tmp == 0.0 ) { + ia += da0 * ylen; + } else { + iy = offsetY; + for ( i0 = 0; i0 < ylen; i0++ ) { + Y[ iy ] += A[ ia ] * tmp; + iy += strideY; + ia += da0; + } } - ix1 += strideX; + ix += strideX; + ia += da1; } return; } // Form: Y = α*A^T*X + Y - // ( !isrm && trans !== 'no-transpose' ) || ( isrm && trans === 'no-transpose' ) - iy1 = offsetY; + // ( !isrm && trans !== CblasNoTrans ) || ( isrm && trans === CblasNoTrans ) + if ( isrm ) { + // For row-major matrices, the last dimension has the fastest changing index... + da0 = strideA2; // offset increment for innermost loop + da1 = strideA1 - ( xlen*strideA2 ); // offset increment for outermost loop + } else { // isColMajor + // For column-major matrices, the first dimension has the fastest changing index... + da0 = strideA1; // offset increment for innermost loop + da1 = strideA2 - ( xlen*strideA1 ); // offset increment for outermost loop + } + ia = offsetA; + iy = offsetY; for ( i1 = 0; i1 < ylen; i1++ ) { - tmp = 0.0f; - ix1 = offsetX; - oa = offsetA + sa1 * i1; + tmp = 0.0; + ix = offsetX; for ( i0 = 0; i0 < xlen; i0++ ) { - tmp += A[ oa + sa0 * i0 ] * X[ ix1 ]; - ix1 += strideX; + tmp += A[ ia ] * X[ ix ]; + ix += strideX; + ia += da0; } - Y[ iy1 ] += alpha * tmp; - iy1 += strideY; + Y[ iy ] += alpha * tmp; + iy += strideY; + ia += da1; } return; } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/column_major_alpha_zero.json b/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/column_major_alpha_zero.json new file mode 100644 index 000000000000..33f237a34ca8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/column_major_alpha_zero.json @@ -0,0 +1,20 @@ +{ + "order": "column-major", + "trans": "no-transpose", + "M": 4, + "N": 2, + "alpha": 0.0, + "beta": 0.5, + "lda": 4, + "A": [ 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ], + "x": [ 1.0, 2.0 ], + "y": [ 1.0, 2.0, 3.0, 4.0 ], + "strideA1": 1, + "strideA2": 4, + "offsetA": 0, + "strideX": 1, + "offsetX": 0, + "strideY": 1, + "offsetY": 0, + "y_out": [ 0.5, 1.0, 1.5, 2.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/column_major_x_zeros.json b/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/column_major_x_zeros.json new file mode 100644 index 000000000000..a0ec9dd61530 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/column_major_x_zeros.json @@ -0,0 +1,20 @@ +{ + "order": "column-major", + "trans": "no-transpose", + "M": 4, + "N": 2, + "alpha": 0.5, + "beta": 0.5, + "lda": 4, + "A": [ 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ], + "x": [ 0.0, 0.0 ], + "y": [ 1.0, 2.0, 3.0, 4.0 ], + "strideA1": 1, + "strideA2": 4, + "offsetA": 0, + "strideX": 1, + "offsetX": 0, + "strideY": 1, + "offsetY": 0, + "y_out": [ 0.5, 1.0, 1.5, 2.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/column_major_x_zeros_beta_one.json b/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/column_major_x_zeros_beta_one.json new file mode 100644 index 000000000000..59e66f7499ac --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/column_major_x_zeros_beta_one.json @@ -0,0 +1,20 @@ +{ + "order": "column-major", + "trans": "no-transpose", + "M": 4, + "N": 2, + "alpha": 0.5, + "beta": 1.0, + "lda": 4, + "A": [ 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ], + "x": [ 0.0, 0.0 ], + "y": [ 1.0, 2.0, 3.0, 4.0 ], + "strideA1": 1, + "strideA2": 4, + "offsetA": 0, + "strideX": 1, + "offsetX": 0, + "strideY": 1, + "offsetY": 0, + "y_out": [ 1.0, 2.0, 3.0, 4.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/row_major_alpha_zero.json b/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/row_major_alpha_zero.json new file mode 100644 index 000000000000..1bced86ae275 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/row_major_alpha_zero.json @@ -0,0 +1,20 @@ +{ + "order": "row-major", + "trans": "no-transpose", + "M": 4, + "N": 2, + "alpha": 0.0, + "beta": 0.5, + "lda": 2, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], + "x": [ 1.0, 2.0 ], + "y": [ 1.0, 2.0, 3.0, 4.0 ], + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "strideX": 1, + "offsetX": 0, + "strideY": 1, + "offsetY": 0, + "y_out": [ 0.5, 1.0, 1.5, 2.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/row_major_x_zeros.json b/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/row_major_x_zeros.json new file mode 100644 index 000000000000..7a5af3e7dc61 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/row_major_x_zeros.json @@ -0,0 +1,20 @@ +{ + "order": "row-major", + "trans": "no-transpose", + "M": 4, + "N": 2, + "alpha": 0.5, + "beta": 0.5, + "lda": 2, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], + "x": [ 0.0, 0.0 ], + "y": [ 1.0, 2.0, 3.0, 4.0 ], + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "strideX": 1, + "offsetX": 0, + "strideY": 1, + "offsetY": 0, + "y_out": [ 0.5, 1.0, 1.5, 2.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/row_major_x_zeros_beta_one.json b/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/row_major_x_zeros_beta_one.json new file mode 100644 index 000000000000..dd08640b3da7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/fixtures/row_major_x_zeros_beta_one.json @@ -0,0 +1,20 @@ +{ + "order": "row-major", + "trans": "no-transpose", + "M": 4, + "N": 2, + "alpha": 0.5, + "beta": 1.0, + "lda": 2, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], + "x": [ 0.0, 0.0 ], + "y": [ 1.0, 2.0, 3.0, 4.0 ], + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "strideX": 1, + "offsetX": 0, + "strideY": 1, + "offsetY": 0, + "y_out": [ 1.0, 2.0, 3.0, 4.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.js index 92cb019805b9..762fbeabf791 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.js @@ -41,6 +41,9 @@ var cxnyn = require( './fixtures/column_major_xnyn.json' ); var cxpyn = require( './fixtures/column_major_xpyn.json' ); var cxnyp = require( './fixtures/column_major_xnyp.json' ); var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cx = require( './fixtures/column_major_x_zeros.json' ); +var cxb = require( './fixtures/column_major_x_zeros_beta_one.json' ); +var ca = require( './fixtures/column_major_alpha_zero.json' ); var rap = require( './fixtures/row_major_complex_access_pattern.json' ); var rnt = require( './fixtures/row_major_nt.json' ); @@ -54,6 +57,9 @@ var rxnyn = require( './fixtures/row_major_xnyn.json' ); var rxpyn = require( './fixtures/row_major_xpyn.json' ); var rxnyp = require( './fixtures/row_major_xnyp.json' ); var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rx = require( './fixtures/row_major_x_zeros.json' ); +var rxb = require( './fixtures/row_major_x_zeros_beta_one.json' ); +var ra = require( './fixtures/row_major_alpha_zero.json' ); // TESTS // @@ -421,6 +427,52 @@ tape( 'if `α` is `0` and `β` is `1`, the function returns the second input vec t.end(); }); +tape( 'if `x` contains only zeros and `β` is `1`, the function returns the second input vector unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxb; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros and `β` is `1`, the function returns the second input vector unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxb; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'if `α` is `0`, the function scales the second input vector by `β` (row-major)', function test( t ) { var expected; var data; @@ -429,15 +481,15 @@ tape( 'if `α` is `0`, the function scales the second input vector by `β` (row- var x; var y; - data = rt; + data = ra; a = new Float32Array( data.A ); x = new Float32Array( data.x ); y = new Float32Array( data.y ); - expected = new Float32Array( data.y.length ); + expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 0.0, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -452,15 +504,61 @@ tape( 'if `α` is `0`, the function scales the second input vector by `β` (colu var x; var y; - data = ct; + data = ca; a = new Float32Array( data.A ); x = new Float32Array( data.x ); y = new Float32Array( data.y ); - expected = new Float32Array( data.y.length ); + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros and `β` is not `1`, the function scales the second input vector by `β` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 0.0, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros and `β` is not `1`, the function scales the second input vector by `β` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cx; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js index e75ac4cfa22b..c6886b2a3a2b 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-len */ + 'use strict'; // MODULES // @@ -40,6 +42,9 @@ var cxnyn = require( './fixtures/column_major_xnyn.json' ); var cxpyn = require( './fixtures/column_major_xpyn.json' ); var cxnyp = require( './fixtures/column_major_xnyp.json' ); var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cx = require( './fixtures/column_major_x_zeros.json' ); +var cxb = require( './fixtures/column_major_x_zeros_beta_one.json' ); +var ca = require( './fixtures/column_major_alpha_zero.json' ); var rap = require( './fixtures/row_major_complex_access_pattern.json' ); var rnt = require( './fixtures/row_major_nt.json' ); @@ -53,13 +58,16 @@ var rxnyn = require( './fixtures/row_major_xnyn.json' ); var rxpyn = require( './fixtures/row_major_xpyn.json' ); var rxnyp = require( './fixtures/row_major_xnyp.json' ); var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rx = require( './fixtures/row_major_x_zeros.json' ); +var rxb = require( './fixtures/row_major_x_zeros_beta_one.json' ); +var ra = require( './fixtures/row_major_alpha_zero.json' ); // VARIABLES // -var sgemv = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var dgemv = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { - 'skip': ( sgemv instanceof Error ) + 'skip': ( dgemv instanceof Error ) }; @@ -67,15 +75,137 @@ var opts = { tape( 'main export is a function', opts, function test( t ) { t.ok( true, __filename ); - t.strictEqual( typeof sgemv, 'function', 'main export is a function' ); + t.strictEqual( typeof dgemv, 'function', 'main export is a function' ); t.end(); }); tape( 'the function has an arity of 15', opts, function test( t ) { - t.strictEqual( sgemv.length, 15, 'returns expected value' ); + t.strictEqual( dgemv.length, 15, 'returns expected value' ); t.end(); }); +tape( 'the function throws an error if provided an invalid first argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rnt; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgemv( value, data.M, data.N, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX, data.beta, new Float32Array( data.y ), data.strideY, data.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rnt; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgemv( data.trans, value, data.N, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX, data.beta, new Float32Array( data.y ), data.strideY, data.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rnt; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgemv( data.trans, data.M, value, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX, data.beta, new Float32Array( data.y ), data.strideY, data.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid tenth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rnt; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgemv( data.trans, data.M, data.N, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), value, data.offsetX, data.beta, new Float32Array( data.y ), data.strideY, data.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fourteenth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rnt; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dgemv( data.trans, data.M, data.N, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX, data.beta, new Float32Array( data.y ), value, data.offsetY ); + }; + } +}); + tape( 'the function performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` (row-major, no-transpose)', opts, function test( t ) { var expected; var data; @@ -92,7 +222,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -115,7 +245,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -138,7 +268,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -161,7 +291,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -181,7 +311,7 @@ tape( 'the function returns a reference to the second input vector (row-major)', x = new Float32Array( data.x ); y = new Float32Array( data.y ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.end(); @@ -200,7 +330,7 @@ tape( 'the function returns a reference to the second input vector (column-major x = new Float32Array( data.x ); y = new Float32Array( data.y ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.end(); @@ -222,11 +352,11 @@ tape( 'if either `M` or `N` is `0`, the function returns the second input vector expected = new Float32Array( data.y ); - out = sgemv( data.trans, 0, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, 0, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); - out = sgemv( data.trans, data.M, 0, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, 0, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -249,11 +379,11 @@ tape( 'if either `M` or `N` is `0`, the function returns the second input vector expected = new Float32Array( data.y ); - out = sgemv( data.trans, 0, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, 0, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); - out = sgemv( data.trans, data.M, 0, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, 0, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -276,7 +406,7 @@ tape( 'if `α` is `0` and `β` is `1`, the function returns the second input vec expected = new Float32Array( data.y ); - out = sgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 1.0, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 1.0, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -299,7 +429,53 @@ tape( 'if `α` is `0` and `β` is `1`, the function returns the second input vec expected = new Float32Array( data.y ); - out = sgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 1.0, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 1.0, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros and `β` is `1`, the function returns the second input vector unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxb; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros and `β` is `1`, the function returns the second input vector unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxb; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -314,15 +490,15 @@ tape( 'if `α` is `0`, the function scales the second input vector by `β` (row- var x; var y; - data = rt; + data = ra; a = new Float32Array( data.A ); x = new Float32Array( data.x ); y = new Float32Array( data.y ); - expected = new Float32Array( data.y.length ); + expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 0.0, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -337,15 +513,61 @@ tape( 'if `α` is `0`, the function scales the second input vector by `β` (colu var x; var y; - data = ct; + data = ca; a = new Float32Array( data.A ); x = new Float32Array( data.x ); y = new Float32Array( data.y ); - expected = new Float32Array( data.y.length ); + expected = new Float32Array( data.y_out ); + + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros and `β` is not `1`, the function scales the second input vector by `β` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros and `β` is not `1`, the function scales the second input vector by `β` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cx; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 0.0, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -368,7 +590,7 @@ tape( 'the function supports specifying the strides of the first and second dime expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -391,7 +613,7 @@ tape( 'the function supports specifying the strides of the first and second dime expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -414,7 +636,7 @@ tape( 'the function supports a negative stride for the first dimension of `A` (r expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -437,7 +659,7 @@ tape( 'the function supports a negative stride for the first dimension of `A` (c expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -460,7 +682,7 @@ tape( 'the function supports a negative stride for the second dimension of `A` ( expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -483,7 +705,7 @@ tape( 'the function supports a negative stride for the second dimension of `A` ( expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -506,7 +728,7 @@ tape( 'the function supports negative strides for `A` (row-major)', opts, functi expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -529,7 +751,7 @@ tape( 'the function supports negative strides for `A` (column-major)', opts, fun expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -552,7 +774,7 @@ tape( 'the function supports specifying an offset parameter for `A` (row-major)' expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -575,7 +797,7 @@ tape( 'the function supports specifying an offset parameter for `A` (column-majo expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -598,7 +820,7 @@ tape( 'the function supports specifying `x` and `y` strides (row-major)', opts, expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -621,7 +843,7 @@ tape( 'the function supports specifying `x` and `y` strides (column-major)', opt expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -644,7 +866,7 @@ tape( 'the function supports specifying a negative `x` stride (row-major)', opts expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -667,7 +889,7 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', o expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -690,7 +912,7 @@ tape( 'the function supports specifying a negative `y` stride (row-major)', opts expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -713,7 +935,7 @@ tape( 'the function supports specifying a negative `y` stride (column-major)', o expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -736,7 +958,7 @@ tape( 'the function supports specifying negative strides for `x` and `y` (row-ma expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -759,7 +981,7 @@ tape( 'the function supports specifying negative strides for `x` and `y` (column expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -782,7 +1004,7 @@ tape( 'the function supports complex access patterns (row-major)', opts, functio expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -805,7 +1027,7 @@ tape( 'the function supports complex access patterns (column-major)', opts, func expected = new Float32Array( data.y_out ); - out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.js b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.js index 4d0fcfea67c9..bc14eb75ee0d 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.js @@ -35,6 +35,9 @@ var cxnyn = require( './fixtures/column_major_xnyn.json' ); var cxpyn = require( './fixtures/column_major_xpyn.json' ); var cxnyp = require( './fixtures/column_major_xnyp.json' ); var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cx = require( './fixtures/column_major_x_zeros.json' ); +var cxb = require( './fixtures/column_major_x_zeros_beta_one.json' ); +var ca = require( './fixtures/column_major_alpha_zero.json' ); var rnt = require( './fixtures/row_major_nt.json' ); var rt = require( './fixtures/row_major_t.json' ); @@ -42,6 +45,9 @@ var rxnyn = require( './fixtures/row_major_xnyn.json' ); var rxpyn = require( './fixtures/row_major_xpyn.json' ); var rxnyp = require( './fixtures/row_major_xnyp.json' ); var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rx = require( './fixtures/row_major_x_zeros.json' ); +var rxb = require( './fixtures/row_major_x_zeros_beta_one.json' ); +var ra = require( './fixtures/row_major_alpha_zero.json' ); // TESTS // @@ -251,6 +257,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); + t.end(); }); @@ -273,6 +280,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); + t.end(); }); @@ -295,6 +303,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); + t.end(); }); @@ -317,6 +326,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); + t.end(); }); @@ -335,6 +345,7 @@ tape( 'the function returns a reference to the second input vector (row-major)', out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); + t.end(); }); @@ -353,6 +364,7 @@ tape( 'the function returns a reference to the second input vector (column-major out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); + t.end(); }); @@ -456,6 +468,52 @@ tape( 'if `α` is `0` and `β` is `1`, the function returns the second input vec t.end(); }); +tape( 'if `x` contains only zeros and `β` is `1`, the function returns the second input vector unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxb; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros and `β` is `1`, the function returns the second input vector unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxb; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'if `α` is `0`, the function scales the second input vector by `β` (row-major)', function test( t ) { var expected; var data; @@ -464,15 +522,15 @@ tape( 'if `α` is `0`, the function scales the second input vector by `β` (row- var x; var y; - data = rt; + data = ra; a = new Float32Array( data.A ); x = new Float32Array( data.x ); y = new Float32Array( data.y ); - expected = new Float32Array( data.y.length ); + expected = new Float32Array( data.y_out ); - out = sgemv( data.order, data.trans, data.M, data.N, 0.0, a, data.lda, x, data.strideX, 0.0, y, data.strideY ); + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -487,15 +545,61 @@ tape( 'if `α` is `0`, the function scales the second input vector by `β` (colu var x; var y; - data = ct; + data = ca; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros and `β` is not `1`, the function scales the second input vector by `β` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros and `β` is not `1`, the function scales the second input vector by `β` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cx; a = new Float32Array( data.A ); x = new Float32Array( data.x ); y = new Float32Array( data.y ); - expected = new Float32Array( data.y.length ); + expected = new Float32Array( data.y_out ); - out = sgemv( data.order, data.trans, data.M, data.N, 0.0, a, data.lda, x, data.strideX, 0.0, y, data.strideY ); + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.native.js index f1f24cfd837e..5a479d669ee8 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.sgemv.native.js @@ -1,3 +1,4 @@ + /** * @license Apache-2.0 * @@ -16,6 +17,8 @@ * limitations under the License. */ +/* eslint-disable max-len */ + 'use strict'; // MODULES // @@ -34,6 +37,9 @@ var cxnyn = require( './fixtures/column_major_xnyn.json' ); var cxpyn = require( './fixtures/column_major_xpyn.json' ); var cxnyp = require( './fixtures/column_major_xnyp.json' ); var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cx = require( './fixtures/column_major_x_zeros.json' ); +var cxb = require( './fixtures/column_major_x_zeros_beta_one.json' ); +var ca = require( './fixtures/column_major_alpha_zero.json' ); var rnt = require( './fixtures/row_major_nt.json' ); var rt = require( './fixtures/row_major_t.json' ); @@ -41,6 +47,9 @@ var rxnyn = require( './fixtures/row_major_xnyn.json' ); var rxpyn = require( './fixtures/row_major_xpyn.json' ); var rxnyp = require( './fixtures/row_major_xnyp.json' ); var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rx = require( './fixtures/row_major_x_zeros.json' ); +var rxb = require( './fixtures/row_major_x_zeros_beta_one.json' ); +var ra = require( './fixtures/row_major_alpha_zero.json' ); // VARIABLES // @@ -64,6 +73,181 @@ tape( 'the function has an arity of 12', opts, function test( t ) { t.end(); }); +tape( 'the function throws an error if provided an invalid first argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rnt; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sgemv( value, data.trans, data.M, data.N, data.alpha, new Float32Array( data.A ), data.LDA, new Float32Array( data.x ), data.strideX, data.beta, new Float32Array( data.y ), data.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rnt; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sgemv( data.order, value, data.M, data.N, data.alpha, new Float32Array( data.A ), data.LDA, new Float32Array( data.x ), data.strideX, data.beta, new Float32Array( data.y ), data.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rnt; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sgemv( data.order, data.trans, value, data.N, data.alpha, new Float32Array( data.A ), data.LDA, new Float32Array( data.x ), data.strideX, data.beta, new Float32Array( data.y ), data.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fourth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rnt; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sgemv( data.order, data.trans, data.M, value, data.alpha, new Float32Array( data.A ), data.LDA, new Float32Array( data.x ), data.strideX, data.beta, new Float32Array( data.y ), data.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid seventh argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rnt; + + values = [ + 1, + 0, + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sgemv( data.order, data.trans, data.M, data.N, data.alpha, new Float32Array( data.A ), value, new Float32Array( data.x ), data.strideX, data.beta, new Float32Array( data.y ), data.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid ninth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rnt; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sgemv( data.order, data.trans, data.M, data.N, data.alpha, new Float32Array( data.A ), data.LDA, new Float32Array( data.x ), value, data.beta, new Float32Array( data.y ), data.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid twelfth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rnt; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sgemv( data.order, data.trans, data.M, data.N, data.alpha, new Float32Array( data.A ), data.LDA, new Float32Array( data.x ), data.strideX, data.beta, new Float32Array( data.y ), value ); + }; + } +}); + tape( 'the function performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T*x + β*y` (row-major, no-transpose)', opts, function test( t ) { var expected; var data; @@ -83,6 +267,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); + t.end(); }); @@ -105,6 +290,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); + t.end(); }); @@ -127,6 +313,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); + t.end(); }); @@ -149,6 +336,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); + t.end(); }); @@ -167,6 +355,7 @@ tape( 'the function returns a reference to the second input vector (row-major)', out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); + t.end(); }); @@ -185,6 +374,7 @@ tape( 'the function returns a reference to the second input vector (column-major out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); + t.end(); }); @@ -288,6 +478,52 @@ tape( 'if `α` is `0` and `β` is `1`, the function returns the second input vec t.end(); }); +tape( 'if `x` contains only zeros and `β` is `1`, the function returns the second input vector unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxb; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros and `β` is `1`, the function returns the second input vector unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxb; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'if `α` is `0`, the function scales the second input vector by `β` (row-major)', opts, function test( t ) { var expected; var data; @@ -296,15 +532,15 @@ tape( 'if `α` is `0`, the function scales the second input vector by `β` (row- var x; var y; - data = rt; + data = ra; a = new Float32Array( data.A ); x = new Float32Array( data.x ); y = new Float32Array( data.y ); - expected = new Float32Array( data.y.length ); + expected = new Float32Array( data.y_out ); - out = sgemv( data.order, data.trans, data.M, data.N, 0.0, a, data.lda, x, data.strideX, 0.0, y, data.strideY ); + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -319,15 +555,61 @@ tape( 'if `α` is `0`, the function scales the second input vector by `β` (colu var x; var y; - data = ct; + data = ca; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros and `β` is not `1`, the function scales the second input vector by `β` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.y_out ); + + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `x` contains only zeros and `β` is not `1`, the function scales the second input vector by `β` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cx; a = new Float32Array( data.A ); x = new Float32Array( data.x ); y = new Float32Array( data.y ); - expected = new Float32Array( data.y.length ); + expected = new Float32Array( data.y_out ); - out = sgemv( data.order, data.trans, data.M, data.N, 0.0, a, data.lda, x, data.strideX, 0.0, y, data.strideY ); + out = sgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); From 3ac7c6b27cc5e959ba1d18f6f50148a389cfc7ee Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Tue, 1 Jul 2025 14:09:36 +0530 Subject: [PATCH 19/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c index 3d56bd4a2d3a..d6059d3e4009 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv.c @@ -89,7 +89,7 @@ void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE trans return; } // Check if we can early return... - if ( M == 0 || N == 0 || ( alpha == 0.0 && beta == 1.0 ) ) { + if ( M == 0 || N == 0 || ( alpha == 0.0f && beta == 1.0f ) ) { return; } if ( trans == CblasNoTrans ) { From 972257580e9da80f109d7731261756bcc3d28522 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Tue, 1 Jul 2025 14:11:04 +0530 Subject: [PATCH 20/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/sgemv/src/sgemv_ndarray.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c index 01d33828ee1c..1cf147fa2822 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_ndarray.c @@ -81,7 +81,7 @@ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M return; } // Check whether we can avoid computation altogether... - if ( M == 0 || N == 0 || ( alpha == 0.0 && beta == 1.0 ) ) { + if ( M == 0 || N == 0 || ( alpha == 0.0f && beta == 1.0f ) ) { return; } // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... @@ -96,12 +96,12 @@ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M ylen = N; } // Y = beta * Y - if ( beta == 0.0 ) { - API_SUFFIX(stdlib_strided_sfill_ndarray)( ylen, 0.0, Y, strideY, offsetY ); - } else if ( beta != 1.0 ) { + if ( beta == 0.0f ) { + API_SUFFIX(stdlib_strided_sfill_ndarray)( ylen, 0.0f, Y, strideY, offsetY ); + } else if ( beta != 1.0f ) { API_SUFFIX(c_sscal_ndarray)( ylen, beta, Y, strideY, offsetY ); } - if ( alpha == 0.0 ) { + if ( alpha == 0.0f ) { return; } // Form: Y = α*A*X + Y @@ -122,7 +122,7 @@ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M ix = offsetX; for ( i1 = 0; i1 < xlen; i1++ ) { tmp = alpha * X[ ix ]; - if ( tmp == 0.0 ) { + if ( tmp == 0.0f ) { ia += da0 * ylen; } else { iy = offsetY; @@ -152,7 +152,7 @@ void API_SUFFIX(c_sgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M ia = offsetA; iy = offsetY; for ( i1 = 0; i1 < ylen; i1++ ) { - tmp = 0.0; + tmp = 0.0f; ix = offsetX; for ( i0 = 0; i0 < xlen; i0++ ) { tmp += A[ ia ] * X[ ix ]; From 0d3359f737676eb0b7f8bb9c6776d60c44991104 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 3 Jul 2025 17:27:35 -0700 Subject: [PATCH 21/21] chore: clean-up --- 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: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - 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 --- --- .../@stdlib/blas/base/sgemv/README.md | 34 +++---- .../@stdlib/blas/base/sgemv/docs/repl.txt | 4 +- .../@stdlib/blas/base/sgemv/lib/base.js | 17 ++-- .../@stdlib/blas/base/sgemv/src/sgemv_cblas.c | 2 +- .../base/sgemv/test/test.ndarray.native.js | 94 +++++++++---------- 5 files changed, 76 insertions(+), 75 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/README.md b/lib/node_modules/@stdlib/blas/base/sgemv/README.md index 5a90e93c2b62..935c66fd0a52 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/README.md +++ b/lib/node_modules/@stdlib/blas/base/sgemv/README.md @@ -208,11 +208,11 @@ Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T* ```c #include "stdlib/blas/base/shared.h" -const float A[] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; -const float x[] = { 1.0, 2.0, 3.0 }; -float y[] = { 1.0, 2.0, 3.0 }; +const float A[] = { 1.0f, 0.0f, 0.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f }; +const float x[] = { 1.0f, 2.0f, 3.0f }; +float y[] = { 1.0f, 2.0f, 3.0f }; -c_sgemv( CblasColMajor, CblasNoTrans, 3, 3, 1.0, A, 3, x, 1, 1.0, y, 1 ); +c_sgemv( CblasColMajor, CblasNoTrans, 3, 3, 1.0f, A, 3, x, 1, 1.0f, y, 1 ); ``` The function accepts the following arguments: @@ -241,11 +241,11 @@ Performs one of the matrix-vector operations `y = α*A*x + β*y` or `y = α*A^T* ```c #include "stdlib/blas/base/shared.h" -const float A[] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; -const float x[] = { 1.0, 2.0, 3.0 }; -float y[] = { 1.0, 2.0, 3.0 }; +const float A[] = { 1.0f, 0.0f, 0.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f }; +const float x[] = { 1.0f, 2.0f, 3.0f }; +float y[] = { 1.0f, 2.0f, 3.0f }; -c_sgemv_ndarray( CblasNoTrans, 3, 3, 1.0, A, 1, 3, 0, x, 1, 0, 1.0, y, 1, 0 ); +c_sgemv_ndarray( CblasNoTrans, 3, 3, 1.0f, A, 1, 3, 0, x, 1, 0, 1.0f, y, 1, 0 ); ``` The function accepts the following arguments: @@ -296,33 +296,33 @@ void c_sgemv_ndarray( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLA int main( void ) { // Define a 3x3 matrix stored in row-major order: const float A[ 3*3 ] = { - 1.0, 2.0, 3.0, - 4.0, 5.0, 6.0, - 7.0, 8.0, 9.0 + 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, + 7.0f, 8.0f, 9.0f }; // Define `x` and `y` vectors: - const float x[ 3 ] = { 1.0, 2.0, 3.0 }; - float y[ 3 ] = { 1.0, 2.0, 3.0 }; + const float x[ 3 ] = { 1.0f, 2.0f, 3.0f }; + float y[ 3 ] = { 1.0f, 2.0f, 3.0f }; // Specify the number of elements along each dimension of `A`: const int M = 3; const int N = 3; // Perform the matrix-vector operation `y = α*A*x + β*y`: - c_sgemv( CblasRowMajor, CblasNoTrans, M, N, 1.0, A, M, x, 1, 1.0, y, 1 ); + c_sgemv( CblasRowMajor, CblasNoTrans, M, N, 1.0f, A, M, x, 1, 1.0f, y, 1 ); // Print the result: for ( int i = 0; i < N; i++ ) { - printf( "y[ %i ] = %lf\n", i, y[ i ] ); + printf( "y[ %i ] = %f\n", i, y[ i ] ); } // Perform the matrix-vector operation `y = α*A*x + β*y` using alternative indexing semantics: - c_sgemv_ndarray( CblasNoTrans, M, N, 1.0, A, N, 1, 0, x, 1, 0, 1.0, y, 1, 0 ); + c_sgemv_ndarray( CblasNoTrans, M, N, 1.0f, A, N, 1, 0, x, 1, 0, 1.0f, y, 1, 0 ); // Print the result: for ( int i = 0; i < N; i++ ) { - printf( "y[ %i ] = %lf\n", i, y[ i ] ); + printf( "y[ %i ] = %f\n", i, y[ i ] ); } } ``` diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/sgemv/docs/repl.txt index e80069e02432..d83cd8ce1306 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/sgemv/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( order, trans, M, N, α, A, lda, x, sx, β, y, sy ) Performs one of the matrix-vector operations `y = α*A*x + β*y` or - `y = α*A**T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are + `y = α*A^T*x + β*y`, where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. Indexing is relative to the first index. To introduce an offset, use typed @@ -87,7 +87,7 @@ {{alias}}.ndarray( trans, M, N, α, A, sa1, sa2, oa, x, sx, ox, β, y, sy, oy ) Performs one of the matrix-vector operations `y = α*A*x + β*y` or - `y = α*A**T*x + β*y`, using alternative indexing semantics and where `α` and + `y = α*A^T*x + β*y`, using alternative indexing semantics and where `α` and `β` are scalars, `x` and `y` are vectors, and `A` is an `M` by `N` matrix. While typed array views mandate a view offset based on the underlying diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/lib/base.js b/lib/node_modules/@stdlib/blas/base/sgemv/lib/base.js index a941c7a171f5..8289eadd514a 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/lib/base.js @@ -20,9 +20,10 @@ // MODULES // +var f32 = require( '@stdlib/number/float64/base/to-float32' ); var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); -var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; -var dscal = require( '@stdlib/blas/base/dscal' ).ndarray; +var sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; +var sscal = require( '@stdlib/blas/base/sscal' ).ndarray; // FUNCTIONS // @@ -109,9 +110,9 @@ function sgemv( trans, M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, } // y = beta*y if ( beta === 0.0 ) { - dfill( ylen, 0.0, y, strideY, offsetY ); + sfill( ylen, 0.0, y, strideY, offsetY ); } else if ( beta !== 1.0 ) { - dscal( ylen, beta, y, strideY, offsetY ); + sscal( ylen, beta, y, strideY, offsetY ); } if ( alpha === 0.0 ) { return y; @@ -133,13 +134,13 @@ function sgemv( trans, M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, ia = offsetA; ix = offsetX; for ( i1 = 0; i1 < xlen; i1++ ) { - tmp = alpha * x[ ix ]; + tmp = f32( alpha * x[ ix ] ); if ( tmp === 0.0 ) { ia += da0 * ylen; } else { iy = offsetY; for ( i0 = 0; i0 < ylen; i0++ ) { - y[ iy ] += A[ ia ] * tmp; + y[ iy ] += f32( A[ ia ] * tmp ); iy += strideY; ia += da0; } @@ -167,11 +168,11 @@ function sgemv( trans, M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, tmp = 0.0; ix = offsetX; for ( i0 = 0; i0 < xlen; i0++ ) { - tmp += A[ ia ] * x[ ix ]; + tmp += f32( A[ ia ] * x[ ix ] ); ix += strideX; ia += da0; } - y[ iy ] += alpha * tmp; + y[ iy ] += f32( alpha * tmp ); iy += strideY; ia += da1; } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c index 1cf00d2eac19..13a3fb89cbe6 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/sgemv/src/sgemv_cblas.c @@ -37,6 +37,6 @@ * @param strideY `y` stride length * @return output value */ -void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, const float *Y, const CBLAS_INT strideY ) { +void API_SUFFIX(c_sgemv)( const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const float alpha, const float *A, const CBLAS_INT LDA, const float *X, const CBLAS_INT strideX, const float beta, float *Y, const CBLAS_INT strideY ) { API_SUFFIX(cblas_sgemv)( layout, trans, M, N, alpha, A, LDA, X, strideX, beta, Y, strideY ); } diff --git a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js index c6886b2a3a2b..c0681fb5fd74 100644 --- a/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/sgemv/test/test.ndarray.native.js @@ -65,9 +65,9 @@ var ra = require( './fixtures/row_major_alpha_zero.json' ); // VARIABLES // -var dgemv = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var sgemv = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { - 'skip': ( dgemv instanceof Error ) + 'skip': ( sgemv instanceof Error ) }; @@ -75,12 +75,12 @@ var opts = { tape( 'main export is a function', opts, function test( t ) { t.ok( true, __filename ); - t.strictEqual( typeof dgemv, 'function', 'main export is a function' ); + t.strictEqual( typeof sgemv, 'function', 'main export is a function' ); t.end(); }); tape( 'the function has an arity of 15', opts, function test( t ) { - t.strictEqual( dgemv.length, 15, 'returns expected value' ); + t.strictEqual( sgemv.length, 15, 'returns expected value' ); t.end(); }); @@ -105,7 +105,7 @@ tape( 'the function throws an error if provided an invalid first argument', opts function badValue( value ) { return function badValue() { - dgemv( value, data.M, data.N, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX, data.beta, new Float32Array( data.y ), data.strideY, data.offsetY ); + sgemv( value, data.M, data.N, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX, data.beta, new Float32Array( data.y ), data.strideY, data.offsetY ); }; } }); @@ -130,7 +130,7 @@ tape( 'the function throws an error if provided an invalid second argument', opt function badValue( value ) { return function badValue() { - dgemv( data.trans, value, data.N, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX, data.beta, new Float32Array( data.y ), data.strideY, data.offsetY ); + sgemv( data.trans, value, data.N, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX, data.beta, new Float32Array( data.y ), data.strideY, data.offsetY ); }; } }); @@ -155,7 +155,7 @@ tape( 'the function throws an error if provided an invalid third argument', opts function badValue( value ) { return function badValue() { - dgemv( data.trans, data.M, value, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX, data.beta, new Float32Array( data.y ), data.strideY, data.offsetY ); + sgemv( data.trans, data.M, value, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX, data.beta, new Float32Array( data.y ), data.strideY, data.offsetY ); }; } }); @@ -178,7 +178,7 @@ tape( 'the function throws an error if provided an invalid tenth argument', opts function badValue( value ) { return function badValue() { - dgemv( data.trans, data.M, data.N, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), value, data.offsetX, data.beta, new Float32Array( data.y ), data.strideY, data.offsetY ); + sgemv( data.trans, data.M, data.N, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), value, data.offsetX, data.beta, new Float32Array( data.y ), data.strideY, data.offsetY ); }; } }); @@ -201,7 +201,7 @@ tape( 'the function throws an error if provided an invalid fourteenth argument', function badValue( value ) { return function badValue() { - dgemv( data.trans, data.M, data.N, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX, data.beta, new Float32Array( data.y ), value, data.offsetY ); + sgemv( data.trans, data.M, data.N, data.alpha, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float32Array( data.x ), data.strideX, data.offsetX, data.beta, new Float32Array( data.y ), value, data.offsetY ); }; } }); @@ -222,7 +222,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -245,7 +245,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -268,7 +268,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -291,7 +291,7 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x + expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -311,7 +311,7 @@ tape( 'the function returns a reference to the second input vector (row-major)', x = new Float32Array( data.x ); y = new Float32Array( data.y ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.end(); @@ -330,7 +330,7 @@ tape( 'the function returns a reference to the second input vector (column-major x = new Float32Array( data.x ); y = new Float32Array( data.y ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.end(); @@ -352,11 +352,11 @@ tape( 'if either `M` or `N` is `0`, the function returns the second input vector expected = new Float32Array( data.y ); - out = dgemv( data.trans, 0, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, 0, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); - out = dgemv( data.trans, data.M, 0, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, 0, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -379,11 +379,11 @@ tape( 'if either `M` or `N` is `0`, the function returns the second input vector expected = new Float32Array( data.y ); - out = dgemv( data.trans, 0, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, 0, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); - out = dgemv( data.trans, data.M, 0, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, 0, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -406,7 +406,7 @@ tape( 'if `α` is `0` and `β` is `1`, the function returns the second input vec expected = new Float32Array( data.y ); - out = dgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 1.0, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 1.0, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -429,7 +429,7 @@ tape( 'if `α` is `0` and `β` is `1`, the function returns the second input vec expected = new Float32Array( data.y ); - out = dgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 1.0, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, 0.0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, 1.0, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -452,7 +452,7 @@ tape( 'if `x` contains only zeros and `β` is `1`, the function returns the seco expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -475,7 +475,7 @@ tape( 'if `x` contains only zeros and `β` is `1`, the function returns the seco expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -498,7 +498,7 @@ tape( 'if `α` is `0`, the function scales the second input vector by `β` (row- expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -521,7 +521,7 @@ tape( 'if `α` is `0`, the function scales the second input vector by `β` (colu expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -544,7 +544,7 @@ tape( 'if `x` contains only zeros and `β` is not `1`, the function scales the s expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -567,7 +567,7 @@ tape( 'if `x` contains only zeros and `β` is not `1`, the function scales the s expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -590,7 +590,7 @@ tape( 'the function supports specifying the strides of the first and second dime expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -613,7 +613,7 @@ tape( 'the function supports specifying the strides of the first and second dime expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -636,7 +636,7 @@ tape( 'the function supports a negative stride for the first dimension of `A` (r expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -659,7 +659,7 @@ tape( 'the function supports a negative stride for the first dimension of `A` (c expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -682,7 +682,7 @@ tape( 'the function supports a negative stride for the second dimension of `A` ( expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -705,7 +705,7 @@ tape( 'the function supports a negative stride for the second dimension of `A` ( expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -728,7 +728,7 @@ tape( 'the function supports negative strides for `A` (row-major)', opts, functi expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -751,7 +751,7 @@ tape( 'the function supports negative strides for `A` (column-major)', opts, fun expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -774,7 +774,7 @@ tape( 'the function supports specifying an offset parameter for `A` (row-major)' expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -797,7 +797,7 @@ tape( 'the function supports specifying an offset parameter for `A` (column-majo expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -820,7 +820,7 @@ tape( 'the function supports specifying `x` and `y` strides (row-major)', opts, expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -843,7 +843,7 @@ tape( 'the function supports specifying `x` and `y` strides (column-major)', opt expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -866,7 +866,7 @@ tape( 'the function supports specifying a negative `x` stride (row-major)', opts expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -889,7 +889,7 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', o expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -912,7 +912,7 @@ tape( 'the function supports specifying a negative `y` stride (row-major)', opts expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -935,7 +935,7 @@ tape( 'the function supports specifying a negative `y` stride (column-major)', o expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -958,7 +958,7 @@ tape( 'the function supports specifying negative strides for `x` and `y` (row-ma expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -981,7 +981,7 @@ tape( 'the function supports specifying negative strides for `x` and `y` (column expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -1004,7 +1004,7 @@ tape( 'the function supports complex access patterns (row-major)', opts, functio expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -1027,7 +1027,7 @@ tape( 'the function supports complex access patterns (column-major)', opts, func expected = new Float32Array( data.y_out ); - out = dgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); + out = sgemv( data.trans, data.M, data.N, data.alpha, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX, data.beta, y, data.strideY, data.offsetY ); t.strictEqual( out, y, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' );