diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/README.md b/lib/node_modules/@stdlib/blas/base/dgemv/README.md index ab38a7abd2d6..d1f4b39bb70a 100644 --- a/lib/node_modules/@stdlib/blas/base/dgemv/README.md +++ b/lib/node_modules/@stdlib/blas/base/dgemv/README.md @@ -30,7 +30,7 @@ limitations under the License. var dgemv = require( '@stdlib/blas/base/dgemv' ); ``` -#### dgemv( ord, trans, M, N, α, A, LDA, x, sx, β, y, sy ) +#### dgemv( 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. @@ -47,7 +47,7 @@ dgemv( '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 [`Float64Array`][mdn-float64array]. - **lda**: stride of the first dimension of `A` (leading dimension of `A`). - **x**: input [`Float64Array`][mdn-float64array]. -- **sx**: index increment for `x`. +- **sx**: stride length for `x`. - **β**: scalar constant. - **y**: output [`Float64Array`][mdn-float64array]. -- **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`, @@ -93,6 +93,8 @@ dgemv( 'row-major', 'no-transpose', 2, 2, 1.0, A, 2, x1, -1, 1.0, y1, -1 ); // y0 => [ 0.0, 8.0, 4.0 ] ``` + + #### dgemv.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/dgemv.h" ``` -#### TODO +#### c_dgemv( layout, trans, M, N, alpha, \*A, LDA, \*X, strideX, beta, \*Y, strideY ) -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. ```c -TODO +#include "stdlib/blas/base/shared.h" + +const double A[] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; +const double x[] = { 1.0, 2.0, 3.0 }; +double y[] = { 1.0, 2.0, 3.0 }; + +c_dgemv( CblasColMajor, CblasNoTrans, 3, 3, 1.0, A, 3, x, 1, 1.0, y, 1 ); ``` -TODO +The function accepts the following arguments: + +- **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] double` scalar constant. +- **A**: `[in] double*` input matrix. +- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **X**: `[in] double*` first input vector. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **beta**: `[in] double` scalar constant. +- **Y**: `[inout] double*` second input vector. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. ```c -TODO +void c_dgemv( const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *A, const CBLAS_INT LDA, const double *X, const CBLAS_INT strideX, const double beta, double *Y, const CBLAS_INT strideY ) +``` + +#### c_dgemv_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`, 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" + +const double A[] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; +const double x[] = { 1.0, 2.0, 3.0 }; +double y[] = { 1.0, 2.0, 3.0 }; + +c_dgemv_ndarray( CblasNoTrans, 3, 3, 1.0, A, 1, 3, 0, x, 1, 0, 1.0, y, 1, 0 ); +``` + +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] double` scalar. +- **A**: `[in] double*` 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] double*` first input vector. +- **sx**: `[in] CBLAS_INT` stride length for `X`. +- **ox**: `[in] CBLAS_INT` starting index for `X`. +- **beta**: `[in] double` scalar. +- **Y**: `[inout] double*` second input vector. +- **sy**: `[in] CBLAS_INT` stride length for `Y`. +- **oy**: `[in] CBLAS_INT` starting index for `Y`. + +```c +void c_dgemv_ndarray( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double beta, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) ``` @@ -232,7 +289,42 @@ TODO ### Examples ```c -TODO +#include "stdlib/blas/base/dgemv.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Define a 3x3 matrix stored in row-major order: + const double 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 double x[ 3 ] = { 1.0, 2.0, 3.0 }; + double 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 operation `y = α*A*x + β*y`: + c_dgemv( 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 ] = %lf\n", i, y[ i ] ); + } + + // Perform the matrix-vector operation `y = α*A*x + β*y` using alternative indexing semantics: + c_dgemv_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 ] = %lf\n", i, y[ i ] ); + } +} ``` diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/benchmark.js index e91b0723e08b..d5527eba72d5 100644 --- a/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/benchmark.js @@ -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/dgemv/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/benchmark.native.js new file mode 100644 index 000000000000..07fa009a4071 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/benchmark.native.js @@ -0,0 +1,104 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var dgemv = tryRequire( resolve( __dirname, './../lib/dgemv.native.js' ) ); +var opts = { + 'skip': ( dgemv instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array length +* @returns {Function} benchmark function +*/ +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 ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dgemv( 'row-major', 'no-transpose', N, N, 1.0, A, N, x, 1, 1.0, y, 1 ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( 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 N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+'::native:size='+(N*N), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/benchmark.ndarray.js index 8bc8d8248ca5..35c732a99544 100644 --- a/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/benchmark.ndarray.js @@ -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+':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/dgemv/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..7bd72cd042d8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,104 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var dgemv = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dgemv instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array length +* @returns {Function} benchmark function +*/ +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 ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dgemv( 'no-transpose', N, N, 1.0, A, N, 1, 0, x, 1, 0, 1.0, y, 1, 0 ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( 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 N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+'::native:ndarray:size='+(N*N), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/c/Makefile new file mode 100644 index 000000000000..cce2c865d7ad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# 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/dgemv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..cc9b9e8fa02d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/benchmark/c/benchmark.length.c @@ -0,0 +1,201 @@ +/** +* @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/dgemv.h" +#include +#include +#include +#include +#include + +#define NAME "dgemv" +#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 double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param N array dimension size +* @return elapsed time in seconds +*/ +static double benchmark1( int iterations, int N ) { + double elapsed; + double A[ N*N ]; + double x[ N ]; + double y[ N ]; + double t; + int i; + int j; + + for ( i = 0, j = 0; i < N; i++, j += 2 ) { + x[ i ] = ( rand_double()*20.0 ) - 10.0; + y[ i ] = ( rand_double()*20.0 ) - 10.0; + A[ j ] = ( rand_double()*20.0 ) - 10.0; + A[ j+1 ] = ( rand_double()*20.0 ) - 10.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + c_dgemv( CblasRowMajor, CblasNoTrans, N, N, 1.0, A, N, x, 1, 1.0, y, 1 ); + if ( y[ i%N ] != y[ i%N ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y[ i%N ] != y[ i%N ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param N array dimension size +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int N ) { + double elapsed; + double A[ N*N ]; + double x[ N ]; + double y[ N ]; + double t; + int i; + int j; + + for ( i = 0, j = 0; i < N; i++, j += 2 ) { + x[ i ] = ( rand_double()*20.0 ) - 10.0; + y[ i ] = ( rand_double()*20.0 ) - 10.0; + A[ j ] = ( rand_double()*20.0 ) - 10.0; + A[ j+1 ] = ( rand_double()*20.0 ) - 10.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + c_dgemv_ndarray( CblasNoTrans, N, N, 1.0, A, N, 1, 0, x, 1, 0, 1.0, y, 1, 0 ); + if ( y[ i%N ] != y[ i%N ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y[ i%N ] != y[ i%N ] ){ + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int N; + 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++ ) { + 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: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:size=%d\n", NAME, N*N ); + elapsed = benchmark2( iter, N ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/binding.gyp b/lib/node_modules/@stdlib/blas/base/dgemv/binding.gyp new file mode 100644 index 000000000000..08de71a2020e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/binding.gyp @@ -0,0 +1,265 @@ +# @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. + +# 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/dgemv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dgemv/docs/repl.txt index 0dda295b33e8..254542bc8c78 100644 --- a/lib/node_modules/@stdlib/blas/base/dgemv/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/dgemv/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/float64}}( [ 1.0, 1.0, 1.0 ] ); - > var y0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 1.0 ] ); + > var y0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 1.0 ] ); > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var y1 = new {{alias:@stdlib/array/float64}}( 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/dgemv/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/dgemv/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# 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/dgemv/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dgemv/examples/c/example.c new file mode 100644 index 000000000000..c3780974bdfd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/examples/c/example.c @@ -0,0 +1,54 @@ +/** +* @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/dgemv.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Define a 3x3 matrix stored in row-major order: + const double 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 double x[ 3 ] = { 1.0, 2.0, 3.0 }; + double 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 operation `y = α*A*x + β*y`: + c_dgemv( 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 ] = %lf\n", i, y[ i ] ); + } + + // Perform the matrix-vector operation `y = α*A*x + β*y` using alternative indexing semantics: + c_dgemv_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 ] = %lf\n", i, y[ i ] ); + } +} diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/examples/index.js b/lib/node_modules/@stdlib/blas/base/dgemv/examples/index.js index e1c12440434c..6752d4cf2fc0 100644 --- a/lib/node_modules/@stdlib/blas/base/dgemv/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/dgemv/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 ); -dgemv( 'row-major', 'no-transpose', M, N, 1.0, A, N, x, -1, 1.0, y, -1 ); +dgemv( 'row-major', 'no-transpose', M, N, 1.0, A, N, x, 1, 1.0, y, 1 ); +console.log( y ); + +dgemv.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/dgemv/include.gypi b/lib/node_modules/@stdlib/blas/base/dgemv/include.gypi new file mode 100644 index 000000000000..4217944b5d20 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/include.gypi @@ -0,0 +1,70 @@ +# @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. + +# 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)', + ' [ 7.0, 16.0 ] +*/ +function dgemv( 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; +} + + +// EXPORTS // + +module.exports = dgemv; diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/lib/native.js b/lib/node_modules/@stdlib/blas/base/dgemv/lib/native.js new file mode 100644 index 000000000000..7b60465bb719 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/lib/native.js @@ -0,0 +1,35 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dgemv = require( './dgemv.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( dgemv, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dgemv; diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dgemv/lib/ndarray.native.js new file mode 100644 index 000000000000..9a017c5b3081 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/lib/ndarray.native.js @@ -0,0 +1,93 @@ +/** +* @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. +*/ + +'use strict'; + +// 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' ); + + +// 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} 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 {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {number} beta - scalar constant +* @param {Float64Array} 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 {Float64Array} `y` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0 ] ); +* +* dgemv( 'no-transpose', 2, 3, 1.0, A, 3, 1, 0, x, 1, 0, 1.0, y, 1, 0 ); +* // y => [ 7.0, 16.0 ] +*/ +function dgemv( 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; +} + + +// EXPORTS // + +module.exports = dgemv; diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/manifest.json b/lib/node_modules/@stdlib/blas/base/dgemv/manifest.json new file mode 100644 index 000000000000..9a3252f0f793 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/manifest.json @@ -0,0 +1,541 @@ +{ + "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": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dgemv.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@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-double", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dgemv.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dgemv.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dgemv_cblas.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@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-double", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dgemv_cblas.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dgemv_cblas.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/dgemv.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@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-double", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/dgemv.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/dgemv.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/dgemv_cblas.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@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-double", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/dgemv_cblas.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/dgemv_cblas.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dgemv_cblas.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@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-double", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dgemv_cblas.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dgemv_cblas.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/dgemv.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@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-double", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/dgemv.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/dgemv.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/dgemv.c", + "./src/dgemv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", + "@stdlib/blas/base/dscal", + "@stdlib/blas/ext/base/dfill", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/package.json b/lib/node_modules/@stdlib/blas/base/dgemv/package.json index b87cabbbd1bb..972ed1b02837 100644 --- a/lib/node_modules/@stdlib/blas/base/dgemv/package.json +++ b/lib/node_modules/@stdlib/blas/base/dgemv/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", diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/src/Makefile b/lib/node_modules/@stdlib/blas/base/dgemv/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @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. +#/ + +# 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/dgemv/src/addon.c b/lib/node_modules/@stdlib/blas/base/dgemv/src/addon.c new file mode 100644 index 000000000000..ca7fd4fd5108 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/src/addon.c @@ -0,0 +1,124 @@ +/** +* @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/dgemv.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_double.h" +#include "stdlib/napi/argv_strided_float64array.h" +#include "stdlib/napi/argv_strided_float64array2d.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 ) { + 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, layout, 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_DOUBLE( env, alpha, argv, 4 ); + STDLIB_NAPI_ARGV_DOUBLE( env, beta, argv, 9 ); + + if ( trans == CblasNoTrans ) { + xlen = N; + ylen = M; + } else { + xlen = M; + ylen = N; + } + if ( layout == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + } else { // layout === CblasRowMajor + sa1 = LDA; + sa2 = 1; + } + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, xlen, strideX, argv, 7 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, ylen, strideY, argv, 10 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, M, N, sa1, sa2, argv, 5 ); + + API_SUFFIX(c_dgemv)( layout, 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 ) { + CBLAS_INT xlen; + CBLAS_INT ylen; + + 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_DOUBLE( env, alpha, argv, 3 ); + STDLIB_NAPI_ARGV_DOUBLE( env, beta, argv, 11 ); + + if ( trans == CblasNoTrans ) { + xlen = N; + ylen = M; + } else { + xlen = M; + ylen = N; + } + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, xlen, strideX, argv, 8 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, ylen, strideY, argv, 12 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, M, N, strideA1, strideA2, argv, 4 ); + + API_SUFFIX(c_dgemv_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/dgemv/src/dgemv.c b/lib/node_modules/@stdlib/blas/base/dgemv/src/dgemv.c new file mode 100644 index 000000000000..e4f6ccdfff0c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/src/dgemv.c @@ -0,0 +1,113 @@ +/** +* @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/dgemv.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 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 beta scalar constant +* @param Y second input vector +* @param strideY `Y` stride length +* @return output value +*/ +void API_SUFFIX(c_dgemv)( const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *A, const CBLAS_INT LDA, const double *X, const CBLAS_INT strideX, const double beta, double *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_dgemv", "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_dgemv", "Error: invalid argument. Second argument must be a valid transpose operation. Value: `%d`.", trans ); + return; + } + if ( M < 0 ) { + c_xerbla( 3, "c_dgemv", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", M ); + return; + } + if ( N < 0 ) { + c_xerbla( 4, "c_dgemv", "Error: invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 9, "c_dgemv", "Error: invalid argument. Ninth argument must be a nonzero. Value: `%d`.", strideX ); + return; + } + if ( strideY == 0 ) { + c_xerbla( 12, "c_dgemv", "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_dgemv", "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; + } else { + xlen = M; + ylen = N; + } + if ( layout == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + } else { // layout === CblasRowMajor + sa1 = LDA; + sa2 = 1; + } + ox = stdlib_strided_stride2offset( xlen, strideX ); + oy = stdlib_strided_stride2offset( ylen, strideY ); + API_SUFFIX(c_dgemv_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/dgemv/src/dgemv_cblas.c b/lib/node_modules/@stdlib/blas/base/dgemv/src/dgemv_cblas.c new file mode 100644 index 000000000000..78b7e7e10f28 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/src/dgemv_cblas.c @@ -0,0 +1,42 @@ +/** +* @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/dgemv.h" +#include "stdlib/blas/base/dgemv_cblas.h" +#include "stdlib/blas/base/shared.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 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 beta scalar constant +* @param y second input vector +* @param strideY `y` stride length +* @return output value +*/ +void API_SUFFIX(c_dgemv)( const CBLAS_LAYOUT layout, const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *A, const CBLAS_INT LDA, const double *X, const CBLAS_INT strideX, const double beta, const double *Y, const CBLAS_INT strideY ) { + API_SUFFIX(cblas_dgemv)( layout, trans, M, N, alpha, A, LDA, X, strideX, beta, Y, strideY ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/src/dgemv_ndarray.c b/lib/node_modules/@stdlib/blas/base/dgemv/src/dgemv_ndarray.c new file mode 100644 index 000000000000..1ff2113ba9da --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/src/dgemv_ndarray.c @@ -0,0 +1,167 @@ +/** +* @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/dgemv.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/xerbla.h" +#include "stdlib/blas/base/dscal.h" +#include "stdlib/blas/ext/base/dfill.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 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` +* @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_dgemv_ndarray)( const CBLAS_TRANSPOSE trans, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double beta, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) { + int64_t sa[ 2 ]; + CBLAS_INT isrm; + CBLAS_INT xlen; + CBLAS_INT ylen; + CBLAS_INT da0; + CBLAS_INT da1; + CBLAS_INT ix; + CBLAS_INT iy; + CBLAS_INT ia; + CBLAS_INT i0; + CBLAS_INT i1; + double tmp; + + // Note on variable naming convention: da#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Perform input argument validation... + if ( trans != CblasTrans && trans != CblasConjTrans && trans != CblasNoTrans ) { + c_xerbla( 1, "c_dgemv_ndarray", "Error: invalid argument. First argument must be a valid transpose operation. Value: `%d`.", trans ); + return; + } + if ( M < 0 ) { + c_xerbla( 2, "c_dgemv_ndarray", "Error: invalid argument. Second argument must be a nonnegative integer. Value: `%d`.", M ); + return; + } + if ( N < 0 ) { + c_xerbla( 3, "c_dgemv_ndarray", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 10, "c_dgemv_ndarray", "Error: invalid argument. Tenth argument must be a nonzero. Value: `%d`.", strideX ); + return; + } + if ( strideY == 0 ) { + c_xerbla( 14, "c_dgemv_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; + } else { + xlen = M; + ylen = N; + } + // Y = beta * Y + if ( beta == 0.0 ) { + API_SUFFIX(stdlib_strided_dfill_ndarray)( ylen, 0.0, Y, strideY, offsetY ); + } else if ( beta != 1.0 ) { + API_SUFFIX(c_dscal_ndarray)( ylen, beta, Y, strideY, offsetY ); + } + if ( alpha == 0.0 ) { + return; + } + // Form: Y = α*A*X + Y + 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[ 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; + } + } + ix += strideX; + ia += da1; + } + return; + } + // Form: Y = α*A^T*X + Y + + // ( !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.0; + ix = offsetX; + for ( i0 = 0; i0 < xlen; i0++ ) { + tmp += A[ ia ] * X[ ix ]; + ix += strideX; + ia += da0; + } + Y[ iy ] += alpha * tmp; + iy += strideY; + ia += da1; + } + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/test/fixtures/column_major_alpha_zero.json b/lib/node_modules/@stdlib/blas/base/dgemv/test/fixtures/column_major_alpha_zero.json new file mode 100644 index 000000000000..33f237a34ca8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/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/dgemv/test/fixtures/column_major_x_zeros.json b/lib/node_modules/@stdlib/blas/base/dgemv/test/fixtures/column_major_x_zeros.json new file mode 100644 index 000000000000..a0ec9dd61530 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/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/dgemv/test/fixtures/column_major_x_zeros_beta_one.json b/lib/node_modules/@stdlib/blas/base/dgemv/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/dgemv/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/dgemv/test/fixtures/row_major_alpha_zero.json b/lib/node_modules/@stdlib/blas/base/dgemv/test/fixtures/row_major_alpha_zero.json new file mode 100644 index 000000000000..1bced86ae275 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/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/dgemv/test/fixtures/row_major_x_zeros.json b/lib/node_modules/@stdlib/blas/base/dgemv/test/fixtures/row_major_x_zeros.json new file mode 100644 index 000000000000..7a5af3e7dc61 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/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/dgemv/test/fixtures/row_major_x_zeros_beta_one.json b/lib/node_modules/@stdlib/blas/base/dgemv/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/dgemv/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/dgemv/test/test.dgemv.js b/lib/node_modules/@stdlib/blas/base/dgemv/test/test.dgemv.js index f74c6ee84680..6e6257e70d91 100644 --- a/lib/node_modules/@stdlib/blas/base/dgemv/test/test.dgemv.js +++ b/lib/node_modules/@stdlib/blas/base/dgemv/test/test.dgemv.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 // @@ -462,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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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; @@ -470,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 Float64Array( data.A ); x = new Float64Array( data.x ); y = new Float64Array( data.y ); - expected = new Float64Array( data.y.length ); + expected = new Float64Array( data.y_out ); - out = dgemv( data.order, data.trans, data.M, data.N, 0.0, a, data.lda, x, data.strideX, 0.0, y, data.strideY ); + out = dgemv( 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' ); @@ -493,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 Float64Array( data.A ); x = new Float64Array( data.x ); y = new Float64Array( data.y ); - expected = new Float64Array( data.y.length ); + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); - out = dgemv( data.order, data.trans, data.M, data.N, 0.0, a, data.lda, x, data.strideX, 0.0, y, data.strideY ); + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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/dgemv/test/test.dgemv.native.js b/lib/node_modules/@stdlib/blas/base/dgemv/test/test.dgemv.native.js new file mode 100644 index 000000000000..1dd8ae30868f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/test/test.dgemv.native.js @@ -0,0 +1,800 @@ +/** +* @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. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +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 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' ); +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 dgemv = tryRequire( resolve( __dirname, './../lib/dgemv.native.js' ) ); +var opts = { + 'skip': ( dgemv instanceof Error ) +}; + + +// TESTS // + +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.end(); +}); + +tape( 'the function has an arity of 12', opts, function test( t ) { + t.strictEqual( dgemv.length, 12, '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.trans, data.M, data.N, data.alpha, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX, data.beta, new Float64Array( 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() { + dgemv( data.order, value, data.M, data.N, data.alpha, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX, data.beta, new Float64Array( 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() { + dgemv( data.order, data.trans, value, data.N, data.alpha, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX, data.beta, new Float64Array( 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() { + dgemv( data.order, data.trans, data.M, value, data.alpha, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX, data.beta, new Float64Array( 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() { + dgemv( data.order, data.trans, data.M, data.N, data.alpha, new Float64Array( data.A ), value, new Float64Array( data.x ), data.strideX, data.beta, new Float64Array( 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() { + dgemv( data.order, data.trans, data.M, data.N, data.alpha, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), value, data.beta, new Float64Array( 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() { + dgemv( data.order, data.trans, data.M, data.N, data.alpha, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX, data.beta, new Float64Array( 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; + var out; + var a; + var x; + var y; + + data = rnt; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y ); + + out = dgemv( 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 = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y ); + + out = dgemv( 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 = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y ); + + out = dgemv( 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 `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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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; + var out; + var a; + var x; + var y; + + data = ra; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 `β` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ca; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyp; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); + + out = dgemv( 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(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dgemv/test/test.ndarray.js index 1b2be0b26f6f..8b239302273c 100644 --- a/lib/node_modules/@stdlib/blas/base/dgemv/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dgemv/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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxb; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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 `α` 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 Float64Array( data.A ); x = new Float64Array( data.x ); y = new Float64Array( data.y ); - expected = new Float64Array( data.y.length ); + expected = new Float64Array( data.y_out ); - out = dgemv( 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' ); @@ -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 Float64Array( data.A ); x = new Float64Array( data.x ); y = new Float64Array( data.y ); - expected = new Float64Array( data.y.length ); + expected = new Float64Array( 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)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.y_out ); - out = dgemv( 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' ); + + 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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' ); diff --git a/lib/node_modules/@stdlib/blas/base/dgemv/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dgemv/test/test.ndarray.native.js new file mode 100644 index 000000000000..0c195ceeda36 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dgemv/test/test.ndarray.native.js @@ -0,0 +1,1035 @@ +/** +* @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. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +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 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' ); +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' ); +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 dgemv = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dgemv instanceof Error ) +}; + + +// TESTS // + +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.end(); +}); + +tape( 'the function has an arity of 15', opts, function test( t ) { + 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 Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX, data.beta, new Float64Array( 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 Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX, data.beta, new Float64Array( 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 Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX, data.beta, new Float64Array( 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 Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), value, data.offsetX, data.beta, new Float64Array( 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 Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX, data.beta, new Float64Array( 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; + var out; + var a; + var x; + var y; + + data = rnt; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( 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 ); + 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( 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 ); + 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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 ); + 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 ); + 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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 ); + 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 ); + 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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 ); + 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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 ); + 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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 `α` 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 = ra; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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 `α` 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 = ca; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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( '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 Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( 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(); +});