From fcf1b0bf36a81603c2a1eb4274e393817e37f68a Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Apr 2025 00:28:32 +0530 Subject: [PATCH 01/32] feat: add c implementation for blas/base/dsyr2 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dsyr2/README.md | 95 ++- .../base/dsyr2/benchmark/benchmark.native.js | 110 +++ .../benchmark/benchmark.ndarray.native.js | 110 +++ .../blas/base/dsyr2/benchmark/c/Makefile | 146 ++++ .../blas/base/dsyr2/benchmark/c/benchmark.c | 182 +++++ .../@stdlib/blas/base/dsyr2/binding.gyp | 265 +++++++ .../blas/base/dsyr2/examples/c/Makefile | 146 ++++ .../blas/base/dsyr2/examples/c/example.c | 47 ++ .../@stdlib/blas/base/dsyr2/include.gypi | 70 ++ .../dsyr2/include/stdlib/blas/base/dsyr2.h | 48 ++ .../include/stdlib/blas/base/dsyr2_cblas.h | 43 ++ .../blas/base/dsyr2/lib/dsyr2.native.js | 63 ++ .../@stdlib/blas/base/dsyr2/lib/native.js | 35 + .../blas/base/dsyr2/lib/ndarray.native.js | 65 ++ .../@stdlib/blas/base/dsyr2/manifest.json | 307 ++++++++ .../@stdlib/blas/base/dsyr2/package.json | 3 + .../@stdlib/blas/base/dsyr2/src/Makefile | 70 ++ .../@stdlib/blas/base/dsyr2/src/addon.c | 58 ++ .../@stdlib/blas/base/dsyr2/src/dsyr2.c | 150 ++++ .../@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c | 39 + .../blas/base/dsyr2/test/test.dsyr2.native.js | 418 +++++++++++ .../base/dsyr2/test/test.ndarray.native.js | 705 ++++++++++++++++++ 22 files changed, 3168 insertions(+), 7 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2.h create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md index a94a443ea293..fc19991f124b 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md @@ -193,21 +193,74 @@ console.log( A ); ### Usage ```c -TODO +#include "stdlib/blas/base/dsyr2.h" ``` -#### TODO +#### c_dsyr2( order, uplo, N, alpha, \*X, strideX, \*Y, strideY, \*A, LDA ) -TODO. +Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. ```c -TODO +#include "stdlib/blas/base/shared.h" + +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 }; +const double y[] = { 1.0, 2.0, 3.0 }; + +c_dsyr2( CblasColMajor, CblasUpper, 3, 1.0, x, 1, y, 1, A, 3 ); +``` + +The function accepts the following arguments: + +- **order**: `[in] CBLAS_LAYOUT` storage layout. +- **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced. +- **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. +- **alpha**: `[in] double` scalar. +- **X**: `[in] double*` first input array. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **Y**: `[in] double*` second input array. +- **strideY**: `[in] CBLAS_INT` index increment for `Y`. +- **A**: `[inout] double*` input matrix. +- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). + +```c +void c_dsyr2( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) +``` + + + +#### c_dsyr2_ndarray( uplo, N, alpha, \*X, strideX, offsetX, \*Y, strideY, offsetY, \*A, sa1, sa2, oa ) + +Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics. + +```c +#include "stdlib/blas/base/shared.h" + +double A[] = { 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 }; +const double x[] = { 1.0, 2.0, 3.0 }; +const double y[] = { 1.0, 2.0, 3.0 }; + +c_dsyr2_ndarray( CblasUpper, 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); ``` -TODO +The function accepts the following arguments: + +- **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced. +- **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. +- **alpha**: `[in] double` scalar. +- **X**: `[in] double*` first input array. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **Y**: `[in] double` second input array. +- **strideY**: `[in] CBLAS_INT` index increment for `Y`. +- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. +- **A**: `[inout] 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`. ```c -TODO +void c_dsyr2_ndarray( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT sa1, const CBLAS_INT sa2, const CBLAS_INT oa ) ``` @@ -229,7 +282,35 @@ TODO ### Examples ```c -TODO +#include "stdlib/blas/base/dsyr2.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Create strided arrays: + 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 }; + const double y[] = { 1.0, 2.0, 3.0 }; + + // Specify the number of elements along each dimension of `A`: + const int N = 3; + + // Perform the symmetric rank 1 operation `A = α*x*x^T + A`: + c_dsyr2( CblasColMajor, CblasUpper, N, 1.0, x, 1, y, 1 A, N ); + + // Print the result: + for ( int i = 0; i < N*N; i++ ) { + printf( "A[ %i ] = %f\n", i, A[ i ] ); + } + + // Perform the symmetric rank 1 operation `A = α*x*x^T + A`: + c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); + + // Print the result: + for ( int i = 0; i < N*N; i++ ) { + printf( "A[ %i ] = %f\n", i, A[ i ] ); + } +} ``` diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.native.js new file mode 100644 index 000000000000..0ce3799353f6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.native.js @@ -0,0 +1,110 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var ones = require( '@stdlib/array/ones' ); +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 dsyr2 = tryRequire( resolve( __dirname, './../lib/dsyr2.native.js' ) ); +var opts = { + 'skip': ( dsyr2 instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = ones( N, options.dtype ); + var y = ones( N, options.dtype ); + var A = ones( N*N, options.dtype ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dsyr2( 'row-major', 'upper', N, 1.0, x, 1, y, 1, A, N ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + 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/dsyr2/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..534af4370389 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,110 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var ones = require( '@stdlib/array/ones' ); +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 dsyr2 = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dsyr2 instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = ones( N, options.dtype ); + var y = ones( N, options.dtype ); + var A = ones( N*N, options.dtype ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dsyr2( 'upper', N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + 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/dsyr2/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/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.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/dsyr2/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c new file mode 100644 index 000000000000..14b36298b44e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c @@ -0,0 +1,182 @@ +/** +* @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/dsyr2.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/blas/ext/base/sfill.h" +#include +#include +#include +#include +#include + +#define NAME "dsyr2" +#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; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param N number of elements along each dimension +* @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; + + stdlib_strided_sfill( N, 0.5, x, 1 ); + stdlib_strided_sfill( N, 0.5, y, 1 ); + stdlib_strided_sfill( N*N, 1.0, A, 1 ); + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_dsyr2( CblasRowMajor, CblasUpper, N, 1.0, x, 1, y, 1, A, N ); + if ( A[ 0 ] != A[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( A[ 0 ] != A[ 0 ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param N number of elements along each dimension +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int N ) { + double elapsed; + double A[ N*N ]; + double x[ N ]; + double t; + int i; + + stdlib_strided_sfill( N, 0.5, x, 1 ); + stdlib_strided_sfill( N, 0.5, y, 1 ); + stdlib_strided_sfill( N*N, 1.0, A, 1 ); + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); + if ( A[ 0 ] != A[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( A[ 0 ] != A[ 0 ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int i; + int j; + int N; + + // 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/dsyr2/binding.gyp b/lib/node_modules/@stdlib/blas/base/dsyr2/binding.gyp new file mode 100644 index 000000000000..08de71a2020e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/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/dsyr2/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/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/dsyr2/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c new file mode 100644 index 000000000000..6e11d89ade11 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c @@ -0,0 +1,47 @@ +/** +* @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/dsyr2.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Create strided arrays: + 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 }; + const double y[] = { 1.0, 2.0, 3.0 }; + + // Specify the number of elements along each dimension of `A`: + const int N = 3; + + // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`: + c_dsyr2( CblasColMajor, CblasUpper, N, 1.0, x, 1, y, 1, A, N ); + + // Print the result: + for ( int i = 0; i < N*N; i++ ) { + printf( "A[ %i ] = %f\n", i, A[ i ] ); + } + + // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`: + c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); + + // Print the result: + for ( int i = 0; i < N*N; i++ ) { + printf( "A[ %i ] = %f\n", i, A[ i ] ); + } +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/include.gypi b/lib/node_modules/@stdlib/blas/base/dsyr2/include.gypi new file mode 100644 index 000000000000..4217944b5d20 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/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)', + ' [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); +* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +*/ +function dsyr2( order, uplo, N, alpha, x, strideX, y, strideY, A, LDA ) { + addon( resolveOrder( order ), resolveUplo( uplo ), N, alpha, x, strideX, y, strideY, A, LDA ); // eslint-disable-line max-len + return A; +} + + +// EXPORTS // + +module.exports = dsyr2; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/native.js new file mode 100644 index 000000000000..eba705c8948d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/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 dsyr2 = require( './dsyr2.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( dsyr2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dsyr2; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js new file mode 100644 index 000000000000..e0747d2680e2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js @@ -0,0 +1,65 @@ +/** +* @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 resolveUplo = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. +* +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` +* @param {number} alpha - scalar +* @param {Float64Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float64Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @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` +* @returns {Float64Array} `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); +* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +*/ +function dsyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params + addon.ndarray( resolveUplo( uplo ), N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ); // eslint-disable-line max-len + return A; +} + + +// EXPORTS // + +module.exports = dsyr2; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json new file mode 100644 index 000000000000..6f6485541e23 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json @@ -0,0 +1,307 @@ +{ + "options": { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "os": "win", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dsyr2_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-double" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dsyr2_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dsyr2_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/dsyr2_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-double" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/dsyr2_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/dsyr2_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dsyr2_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-double" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dsyr2_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dsyr2_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dsyr2.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-double" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dsyr2.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/ext/base/sfill", + "@stdlib/math/base/special/floor" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dsyr2.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + }, + + { + "task": "build", + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/dsyr2.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/package.json b/lib/node_modules/@stdlib/blas/base/dsyr2/package.json index a98704dd8ba8..cebe22452ed2 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/package.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/package.json @@ -14,11 +14,14 @@ } ], "main": "./lib", + "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/dsyr2/src/Makefile b/lib/node_modules/@stdlib/blas/base/dsyr2/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/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/dsyr2/src/addon.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c new file mode 100644 index 000000000000..7644f86f30e8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c @@ -0,0 +1,58 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/dsyr2.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 + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 10 ); + + STDLIB_NAPI_ARGV_INT32( env, order, argv, 0 ); + STDLIB_NAPI_ARGV_INT32( env, uplo, argv, 1 ); + + STDLIB_NAPI_ARGV_INT64( env, N, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 7 ); + STDLIB_NAPI_ARGV_INT64( env, LDA, argv, 9 ); + + STDLIB_NAPI_ARGV_DOUBLE( env, alpha, argv, 3 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 4 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, A, ((N-1)*LDA) + N, 1, argv, 8 ); + + API_SUFFIX(c_dsyr2)( order, uplo, N, alpha, X, strideX, Y, strideY, A, LDA ); + + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c new file mode 100644 index 000000000000..0a864a0673bc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c @@ -0,0 +1,150 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/base/ssyr2.h" +#include "stdlib/blas/base/shared.h" + +/** +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. +* +* @param order storage layout +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param N number of elements along each dimension of `A` +* @param alpha scalar +* @param x first input vector +* @param strideX `x` stride length +* @param y second input vector +* @param strideY `y` stride length +* @param A input matrix +* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +*/ +void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { + CBLAS_INT sa1; + CBLAS_INT sa2; + CBLAS_INT ox; + CBLAS_INT oy; + + if ( N == 0 || alpha == 0.0 ) { + return; + } + if ( order == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + ox = STDLIB_BLAS_BASE_STRIDE2OFFSET( N, strideX ); + oy = STDLIB_BLAS_BASE_STRIDE2OFFSET( N, strideY ); + API_SUFFIX(c_dsyr2_ndarray)( uplo, N, alpha, X, strideX, ox, Y, strideY, oy, A, sa1, sa2, 0 ); + return; +} + +/** +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics. +* +* @param order storage layout +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param N number of elements along each dimension of `A` +* @param alpha scalar +* @param x first input vector +* @param strideX `x` stride length +* @param offsetX starting index of `X` +* @param y second input vector +* @param strideY `y` stride length +* @param offsetY starting index of `Y` +* @param A input matrix +* @param strideA1 stride of the first dimension of `A` +* @param strideA2 stride of the second dimension of `A` +* @param offsetA starting index of `A` +*/ +void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) { + CBLAS_INT isrm; + CBLAS_INT ix0; + CBLAS_INT ix1; + CBLAS_INT iy0; + CBLAS_INT iy1; + CBLAS_INT sa0; + CBLAS_INT sa1; + CBLAS_INT i0; + CBLAS_INT i1; + CBLAS_INT oa; + CBLAS_INT ox; + CBLAS_INT oy; + double tmp1; + double tmp2; + + int64_t strides[] = { strideA1, strideA2 }; + if ( N == 0 || alpha == 0.0 ) { + return; + } + isrm = stdlib_ndarray_is_row_major( 2, strides ); + if ( isrm ) { + // For row-major matrices, the last dimension has the fastest changing index... + sa0 = strideA2; // stride for innermost loop + sa1 = strideA1; // stride for outermost loop + } else { // isColMajor + // For column-major matrices, the first dimension has the fastest changing index... + sa0 = strideA1; // stride for innermost loop + sa1 = strideA2; // stride for outermost loop + } + ox = offsetX; + oy = offsetY; + ix1 = ox; + iy1 = oy; + if ( + ( isrm && uplo == CblasLower ) || + ( isrm && uplo == CblasUpper ) + ) { + for ( i1 = 0; i1 < N; i1++ ) { + if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) { + tmp1 = alpha * Y[ iy1 ]; + tmp2 = alpha * X[ ix1 ]; + oa = offsetA + (sa1*i1); + ix0 = ox; + iy0 = oy; + for ( i0 = 0; i0 <= i1; i0++ ) { + A[ oa+(sa0*i0) ] += ( x[ ix0 ] * tmp1 ) + ( y[ iy0 ] * tmp2 ); // eslint-disable-line max-len + ix0 += strideX; + iy0 += strideY; + } + } + ix1 += strideX; + iy1 += strideY; + } + return; + } + // ( order == CblasRowMajor && uplo == CblasUpper ) || ( order == CblasColMajor && uplo == CblasLower ) + for ( i1 = 0; i1 < N; i1++ ) { + if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) { + tmp1 = alpha * Y[ iy1 ]; + tmp2 = alpha * X[ ix1 ]; + oa = offsetA + (sa1*i1); + ix0 = ix1; + iy0 = iy1; + for ( i0 = i1; i0 < N; i0++ ) { + A[ oa+(sa0*i0) ] += ( x[ ix0 ] * tmp1 ) + ( y[ iy0 ] * tmp2 ); + ix0 += strideX; + iy0 += strideY; + } + } + ix1 += strideX; + iy1 += strideY; + } + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c new file mode 100644 index 000000000000..8fee943a07c4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c @@ -0,0 +1,39 @@ +/** +* @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/dsyr2.h" +#include "stdlib/blas/base/dsyr2_cblas.h" +#include "stdlib/blas/base/shared.h" + +/** +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. +* +* @param order storage layout +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param N number of elements along each dimension of `A` +* @param alpha scalar +* @param x first input vector +* @param strideX `X` stride length +* @param y second input vector +* @param strideY `Y` stride length +* @param A input matrix +* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +*/ +void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { + API_SUFFIX(cblas_dsyr2)( order, uplo, N, alpha, X, strideX, Y, strideY, A, LDA ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js new file mode 100644 index 000000000000..1dd1b87426e8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js @@ -0,0 +1,418 @@ +/** +* @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 str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); +var str2enumLayout = require( '@stdlib/blas/base/layout-str2enum' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// FIXTURES // + +var ru = require( './fixtures/row_major_u.json' ); +var rl = require( './fixtures/row_major_l.json' ); +var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rxnyp = require( './fixtures/row_major_xnyp.json' ); +var rxpyn = require( './fixtures/row_major_xpyn.json' ); +var rxnyn = require( './fixtures/row_major_xnyn.json' ); + +var cu = require( './fixtures/column_major_u.json' ); +var cl = require( './fixtures/column_major_l.json' ); +var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cxnyp = require( './fixtures/column_major_xnyp.json' ); +var cxpyn = require( './fixtures/column_major_xpyn.json' ); +var cxnyn = require( './fixtures/column_major_xnyn.json' ); + + +// VARIABLES // + +var dsyr2 = tryRequire( resolve( __dirname, './../lib/dsyr.native.js' ) ); +var opts = { + 'skip': ( dsyr2 instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dsyr2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', opts, function test( t ) { + t.strictEqual( dsyr2.length, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, upper)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ru; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, upper)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, lower)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, lower)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the input matrix `A`', opts, function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = ru; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying 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.A_out ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying 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.A_out ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, '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.A_out ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, '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.A_out ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, '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.A_out ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, '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.A_out ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, '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.A_out ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, '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.A_out ); + + out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js new file mode 100644 index 000000000000..f56516e74f40 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js @@ -0,0 +1,705 @@ +/** +* @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 str2enumMatrixTriangle = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// FIXTURES // + +var ru = require( './fixtures/row_major_u.json' ); +var rl = require( './fixtures/row_major_l.json' ); +var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rxnyp = require( './fixtures/row_major_xnyp.json' ); +var rxpyn = require( './fixtures/row_major_xpyn.json' ); +var rxnyn = require( './fixtures/row_major_xnyn.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 rcap = require( './fixtures/row_major_complex_access_pattern.json' ); + +var cu = require( './fixtures/column_major_u.json' ); +var cl = require( './fixtures/column_major_l.json' ); +var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cxnyp = require( './fixtures/column_major_xnyp.json' ); +var cxpyn = require( './fixtures/column_major_xpyn.json' ); +var cxnyn = require( './fixtures/column_major_xnyn.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 ccap = require( './fixtures/column_major_complex_access_pattern.json' ); + + +// VARIABLES // + +var dsyr2 = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dsyr2 instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dsyr2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', opts, function test( t ) { + t.strictEqual( dsyr2.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, upper)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ru; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, upper)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, lower)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, lower)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the input matrix `A`', function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = ru; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the strides for the first and the second dimensions of `A` (row-major)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the strides for the first and the second dimensions of `A` (column-major)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, '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)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, '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)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, '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)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, '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)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides for `A` (row-major)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides for `A` (column-major)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `A` offset (row-major)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `A` offset (column-major)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (row-major)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` strides (column-major)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (row-major)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (column-major)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (row-major)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (column-major)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, '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)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, '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)', 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.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rcap; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ccap; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); From b57a3f43357d904087e9849352674082fd4d465a Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Apr 2025 01:01:54 +0530 Subject: [PATCH 02/32] chore: add correct packages --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/base/dsyr2/benchmark/c/benchmark.c | 15 ++++++----- .../@stdlib/blas/base/dsyr2/manifest.json | 20 +++++++++----- .../@stdlib/blas/base/dsyr2/src/dsyr2.c | 27 ++++++++++--------- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c index 14b36298b44e..5de3721a0cbd 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c @@ -18,7 +18,7 @@ #include "stdlib/blas/base/dsyr2.h" #include "stdlib/blas/base/shared.h" -#include "stdlib/blas/ext/base/sfill.h" +#include "stdlib/blas/ext/base/dfill.h" #include #include #include @@ -94,9 +94,9 @@ static double benchmark1( int iterations, int N ) { double t; int i; - stdlib_strided_sfill( N, 0.5, x, 1 ); - stdlib_strided_sfill( N, 0.5, y, 1 ); - stdlib_strided_sfill( N*N, 1.0, A, 1 ); + stdlib_strided_dfill( N, 0.5, x, 1 ); + stdlib_strided_dfill( N, 0.5, y, 1 ); + stdlib_strided_dfill( N*N, 1.0, A, 1 ); t = tic(); for ( i = 0; i < iterations; i++ ) { c_dsyr2( CblasRowMajor, CblasUpper, N, 1.0, x, 1, y, 1, A, N ); @@ -123,12 +123,13 @@ static double benchmark2( int iterations, int N ) { double elapsed; double A[ N*N ]; double x[ N ]; + double y[ N ]; double t; int i; - stdlib_strided_sfill( N, 0.5, x, 1 ); - stdlib_strided_sfill( N, 0.5, y, 1 ); - stdlib_strided_sfill( N*N, 1.0, A, 1 ); + stdlib_strided_dfill( N, 0.5, x, 1 ); + stdlib_strided_dfill( N, 0.5, y, 1 ); + stdlib_strided_dfill( N*N, 1.0, A, 1 ); t = tic(); for ( i = 0; i < iterations; i++ ) { c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json index 6f6485541e23..5ab670b7d03d 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json @@ -51,7 +51,7 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", - "@stdlib/napi/argv-double" + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -246,7 +246,9 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-double", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -264,8 +266,10 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/ext/base/sfill", - "@stdlib/math/base/special/floor" + "@stdlib/blas/ext/base/dfill", + "@stdlib/math/base/special/floor", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -282,7 +286,9 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, @@ -300,7 +306,9 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] } ] diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c index 0a864a0673bc..371cc8b5862a 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c @@ -16,8 +16,10 @@ * limitations under the License. */ -#include "stdlib/blas/base/ssyr2.h" +#include "stdlib/blas/base/dsyr2.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" +#include "stdlib/ndarray/base/assert/is_row_major.h" /** * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. @@ -26,10 +28,10 @@ * @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced * @param N number of elements along each dimension of `A` * @param alpha scalar -* @param x first input vector -* @param strideX `x` stride length -* @param y second input vector -* @param strideY `y` stride length +* @param X first input vector +* @param strideX `X` stride length +* @param Y second input vector +* @param strideY `Y` stride length * @param A input matrix * @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) */ @@ -58,22 +60,21 @@ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const /** * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics. * -* @param order storage layout * @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced * @param N number of elements along each dimension of `A` * @param alpha scalar -* @param x first input vector -* @param strideX `x` stride length +* @param X first input vector +* @param strideX `X` stride length * @param offsetX starting index of `X` -* @param y second input vector -* @param strideY `y` stride length +* @param Y second input vector +* @param strideY `Y` stride length * @param offsetY starting index of `Y` * @param A input matrix * @param strideA1 stride of the first dimension of `A` * @param strideA2 stride of the second dimension of `A` * @param offsetA starting index of `A` */ -void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) { +void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) { CBLAS_INT isrm; CBLAS_INT ix0; CBLAS_INT ix1; @@ -119,7 +120,7 @@ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const ix0 = ox; iy0 = oy; for ( i0 = 0; i0 <= i1; i0++ ) { - A[ oa+(sa0*i0) ] += ( x[ ix0 ] * tmp1 ) + ( y[ iy0 ] * tmp2 ); // eslint-disable-line max-len + A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 ); // eslint-disable-line max-len ix0 += strideX; iy0 += strideY; } @@ -138,7 +139,7 @@ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const ix0 = ix1; iy0 = iy1; for ( i0 = i1; i0 < N; i0++ ) { - A[ oa+(sa0*i0) ] += ( x[ ix0 ] * tmp1 ) + ( y[ iy0 ] * tmp2 ); + A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 ); ix0 += strideX; iy0 += strideY; } From 441ce2e6c279539e046ddbdfec376cb9f57c8aa0 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sat, 5 Apr 2025 19:36:36 +0000 Subject: [PATCH 03/32] chore: update copyright years --- lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c | 2 +- lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c index 7644f86f30e8..96dbfc3965e9 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c index 371cc8b5862a..69615654a09b 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From d466893f7ba5f770ed7f4178ab65f20c6bd290f0 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 6 Apr 2025 12:19:56 +0530 Subject: [PATCH 04/32] fix: test case errors --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dsyr2/manifest.json | 4 +++ .../@stdlib/blas/base/dsyr2/src/addon.c | 35 ++++++++++++++++++- .../@stdlib/blas/base/dsyr2/src/dsyr2.c | 2 +- .../blas/base/dsyr2/test/test.dsyr2.native.js | 6 ++-- .../base/dsyr2/test/test.ndarray.native.js | 5 ++- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json index 5ab670b7d03d..b660f6f457b1 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json @@ -51,6 +51,7 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d", "@stdlib/ndarray/base/assert/is-row-major" ] }, @@ -117,6 +118,7 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d", "@stdlib/napi/argv-double" ] }, @@ -182,6 +184,7 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d", "@stdlib/napi/argv-double" ] }, @@ -246,6 +249,7 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d", "@stdlib/napi/argv-double", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major" diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c index 96dbfc3965e9..a5b92cc4abf1 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c @@ -24,6 +24,7 @@ #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 /** @@ -55,4 +56,36 @@ static napi_value addon( napi_env env, napi_callback_info info ) { return NULL; } -STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 13 ); + + STDLIB_NAPI_ARGV_INT32( env, uplo, argv, 0 ); + + STDLIB_NAPI_ARGV_INT64( env, N, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 7 ); + STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 8 ); + STDLIB_NAPI_ARGV_INT64( env, strideA1, argv, 10 ); + STDLIB_NAPI_ARGV_INT64( env, strideA2, argv, 11 ); + STDLIB_NAPI_ARGV_INT64( env, offsetA, argv, 12 ); + + STDLIB_NAPI_ARGV_DOUBLE( env, alpha, argv, 2 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, N, N, strideA1, strideA2, argv, 9 ); + + API_SUFFIX(c_dsyr2_ndarray)( uplo, N, alpha, X, strideX, offsetX, Y, strideY, offsetY, A, strideA1, strideA2, offsetA ); + + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c index 69615654a09b..f58daa507ff7 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c @@ -110,7 +110,7 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons iy1 = oy; if ( ( isrm && uplo == CblasLower ) || - ( isrm && uplo == CblasUpper ) + ( !isrm && uplo == CblasUpper ) ) { for ( i1 = 0; i1 < N; i1++ ) { if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) { diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js index 1dd1b87426e8..568dbc0d1643 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js @@ -49,7 +49,7 @@ var cxnyn = require( './fixtures/column_major_xnyn.json' ); // VARIABLES // -var dsyr2 = tryRequire( resolve( __dirname, './../lib/dsyr.native.js' ) ); +var dsyr2 = tryRequire( resolve( __dirname, './../lib/dsyr2.native.js' ) ); var opts = { 'skip': ( dsyr2 instanceof Error ) }; @@ -63,8 +63,8 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); -tape( 'the function has an arity of 8', opts, function test( t ) { - t.strictEqual( dsyr2.length, 8, 'returns expected value' ); +tape( 'the function has an arity of 10', opts, function test( t ) { + t.strictEqual( dsyr2.length, 10, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js index f56516e74f40..3f007e8b9fdc 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js @@ -74,8 +74,8 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); -tape( 'the function has an arity of 10', opts, function test( t ) { - t.strictEqual( dsyr2.length, 10, 'returns expected value' ); +tape( 'the function has an arity of 13', opts, function test( t ) { + t.strictEqual( dsyr2.length, 13, 'returns expected value' ); t.end(); }); @@ -700,6 +700,5 @@ tape( 'the function supports complex access patterns (column-major)', function t out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); - t.end(); }); From 5bdfcf19f19bd8f767c55b03823df35dc5ea78ac Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sun, 6 Apr 2025 13:00:17 +0530 Subject: [PATCH 05/32] fix: jsdoc examples Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js index e0747d2680e2..d15f834fa0cf 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js @@ -51,7 +51,7 @@ var addon = require( './../src/addon.node' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * -* dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); +* dsyr2( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); * // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] */ function dsyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params From dc00b12a6eb3cb097bf8367f7ef7154c889a067f Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 7 May 2025 18:16:04 +0530 Subject: [PATCH 06/32] chore: update implementation --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dsyr2/manifest.json | 12 +- .../@stdlib/blas/base/dsyr2/src/dsyr2.c | 98 +-------------- .../@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c | 46 ++++++- .../blas/base/dsyr2/src/dsyr2_ndarray.c | 115 ++++++++++++++++++ 4 files changed, 168 insertions(+), 103 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json index b660f6f457b1..4bd82276d41a 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json @@ -235,7 +235,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dsyr2.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -261,7 +262,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dsyr2.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -282,7 +284,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dsyr2.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -302,7 +305,8 @@ "blas": "", "wasm": true, "src": [ - "./src/dsyr2.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c index f58daa507ff7..30a79e7ec5e0 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c @@ -19,7 +19,6 @@ #include "stdlib/blas/base/dsyr2.h" #include "stdlib/blas/base/shared.h" #include "stdlib/strided/base/stride2offset.h" -#include "stdlib/ndarray/base/assert/is_row_major.h" /** * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. @@ -51,101 +50,8 @@ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const sa1 = LDA; sa2 = 1; } - ox = STDLIB_BLAS_BASE_STRIDE2OFFSET( N, strideX ); - oy = STDLIB_BLAS_BASE_STRIDE2OFFSET( N, strideY ); + ox = stdlib_strided_stride2offset( N, strideX ); + oy = stdlib_strided_stride2offset( N, strideY ); API_SUFFIX(c_dsyr2_ndarray)( uplo, N, alpha, X, strideX, ox, Y, strideY, oy, A, sa1, sa2, 0 ); return; } - -/** -* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics. -* -* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced -* @param N number of elements along each dimension of `A` -* @param alpha scalar -* @param X first input vector -* @param strideX `X` stride length -* @param offsetX starting index of `X` -* @param Y second input vector -* @param strideY `Y` stride length -* @param offsetY starting index of `Y` -* @param A input matrix -* @param strideA1 stride of the first dimension of `A` -* @param strideA2 stride of the second dimension of `A` -* @param offsetA starting index of `A` -*/ -void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) { - CBLAS_INT isrm; - CBLAS_INT ix0; - CBLAS_INT ix1; - CBLAS_INT iy0; - CBLAS_INT iy1; - CBLAS_INT sa0; - CBLAS_INT sa1; - CBLAS_INT i0; - CBLAS_INT i1; - CBLAS_INT oa; - CBLAS_INT ox; - CBLAS_INT oy; - double tmp1; - double tmp2; - - int64_t strides[] = { strideA1, strideA2 }; - if ( N == 0 || alpha == 0.0 ) { - return; - } - isrm = stdlib_ndarray_is_row_major( 2, strides ); - if ( isrm ) { - // For row-major matrices, the last dimension has the fastest changing index... - sa0 = strideA2; // stride for innermost loop - sa1 = strideA1; // stride for outermost loop - } else { // isColMajor - // For column-major matrices, the first dimension has the fastest changing index... - sa0 = strideA1; // stride for innermost loop - sa1 = strideA2; // stride for outermost loop - } - ox = offsetX; - oy = offsetY; - ix1 = ox; - iy1 = oy; - if ( - ( isrm && uplo == CblasLower ) || - ( !isrm && uplo == CblasUpper ) - ) { - for ( i1 = 0; i1 < N; i1++ ) { - if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) { - tmp1 = alpha * Y[ iy1 ]; - tmp2 = alpha * X[ ix1 ]; - oa = offsetA + (sa1*i1); - ix0 = ox; - iy0 = oy; - for ( i0 = 0; i0 <= i1; i0++ ) { - A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 ); // eslint-disable-line max-len - ix0 += strideX; - iy0 += strideY; - } - } - ix1 += strideX; - iy1 += strideY; - } - return; - } - // ( order == CblasRowMajor && uplo == CblasUpper ) || ( order == CblasColMajor && uplo == CblasLower ) - for ( i1 = 0; i1 < N; i1++ ) { - if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) { - tmp1 = alpha * Y[ iy1 ]; - tmp2 = alpha * X[ ix1 ]; - oa = offsetA + (sa1*i1); - ix0 = ix1; - iy0 = iy1; - for ( i0 = i1; i0 < N; i0++ ) { - A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 ); - ix0 += strideX; - iy0 += strideY; - } - } - ix1 += strideX; - iy1 += strideY; - } - return; -} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c index 8fee943a07c4..d72de559d1a0 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c @@ -16,9 +16,11 @@ * limitations under the License. */ -#include "stdlib/blas/base/dsyr2.h" -#include "stdlib/blas/base/dsyr2_cblas.h" +#include "stdlib/blas/base/dsyr22.h" +#include "stdlib/blas/base/dsyr22_cblas.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/min_view_buffer_index.h" +#include "stdlib/ndarray/base/min_view_buffer_index.h" /** * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. @@ -35,5 +37,43 @@ * @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) */ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { - API_SUFFIX(cblas_dsyr2)( order, uplo, N, alpha, X, strideX, Y, strideY, A, LDA ); + CBLAS_INT sx = strideX; + if ( sx < 0 ) { + sx = -sx; + } + API_SUFFIX(cblas_dsyr2)( order, uplo, N, alpha, X, sx, A, LDA ); +} + +/** +* Performs the symmetric rank 2 operation `A = α*x*x^T + A` using alternative indexing semantics. +* +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param N number of elements along each dimension of `A` +* @param alpha scalar +* @param X input vector +* @param strideX `x` stride length +* @param offsetX starting index for `x` +* @param Y input vector +* @param strideY `y` stride length +* @param offsetY starting index for `y` +* @param A input matrix +* @param strideA1 stride of the first dimension of `A` +* @param strideA2 stride of the second dimension of `A` +* @param offsetA starting index for `A` +*/ +void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) { + CBLAS_INT sx = strideX; + CBLAS_INT sy = strideY; + X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer + Y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer + CBLAS_INT shape[] = { N, N }; + CBLAS_INT strides[] = { strideA1, strideA2 }; + A += stdlib_ndarray_min_view_buffer_index( 2, shape, strides, offsetA ); // adjust array pointer + if ( sx < 0 ) { + sx = -sx; + } + if ( sy < 0 ) { + sy = -sy; + } + API_SUFFIX(cblas_dsyr2)( order, uplo, N, alpha, X, sx, Y, sy, A, LDA ); } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c new file mode 100644 index 000000000000..c7186fdfc298 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c @@ -0,0 +1,115 @@ +/** +* @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/dsyr2.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" +#include "stdlib/ndarray/base/assert/is_row_major.h" + +/** +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics. +* +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param N number of elements along each dimension of `A` +* @param alpha scalar +* @param X first input vector +* @param strideX `X` stride length +* @param offsetX starting index of `X` +* @param Y second input vector +* @param strideY `Y` stride length +* @param offsetY starting index of `Y` +* @param A input matrix +* @param strideA1 stride of the first dimension of `A` +* @param strideA2 stride of the second dimension of `A` +* @param offsetA starting index of `A` +*/ +void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) { + CBLAS_INT isrm; + CBLAS_INT ix0; + CBLAS_INT ix1; + CBLAS_INT iy0; + CBLAS_INT iy1; + CBLAS_INT sa0; + CBLAS_INT sa1; + CBLAS_INT i0; + CBLAS_INT i1; + CBLAS_INT oa; + CBLAS_INT ox; + CBLAS_INT oy; + double tmp1; + double tmp2; + + int64_t strides[] = { strideA1, strideA2 }; + if ( N == 0 || alpha == 0.0 ) { + return; + } + isrm = stdlib_ndarray_is_row_major( 2, strides ); + if ( isrm ) { + // For row-major matrices, the last dimension has the fastest changing index... + sa0 = strideA2; // stride for innermost loop + sa1 = strideA1; // stride for outermost loop + } else { // isColMajor + // For column-major matrices, the first dimension has the fastest changing index... + sa0 = strideA1; // stride for innermost loop + sa1 = strideA2; // stride for outermost loop + } + ox = offsetX; + oy = offsetY; + ix1 = ox; + iy1 = oy; + if ( + ( isrm && uplo == CblasLower ) || + ( !isrm && uplo == CblasUpper ) + ) { + for ( i1 = 0; i1 < N; i1++ ) { + if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) { + tmp1 = alpha * Y[ iy1 ]; + tmp2 = alpha * X[ ix1 ]; + oa = offsetA + (sa1*i1); + ix0 = ox; + iy0 = oy; + for ( i0 = 0; i0 <= i1; i0++ ) { + A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 ); // eslint-disable-line max-len + ix0 += strideX; + iy0 += strideY; + } + } + ix1 += strideX; + iy1 += strideY; + } + return; + } + // ( order == CblasRowMajor && uplo == CblasUpper ) || ( order == CblasColMajor && uplo == CblasLower ) + for ( i1 = 0; i1 < N; i1++ ) { + if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) { + tmp1 = alpha * Y[ iy1 ]; + tmp2 = alpha * X[ ix1 ]; + oa = offsetA + (sa1*i1); + ix0 = ix1; + iy0 = iy1; + for ( i0 = i1; i0 < N; i0++ ) { + A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 ); + ix0 += strideX; + iy0 += strideY; + } + } + ix1 += strideX; + iy1 += strideY; + } + return; +} From c5705ab13926e34aca7ea6f41f91fbe14352ddf7 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 7 May 2025 18:29:30 +0530 Subject: [PATCH 07/32] chore: update datatypes --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c index d72de559d1a0..7280de1abce6 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c @@ -66,8 +66,8 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons CBLAS_INT sy = strideY; X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer Y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer - CBLAS_INT shape[] = { N, N }; - CBLAS_INT strides[] = { strideA1, strideA2 }; + const int64_t shape[] = { N, N }; + const int64_t strides[] = { strideA1, strideA2 }; A += stdlib_ndarray_min_view_buffer_index( 2, shape, strides, offsetA ); // adjust array pointer if ( sx < 0 ) { sx = -sx; From 225459e48067362c9add9850732166c732622a1b Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 7 May 2025 18:36:17 +0530 Subject: [PATCH 08/32] chore: update header files --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c index 7280de1abce6..6e6f0b1b1371 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c @@ -16,8 +16,8 @@ * limitations under the License. */ -#include "stdlib/blas/base/dsyr22.h" -#include "stdlib/blas/base/dsyr22_cblas.h" +#include "stdlib/blas/base/dsyr2.h" +#include "stdlib/blas/base/dsyr2_cblas.h" #include "stdlib/blas/base/shared.h" #include "stdlib/strided/base/min_view_buffer_index.h" #include "stdlib/ndarray/base/min_view_buffer_index.h" From f6fa175fee7c836ead2a330f6529ad54ce801d93 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Wed, 7 May 2025 19:04:40 +0530 Subject: [PATCH 09/32] remove header files Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c index c7186fdfc298..4c1bad094cc9 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c @@ -18,7 +18,6 @@ #include "stdlib/blas/base/dsyr2.h" #include "stdlib/blas/base/shared.h" -#include "stdlib/strided/base/stride2offset.h" #include "stdlib/ndarray/base/assert/is_row_major.h" /** From 468b2dc1251d92ebd55c21db00e43f096d57e5de Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 28 Jun 2025 17:26:06 +0530 Subject: [PATCH 10/32] chore: clean-up --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dsyr2/README.md | 24 +++++--- .../blas/base/dsyr2/benchmark/c/benchmark.c | 56 +++++++++---------- .../blas/base/dsyr2/examples/c/example.c | 10 +++- .../dsyr2/include/stdlib/blas/base/dsyr2.h | 4 +- .../include/stdlib/blas/base/dsyr2_cblas.h | 2 +- .../blas/base/dsyr2/lib/dsyr2.native.js | 4 +- .../blas/base/dsyr2/lib/ndarray.native.js | 4 +- .../@stdlib/blas/base/dsyr2/src/addon.c | 13 ++++- .../@stdlib/blas/base/dsyr2/src/dsyr2.c | 6 +- .../@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c | 8 +-- .../blas/base/dsyr2/src/dsyr2_ndarray.c | 4 +- 11 files changed, 79 insertions(+), 56 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md index fc19991f124b..8a2328529164 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md @@ -48,7 +48,7 @@ dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); The function has the following parameters: - **order**: storage layout. -- **uplo**: specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced. +- **uplo**: specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied. - **N**: number of elements along each dimension of `A`. - **α**: scalar constant. - **x**: first input [`Float64Array`][mdn-float64array]. @@ -198,7 +198,7 @@ console.log( A ); #### c_dsyr2( order, uplo, N, alpha, \*X, strideX, \*Y, strideY, \*A, LDA ) -Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. +Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. ```c #include "stdlib/blas/base/shared.h" @@ -213,7 +213,7 @@ c_dsyr2( CblasColMajor, CblasUpper, 3, 1.0, x, 1, y, 1, A, 3 ); The function accepts the following arguments: - **order**: `[in] CBLAS_LAYOUT` storage layout. -- **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced. +- **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied. - **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. - **alpha**: `[in] double` scalar. - **X**: `[in] double*` first input array. @@ -231,7 +231,7 @@ void c_dsyr2( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N #### c_dsyr2_ndarray( uplo, N, alpha, \*X, strideX, offsetX, \*Y, strideY, offsetY, \*A, sa1, sa2, oa ) -Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics. +Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. ```c #include "stdlib/blas/base/shared.h" @@ -245,7 +245,7 @@ c_dsyr2_ndarray( CblasUpper, 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); The function accepts the following arguments: -- **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced. +- **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied. - **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. - **alpha**: `[in] double` scalar. - **X**: `[in] double*` first input array. @@ -287,23 +287,29 @@ void c_dsyr2_ndarray( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alp #include int main( void ) { + // Define a 3x3 symmetric matrix stored in row-major order: + double A[] = { + 1.0, 0.0, 0.0, + 2.0, 1.0, 0.0, + 3.0, 2.0, 1.0 + }; + // Create strided arrays: - 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 }; const double y[] = { 1.0, 2.0, 3.0 }; // Specify the number of elements along each dimension of `A`: const int N = 3; - // Perform the symmetric rank 1 operation `A = α*x*x^T + A`: - c_dsyr2( CblasColMajor, CblasUpper, N, 1.0, x, 1, y, 1 A, N ); + // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`: + c_dsyr2( CblasColMajor, CblasUpper, N, 1.0, x, 1, y, 1, A, N ); // Print the result: for ( int i = 0; i < N*N; i++ ) { printf( "A[ %i ] = %f\n", i, A[ i ] ); } - // Perform the symmetric rank 1 operation `A = α*x*x^T + A`: + // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative semantics indexing: c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); // Print the result: diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c index 5de3721a0cbd..a07fb3f603c6 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c @@ -83,30 +83,30 @@ static double tic( void ) { * Runs a benchmark. * * @param iterations number of iterations -* @param N number of elements along each dimension +* @param len number of elements along each dimension * @return elapsed time in seconds */ -static double benchmark1( int iterations, int N ) { +static double benchmark1( int iterations, int len ) { double elapsed; - double A[ N*N ]; - double x[ N ]; - double y[ N ]; + double A[ len*len ]; + double x[ len ]; + double y[ len ]; double t; int i; - stdlib_strided_dfill( N, 0.5, x, 1 ); - stdlib_strided_dfill( N, 0.5, y, 1 ); - stdlib_strided_dfill( N*N, 1.0, A, 1 ); + stdlib_strided_dfill( len, 1.0, x, 1 ); + stdlib_strided_dfill( len, 1.0, y, 1 ); + stdlib_strided_dfill( len*len, 1.0, A, 1 ); t = tic(); for ( i = 0; i < iterations; i++ ) { - c_dsyr2( CblasRowMajor, CblasUpper, N, 1.0, x, 1, y, 1, A, N ); - if ( A[ 0 ] != A[ 0 ] ) { + c_dsyr2( CblasRowMajor, CblasUpper, len, 1.0, x, 1, y, 1, A, len ); + if ( A[ i%len ] != A[ i%len ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( A[ 0 ] != A[ 0 ] ) { + if ( A[ i%len ] != A[ i%len ] ) { printf( "should not return NaN\n" ); } return elapsed; @@ -116,30 +116,30 @@ static double benchmark1( int iterations, int N ) { * Runs a benchmark. * * @param iterations number of iterations -* @param N number of elements along each dimension +* @param len number of elements along each dimension * @return elapsed time in seconds */ -static double benchmark2( int iterations, int N ) { +static double benchmark2( int iterations, int len ) { double elapsed; - double A[ N*N ]; - double x[ N ]; - double y[ N ]; + double A[ len*len ]; + double x[ len ]; + double y[ len ]; double t; int i; - stdlib_strided_dfill( N, 0.5, x, 1 ); - stdlib_strided_dfill( N, 0.5, y, 1 ); - stdlib_strided_dfill( N*N, 1.0, A, 1 ); + stdlib_strided_dfill( len, 1.0, x, 1 ); + stdlib_strided_dfill( len, 1.0, y, 1 ); + stdlib_strided_dfill( len*len, 1.0, A, 1 ); t = tic(); for ( i = 0; i < iterations; i++ ) { - c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); - if ( A[ 0 ] != A[ 0 ] ) { + c_dsyr2_ndarray( CblasUpper, len, 1.0, x, 1, 0, y, 1, 0, A, len, 1, 0 ); + if ( A[ i%len ] != A[ i%len ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( A[ 0 ] != A[ 0 ] ) { + if ( A[ i%len ] != A[ i%len ] ) { printf( "should not return NaN\n" ); } return elapsed; @@ -154,7 +154,7 @@ int main( void ) { int iter; int i; int j; - int N; + int len; // Use the current time to seed the random number generator: srand( time( NULL ) ); @@ -162,19 +162,19 @@ int main( void ) { print_version(); count = 0; for ( i = MIN; i <= MAX; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + len = 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 ); + printf( "# c::%s:size=%d\n", NAME, len*len ); + elapsed = benchmark1( iter, len ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } for ( j = 0; j < REPEATS; j++ ) { count += 1; - printf( "# c::%s:ndarray:size=%d\n", NAME, N*N ); - elapsed = benchmark2( iter, N ); + printf( "# c::%s:ndarray:size=%d\n", NAME, len*len ); + elapsed = benchmark2( iter, len ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c index 6e11d89ade11..1e9d58e44cff 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c @@ -21,8 +21,14 @@ #include int main( void ) { + // Define a 3x3 symmetric matrix stored in row-major order: + double A[] = { + 1.0, 0.0, 0.0, + 2.0, 1.0, 0.0, + 3.0, 2.0, 1.0 + }; + // Create strided arrays: - 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 }; const double y[] = { 1.0, 2.0, 3.0 }; @@ -37,7 +43,7 @@ int main( void ) { printf( "A[ %i ] = %f\n", i, A[ i ] ); } - // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`: + // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative semantics indexing: c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); // Print the result: diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2.h b/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2.h index b8ff19e15d86..62cd104a2afb 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2.h +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2.h @@ -32,12 +32,12 @@ extern "C" { #endif /** -* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. */ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ); /** -* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics. +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. */ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2_cblas.h b/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2_cblas.h index a6220dae2a32..328290ca0266 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2_cblas.h @@ -32,7 +32,7 @@ extern "C" { #endif /** -* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. */ void API_SUFFIX(cblas_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.native.js index edfa1ea476f6..500725eeb8bf 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.native.js @@ -28,10 +28,10 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * * @param {string} order - storage layout -* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied * @param {NonNegativeInteger} N - number of elements along each dimension of `A` * @param {number} alpha - scalar * @param {Float64Array} x - first input vector diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js index d15f834fa0cf..3b9830bc8b82 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js @@ -27,9 +27,9 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * -* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied * @param {NonNegativeInteger} N - number of elements along each dimension of `A` * @param {number} alpha - scalar * @param {Float64Array} x - first input vector diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c index a5b92cc4abf1..62273bdb3e45 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c @@ -35,6 +35,9 @@ * @return Node-API value */ static napi_value addon( napi_env env, napi_callback_info info ) { + CBLAS_INT sa1; + CBLAS_INT sa2; + STDLIB_NAPI_ARGV( env, info, argv, argc, 10 ); STDLIB_NAPI_ARGV_INT32( env, order, argv, 0 ); @@ -47,9 +50,17 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_DOUBLE( env, alpha, argv, 3 ); + if ( order == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + } else { // order === CblasRowMajor + sa1 = LDA; + sa2 = 1; + } + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 4 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 6 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, A, ((N-1)*LDA) + N, 1, argv, 8 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, M, N, sa1, sa2, argv, 8 ); API_SUFFIX(c_dsyr2)( order, uplo, N, alpha, X, strideX, Y, strideY, A, LDA ); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c index 30a79e7ec5e0..3eaf300042b7 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c @@ -21,10 +21,10 @@ #include "stdlib/strided/base/stride2offset.h" /** -* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * * @param order storage layout -* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied * @param N number of elements along each dimension of `A` * @param alpha scalar * @param X first input vector @@ -46,7 +46,7 @@ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const if ( order == CblasColMajor ) { sa1 = 1; sa2 = LDA; - } else { // order === 'row-major' + } else { // order === CblasRowMajor sa1 = LDA; sa2 = 1; } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c index 6e6f0b1b1371..adeef6bbb2b2 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c @@ -23,10 +23,10 @@ #include "stdlib/ndarray/base/min_view_buffer_index.h" /** -* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`. +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * * @param order storage layout -* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied * @param N number of elements along each dimension of `A` * @param alpha scalar * @param x first input vector @@ -45,9 +45,9 @@ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const } /** -* Performs the symmetric rank 2 operation `A = α*x*x^T + A` using alternative indexing semantics. +* Performs the symmetric rank 2 operation `A = α*x*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * -* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied * @param N number of elements along each dimension of `A` * @param alpha scalar * @param X input vector diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c index 4c1bad094cc9..723a2e8bb287 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c @@ -21,9 +21,9 @@ #include "stdlib/ndarray/base/assert/is_row_major.h" /** -* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics. +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * -* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied * @param N number of elements along each dimension of `A` * @param alpha scalar * @param X first input vector From 7eec8e6adc2d0b16c81c4b89f3d387e4628a647c Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sat, 28 Jun 2025 17:35:06 +0530 Subject: [PATCH 11/32] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c index 62273bdb3e45..07bbe4624ae1 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c @@ -60,7 +60,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 4 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 6 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, M, N, sa1, sa2, argv, 8 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, N, N, sa1, sa2, argv, 8 ); API_SUFFIX(c_dsyr2)( order, uplo, N, alpha, X, strideX, Y, strideY, A, LDA ); From b3e0f9fe19df083458a535999c00292dae63c16c Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sat, 28 Jun 2025 17:40:59 +0530 Subject: [PATCH 12/32] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c index a07fb3f603c6..8561548e1841 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c @@ -83,7 +83,7 @@ static double tic( void ) { * Runs a benchmark. * * @param iterations number of iterations -* @param len number of elements along each dimension +* @param len number of elements along each dimension * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { @@ -116,7 +116,7 @@ static double benchmark1( int iterations, int len ) { * Runs a benchmark. * * @param iterations number of iterations -* @param len number of elements along each dimension +* @param len number of elements along each dimension * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { From 924b10b4cbc06debf433dab0edebc01bdcf041b0 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 28 Jun 2025 17:53:15 +0530 Subject: [PATCH 13/32] chore: update manifest.json --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dsyr2/manifest.json | 244 +++++++++++++++--- 1 file changed, 201 insertions(+), 43 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json index 4bd82276d41a..5240f72e65b7 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json @@ -30,11 +30,80 @@ "confs": [ { "task": "build", - "os": "win", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dsyr.c", + "./src/dsyr_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@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/dsyr.c", + "./src/dsyr_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/blas/ext/base/dfill" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dsyr.c", + "./src/dsyr_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "linux", "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr_cblas.c" ], "include": [ "./include" @@ -46,22 +115,24 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-double", "@stdlib/napi/argv-strided-float64array", - "@stdlib/napi/argv-strided-float64array2d", - "@stdlib/ndarray/base/assert/is-row-major" + "@stdlib/napi/argv-strided-float64array2d" ] }, { "task": "benchmark", - "os": "win", + "os": "linux", "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr_cblas.c" ], "include": [ "./include" @@ -72,16 +143,19 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/ext/base/dfill" ] }, { "task": "examples", - "os": "win", + "os": "linux", "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr_cblas.c" ], "include": [ "./include" @@ -92,7 +166,78 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/dsyr.c", + "./src/dsyr_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@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/dsyr.c", + "./src/dsyr_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/blas/ext/base/dfill" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/dsyr.c", + "./src/dsyr_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, @@ -102,7 +247,7 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr_cblas.c" ], "include": [ "./include" @@ -113,13 +258,15 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-double", "@stdlib/napi/argv-strided-float64array", - "@stdlib/napi/argv-strided-float64array2d", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-strided-float64array2d" ] }, { @@ -128,7 +275,7 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr_cblas.c" ], "include": [ "./include" @@ -138,16 +285,19 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/ext/base/dfill" ] }, { - "task": "examples", + "task": "examples", "os": "mac", "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr_cblas.c" ], "include": [ "./include" @@ -157,7 +307,9 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index" ] }, @@ -167,7 +319,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr_cblas.c" ], "include": [ "./include" @@ -179,13 +331,15 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-double", "@stdlib/napi/argv-strided-float64array", - "@stdlib/napi/argv-strided-float64array2d", - "@stdlib/napi/argv-double" + "@stdlib/napi/argv-strided-float64array2d" ] }, { @@ -194,7 +348,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr_cblas.c" ], "include": [ "./include" @@ -205,7 +359,10 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/ext/base/dfill" ] }, { @@ -214,7 +371,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr_cblas.c" ], "include": [ "./include" @@ -225,18 +382,20 @@ ], "libpath": [], "dependencies": [ - "@stdlib/blas/base/shared" + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index" ] }, { "task": "build", - "os": "linux", + "os": "win", "blas": "", "wasm": false, "src": [ - "./src/dsyr2.c", - "./src/dsyr2_ndarray.c" + "./src/dsyr.c", + "./src/dsyr_ndarray.c" ], "include": [ "./include" @@ -245,25 +404,25 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@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-strided-float64array", - "@stdlib/napi/argv-strided-float64array2d", "@stdlib/napi/argv-double", - "@stdlib/strided/base/stride2offset", - "@stdlib/ndarray/base/assert/is-row-major" + "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" ] }, { "task": "benchmark", - "os": "linux", + "os": "win", "blas": "", "wasm": false, "src": [ - "./src/dsyr2.c", - "./src/dsyr2_ndarray.c" + "./src/dsyr.c", + "./src/dsyr_ndarray.c" ], "include": [ "./include" @@ -272,20 +431,19 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/blas/ext/base/dfill", - "@stdlib/math/base/special/floor", "@stdlib/strided/base/stride2offset", - "@stdlib/ndarray/base/assert/is-row-major" + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/blas/ext/base/dfill" ] }, { "task": "examples", - "os": "linux", + "os": "win", "blas": "", "wasm": false, "src": [ - "./src/dsyr2.c", - "./src/dsyr2_ndarray.c" + "./src/dsyr.c", + "./src/dsyr_ndarray.c" ], "include": [ "./include" @@ -305,8 +463,8 @@ "blas": "", "wasm": true, "src": [ - "./src/dsyr2.c", - "./src/dsyr2_ndarray.c" + "./src/dsyr.c", + "./src/dsyr_ndarray.c" ], "include": [ "./include" From 57bf0f7e08b0293f3fd01fb74637b62f57c76054 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sat, 28 Jun 2025 18:01:34 +0530 Subject: [PATCH 14/32] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/dsyr2/manifest.json | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json index 5240f72e65b7..83890b4d8b38 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json @@ -34,8 +34,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dsyr.c", - "./src/dsyr_ndarray.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -61,8 +61,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dsyr.c", - "./src/dsyr_ndarray.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -82,8 +82,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dsyr.c", - "./src/dsyr_ndarray.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -103,7 +103,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr_cblas.c" + "./src/dsyr2_cblas.c" ], "include": [ "./include" @@ -132,7 +132,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr_cblas.c" + "./src/dsyr2_cblas.c" ], "include": [ "./include" @@ -155,7 +155,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr_cblas.c" + "./src/dsyr2_cblas.c" ], "include": [ "./include" @@ -178,8 +178,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dsyr.c", - "./src/dsyr_ndarray.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -205,8 +205,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dsyr.c", - "./src/dsyr_ndarray.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -226,8 +226,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dsyr.c", - "./src/dsyr_ndarray.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -247,7 +247,7 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dsyr_cblas.c" + "./src/dsyr2_cblas.c" ], "include": [ "./include" @@ -275,7 +275,7 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dsyr_cblas.c" + "./src/dsyr2_cblas.c" ], "include": [ "./include" @@ -297,7 +297,7 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dsyr_cblas.c" + "./src/dsyr2_cblas.c" ], "include": [ "./include" @@ -319,7 +319,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr_cblas.c" + "./src/dsyr2_cblas.c" ], "include": [ "./include" @@ -348,7 +348,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr_cblas.c" + "./src/dsyr2_cblas.c" ], "include": [ "./include" @@ -371,7 +371,7 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr_cblas.c" + "./src/dsyr2_cblas.c" ], "include": [ "./include" @@ -394,8 +394,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dsyr.c", - "./src/dsyr_ndarray.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -421,8 +421,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dsyr.c", - "./src/dsyr_ndarray.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -442,8 +442,8 @@ "blas": "", "wasm": false, "src": [ - "./src/dsyr.c", - "./src/dsyr_ndarray.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -463,8 +463,8 @@ "blas": "", "wasm": true, "src": [ - "./src/dsyr.c", - "./src/dsyr_ndarray.c" + "./src/dsyr2.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" From 19362c142cc3d2a700cfdbdd97bb1fb27c59b245 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 28 Jun 2025 18:28:41 +0530 Subject: [PATCH 15/32] chore: add checks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dsyr2/src/dsyr2.c | 27 +++++++++++++++++++ .../blas/base/dsyr2/src/dsyr2_ndarray.c | 27 +++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c index 3eaf300042b7..013cc5437e9d 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c @@ -35,11 +35,38 @@ * @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) */ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { + CBLAS_INT vala; CBLAS_INT sa1; CBLAS_INT sa2; CBLAS_INT ox; CBLAS_INT oy; + // Perform input argument validation... + if ( order != CblasRowMajor && order != CblasColMajor ) { + c_xerbla( 1, "c_dsyr2", "Error: invalid argument. First argument must be a valid order. Value: `%d`.", order ); + return; + } + if ( uplo != CblasLower && uplo != CblasUpper ) { + c_xerbla( 2, "c_dsyr2", "Error: invalid argument. Second argument must specify whether to reference the lower or upper triangular matrixecond argument must specify whether to reference the lower or upper triangular matrix. Value: `%d`.", uplo ); + return; + } + if ( N < 0 ) { + c_xerbla( 3, "c_dsyr2", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 6, "c_dsyr2", "Error: invalid argument. Sixth argument must be nonzero. Value: `%d`.", strideX ); + return; + } + if ( strideY == 0 ) { + c_xerbla( 8, "c_dsyr2", "Error: invalid argument. Eighth argument must be nonzero. Value: `%d`.", strideX ); + return; + } + if ( LDA < N ) { + c_xerbla( 10, "c_dsyr2", "Error: invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.", N, LDA ); + return; + } + // Check whether we can avoid computation altogether... if ( N == 0 || alpha == 0.0 ) { return; } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c index 723a2e8bb287..af90688c9003 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c @@ -38,6 +38,7 @@ * @param offsetA starting index of `A` */ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) { + int64_t sa[ 2 ]; CBLAS_INT isrm; CBLAS_INT ix0; CBLAS_INT ix1; @@ -53,11 +54,33 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons double tmp1; double tmp2; - int64_t strides[] = { strideA1, strideA2 }; + // Note on variable naming convention: S#, ix#, iy#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + // Perform input argument validation... + if ( uplo != CblasLower && uplo != CblasUpper ) { + c_xerbla( 1, "c_dsyr2_ndarray", "Error: invalid argument. First argument must specify whether to reference the lower or upper triangular matrixecond argument must specify whether to reference the lower or upper triangular matrix. Value: `%d`.", uplo ); + return; + } + if ( N < 0 ) { + c_xerbla( 2, "c_dsyr2_ndarray", "Error: invalid argument. Second argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 5, "c_dsyr2_ndarray", "Error: invalid argument. Fifth argument must be a nonzero. Value: `%d`.", strideX ); + return; + } + if ( strideY == 0 ) { + c_xerbla( 8, "c_dsyr2_ndarray", "Error: invalid argument. Eighth argument must be a nonzero. Value: `%d`.", strideY ); + return; + } + // Check whether we can avoid computation altogether... if ( N == 0 || alpha == 0.0 ) { return; } - isrm = stdlib_ndarray_is_row_major( 2, strides ); + // 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 ( isrm ) { // For row-major matrices, the last dimension has the fastest changing index... sa0 = strideA2; // stride for innermost loop From 3faf92239392f0e8463437eb970bead7d61bf4ba Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sat, 28 Jun 2025 18:32:54 +0530 Subject: [PATCH 16/32] chore: add checks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json | 10 ++++++++++ lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c | 1 + .../@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c | 1 + 3 files changed, 12 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json index 83890b4d8b38..2c555453124b 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json @@ -44,6 +44,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/napi/export", @@ -71,6 +72,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/blas/ext/base/dfill" @@ -92,6 +94,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major" ] @@ -188,6 +191,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/napi/export", @@ -215,6 +219,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/blas/ext/base/dfill" @@ -236,6 +241,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major" ] @@ -404,6 +410,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/napi/export", @@ -431,6 +438,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/blas/ext/base/dfill" @@ -452,6 +460,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major" ] @@ -473,6 +482,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major" ] diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c index 013cc5437e9d..6fa37bb73406 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c @@ -18,6 +18,7 @@ #include "stdlib/blas/base/dsyr2.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/xerbla.h" #include "stdlib/strided/base/stride2offset.h" /** diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c index af90688c9003..854ad1cdec50 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c @@ -18,6 +18,7 @@ #include "stdlib/blas/base/dsyr2.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/xerbla.h" #include "stdlib/ndarray/base/assert/is_row_major.h" /** From 41c8ba7115ad6758ea9b56e010c9a5ee02d31734 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sat, 28 Jun 2025 21:49:11 +0530 Subject: [PATCH 17/32] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c index 6fa37bb73406..3b334d825e2a 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c @@ -36,7 +36,6 @@ * @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) */ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { - CBLAS_INT vala; CBLAS_INT sa1; CBLAS_INT sa2; CBLAS_INT ox; From 4d47e873f9fbf3ecf97fafb7c27927e6f098d198 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 29 Jun 2025 22:23:19 +0530 Subject: [PATCH 18/32] chore: clean-up --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dsyr2/README.md | 24 +-- .../blas/base/dsyr2/benchmark/benchmark.js | 2 +- .../base/dsyr2/benchmark/benchmark.native.js | 2 +- .../base/dsyr2/benchmark/benchmark.ndarray.js | 2 +- .../benchmark/benchmark.ndarray.native.js | 2 +- .../blas/base/dsyr2/benchmark/c/benchmark.c | 56 ++--- .../@stdlib/blas/base/dsyr2/docs/repl.txt | 17 ++ .../blas/base/dsyr2/examples/c/example.c | 8 +- .../dsyr2/include/stdlib/blas/base/dsyr2.h | 2 +- .../include/stdlib/blas/base/dsyr2_cblas.h | 2 +- .../@stdlib/blas/base/dsyr2/lib/dsyr2.js | 7 +- .../blas/base/dsyr2/lib/dsyr2.native.js | 31 +++ .../@stdlib/blas/base/dsyr2/lib/ndarray.js | 1 + .../blas/base/dsyr2/lib/ndarray.native.js | 30 +++ .../@stdlib/blas/base/dsyr2/manifest.json | 72 ++++--- .../@stdlib/blas/base/dsyr2/src/addon.c | 8 +- .../@stdlib/blas/base/dsyr2/src/dsyr2.c | 14 +- .../@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c | 48 +---- .../blas/base/dsyr2/src/dsyr2_ndarray.c | 4 +- .../blas/base/dsyr2/test/test.dsyr2.native.js | 187 ++++++++++++++-- .../base/dsyr2/test/test.ndarray.native.js | 202 +++++++++++++++--- 21 files changed, 535 insertions(+), 186 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md index 8a2328529164..91bcc95becda 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md @@ -52,9 +52,9 @@ The function has the following parameters: - **N**: number of elements along each dimension of `A`. - **α**: scalar constant. - **x**: first input [`Float64Array`][mdn-float64array]. -- **sx**: index increment for `x`. +- **sx**: stride length for `x`. - **y**: second input [`Float64Array`][mdn-float64array]. -- **sy**: index increment for `y`. +- **sy**: stride length for `y`. - **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. - **lda**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). @@ -196,7 +196,7 @@ console.log( A ); #include "stdlib/blas/base/dsyr2.h" ``` -#### c_dsyr2( order, uplo, N, alpha, \*X, strideX, \*Y, strideY, \*A, LDA ) +#### c_dsyr2( order, uplo, N, alpha, \*X, sx, \*Y, sy, \*A, LDA ) Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. @@ -215,11 +215,11 @@ The function accepts the following arguments: - **order**: `[in] CBLAS_LAYOUT` storage layout. - **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied. - **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. -- **alpha**: `[in] double` scalar. +- **alpha**: `[in] double` scalar constant. - **X**: `[in] double*` first input array. -- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. - **Y**: `[in] double*` second input array. -- **strideY**: `[in] CBLAS_INT` index increment for `Y`. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. - **A**: `[inout] double*` input matrix. - **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). @@ -229,7 +229,7 @@ void c_dsyr2( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N -#### c_dsyr2_ndarray( uplo, N, alpha, \*X, strideX, offsetX, \*Y, strideY, offsetY, \*A, sa1, sa2, oa ) +#### c_dsyr2_ndarray( uplo, N, alpha, \*X, sx, ox, \*Y, sy, oy, \*A, sa1, sa2, oa ) Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. @@ -247,12 +247,12 @@ The function accepts the following arguments: - **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied. - **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. -- **alpha**: `[in] double` scalar. +- **alpha**: `[in] double` scalar constant. - **X**: `[in] double*` first input array. -- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. - **Y**: `[in] double` second input array. -- **strideY**: `[in] CBLAS_INT` index increment for `Y`. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. - **offsetY**: `[in] CBLAS_INT` starting index for `Y`. - **A**: `[inout] double*` input matrix. - **sa1**: `[in] CBLAS_INT` stride of the first dimension of `A`. @@ -260,7 +260,7 @@ The function accepts the following arguments: - **oa**: `[in] CBLAS_INT` starting index for `A`. ```c -void c_dsyr2_ndarray( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT sa1, const CBLAS_INT sa2, const CBLAS_INT oa ) +void c_dsyr2_ndarray( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *y, CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) ``` @@ -294,7 +294,7 @@ int main( void ) { 3.0, 2.0, 1.0 }; - // Create strided arrays: + // Define `x` and `y` vectors: const double x[] = { 1.0, 2.0, 3.0 }; const double y[] = { 1.0, 2.0, 3.0 }; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.js index 1ed4902b29e4..641e1fa0fce1 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.js @@ -42,7 +42,7 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - number of elements along each dimension +* @param {PositiveInteger} N - array length * @returns {Function} benchmark function */ function createBenchmark( N ) { diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.native.js index 0ce3799353f6..eeca12213e9e 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.native.js @@ -47,7 +47,7 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - number of elements along each dimension +* @param {PositiveInteger} N - array length * @returns {Function} benchmark function */ function createBenchmark( N ) { diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.js index 3685431ce0d1..59e97826d571 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.js @@ -42,7 +42,7 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - number of elements along each dimension +* @param {PositiveInteger} N - array length * @returns {Function} benchmark function */ function createBenchmark( N ) { diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.native.js index 534af4370389..943849f5069b 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.native.js @@ -47,7 +47,7 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - number of elements along each dimension +* @param {PositiveInteger} N - array length * @returns {Function} benchmark function */ function createBenchmark( N ) { diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c index 8561548e1841..ce5228824c7a 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c @@ -83,30 +83,30 @@ static double tic( void ) { * Runs a benchmark. * * @param iterations number of iterations -* @param len number of elements along each dimension +* @param N array dimension size * @return elapsed time in seconds */ -static double benchmark1( int iterations, int len ) { +static double benchmark1( int iterations, int N ) { double elapsed; - double A[ len*len ]; - double x[ len ]; - double y[ len ]; + double A[ N*N ]; + double x[ N ]; + double y[ N ]; double t; int i; - stdlib_strided_dfill( len, 1.0, x, 1 ); - stdlib_strided_dfill( len, 1.0, y, 1 ); - stdlib_strided_dfill( len*len, 1.0, A, 1 ); + stdlib_strided_dfill( N, 1.0, x, 1 ); + stdlib_strided_dfill( N, 1.0, y, 1 ); + stdlib_strided_dfill( N*N, 1.0, A, 1 ); t = tic(); for ( i = 0; i < iterations; i++ ) { - c_dsyr2( CblasRowMajor, CblasUpper, len, 1.0, x, 1, y, 1, A, len ); - if ( A[ i%len ] != A[ i%len ] ) { + c_dsyr2( CblasRowMajor, CblasUpper, N, 1.0, x, 1, y, 1, A, N ); + if ( A[ i%N ] != A[ i%N ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( A[ i%len ] != A[ i%len ] ) { + if ( A[ i%N ] != A[ i%N ] ) { printf( "should not return NaN\n" ); } return elapsed; @@ -116,30 +116,30 @@ static double benchmark1( int iterations, int len ) { * Runs a benchmark. * * @param iterations number of iterations -* @param len number of elements along each dimension +* @param N array dimension size * @return elapsed time in seconds */ -static double benchmark2( int iterations, int len ) { +static double benchmark2( int iterations, int N ) { double elapsed; - double A[ len*len ]; - double x[ len ]; - double y[ len ]; + double A[ N*N ]; + double x[ N ]; + double y[ N ]; double t; int i; - stdlib_strided_dfill( len, 1.0, x, 1 ); - stdlib_strided_dfill( len, 1.0, y, 1 ); - stdlib_strided_dfill( len*len, 1.0, A, 1 ); + stdlib_strided_dfill( N, 1.0, x, 1 ); + stdlib_strided_dfill( N, 1.0, y, 1 ); + stdlib_strided_dfill( N*N, 1.0, A, 1 ); t = tic(); for ( i = 0; i < iterations; i++ ) { - c_dsyr2_ndarray( CblasUpper, len, 1.0, x, 1, 0, y, 1, 0, A, len, 1, 0 ); - if ( A[ i%len ] != A[ i%len ] ) { + c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); + if ( A[ i%N ] != A[ i%N ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( A[ i%len ] != A[ i%len ] ) { + if ( A[ i%N ] != A[ i%N ] ) { printf( "should not return NaN\n" ); } return elapsed; @@ -154,7 +154,7 @@ int main( void ) { int iter; int i; int j; - int len; + int N; // Use the current time to seed the random number generator: srand( time( NULL ) ); @@ -162,19 +162,19 @@ int main( void ) { print_version(); count = 0; for ( i = MIN; i <= MAX; i++ ) { - len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); iter = ITERATIONS / pow( 10, i-1 ); for ( j = 0; j < REPEATS; j++ ) { count += 1; - printf( "# c::%s:size=%d\n", NAME, len*len ); - elapsed = benchmark1( iter, len ); + printf( "# c::%s:size=%d\n", NAME, N*N ); + elapsed = benchmark1( iter, N ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } for ( j = 0; j < REPEATS; j++ ) { count += 1; - printf( "# c::%s:ndarray:size=%d\n", NAME, len*len ); - elapsed = benchmark2( iter, len ); + printf( "# c::%s:ndarray:size=%d\n", NAME, N*N ); + elapsed = benchmark2( iter, N ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dsyr2/docs/repl.txt index c72246eb7aac..289d7441a3cc 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/docs/repl.txt @@ -52,12 +52,29 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); > var y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 2.0 ] ); > {{alias}}( 'row-major', 'upper', 2, 1.0, x, 1, y, 1, A, 2 ) [ 3.0, 4.0, 0.0, 4.0 ] + // Advanced indexing: + > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 2.0 ] ); + > {{alias}}( 'row-major', 'upper', 2, 1.0, x, -1, y, -1, A, 2 ) + [ 3.0, 4.0, 0.0, 4.0 ] + + // Using typed array views: + > 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, 0.0, 2.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}}( 'row-major', 'upper', 2, 1.0, x, 1, y, 1, A, 2 ) + [ 3.0, 4.0, 0.0, 4.0 ] + {{alias}}.ndarray( uplo, N, α, x, sx, ox, y, sy, oy, A, sa1, sa2, oa ) Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c index 1e9d58e44cff..ef7381fee3a7 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c @@ -22,15 +22,15 @@ int main( void ) { // Define a 3x3 symmetric matrix stored in row-major order: - double A[] = { + double A[ 3*3 ] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; - // Create strided arrays: - const double x[] = { 1.0, 2.0, 3.0 }; - const double y[] = { 1.0, 2.0, 3.0 }; + // Define `x` and `y` vectors: + const double x[ 3 ] = { 1.0, 2.0, 3.0 }; + const double y[ 3 ] = { 1.0, 2.0, 3.0 }; // Specify the number of elements along each dimension of `A`: const int N = 3; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2.h b/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2.h index 62cd104a2afb..f038032748b4 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2.h +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2.h @@ -34,7 +34,7 @@ extern "C" { /** * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. */ -void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ); +void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ); /** * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2_cblas.h b/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2_cblas.h index 328290ca0266..cf9fe0d4c564 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/include/stdlib/blas/base/dsyr2_cblas.h @@ -34,7 +34,7 @@ extern "C" { /** * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. */ -void API_SUFFIX(cblas_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ); +void API_SUFFIX(cblas_dsyr2)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.js index 8921f2922059..cb506ca4b603 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.js @@ -20,11 +20,11 @@ // MODULES // -var max = require( '@stdlib/math/base/special/fast/max' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); -var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var max = require( '@stdlib/math/base/special/fast/max' ); var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); @@ -48,7 +48,7 @@ var base = require( './base.js' ); * @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} sixth argument must be non-zero -* @throws {RangeError} eighth argument must be greater than or equal to max(1,N) +* @throws {RangeError} eighth argument must be a valid stride * @returns {Float64Array} `A` * * @example @@ -85,6 +85,7 @@ function dsyr2( order, uplo, N, alpha, x, strideX, y, strideY, A, LDA ) { if ( LDA < max( 1, N ) ) { throw new RangeError( format( 'invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); } + // Check if we can early return... if ( N === 0 || alpha === 0.0 ) { return A; } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.native.js index 500725eeb8bf..ccde52fc0298 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.native.js @@ -20,8 +20,12 @@ // MODULES // +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); var resolveOrder = require( '@stdlib/blas/base/layout-resolve-enum' ); var resolveUplo = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); var addon = require( './../src/addon.node' ); @@ -40,6 +44,11 @@ var addon = require( './../src/addon.node' ); * @param {integer} strideY - `y` stride length * @param {Float64Array} A - input matrix * @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be non-zero +* @throws {RangeError} eighth argument must be a valid stride * @returns {Float64Array} `A` * * @example @@ -53,6 +62,28 @@ var addon = require( './../src/addon.node' ); * // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] */ function dsyr2( order, uplo, N, alpha, x, strideX, y, strideY, A, LDA ) { + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. Second argument must specify whether to reference the lower or upper triangular matrix. Value: `%s`.', uplo ) ); + } + 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. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( strideY === 0 ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); + } + // Check if we can early return... + if ( N === 0 || alpha === 0.0 ) { + return A; + } addon( resolveOrder( order ), resolveUplo( uplo ), N, alpha, x, strideX, y, strideY, A, LDA ); // eslint-disable-line max-len return A; } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.js index c25ad46f8fb7..cad070cd1bae 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.js @@ -80,6 +80,7 @@ function dsyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, str if ( strideA2 === 0 ) { throw new RangeError( format( 'invalid argument. Twelfth argument must be non-zero. Value: `%d`.', strideA2 ) ); } + // Check if we can early return... if ( N === 0 || alpha === 0.0 ) { return A; } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js index 3b9830bc8b82..685ab00659a7 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js @@ -20,7 +20,9 @@ // MODULES // +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); var resolveUplo = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); +var format = require( '@stdlib/string/format' ); var addon = require( './../src/addon.node' ); @@ -42,6 +44,12 @@ var addon = require( './../src/addon.node' ); * @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` +* @throws {TypeError} first argument must specify whether to reference the lower or upper triangular matrix +* @throws {RangeError} second argument must be a nonnegative integer +* @throws {RangeError} fifth argument must be non-zero +* @throws {RangeError} eighth argument must be non-zero +* @throws {RangeError} eleventh argument must be non-zero +* @throws {RangeError} twelfth argument must be non-zero * @returns {Float64Array} `A` * * @example @@ -55,6 +63,28 @@ var addon = require( './../src/addon.node' ); * // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] */ function dsyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. First argument must specify whether the reference the lower or upper triangular matrix. Value: `%s`.', uplo ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( strideY === 0 ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideY ) ); + } + if ( strideA1 === 0 ) { + throw new RangeError( format( 'invalid argument. Eleventh argument must be non-zero. Value: `%d`.', strideA1 ) ); + } + if ( strideA2 === 0 ) { + throw new RangeError( format( 'invalid argument. Twelfth argument must be non-zero. Value: `%d`.', strideA2 ) ); + } + // Check if we can early return... + if ( N === 0 || alpha === 0.0 ) { + return A; + } addon.ndarray( resolveUplo( uplo ), N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ); // eslint-disable-line max-len return A; } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json index 2c555453124b..e439a390a64c 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/manifest.json @@ -106,7 +106,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr2_cblas.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -118,8 +119,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/base/xerbla", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -135,7 +137,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr2_cblas.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -147,8 +150,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/base/xerbla", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/blas/ext/base/dfill" ] }, @@ -158,7 +162,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr2_cblas.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -170,8 +175,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index" + "@stdlib/blas/base/xerbla", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, @@ -253,7 +259,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr2_cblas.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -264,8 +271,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/base/xerbla", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -281,7 +289,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr2_cblas.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -292,8 +301,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/base/xerbla", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/blas/ext/base/dfill" ] }, @@ -303,7 +313,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr2_cblas.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -314,8 +325,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index" + "@stdlib/blas/base/xerbla", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, @@ -325,7 +337,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr2_cblas.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -337,8 +350,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/base/xerbla", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -354,7 +368,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr2_cblas.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -366,8 +381,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/base/xerbla", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/blas/ext/base/dfill" ] }, @@ -377,7 +393,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dsyr2_cblas.c" + "./src/dsyr2_cblas.c", + "./src/dsyr2_ndarray.c" ], "include": [ "./include" @@ -389,8 +406,9 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/min-view-buffer-index", - "@stdlib/ndarray/base/min-view-buffer-index" + "@stdlib/blas/base/xerbla", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" ] }, diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c index 07bbe4624ae1..a321b719768e 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c @@ -40,7 +40,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 10 ); - STDLIB_NAPI_ARGV_INT32( env, order, argv, 0 ); + STDLIB_NAPI_ARGV_INT32( env, layout, argv, 0 ); STDLIB_NAPI_ARGV_INT32( env, uplo, argv, 1 ); STDLIB_NAPI_ARGV_INT64( env, N, argv, 2 ); @@ -50,10 +50,10 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_DOUBLE( env, alpha, argv, 3 ); - if ( order == CblasColMajor ) { + if ( layout == CblasColMajor ) { sa1 = 1; sa2 = LDA; - } else { // order === CblasRowMajor + } else { // layout === CblasRowMajor sa1 = LDA; sa2 = 1; } @@ -62,7 +62,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 6 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, N, N, sa1, sa2, argv, 8 ); - API_SUFFIX(c_dsyr2)( order, uplo, N, alpha, X, strideX, Y, strideY, A, LDA ); + API_SUFFIX(c_dsyr2)( layout, uplo, N, alpha, X, strideX, Y, strideY, A, LDA ); return NULL; } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c index 3b334d825e2a..0febf1ca89ae 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c @@ -24,10 +24,10 @@ /** * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * -* @param order storage layout +* @param layout storage layout * @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied * @param N number of elements along each dimension of `A` -* @param alpha scalar +* @param alpha scalar constant * @param X first input vector * @param strideX `X` stride length * @param Y second input vector @@ -35,15 +35,15 @@ * @param A input matrix * @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) */ -void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { +void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { CBLAS_INT sa1; CBLAS_INT sa2; CBLAS_INT ox; CBLAS_INT oy; // Perform input argument validation... - if ( order != CblasRowMajor && order != CblasColMajor ) { - c_xerbla( 1, "c_dsyr2", "Error: invalid argument. First argument must be a valid order. Value: `%d`.", order ); + if ( layout != CblasRowMajor && layout != CblasColMajor ) { + c_xerbla( 1, "c_dsyr2", "Error: invalid argument. First argument must be a valid layout. Value: `%d`.", layout ); return; } if ( uplo != CblasLower && uplo != CblasUpper ) { @@ -70,10 +70,10 @@ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const if ( N == 0 || alpha == 0.0 ) { return; } - if ( order == CblasColMajor ) { + if ( layout == CblasColMajor ) { sa1 = 1; sa2 = LDA; - } else { // order === CblasRowMajor + } else { // layout === CblasRowMajor sa1 = LDA; sa2 = 1; } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c index adeef6bbb2b2..ccbdac936830 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c @@ -19,16 +19,14 @@ #include "stdlib/blas/base/dsyr2.h" #include "stdlib/blas/base/dsyr2_cblas.h" #include "stdlib/blas/base/shared.h" -#include "stdlib/strided/base/min_view_buffer_index.h" -#include "stdlib/ndarray/base/min_view_buffer_index.h" /** * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * -* @param order storage layout +* @param layout storage layout * @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied * @param N number of elements along each dimension of `A` -* @param alpha scalar +* @param alpha scalar constant * @param x first input vector * @param strideX `X` stride length * @param y second input vector @@ -36,44 +34,6 @@ * @param A input matrix * @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) */ -void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { - CBLAS_INT sx = strideX; - if ( sx < 0 ) { - sx = -sx; - } - API_SUFFIX(cblas_dsyr2)( order, uplo, N, alpha, X, sx, A, LDA ); -} - -/** -* Performs the symmetric rank 2 operation `A = α*x*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. -* -* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied -* @param N number of elements along each dimension of `A` -* @param alpha scalar -* @param X input vector -* @param strideX `x` stride length -* @param offsetX starting index for `x` -* @param Y input vector -* @param strideY `y` stride length -* @param offsetY starting index for `y` -* @param A input matrix -* @param strideA1 stride of the first dimension of `A` -* @param strideA2 stride of the second dimension of `A` -* @param offsetA starting index for `A` -*/ -void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, const float alpha, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) { - CBLAS_INT sx = strideX; - CBLAS_INT sy = strideY; - X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer - Y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer - const int64_t shape[] = { N, N }; - const int64_t strides[] = { strideA1, strideA2 }; - A += stdlib_ndarray_min_view_buffer_index( 2, shape, strides, offsetA ); // adjust array pointer - if ( sx < 0 ) { - sx = -sx; - } - if ( sy < 0 ) { - sy = -sy; - } - API_SUFFIX(cblas_dsyr2)( order, uplo, N, alpha, X, sx, Y, sy, A, LDA ); +void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { + API_SUFFIX(cblas_dsyr2)( layout, uplo, N, alpha, X, strideX, A, LDA ); } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c index 854ad1cdec50..6f5210450ec4 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c @@ -26,7 +26,7 @@ * * @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied * @param N number of elements along each dimension of `A` -* @param alpha scalar +* @param alpha scalar constant * @param X first input vector * @param strideX `X` stride length * @param offsetX starting index of `X` @@ -117,7 +117,7 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons } return; } - // ( order == CblasRowMajor && uplo == CblasUpper ) || ( order == CblasColMajor && uplo == CblasLower ) + // ( isrm && uplo == CblasUpper ) || ( !isrm && uplo == CblasLower ) for ( i1 = 0; i1 < N; i1++ ) { if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) { tmp1 = alpha * Y[ iy1 ]; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js index 568dbc0d1643..d8b6f23fadae 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js @@ -25,8 +25,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var Float64Array = require( '@stdlib/array/float64' ); -var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); -var str2enumLayout = require( '@stdlib/blas/base/layout-str2enum' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -68,6 +66,157 @@ tape( 'the function has an arity of 10', opts, function test( t ) { t.end(); }); +tape( 'the function throws an error if provided an invalid first argument', opts, function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + dsyr2( value, data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( data.A ), data.lda ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', opts, function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + dsyr2( data.order, value, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( data.A ), data.lda ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', opts, function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + dsyr2( data.order, data.uplo, value, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( data.A ), data.lda ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid sixth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + dsyr2( data.order, data.uplo, data.N, data.alpha, new Float64Array( data.x ), value, new Float64Array( data.y ), data.strideY, new Float64Array( data.A ), data.lda ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eighth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + dsyr2( data.order, data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), value, new Float64Array( data.A ), data.lda ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid tenth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = ru; + + values = [ + 2, + 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() { + dsyr2( data.order, data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( data.A ), value ); + }; + } +}); + tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, upper)', opts, function test( t ) { var expected; var data; @@ -84,7 +233,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -107,7 +256,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -130,7 +279,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -153,7 +302,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -173,7 +322,7 @@ tape( 'the function returns a reference to the input matrix `A`', opts, function x = new Float64Array( data.x ); y = new Float64Array( data.y ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.end(); @@ -195,11 +344,11 @@ tape( 'if `N` is zero or the scalar constant is zero, the function returns the i expected = new Float64Array( data.A ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( a, expected, 'returns expected value' ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( a, expected, 'returns expected value' ); @@ -222,11 +371,11 @@ tape( 'if `N` is zero or the scalar constant is zero, the function returns the i expected = new Float64Array( data.A ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( a, expected, 'returns expected value' ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( a, expected, 'returns expected value' ); @@ -249,7 +398,7 @@ tape( 'the function supports specifying strides (row-major)', opts, function tes expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -272,7 +421,7 @@ tape( 'the function supports specifying strides (column-major)', opts, function expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -295,7 +444,7 @@ tape( 'the function supports specifying a negative `x` stride (row-major)', opts expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -318,7 +467,7 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', o expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -341,7 +490,7 @@ tape( 'the function supports specifying a negative `y` stride (row-major)', opts expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -364,7 +513,7 @@ tape( 'the function supports specifying a negative `y` stride (column-major)', o expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -387,7 +536,7 @@ tape( 'the function supports complex access patterns (row-major)', opts, functio expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -410,7 +559,7 @@ tape( 'the function supports complex access patterns (column-major)', opts, func expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumLayout( data.order ), str2enum( data.uplo ), data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js index 3f007e8b9fdc..3dc49a01b772 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js @@ -25,7 +25,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var Float64Array = require( '@stdlib/array/float64' ); -var str2enumMatrixTriangle = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -79,6 +78,149 @@ tape( 'the function has an arity of 13', opts, function test( t ) { t.end(); }); +tape( 'the function throws an error if provided an invalid first argument', opts, function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + dsyr2( value, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.y ), data.strideY, data.offsetY, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', opts, function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + dsyr2( data.uplo, value, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.y ), data.strideY, data.offsetY, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + dsyr2( data.uplo, data.N, data.alpha, new Float64Array( data.x ), value, data.offsetX, new Float64Array( data.y ), data.strideY, data.offsetY, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eighth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + dsyr2( data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.y ), value, data.offsetY, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eleventh argument', opts, function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + dsyr2( data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.y ), data.strideY, data.offsetY, new Float64Array( data.A ), value, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid twelfth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + dsyr2( data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.y ), data.strideY, data.offsetY, new Float64Array( data.A ), data.strideA1, value, data.offsetA ); + }; + } +}); + tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, upper)', function test( t ) { var expected; var data; @@ -95,7 +237,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -118,7 +260,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -141,7 +283,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -164,7 +306,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -184,7 +326,7 @@ tape( 'the function returns a reference to the input matrix `A`', function test( x = new Float64Array( data.x ); y = new Float64Array( data.y ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.end(); @@ -206,11 +348,11 @@ tape( 'if `N` is zero or the scalar constant is zero, the function returns the i expected = new Float64Array( data.A ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( a, expected, 'returns expected value' ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( a, expected, 'returns expected value' ); @@ -233,11 +375,11 @@ tape( 'if `N` is zero or the scalar constant is zero, the function returns the i expected = new Float64Array( data.A ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( a, expected, 'returns expected value' ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( a, expected, 'returns expected value' ); @@ -260,7 +402,7 @@ tape( 'the function supports specifying the strides for the first and the second expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -283,7 +425,7 @@ tape( 'the function supports specifying the strides for the first and the second expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -306,7 +448,7 @@ tape( 'the function supports a negative stride for the first dimension of `A` (r expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -329,7 +471,7 @@ tape( 'the function supports a negative stride for the first dimension of `A` (c expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -352,7 +494,7 @@ tape( 'the function supports a negative stride for the second dimension of `A` ( expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -375,7 +517,7 @@ tape( 'the function supports a negative stride for the second dimension of `A` ( expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -398,7 +540,7 @@ tape( 'the function supports negative strides for `A` (row-major)', function tes expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -421,7 +563,7 @@ tape( 'the function supports negative strides for `A` (column-major)', function expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -444,7 +586,7 @@ tape( 'the function supports specifying an `A` offset (row-major)', function tes expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -467,7 +609,7 @@ tape( 'the function supports specifying an `A` offset (column-major)', function expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -490,7 +632,7 @@ tape( 'the function supports specifying `x` and `y` strides (row-major)', functi expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -513,7 +655,7 @@ tape( 'the function supports specifying `x` and `y` strides (column-major)', fun expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -536,7 +678,7 @@ tape( 'the function supports specifying a negative `x` stride (row-major)', func expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -559,7 +701,7 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', f expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -582,7 +724,7 @@ tape( 'the function supports specifying a negative `y` stride (row-major)', func expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -605,7 +747,7 @@ tape( 'the function supports specifying a negative `y` stride (column-major)', f expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -628,7 +770,7 @@ tape( 'the function supports specifying negative strides for `x` and `y` (row-ma expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -651,7 +793,7 @@ tape( 'the function supports specifying negative strides for `x` and `y` (column expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -674,7 +816,7 @@ tape( 'the function supports complex access patterns (row-major)', function test expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); @@ -697,7 +839,7 @@ tape( 'the function supports complex access patterns (column-major)', function t expected = new Float64Array( data.A_out ); - out = dsyr2( str2enumMatrixTriangle( data.uplo ), data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); t.end(); From 9d5df46046b988e4edc7417418943f6897869519 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sun, 29 Jun 2025 23:19:09 +0530 Subject: [PATCH 19/32] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dsyr2/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md index 91bcc95becda..d077bf6c6c3b 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md @@ -288,15 +288,15 @@ void c_dsyr2_ndarray( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alp int main( void ) { // Define a 3x3 symmetric matrix stored in row-major order: - double A[] = { + double A[ 3*3 ] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; // Define `x` and `y` vectors: - const double x[] = { 1.0, 2.0, 3.0 }; - const double y[] = { 1.0, 2.0, 3.0 }; + const double x[ 3 ] = { 1.0, 2.0, 3.0 }; + const double y[ 3 ] = { 1.0, 2.0, 3.0 }; // Specify the number of elements along each dimension of `A`: const int N = 3; From 34912198d5d0ddaffa595055d03884c2d1219332 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Sun, 29 Jun 2025 23:26:02 +0530 Subject: [PATCH 20/32] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c index a321b719768e..f3ace4ab9ea2 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/addon.c @@ -57,7 +57,6 @@ static napi_value addon( napi_env env, napi_callback_info info ) { sa1 = LDA; sa2 = 1; } - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 4 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 6 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, N, N, sa1, sa2, argv, 8 ); From 97dfb640000df973f9a7c5e8e34dc80e45852d87 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 30 Jun 2025 00:08:57 +0530 Subject: [PATCH 21/32] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c index 0febf1ca89ae..0ccc38cb9c98 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c @@ -36,6 +36,7 @@ * @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) */ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { + CBLAS_INT vala; CBLAS_INT sa1; CBLAS_INT sa2; CBLAS_INT ox; @@ -62,8 +63,14 @@ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, cons c_xerbla( 8, "c_dsyr2", "Error: invalid argument. Eighth argument must be nonzero. Value: `%d`.", strideX ); return; } - if ( LDA < N ) { - c_xerbla( 10, "c_dsyr2", "Error: invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.", N, LDA ); + // max(1, N) + if ( N < 1 ) { + vala = 1; + } else { + vala = N; + } + if ( LDA < vala ) { + c_xerbla( 10, "c_dsyr2", "Error: invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.", vala, LDA ); return; } // Check whether we can avoid computation altogether... From 87c7fecdccd81ed7e7d1638cff6f1eb0748db047 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 30 Jun 2025 17:22:08 +0530 Subject: [PATCH 22/32] chore: update implementation --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dsyr2/README.md | 68 +++++++++++-------- .../@stdlib/blas/base/dsyr2/docs/repl.txt | 16 ++--- .../blas/base/dsyr2/docs/types/index.d.ts | 16 ++--- .../blas/base/dsyr2/examples/c/example.c | 24 ++++--- .../@stdlib/blas/base/dsyr2/examples/index.js | 12 +++- .../@stdlib/blas/base/dsyr2/lib/base.js | 6 +- .../@stdlib/blas/base/dsyr2/lib/dsyr2.js | 9 +-- .../blas/base/dsyr2/lib/dsyr2.native.js | 11 +-- .../@stdlib/blas/base/dsyr2/lib/index.js | 8 +-- .../@stdlib/blas/base/dsyr2/lib/ndarray.js | 6 +- .../blas/base/dsyr2/lib/ndarray.native.js | 8 +-- .../@stdlib/blas/base/dsyr2/src/dsyr2.c | 2 +- .../blas/base/dsyr2/src/dsyr2_ndarray.c | 10 ++- 13 files changed, 115 insertions(+), 81 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md index d077bf6c6c3b..39d5a46fccc4 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md @@ -37,12 +37,12 @@ Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, where `α ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); -// A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +// A => [ 3.0, 6.0, 9.0, 2.0, 9.0, 14.0, 3.0, 2.0, 19.0 ] ``` The function has the following parameters: @@ -63,12 +63,12 @@ The stride parameters determine how elements in the input arrays are accessed at ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); dsyr2( 'row-major', 'upper', 3, 1.0, x, 2, y, 1, A, 3 ); -// A => [ 3.0, 7.0, 11.0, 0.0, 13.0, 21.0, 0.0, 0.0, 31.0 ] +// A => [ 3.0, 7.0, 11.0, 2.0, 13.0, 21.0, 3.0, 2.0, 31.0 ] ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -81,14 +81,14 @@ var Float64Array = require( '@stdlib/array/float64' ); // Initial arrays... var x0 = new Float64Array( [ 0.0, 1.0, 1.0, 1.0 ] ); var y0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); // Create offset views... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element dsyr2( 'row-major', 'upper', 3, 1.0, x1, 1, y1, 1, A, 3 ); -// A => [ 3.0, 5.0, 7.0, 0.0, 5.0, 7.0, 0.0, 0.0, 7.0 ] +// A => [ 3.0, 5.0, 7.0, 2.0, 5.0, 7.0, 3.0, 2.0, 7.0 ] ``` #### dsyr2.ndarray( uplo, N, α, x, sx, ox, y, sy, oy, A, sa1, sa2, oa ) @@ -98,12 +98,12 @@ Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alt ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); dsyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); -// A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +// A => [ 3.0, 6.0, 9.0, 2.0, 9.0, 14.0, 3.0, 2.0, 19.0 ] ``` The function has the following additional parameters: @@ -119,12 +119,12 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); dsyr2.ndarray( 'upper', 3, 1.0, x, -2, 4, y, 1, 0, A, 3, 1, 0 ); -// A => [ 11.0, 15.0, 19.0, 0.0, 13.0, 13.0, 0.0, 0.0, 7.0 ] +// A => [ 11.0, 15.0, 19.0, 2.0, 13.0, 13.0, 3.0, 2.0, 7.0 ] ``` @@ -158,12 +158,18 @@ var opts = { var N = 3; -var A = ones( N*N, opts.dtype ); +// Define 3x3 symmetric matrices: +var A1 = ones( N*N, opts.dtype ); +var A2 = ones( N*N, opts.dtype ); + var x = discreteUniform( N, -10.0, 10.0, opts ); var y = discreteUniform( N, -10.0, 10.0, opts ); -dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); -console.log( A ); +dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A1, 3 ); +console.log( A1 ); + +dsyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A2, 3, 1, 0 ); +console.log( A2 ); ``` @@ -203,7 +209,7 @@ Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` ```c #include "stdlib/blas/base/shared.h" -double A[] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; +double A[] = { 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 }; const double x[] = { 1.0, 2.0, 3.0 }; const double y[] = { 1.0, 2.0, 3.0 }; @@ -236,7 +242,7 @@ Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alt ```c #include "stdlib/blas/base/shared.h" -double A[] = { 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 }; +double A[] = { 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 }; const double x[] = { 1.0, 2.0, 3.0 }; const double y[] = { 1.0, 2.0, 3.0 }; @@ -249,11 +255,11 @@ The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. - **alpha**: `[in] double` scalar constant. - **X**: `[in] double*` first input array. -- **strideX**: `[in] CBLAS_INT` stride length for `X`. -- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **sx**: `[in] CBLAS_INT` stride length for `X`. +- **ox**: `[in] CBLAS_INT` starting index for `X`. - **Y**: `[in] double` second input array. -- **strideY**: `[in] CBLAS_INT` stride length for `Y`. -- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. +- **sy**: `[in] CBLAS_INT` stride length for `Y`. +- **oy**: `[in] CBLAS_INT` starting index for `Y`. - **A**: `[inout] 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`. @@ -287,10 +293,16 @@ void c_dsyr2_ndarray( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alp #include int main( void ) { - // Define a 3x3 symmetric matrix stored in row-major order: - double A[ 3*3 ] = { - 1.0, 0.0, 0.0, - 2.0, 1.0, 0.0, + // Define 3x3 symmetric matrices stored in row-major layout: + double A1[ 3*3 ] = { + 1.0, 2.0, 3.0, + 2.0, 1.0, 2.0, + 3.0, 2.0, 1.0 + }; + + double A2[ 3*3 ] = { + 1.0, 2.0, 3.0, + 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 }; @@ -298,23 +310,23 @@ int main( void ) { const double x[ 3 ] = { 1.0, 2.0, 3.0 }; const double y[ 3 ] = { 1.0, 2.0, 3.0 }; - // Specify the number of elements along each dimension of `A`: + // Specify the number of elements along each dimension of `A1` and `A2`: const int N = 3; // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`: - c_dsyr2( CblasColMajor, CblasUpper, N, 1.0, x, 1, y, 1, A, N ); + c_dsyr2( CblasColMajor, CblasUpper, N, 1.0, x, 1, y, 1, A1, N ); // Print the result: for ( int i = 0; i < N*N; i++ ) { - printf( "A[ %i ] = %f\n", i, A[ i ] ); + printf( "A1[ %i ] = %f\n", i, A1[ i ] ); } // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative semantics indexing: - c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); + c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A2, N, 1, 0 ); // Print the result: for ( int i = 0; i < N*N; i++ ) { - printf( "A[ %i ] = %f\n", i, A[ i ] ); + printf( "A2[ %i ] = %f\n", i, A2[ i ] ); } } ``` diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dsyr2/docs/repl.txt index 289d7441a3cc..2dea7d6a6012 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/docs/repl.txt @@ -55,25 +55,25 @@ // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); > var y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); - > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 2.0 ] ); + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 2.0, 1.0 ] ); > {{alias}}( 'row-major', 'upper', 2, 1.0, x, 1, y, 1, A, 2 ) - [ 3.0, 4.0, 0.0, 4.0 ] + [ 3.0, 4.0, 2.0, 3.0 ] // Advanced indexing: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); > y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); - > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 2.0 ] ); + > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 2.0, 1.0 ] ); > {{alias}}( 'row-major', 'upper', 2, 1.0, x, -1, y, -1, A, 2 ) - [ 3.0, 4.0, 0.0, 4.0 ] + [ 3.0, 4.0, 2.0, 3.0 ] // Using typed array views: > 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, 0.0, 2.0 ] ); + > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 2.0, 1.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}}( 'row-major', 'upper', 2, 1.0, x, 1, y, 1, A, 2 ) - [ 3.0, 4.0, 0.0, 4.0 ] + [ 3.0, 4.0, 2.0, 3.0 ] {{alias}}.ndarray( uplo, N, α, x, sx, ox, y, sy, oy, A, sa1, sa2, oa ) @@ -136,9 +136,9 @@ -------- > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); > var y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); - > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 2.0 ] ); + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 2.0, 1.0 ] ); > {{alias}}.ndarray( 'upper', 2, 1.0, x, 1, 0, y, 1, 0, A, 2, 1, 0 ) - [ 3.0, 4.0, 0.0, 4.0 ] + [ 3.0, 4.0, 2.0, 3.0 ] See Also -------- diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dsyr2/docs/types/index.d.ts index 7a9b874990be..7956c6bfa931 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/docs/types/index.d.ts @@ -44,12 +44,12 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * - * var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ] * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * * dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); - * // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] + * // A => [ 3.0, 6.0, 9.0, 2.0, 9.0, 14.0, 3.0, 2.0, 19.0 ] */ ( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, x: Float64Array, strideX: number, y: Float64Array, strideY: number, A: Float64Array, LDA: number ): Float64Array; @@ -74,12 +74,12 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * - * var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ] * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * * dsyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); - * // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] + * // A => [ 3.0, 6.0, 9.0, 2.0, 9.0, 14.0, 3.0, 2.0, 19.0 ] */ ndarray( uplo: MatrixTriangle, N: number, alpha: number, x: Float64Array, strideX: number, offsetX: number, y: Float64Array, strideY: number, offsetY: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): Float64Array; } @@ -102,22 +102,22 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * * dsyr2( 'column-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); -* // A => [ 3.0, 0.0, 0.0, 6.0, 9.0, 0.0, 9.0, 14.0, 19.0 ] +* // A => [ 3.0, 6.0, 9.0, 2.0, 9.0, 14.0, 3.0, 2.0, 19.0 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Float64Array( [ 1.0, 1.0, 1.0, 0.0, 2.0, 2.0, 0.0, 0.0, 3.0 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * * dsyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 1, 3, 0 ); -* // A => [ 3.0, 0.0, 0.0, 6.0, 9.0, 0.0, 9.0, 14.0, 19.0 ] +* // A => [ 3.0, 6.0, 9.0, 2.0, 9.0, 14.0, 3.0, 2.0, 19.0 ] */ declare var dsyr2: Routine; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c index ef7381fee3a7..1faa29c4d929 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c @@ -21,10 +21,16 @@ #include int main( void ) { - // Define a 3x3 symmetric matrix stored in row-major order: - double A[ 3*3 ] = { - 1.0, 0.0, 0.0, - 2.0, 1.0, 0.0, + // Define 3x3 symmetric matrices stored in row-major layout: + double A1[ 3*3 ] = { + 1.0, 2.0, 3.0, + 2.0, 1.0, 2.0, + 3.0, 2.0, 1.0 + }; + + double A2[ 3*3 ] = { + 1.0, 2.0, 3.0, + 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 }; @@ -32,22 +38,22 @@ int main( void ) { const double x[ 3 ] = { 1.0, 2.0, 3.0 }; const double y[ 3 ] = { 1.0, 2.0, 3.0 }; - // Specify the number of elements along each dimension of `A`: + // Specify the number of elements along each dimension of `A1` and `A2`: const int N = 3; // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`: - c_dsyr2( CblasColMajor, CblasUpper, N, 1.0, x, 1, y, 1, A, N ); + c_dsyr2( CblasColMajor, CblasUpper, N, 1.0, x, 1, y, 1, A1, N ); // Print the result: for ( int i = 0; i < N*N; i++ ) { - printf( "A[ %i ] = %f\n", i, A[ i ] ); + printf( "A1[ %i ] = %f\n", i, A1[ i ] ); } // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative semantics indexing: - c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); + c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A2, N, 1, 0 ); // Print the result: for ( int i = 0; i < N*N; i++ ) { - printf( "A[ %i ] = %f\n", i, A[ i ] ); + printf( "A2[ %i ] = %f\n", i, A2[ i ] ); } } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/examples/index.js b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/index.js index d8e405b8335e..fffc3ac3f690 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/index.js @@ -28,9 +28,15 @@ var opts = { var N = 3; -var A = ones( N*N, opts.dtype ); +// Define 3x3 symmetric matrices: +var A1 = ones( N*N, opts.dtype ); +var A2 = ones( N*N, opts.dtype ); + var x = discreteUniform( N, -10.0, 10.0, opts ); var y = discreteUniform( N, -10.0, 10.0, opts ); -dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); -console.log( A ); +dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A1, 3 ); +console.log( A1 ); + +dsyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A2, 3, 1, 0 ); +console.log( A2 ); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/base.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/base.js index 1632825178cc..4c3bd857ffe9 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/base.js @@ -31,7 +31,7 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); * @private * @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced * @param {NonNegativeInteger} N - number of elements along each dimension of `A` -* @param {number} alpha - scalar +* @param {number} alpha - scalar constant * @param {Float64Array} x - first input vector * @param {integer} strideX - `x` stride length * @param {NonNegativeInteger} offsetX - starting index for `x` @@ -47,12 +47,12 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ] * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * * dsyr2( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); -* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +* // A => [ 3.0, 6.0, 9.0, 2.0, 9.0, 14.0, 3.0, 2.0, 19.0 ] */ function dsyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params var tmp1; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.js index cb506ca4b603..67082192f95d 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.js @@ -37,7 +37,7 @@ var base = require( './base.js' ); * @param {string} order - storage layout * @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced * @param {NonNegativeInteger} N - number of elements along each dimension of `A` -* @param {number} alpha - scalar +* @param {number} alpha - scalar constant * @param {Float64Array} x - first input vector * @param {integer} strideX - `x` stride length * @param {Float64Array} y - second input vector @@ -48,18 +48,19 @@ var base = require( './base.js' ); * @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} sixth argument must be non-zero -* @throws {RangeError} eighth argument must be a valid stride +* @throws {RangeError} eighth argument must be non-zero +* @throws {RangeError} tenth argument must be a valid stride * @returns {Float64Array} `A` * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ] * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * * dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); -* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +* // A => [ 3.0, 6.0, 9.0, 2.0, 9.0, 14.0, 3.0, 2.0, 19.0 ] */ function dsyr2( order, uplo, N, alpha, x, strideX, y, strideY, A, LDA ) { var sa1; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.native.js index ccde52fc0298..0909b4f44b03 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/dsyr2.native.js @@ -35,9 +35,9 @@ var addon = require( './../src/addon.node' ); * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * * @param {string} order - storage layout -* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced * @param {NonNegativeInteger} N - number of elements along each dimension of `A` -* @param {number} alpha - scalar +* @param {number} alpha - scalar constant * @param {Float64Array} x - first input vector * @param {integer} strideX - `x` stride length * @param {Float64Array} y - second input vector @@ -48,18 +48,19 @@ var addon = require( './../src/addon.node' ); * @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} sixth argument must be non-zero -* @throws {RangeError} eighth argument must be a valid stride +* @throws {RangeError} eighth argument must be non-zero +* @throws {RangeError} tenth argument must be a valid stride * @returns {Float64Array} `A` * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ] * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * * dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); -* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +* // A => [ 3.0, 6.0, 9.0, 2.0, 9.0, 14.0, 3.0, 2.0, 19.0 ] */ function dsyr2( order, uplo, N, alpha, x, strideX, y, strideY, A, LDA ) { if ( !isLayout( order ) ) { diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/index.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/index.js index 9fe8f4c79320..5b59606fed84 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/index.js @@ -27,23 +27,23 @@ * var Float64Array = require( '@stdlib/array/float64' ); * var dsyr2 = require( '@stdlib/blas/base/dsyr2' ); * -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ] * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * * dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); -* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +* // A => [ 3.0, 6.0, 9.0, 2.0, 9.0, 14.0, 3.0, 2.0, 19.0 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * var dsyr2 = require( '@stdlib/blas/base/dsyr2' ); * -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ] * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * * dsyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); -* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +* // A => [ 3.0, 6.0, 9.0, 2.0, 9.0, 14.0, 3.0, 2.0, 19.0 ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.js index cad070cd1bae..fef831f9c081 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.js @@ -32,7 +32,7 @@ var base = require( './base.js' ); * * @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced * @param {NonNegativeInteger} N - number of elements along each dimension of `A` -* @param {number} alpha - scalar +* @param {number} alpha - scalar constant * @param {Float64Array} x - first input vector * @param {integer} strideX - `x` stride length * @param {NonNegativeInteger} offsetX - starting index for `x` @@ -54,12 +54,12 @@ var base = require( './base.js' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ] * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * * dsyr2( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); -* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +* // A => [ 3.0, 6.0, 9.0, 2.0, 9.0, 14.0, 3.0, 2.0, 19.0 ] */ function dsyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params if ( !isMatrixTriangle( uplo ) ) { diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js index 685ab00659a7..eaed2eb08069 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/ndarray.native.js @@ -31,9 +31,9 @@ var addon = require( './../src/addon.node' ); /** * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * -* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced * @param {NonNegativeInteger} N - number of elements along each dimension of `A` -* @param {number} alpha - scalar +* @param {number} alpha - scalar constant * @param {Float64Array} x - first input vector * @param {integer} strideX - `x` stride length * @param {NonNegativeInteger} offsetX - starting index for `x` @@ -55,12 +55,12 @@ var addon = require( './../src/addon.node' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 2.0, 1.0, 2.0, 3.0, 2.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 2.0, 1.0, 2.0 ], [ 3.0, 2.0, 1.0 ] ] * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * * dsyr2( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); -* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +* // A => [ 3.0, 6.0, 9.0, 2.0, 9.0, 14.0, 3.0, 2.0, 19.0 ] */ function dsyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params if ( !isMatrixTriangle( uplo ) ) { diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c index 0ccc38cb9c98..0c002acdef60 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c @@ -48,7 +48,7 @@ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, cons return; } if ( uplo != CblasLower && uplo != CblasUpper ) { - c_xerbla( 2, "c_dsyr2", "Error: invalid argument. Second argument must specify whether to reference the lower or upper triangular matrixecond argument must specify whether to reference the lower or upper triangular matrix. Value: `%d`.", uplo ); + c_xerbla( 2, "c_dsyr2", "Error: invalid argument. Second argument must specify whether to reference the lower or upper triangular matrix. Value: `%d`.", uplo ); return; } if ( N < 0 ) { diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c index 6f5210450ec4..d112edb11c7b 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c @@ -59,7 +59,7 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons // Perform input argument validation... if ( uplo != CblasLower && uplo != CblasUpper ) { - c_xerbla( 1, "c_dsyr2_ndarray", "Error: invalid argument. First argument must specify whether to reference the lower or upper triangular matrixecond argument must specify whether to reference the lower or upper triangular matrix. Value: `%d`.", uplo ); + c_xerbla( 1, "c_dsyr2_ndarray", "Error: invalid argument. First argument must specify whether to reference the lower or upper triangular matrix. Value: `%d`.", uplo ); return; } if ( N < 0 ) { @@ -74,6 +74,14 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons c_xerbla( 8, "c_dsyr2_ndarray", "Error: invalid argument. Eighth argument must be a nonzero. Value: `%d`.", strideY ); return; } + if ( strideA1 == 0 ) { + c_xerbla( 11, "c_dsyr2_ndarray", "Error: invalid argument. Eleventh argument must be a nonzero. Value: `%d`.", strideA1 ); + return; + } + if ( strideA2 == 0 ) { + c_xerbla( 12, "c_dsyr2_ndarray", "Error: invalid argument. Twelfth argument must be a nonzero. Value: `%d`.", strideA2 ); + return; + } // Check whether we can avoid computation altogether... if ( N == 0 || alpha == 0.0 ) { return; From 3da5d9e83d7c539c9de55baaefe799a9f5252a65 Mon Sep 17 00:00:00 2001 From: Aman Bhansali <92033532+aman-095@users.noreply.github.com> Date: Tue, 15 Jul 2025 11:49:46 +0530 Subject: [PATCH 23/32] Update README.md Signed-off-by: Aman Bhansali <92033532+aman-095@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dsyr2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md index 39d5a46fccc4..57087aac6aed 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md @@ -158,7 +158,7 @@ var opts = { var N = 3; -// Define 3x3 symmetric matrices: +// Create N-by-N symmetric matrices: var A1 = ones( N*N, opts.dtype ); var A2 = ones( N*N, opts.dtype ); From 6e9d58bc0ac6056b559934269b285ff46627ca4f Mon Sep 17 00:00:00 2001 From: Aman Bhansali <92033532+aman-095@users.noreply.github.com> Date: Tue, 15 Jul 2025 11:57:57 +0530 Subject: [PATCH 24/32] Update README.md Signed-off-by: Aman Bhansali <92033532+aman-095@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dsyr2/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md index 57087aac6aed..d31842617dc8 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md @@ -318,7 +318,7 @@ int main( void ) { // Print the result: for ( int i = 0; i < N*N; i++ ) { - printf( "A1[ %i ] = %f\n", i, A1[ i ] ); + printf( "A1[ %i ] = %lf\n", i, A1[ i ] ); } // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative semantics indexing: @@ -326,7 +326,7 @@ int main( void ) { // Print the result: for ( int i = 0; i < N*N; i++ ) { - printf( "A2[ %i ] = %f\n", i, A2[ i ] ); + printf( "A2[ %i ] = %lf\n", i, A2[ i ] ); } } ``` From 19ea8e05f74afeb42b17d521ddf5ca957a28ad6c Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Wed, 16 Jul 2025 08:08:44 +0530 Subject: [PATCH 25/32] chore: update parameter descriptions Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dsyr2/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md index d31842617dc8..8bfb6ec892f3 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md @@ -48,7 +48,7 @@ dsyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); The function has the following parameters: - **order**: storage layout. -- **uplo**: specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied. +- **uplo**: specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced. - **N**: number of elements along each dimension of `A`. - **α**: scalar constant. - **x**: first input [`Float64Array`][mdn-float64array]. @@ -219,7 +219,7 @@ c_dsyr2( CblasColMajor, CblasUpper, 3, 1.0, x, 1, y, 1, A, 3 ); The function accepts the following arguments: - **order**: `[in] CBLAS_LAYOUT` storage layout. -- **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied. +- **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced. - **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. - **alpha**: `[in] double` scalar constant. - **X**: `[in] double*` first input array. @@ -251,7 +251,7 @@ c_dsyr2_ndarray( CblasUpper, 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); The function accepts the following arguments: -- **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied. +- **uplo**: `[in] CBLAS_UPLO` specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced. - **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. - **alpha**: `[in] double` scalar constant. - **X**: `[in] double*` first input array. From 32d64c82686ad60ce8b469edb45ac709a09518a4 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Wed, 16 Jul 2025 08:18:27 +0530 Subject: [PATCH 26/32] chore: update doxygen --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c | 4 ++-- lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c | 2 +- lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c index 0c002acdef60..d7f9e2a7b659 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2.c @@ -24,8 +24,8 @@ /** * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * -* @param layout storage layout -* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied +* @param layout storage layout +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced * @param N number of elements along each dimension of `A` * @param alpha scalar constant * @param X first input vector diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c index ccbdac936830..d5a3d80e52f8 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c @@ -24,7 +24,7 @@ * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * * @param layout storage layout -* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced * @param N number of elements along each dimension of `A` * @param alpha scalar constant * @param x first input vector diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c index d112edb11c7b..385dee7ac5d2 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c @@ -24,7 +24,7 @@ /** * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * -* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced * @param N number of elements along each dimension of `A` * @param alpha scalar constant * @param X first input vector From f2dcd778b4be7c6856346dd437820dce0aa343a2 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 15 Jul 2025 21:58:40 -0700 Subject: [PATCH 27/32] Discard changes to lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.js --- .../@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.js index 59e97826d571..3685431ce0d1 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.js @@ -42,7 +42,7 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - array length +* @param {PositiveInteger} N - number of elements along each dimension * @returns {Function} benchmark function */ function createBenchmark( N ) { From c1666bf5f843c726eac2e57a728bfe3eef26ae2b Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 15 Jul 2025 21:58:53 -0700 Subject: [PATCH 28/32] Discard changes to lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.js --- lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.js index 641e1fa0fce1..1ed4902b29e4 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.js @@ -42,7 +42,7 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - array length +* @param {PositiveInteger} N - number of elements along each dimension * @returns {Function} benchmark function */ function createBenchmark( N ) { From cf37158e9f96795f1f81cd4f1e4e7a085ed3b710 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 15 Jul 2025 21:59:10 -0700 Subject: [PATCH 29/32] docs: update description Signed-off-by: Athan --- .../@stdlib/blas/base/dsyr2/benchmark/benchmark.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.native.js index eeca12213e9e..0ce3799353f6 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.native.js @@ -47,7 +47,7 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - array length +* @param {PositiveInteger} N - number of elements along each dimension * @returns {Function} benchmark function */ function createBenchmark( N ) { From 76dd1a9a2b2451d2379c0689d10c89ca50d61d5e Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 15 Jul 2025 22:00:01 -0700 Subject: [PATCH 30/32] docs: update description Signed-off-by: Athan --- .../blas/base/dsyr2/benchmark/benchmark.ndarray.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.native.js index 943849f5069b..534af4370389 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/benchmark.ndarray.native.js @@ -47,7 +47,7 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - array length +* @param {PositiveInteger} N - number of elements along each dimension * @returns {Function} benchmark function */ function createBenchmark( N ) { From 704d5086b883d97b4e2d5e771a591cf4a824ef17 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 15 Jul 2025 22:02:02 -0700 Subject: [PATCH 31/32] fix: update error messages Signed-off-by: Athan --- .../@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c index 385dee7ac5d2..2e3f68cf4b99 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c @@ -67,19 +67,19 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons return; } if ( strideX == 0 ) { - c_xerbla( 5, "c_dsyr2_ndarray", "Error: invalid argument. Fifth argument must be a nonzero. Value: `%d`.", strideX ); + c_xerbla( 5, "c_dsyr2_ndarray", "Error: invalid argument. Fifth argument must be nonzero. Value: `%d`.", strideX ); return; } if ( strideY == 0 ) { - c_xerbla( 8, "c_dsyr2_ndarray", "Error: invalid argument. Eighth argument must be a nonzero. Value: `%d`.", strideY ); + c_xerbla( 8, "c_dsyr2_ndarray", "Error: invalid argument. Eighth argument must be nonzero. Value: `%d`.", strideY ); return; } if ( strideA1 == 0 ) { - c_xerbla( 11, "c_dsyr2_ndarray", "Error: invalid argument. Eleventh argument must be a nonzero. Value: `%d`.", strideA1 ); + c_xerbla( 11, "c_dsyr2_ndarray", "Error: invalid argument. Eleventh argument must be nonzero. Value: `%d`.", strideA1 ); return; } if ( strideA2 == 0 ) { - c_xerbla( 12, "c_dsyr2_ndarray", "Error: invalid argument. Twelfth argument must be a nonzero. Value: `%d`.", strideA2 ); + c_xerbla( 12, "c_dsyr2_ndarray", "Error: invalid argument. Twelfth argument must be nonzero. Value: `%d`.", strideA2 ); return; } // Check whether we can avoid computation altogether... From 47d27147e10be742f9f6a5395ad0b4093ac8fbe9 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 15 Jul 2025 22:35:37 -0700 Subject: [PATCH 32/32] chore: clean-up --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/dsyr2/README.md | 5 +- .../blas/base/dsyr2/benchmark/c/benchmark.c | 8 +- .../blas/base/dsyr2/examples/c/example.c | 6 +- .../@stdlib/blas/base/dsyr2/examples/index.js | 3 +- .../@stdlib/blas/base/dsyr2/lib/base.js | 12 +- .../@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c | 2 +- .../blas/base/dsyr2/src/dsyr2_ndarray.c | 32 +-- .../blas/base/dsyr2/test/test.dsyr2.native.js | 48 +++++ .../base/dsyr2/test/test.ndarray.native.js | 199 +++++++++++++++--- 9 files changed, 257 insertions(+), 58 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md index 8bfb6ec892f3..b4c40e38087f 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/README.md +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/README.md @@ -162,6 +162,7 @@ var N = 3; var A1 = ones( N*N, opts.dtype ); var A2 = ones( N*N, opts.dtype ); +// Create random vectors: var x = discreteUniform( N, -10.0, 10.0, opts ); var y = discreteUniform( N, -10.0, 10.0, opts ); @@ -266,7 +267,7 @@ The function accepts the following arguments: - **oa**: `[in] CBLAS_INT` starting index for `A`. ```c -void c_dsyr2_ndarray( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *x, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *y, CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) +void c_dsyr2_ndarray( const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const double *Y, CBLAS_INT strideY, const CBLAS_INT offsetY, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA ) ``` @@ -321,7 +322,7 @@ int main( void ) { printf( "A1[ %i ] = %lf\n", i, A1[ i ] ); } - // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative semantics indexing: + // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics: c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A2, N, 1, 0 ); // Print the result: diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c index ce5228824c7a..7605a9f065f7 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/benchmark/c/benchmark.c @@ -100,13 +100,13 @@ static double benchmark1( int iterations, int N ) { t = tic(); for ( i = 0; i < iterations; i++ ) { c_dsyr2( CblasRowMajor, CblasUpper, N, 1.0, x, 1, y, 1, A, N ); - if ( A[ i%N ] != A[ i%N ] ) { + if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( A[ i%N ] != A[ i%N ] ) { + if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } return elapsed; @@ -133,13 +133,13 @@ static double benchmark2( int iterations, int N ) { t = tic(); for ( i = 0; i < iterations; i++ ) { c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); - if ( A[ i%N ] != A[ i%N ] ) { + if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( A[ i%N ] != A[ i%N ] ) { + if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } return elapsed; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c index 1faa29c4d929..aab0d43b67da 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/c/example.c @@ -46,14 +46,14 @@ int main( void ) { // Print the result: for ( int i = 0; i < N*N; i++ ) { - printf( "A1[ %i ] = %f\n", i, A1[ i ] ); + printf( "A1[ %i ] = %lf\n", i, A1[ i ] ); } - // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative semantics indexing: + // Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` using alternative indexing semantics: c_dsyr2_ndarray( CblasUpper, N, 1.0, x, 1, 0, y, 1, 0, A2, N, 1, 0 ); // Print the result: for ( int i = 0; i < N*N; i++ ) { - printf( "A2[ %i ] = %f\n", i, A2[ i ] ); + printf( "A2[ %i ] = %lf\n", i, A2[ i ] ); } } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/examples/index.js b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/index.js index fffc3ac3f690..fabd7886fdfe 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/examples/index.js @@ -28,10 +28,11 @@ var opts = { var N = 3; -// Define 3x3 symmetric matrices: +// Define N-by-N symmetric matrices: var A1 = ones( N*N, opts.dtype ); var A2 = ones( N*N, opts.dtype ); +// Create random vectors: var x = discreteUniform( N, -10.0, 10.0, opts ); var y = discreteUniform( N, -10.0, 10.0, opts ); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/base.js b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/base.js index 4c3bd857ffe9..e4306841d230 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/lib/base.js @@ -66,7 +66,7 @@ function dsyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, str var sa1; var i0; var i1; - var oa; + var ia; var ox; var oy; @@ -92,13 +92,14 @@ function dsyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, str if ( ( x[ ix1 ] !== 0.0 ) || ( y[ iy1 ] !== 0.0 ) ) { tmp1 = alpha * y[ iy1 ]; tmp2 = alpha * x[ ix1 ]; - oa = offsetA + (sa1*i1); + ia = offsetA + ( sa1*i1 ); ix0 = ox; iy0 = oy; for ( i0 = 0; i0 <= i1; i0++ ) { - A[ oa+(sa0*i0) ] += ( x[ ix0 ] * tmp1 ) + ( y[ iy0 ] * tmp2 ); // eslint-disable-line max-len + A[ ia ] += ( x[ ix0 ] * tmp1 ) + ( y[ iy0 ] * tmp2 ); ix0 += strideX; iy0 += strideY; + ia += sa0; } } ix1 += strideX; @@ -111,13 +112,14 @@ function dsyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, str if ( ( x[ ix1 ] !== 0.0 ) || ( y[ iy1 ] !== 0.0 ) ) { tmp1 = alpha * y[ iy1 ]; tmp2 = alpha * x[ ix1 ]; - oa = offsetA + (sa1*i1); + ia = offsetA + ( sa1*i1 ) + ( sa0*i1 ); ix0 = ix1; iy0 = iy1; for ( i0 = i1; i0 < N; i0++ ) { - A[ oa+(sa0*i0) ] += ( x[ ix0 ] * tmp1 ) + ( y[ iy0 ] * tmp2 ); + A[ ia ] += ( x[ ix0 ] * tmp1 ) + ( y[ iy0 ] * tmp2 ); ix0 += strideX; iy0 += strideY; + ia += sa0; } } ix1 += strideX; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c index d5a3d80e52f8..fbbdc5edf56b 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_cblas.c @@ -35,5 +35,5 @@ * @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) */ void API_SUFFIX(c_dsyr2)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { - API_SUFFIX(cblas_dsyr2)( layout, uplo, N, alpha, X, strideX, A, LDA ); + API_SUFFIX(cblas_dsyr2)( layout, uplo, N, alpha, X, strideX, Y, strideY, A, LDA ); } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c index 2e3f68cf4b99..8de38edab45d 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/src/dsyr2_ndarray.c @@ -24,16 +24,16 @@ /** * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * -* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced -* @param N number of elements along each dimension of `A` -* @param alpha scalar constant -* @param X first input vector -* @param strideX `X` stride length -* @param offsetX starting index of `X` -* @param Y second input vector -* @param strideY `Y` stride length -* @param offsetY starting index of `Y` -* @param A input matrix +* @param uplo specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param N number of elements along each dimension of `A` +* @param alpha scalar constant +* @param X first input vector +* @param strideX `X` stride length +* @param offsetX starting index of `X` +* @param Y second input vector +* @param strideY `Y` stride length +* @param offsetY starting index of `Y` +* @param A input matrix * @param strideA1 stride of the first dimension of `A` * @param strideA2 stride of the second dimension of `A` * @param offsetA starting index of `A` @@ -49,7 +49,7 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons CBLAS_INT sa1; CBLAS_INT i0; CBLAS_INT i1; - CBLAS_INT oa; + CBLAS_INT ia; CBLAS_INT ox; CBLAS_INT oy; double tmp1; @@ -111,13 +111,14 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) { tmp1 = alpha * Y[ iy1 ]; tmp2 = alpha * X[ ix1 ]; - oa = offsetA + (sa1*i1); + ia = offsetA + ( sa1*i1 ); ix0 = ox; iy0 = oy; for ( i0 = 0; i0 <= i1; i0++ ) { - A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 ); // eslint-disable-line max-len + A[ ia ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 ); ix0 += strideX; iy0 += strideY; + ia += sa0; } } ix1 += strideX; @@ -130,13 +131,14 @@ void API_SUFFIX(c_dsyr2_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT N, cons if ( ( X[ ix1 ] != 0.0 ) || ( Y[ iy1 ] != 0.0 ) ) { tmp1 = alpha * Y[ iy1 ]; tmp2 = alpha * X[ ix1 ]; - oa = offsetA + (sa1*i1); + ia = offsetA + ( sa1*i1 ) + ( sa0*i1 ); ix0 = ix1; iy0 = iy1; for ( i0 = i1; i0 < N; i0++ ) { - A[ oa+(sa0*i0) ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 ); + A[ ia ] += ( X[ ix0 ] * tmp1 ) + ( Y[ iy0 ] * tmp2 ); ix0 += strideX; iy0 += strideY; + ia += sa0; } } ix1 += strideX; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js index d8b6f23fadae..22584d231bb1 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.native.js @@ -32,6 +32,7 @@ var tryRequire = require( '@stdlib/utils/try-require' ); var ru = require( './fixtures/row_major_u.json' ); var rl = require( './fixtures/row_major_l.json' ); +var rx0 = require( './fixtures/row_major_x0.json' ); var rxpyp = require( './fixtures/row_major_xpyp.json' ); var rxnyp = require( './fixtures/row_major_xnyp.json' ); var rxpyn = require( './fixtures/row_major_xpyn.json' ); @@ -39,6 +40,7 @@ var rxnyn = require( './fixtures/row_major_xnyn.json' ); var cu = require( './fixtures/column_major_u.json' ); var cl = require( './fixtures/column_major_l.json' ); +var cx0 = require( './fixtures/column_major_x0.json' ); var cxpyp = require( './fixtures/column_major_xpyp.json' ); var cxnyp = require( './fixtures/column_major_xnyp.json' ); var cxpyn = require( './fixtures/column_major_xpyn.json' ); @@ -309,6 +311,52 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y t.end(); }); +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, zero-vector)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx0; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, zero-vector)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cx0; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a reference to the input matrix `A`', opts, function test( t ) { var data; var out; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js index 3dc49a01b772..ef796b3f6105 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.ndarray.native.js @@ -32,11 +32,14 @@ var tryRequire = require( '@stdlib/utils/try-require' ); var ru = require( './fixtures/row_major_u.json' ); var rl = require( './fixtures/row_major_l.json' ); +var rx0 = require( './fixtures/row_major_x0.json' ); var rxpyp = require( './fixtures/row_major_xpyp.json' ); var rxnyp = require( './fixtures/row_major_xnyp.json' ); var rxpyn = require( './fixtures/row_major_xpyn.json' ); var rxnyn = require( './fixtures/row_major_xnyn.json' ); var roa = require( './fixtures/row_major_oa.json' ); +var rox = require( './fixtures/row_major_ox.json' ); +var roy = require( './fixtures/row_major_oy.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' ); @@ -45,11 +48,14 @@ var rcap = require( './fixtures/row_major_complex_access_pattern.json' ); var cu = require( './fixtures/column_major_u.json' ); var cl = require( './fixtures/column_major_l.json' ); +var cx0 = require( './fixtures/column_major_x0.json' ); var cxpyp = require( './fixtures/column_major_xpyp.json' ); var cxnyp = require( './fixtures/column_major_xnyp.json' ); var cxpyn = require( './fixtures/column_major_xpyn.json' ); var cxnyn = require( './fixtures/column_major_xnyn.json' ); var coa = require( './fixtures/column_major_oa.json' ); +var cox = require( './fixtures/column_major_ox.json' ); +var coy = require( './fixtures/column_major_oy.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' ); @@ -221,7 +227,7 @@ tape( 'the function throws an error if provided an invalid twelfth argument', op } }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, upper)', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, upper)', opts, function test( t ) { var expected; var data; var out; @@ -244,7 +250,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, upper)', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, upper)', opts, function test( t ) { var expected; var data; var out; @@ -267,7 +273,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, lower)', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, lower)', opts, function test( t ) { var expected; var data; var out; @@ -290,7 +296,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, lower)', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, lower)', opts, function test( t ) { var expected; var data; var out; @@ -313,7 +319,53 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y t.end(); }); -tape( 'the function returns a reference to the input matrix `A`', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, zero-vector)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rx0; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, zero-vector)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cx0; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the input matrix `A`', opts, function test( t ) { var data; var out; var a; @@ -332,7 +384,7 @@ tape( 'the function returns a reference to the input matrix `A`', function test( t.end(); }); -tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (row-major)', function test( t ) { +tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (row-major)', opts, function test( t ) { var expected; var data; var out; @@ -359,7 +411,7 @@ tape( 'if `N` is zero or the scalar constant is zero, the function returns the i t.end(); }); -tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (column-major)', function test( t ) { +tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (column-major)', opts, function test( t ) { var expected; var data; var out; @@ -386,7 +438,7 @@ tape( 'if `N` is zero or the scalar constant is zero, the function returns the i t.end(); }); -tape( 'the function supports specifying the strides for the first and the second dimensions of `A` (row-major)', function test( t ) { +tape( 'the function supports specifying the strides for the first and the second dimensions of `A` (row-major)', opts, function test( t ) { var expected; var data; var out; @@ -409,7 +461,7 @@ tape( 'the function supports specifying the strides for the first and the second t.end(); }); -tape( 'the function supports specifying the strides for the first and the second dimensions of `A` (column-major)', function test( t ) { +tape( 'the function supports specifying the strides for the first and the second dimensions of `A` (column-major)', opts, function test( t ) { var expected; var data; var out; @@ -432,7 +484,7 @@ tape( 'the function supports specifying the strides for the first and the second t.end(); }); -tape( 'the function supports a negative stride for the first dimension of `A` (row-major)', function test( t ) { +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; @@ -455,7 +507,7 @@ tape( 'the function supports a negative stride for the first dimension of `A` (r t.end(); }); -tape( 'the function supports a negative stride for the first dimension of `A` (column-major)', function test( t ) { +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; @@ -478,7 +530,7 @@ tape( 'the function supports a negative stride for the first dimension of `A` (c t.end(); }); -tape( 'the function supports a negative stride for the second dimension of `A` (row-major)', function test( t ) { +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; @@ -501,7 +553,7 @@ tape( 'the function supports a negative stride for the second dimension of `A` ( t.end(); }); -tape( 'the function supports a negative stride for the second dimension of `A` (column-major)', function test( t ) { +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; @@ -524,7 +576,7 @@ tape( 'the function supports a negative stride for the second dimension of `A` ( t.end(); }); -tape( 'the function supports negative strides for `A` (row-major)', function test( t ) { +tape( 'the function supports negative strides for `A` (row-major)', opts, function test( t ) { var expected; var data; var out; @@ -547,7 +599,7 @@ tape( 'the function supports negative strides for `A` (row-major)', function tes t.end(); }); -tape( 'the function supports negative strides for `A` (column-major)', function test( t ) { +tape( 'the function supports negative strides for `A` (column-major)', opts, function test( t ) { var expected; var data; var out; @@ -570,7 +622,7 @@ tape( 'the function supports negative strides for `A` (column-major)', function t.end(); }); -tape( 'the function supports specifying an `A` offset (row-major)', function test( t ) { +tape( 'the function supports specifying an `A` offset (row-major)', opts, function test( t ) { var expected; var data; var out; @@ -593,7 +645,7 @@ tape( 'the function supports specifying an `A` offset (row-major)', function tes t.end(); }); -tape( 'the function supports specifying an `A` offset (column-major)', function test( t ) { +tape( 'the function supports specifying an `A` offset (column-major)', opts, function test( t ) { var expected; var data; var out; @@ -616,7 +668,7 @@ tape( 'the function supports specifying an `A` offset (column-major)', function t.end(); }); -tape( 'the function supports specifying `x` and `y` strides (row-major)', function test( t ) { +tape( 'the function supports specifying `x` and `y` strides (row-major)', opts, function test( t ) { var expected; var data; var out; @@ -639,7 +691,7 @@ tape( 'the function supports specifying `x` and `y` strides (row-major)', functi t.end(); }); -tape( 'the function supports specifying `x` and `y` strides (column-major)', function test( t ) { +tape( 'the function supports specifying `x` and `y` strides (column-major)', opts, function test( t ) { var expected; var data; var out; @@ -662,7 +714,7 @@ tape( 'the function supports specifying `x` and `y` strides (column-major)', fun t.end(); }); -tape( 'the function supports specifying a negative `x` stride (row-major)', function test( t ) { +tape( 'the function supports specifying a negative `x` stride (row-major)', opts, function test( t ) { var expected; var data; var out; @@ -685,7 +737,7 @@ tape( 'the function supports specifying a negative `x` stride (row-major)', func t.end(); }); -tape( 'the function supports specifying a negative `x` stride (column-major)', function test( t ) { +tape( 'the function supports specifying a negative `x` stride (column-major)', opts, function test( t ) { var expected; var data; var out; @@ -708,7 +760,7 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', f t.end(); }); -tape( 'the function supports specifying a negative `y` stride (row-major)', function test( t ) { +tape( 'the function supports specifying a negative `y` stride (row-major)', opts, function test( t ) { var expected; var data; var out; @@ -731,7 +783,7 @@ tape( 'the function supports specifying a negative `y` stride (row-major)', func t.end(); }); -tape( 'the function supports specifying a negative `y` stride (column-major)', function test( t ) { +tape( 'the function supports specifying a negative `y` stride (column-major)', opts, function test( t ) { var expected; var data; var out; @@ -754,7 +806,7 @@ tape( 'the function supports specifying a negative `y` stride (column-major)', f t.end(); }); -tape( 'the function supports specifying negative strides for `x` and `y` (row-major)', function test( t ) { +tape( 'the function supports specifying negative strides for `x` and `y` (row-major)', opts, function test( t ) { var expected; var data; var out; @@ -777,7 +829,7 @@ tape( 'the function supports specifying negative strides for `x` and `y` (row-ma t.end(); }); -tape( 'the function supports specifying negative strides for `x` and `y` (column-major)', function test( t ) { +tape( 'the function supports specifying negative strides for `x` and `y` (column-major)', opts, function test( t ) { var expected; var data; var out; @@ -800,7 +852,99 @@ tape( 'the function supports specifying negative strides for `x` and `y` (column t.end(); }); -tape( 'the function supports complex access patterns (row-major)', function test( t ) { +tape( 'the function supports specifying an `x` offset (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rox; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` offset (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cox; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a `y` offset (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = roy; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a `y` offset (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = coy; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + y = new Float64Array( data.y ); + + expected = new Float64Array( data.A_out ); + + out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, '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; @@ -823,7 +967,7 @@ tape( 'the function supports complex access patterns (row-major)', function test t.end(); }); -tape( 'the function supports complex access patterns (column-major)', function test( t ) { +tape( 'the function supports complex access patterns (column-major)', opts, function test( t ) { var expected; var data; var out; @@ -842,5 +986,6 @@ tape( 'the function supports complex access patterns (column-major)', function t out = dsyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( out, expected, 'returns expected value' ); + t.end(); });