From f86f88969dd1a041a565594d4d02e2985c1a5cfc Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 1 Jun 2025 20:59:17 +0530 Subject: [PATCH 01/21] feat: add blas/base/dtrsv --- 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/dtrsv/README.md | 92 +- .../base/dtrsv/benchmark/benchmark.native.js | 111 +++ .../benchmark/benchmark.ndarray.native.js | 110 +++ .../blas/base/dtrsv/benchmark/c/Makefile | 146 ++++ .../base/dtrsv/benchmark/c/benchmark.length.c | 179 ++++ .../@stdlib/blas/base/dtrsv/binding.gyp | 265 ++++++ .../blas/base/dtrsv/examples/c/Makefile | 146 ++++ .../blas/base/dtrsv/examples/c/example.c | 46 + .../@stdlib/blas/base/dtrsv/include.gypi | 70 ++ .../dtrsv/include/stdlib/blas/base/dtrsv.h | 48 + .../include/stdlib/blas/base/dtrsv_cblas.h | 44 + .../blas/base/dtrsv/lib/dtrsv.native.js | 63 ++ .../@stdlib/blas/base/dtrsv/lib/native.js | 36 + .../blas/base/dtrsv/lib/ndarray.native.js | 64 ++ .../@stdlib/blas/base/dtrsv/manifest.json | 484 +++++++++++ .../@stdlib/blas/base/dtrsv/package.json | 4 + .../@stdlib/blas/base/dtrsv/src/Makefile | 70 ++ .../@stdlib/blas/base/dtrsv/src/addon.c | 96 ++ .../@stdlib/blas/base/dtrsv/src/dtrsv.c | 52 ++ .../@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c | 74 ++ .../blas/base/dtrsv/src/dtrsv_ndarray.c | 152 ++++ .../blas/base/dtrsv/test/test.dtrsv.native.js | 554 ++++++++++++ .../base/dtrsv/test/test.ndarray.native.js | 818 ++++++++++++++++++ 23 files changed, 3717 insertions(+), 7 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/include/stdlib/blas/base/dtrsv.h create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/include/stdlib/blas/base/dtrsv_cblas.h create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/lib/dtrsv.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/test/test.dtrsv.native.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrsv/test/test.ndarray.native.js diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/README.md b/lib/node_modules/@stdlib/blas/base/dtrsv/README.md index 0a8cd0d23c11..2dd242edbfec 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/README.md +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/README.md @@ -184,24 +184,75 @@ console.log( x );
+ + +
+ ### Usage ```c -TODO +#include "stdlib/blas/base/dtrsv.h" +``` + +#### c_dtrsv( order, uplo, trans, diag, N, \*A, LDA, \*X, strideX ) + +Solves one of the systems of equations `A*x = b` or `A^T*x = b` where `b` and `x` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. + +```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 }; + +c_dtrsv( CblasRowMajor, CblasUpper, CblasNoTrans, CblasUnit, 3, A, 3, x, 1 ); +``` + +The function accepts the following arguments: + +- **order**: `[in] CBLAS_LAYOUT` storage layout. +- **uplo**: `[in] CBLAS_UPLO` specifies whether `A` is an upper or lower triangular matrix. +- **trans**: `[in] CBLAS_TRANSPOSE` specifies whether `A` should be transposed, conjugate-transposed, or not transposed. +- **diag**: `[in] CBLAS_DIAG` specifies whether `A` has a unit diagonal. +- **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. +- **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`). +- **X**: `[in] double*` input vector. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. + +```c +void c_dtrsv( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *x, const CBLAS_INT strideX ) ``` -#### TODO + +#### c_dtrsv_ndarray( uplo, trans, diag, N, \*A, strideA1, strideA2, offsetA, \*X, strideX, offsetA ) -TODO. +Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` using alternative indexing semantics, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. ```c -TODO +#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 }; + +c_dtrsv_ndarray( CblasUpper, CblasNoTrans, CblasUnit, 3, A, 3, 1, 0, x, 1, 0 ); ``` -TODO +The function accepts the following arguments: + +- **uplo**: `[in] CBLAS_UPLO` specifies whether `A` is an upper or lower triangular matrix. +- **trans**: `[in] CBLAS_TRANSPOSE` specifies whether `A` should be transposed, conjugate-transposed, or not transposed. +- **diag**: `[in] CBLAS_DIAG` specifies whether `A` has a unit diagonal. +- **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. +- **A**: `[inout] double*` input matrix. +- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A`. +- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **offsetA**: `[in] CBLAS_INT` starting index for `A`. +- **X**: `[in] double*` input vector. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. ```c -TODO +void c_dtrsv_ndarray( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *x, const CBLAS_INT strideX, const CBLAS_INT offsetX ) ```
@@ -223,7 +274,34 @@ TODO ### Examples ```c -TODO +#include "stdlib/blas/base/dtrsv.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Create a strided array: + const double A[] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; + double X[] = { 1.0, 2.0, 3.0 }; + + // Specify the number of elements along each dimension of `A`: + const int N = 3; + + // Perform the matrix-vector operations `A*X = b` for `lower` triangular matrix `A`: + c_dtrsv( CblasRowMajor, CblasLower, CblasNoTrans, CblasNonUnit, N, A, N, X, 1 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "X[ %i ] = %f\n", i, X[ i ] ); + } + + // Perform the matrix-vector operations `A*X = b` for `lower` triangular matrix `A`: + c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasNonUnit, N, A, N, 1, 0, X, 1, 0 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "X[ %i ] = %f\n", i, X[ i ] ); + } +} ```
diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.native.js new file mode 100644 index 000000000000..2546e98b633d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.native.js @@ -0,0 +1,111 @@ + +/** +* @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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var zeros = require( '@stdlib/array/zeros' ); +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 dtrsv = tryRequire( resolve( __dirname, './../lib/dtrsv.native.js' ) ); +var opts = { + 'skip': ( dtrsv 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 A = discreteUniform( N*N, -10.0, 10.0, options ); + var x = zeros( 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 = dtrsv( 'row-major', 'upper', 'transpose', 'non-unit', N, A, N, x, 1 ); + 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+':size='+(N*N), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..27ddcbc8fb63 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var zeros = require( '@stdlib/array/zeros' ); +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 dtrsv = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dtrsv 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 A = discreteUniform( N*N, -10.0, 10.0, options ); + var x = zeros( 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 = dtrsv( 'upper', 'transpose', 'non-unit', N, A, N, 1, 0, x, 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+':ndarray:size='+(N*N), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/Makefile new file mode 100644 index 000000000000..cce2c865d7ad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..40051ea1cd5b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c @@ -0,0 +1,179 @@ +/** +* @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/dtrsv.h" +#include "stdlib/blas/ext/base/dfill.h" +#include "stdlib/math/base/special/floorf.h" +#include +#include +#include +#include +#include + +#define NAME "dtrsv" +#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 len array length +* @return elapsed time in seconds +*/ +static double benchmark1( int iterations, int len ) { + double elapsed; + double A[ len*len ]; + double X[ len ]; + double t; + int i; + + stdlib_strided_dfill( len, 1.0, X, 1 ); + stdlib_strided_dfill( len*len, 1.0, A, 1 ); + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_dtrsv( CblasRowMajor, CblasLower, CblasNoTrans, CblasUnit, len, A, len, X, 1 ); + if ( X[ 0 ] != X[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( X[ 0 ] != X[ 0 ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int len ) { + double elapsed; + double A[ len*len ]; + double X[ len ]; + double t; + int i; + + stdlib_strided_dfill( len, 1.0, X, 1 ); + stdlib_strided_dfill( len*len, 1.0, A, 1 ); + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasUnit, len, A, len, 1, 0, X, 1, 0 ); + if ( X[ 0 ] != X[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( X[ 0 ] != X[ 0 ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int len; + int i; + int j; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + for ( i = MIN; i <= MAX; i++ ) { + len = stdlib_base_floorf( pow( pow( 10, i ), 1.0/2.0 ) ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:len=%d\n", NAME, len ); + elapsed = benchmark1( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:ndarray:len=%d\n", NAME, len ); + elapsed = benchmark2( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/binding.gyp b/lib/node_modules/@stdlib/blas/base/dtrsv/binding.gyp new file mode 100644 index 000000000000..08de71a2020e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/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/dtrsv/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/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/dtrsv/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c new file mode 100644 index 000000000000..b0827ed71cb6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c @@ -0,0 +1,46 @@ +/** +* @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/dtrsv.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Create a strided array: + const double A[] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; + double X[] = { 1.0, 2.0, 3.0 }; + + // Specify the number of elements along each dimension of `A`: + const int N = 3; + + // Perform the matrix-vector operations `A*X = b` for `lower` triangular matrix `A`: + c_dtrsv( CblasRowMajor, CblasLower, CblasNoTrans, CblasNonUnit, N, A, N, X, 1 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "X[ %i ] = %f\n", i, X[ i ] ); + } + + // Perform the matrix-vector operations `A*X = b` for `lower` triangular matrix `A`: + c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasNonUnit, N, A, N, 1, 0, X, 1, 0 ); + + // Print the result: + for ( int i = 0; i < N; i++ ) { + printf( "X[ %i ] = %f\n", i, X[ i ] ); + } +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/include.gypi b/lib/node_modules/@stdlib/blas/base/dtrsv/include.gypi new file mode 100644 index 000000000000..4217944b5d20 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/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 ] ); +* +* dtrsv( 'row-major', 'upper', 'no-transpose', 'unit', 3, A, 3, x, 1 ); +* // x => [ 0.0, -4.0, 3.0 ] +*/ +function dtrsv( order, uplo, trans, diag, N, A, LDA, x, strideX ) { + addon( resolveOrder( order ), resolveUplo( uplo ), resolveTrans( trans ), resolveDiag( diag ), N, A, LDA, x, strideX ); // eslint-disable-line max-len + return x; +} + + +// EXPORTS // + +module.exports = dtrsv; diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/lib/native.js b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/native.js new file mode 100644 index 000000000000..61b1015f0185 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/native.js @@ -0,0 +1,36 @@ + +/** +* @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 dtrsv = require( './dtrsv.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( dtrsv, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dtrsv; diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.native.js new file mode 100644 index 000000000000..3e5da6f792be --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.native.js @@ -0,0 +1,64 @@ +/** +* @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 resolveTrans = require( '@stdlib/blas/base/transpose-operation-resolve-enum' ); +var resolveDiag = require( '@stdlib/blas/base/diagonal-type-resolve-enum' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Solves one of the systems of equations `A*x = b` or `A^T*x = b` where `b` and `x` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. +* +* @param {string} uplo - specifies whether `A` is an upper or lower triangular matrix +* @param {string} trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param {string} diag - specifies whether `A` has a unit diagonal +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} x - input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @returns {Float64Array} `x` +* +* @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 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dtrsv( 'upper', 'no-transpose', 'unit', 3, A, 3, 1, 0, x, 1, 0 ); +* // x => [ 0.0, -4.0, 3.0 ] +*/ +function dtrsv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-params, max-len + addon.ndarray( resolveUplo( uplo ), resolveTrans( trans ), resolveDiag( diag ), N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ); // eslint-disable-line max-len + return x; +} + + +// EXPORTS // + +module.exports = dtrsv; diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json b/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json new file mode 100644 index 000000000000..b6ecf25668a2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json @@ -0,0 +1,484 @@ +{ + "options": { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dtrsv.c", + "./src/dtrsv_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-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dtrsv.c", + "./src/dtrsv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/math/base/special/floorf", + "@stdlib/blas/ext/base/dfill" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dtrsv.c", + "./src/dtrsv_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/dtrsv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "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-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dtrsv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/ext/base/dfill", + "@stdlib/math/base/special/floorf", + "@stdlib/blas/ext/base/dfill" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dtrsv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@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/dtrsv.c", + "./src/dtrsv_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-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/dtrsv.c", + "./src/dtrsv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/math/base/special/floorf", + "@stdlib/blas/ext/base/dfill" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/dtrsv.c", + "./src/dtrsv_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": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/dtrsv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "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-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/dtrsv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/ext/base/dfill", + "@stdlib/math/base/special/floorf", + "@stdlib/blas/ext/base/dfill" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/dtrsv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dtrsv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "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-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dtrsv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index", + "@stdlib/blas/ext/base/dfill", + "@stdlib/math/base/special/floorf", + "@stdlib/blas/ext/base/dfill" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/dtrsv_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/ndarray/base/min-view-buffer-index" + ] + }, + + { + "task": "build", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/dtrsv.c", + "./src/dtrsv_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-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/dtrsv.c", + "./src/dtrsv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/math/base/special/floorf", + "@stdlib/blas/ext/base/dfill" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/dtrsv.c", + "./src/dtrsv_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": "", + "blas": "", + "wasm": true, + "src": [ + "./src/dtrsv.c", + "./src/dtrsv_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/ndarray/base/assert/is-row-major" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/package.json b/lib/node_modules/@stdlib/blas/base/dtrsv/package.json index b3c34038220e..dd03402deb58 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/package.json +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/package.json @@ -14,11 +14,15 @@ } ], "main": "./lib", + "browser": "./lib/main.js", + "gypfile": true, "directories": { "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", + "include": "./include", "lib": "./lib", + "src": "./src", "test": "./test" }, "types": "./docs/types", diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/Makefile b/lib/node_modules/@stdlib/blas/base/dtrsv/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/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/dtrsv/src/addon.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c new file mode 100644 index 000000000000..104b6121c75a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c @@ -0,0 +1,96 @@ +/** +* @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/strsv.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_strided_float64array.h" +#include "stdlib/napi/argv_strided_float64array2d.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 9 ); + + STDLIB_NAPI_ARGV_INT32( env, order, argv, 0 ); + STDLIB_NAPI_ARGV_INT32( env, uplo, argv, 1 ); + STDLIB_NAPI_ARGV_INT32( env, trans, argv, 2 ); + STDLIB_NAPI_ARGV_INT32( env, diag, argv, 3 ); + + STDLIB_NAPI_ARGV_INT64( env, N, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 8 ); + STDLIB_NAPI_ARGV_INT64( env, LDA, argv, 6 ); + + CBLAS_INT sa1; + CBLAS_INT sa2; + + if ( order == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + } else { // order == 'row-major' + sa1 = LDA; + sa2 = 1; + } + + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 7 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, N, N, sa1, sa2, argv, 5 ); + + API_SUFFIX(c_strsv)( order, uplo, trans, diag, N, A, LDA, X, strideX ); + + return NULL; +} + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 11 ); + + STDLIB_NAPI_ARGV_INT32( env, uplo, argv, 0 ); + STDLIB_NAPI_ARGV_INT32( env, trans, argv, 1 ); + STDLIB_NAPI_ARGV_INT32( env, diag, argv, 2 ); + + STDLIB_NAPI_ARGV_INT64( env, N, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 9 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 10 ); + STDLIB_NAPI_ARGV_INT64( env, strideA1, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, strideA2, argv, 6 ); + STDLIB_NAPI_ARGV_INT64( env, offsetA, argv, 7 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 8 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, N, N, strideA1, strideA2, argv, 4 ); + + API_SUFFIX(c_strsv_ndarray)( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, X, strideX, offsetX ); + + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c new file mode 100644 index 000000000000..35b407c085a6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c @@ -0,0 +1,52 @@ +/** +* @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/dtrsv.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" + +/** +* Solves one of the systems of equations `A*X = b` or `A^T*X = b` where `b` and `X` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. +* +* @param order storage layout +* @param uplo specifies whether `A` is an upper or lower triangular matrix +* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param diag specifies whether `A` has a unit diagonal +* @param N number of elements along each dimension of `A` +* @param A input matrix +* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param X input vector +* @param strideX `X` stride length +* @return output value +*/ +void API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *X, const CBLAS_INT strideX ) { + CBLAS_INT sa1; + CBLAS_INT sa2; + CBLAS_INT ox; + + if ( order == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + } else { // order == 'row-major' + sa1 = LDA; + sa2 = 1; + } + ox = stdlib_strided_stride2offset( N, strideX ); + API_SUFFIX(c_dtrsv_ndarray)( uplo, trans, diag, N, A, sa1, sa2, 0, X, strideX, ox ); + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c new file mode 100644 index 000000000000..4cf83056e65e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c @@ -0,0 +1,74 @@ + +/** +* @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/dtrsv.h" +#include "stdlib/blas/base/dtrsv_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" + +/** +* Solves one of the systems of equations `A*X = b` or `A^T*X = b` where `b` and `X` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. +* +* @param order storage layout +* @param uplo specifies whether `A` is an upper or lower triangular matrix +* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param diag specifies whether `A` has a unit diagonal +* @param N number of elements along each dimension of `A` +* @param A input matrix +* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param X input vector +* @param strideX `X` stride length +* @return output value +*/ +double API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *X, const CBLAS_INT strideX ) { + CBLAS_INT sx = strideX; + if ( sx < 0 ) { + sx = -sx; + } + return API_SUFFIX(cblas_dtrsv)( order, uplo, trans, diag, N, A, LDA, X, sx ); +} + +/** +* Solves one of the systems of equations `A*X = b` or `A^T*X = b` using alternative indexing semantics, where `b` and `X` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. +* +* @param uplo specifies whether `A` is an upper or lower triangular matrix +* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param diag specifies whether `A` has a unit diagonal +* @param N number of elements along each dimension of `A` +* @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` +* @param X input vector +* @param strideX `X` stride length +* @param offsetX starting index for `X` +* @return output value +*/ +double API_SUFFIX(c_dtrsv_ndarray)( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + CBLAS_INT sx = strideX; + if ( sx < 0 ) { + sx = -sx; + } + X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // 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 + return API_SUFFIX(cblas_dtrsv)( order, uplo, trans, diag, N, A, LDA, X, sx ); +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c new file mode 100644 index 000000000000..d534749fd4e9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c @@ -0,0 +1,152 @@ +/** +* @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/dtrsv.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/ndarray/base/assert/is_row_major.h" + +/** +* Solves one of the systems of equations `A*X = b` or `A^T*X = b` using alternative indexing semantics, where `b` and `X` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. +* +* @param uplo specifies whether `A` is an upper or lower triangular matrix +* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param diag specifies whether `A` has a unit diagonal +* @param N number of elements along each dimension of `A` +* @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` +* @param X input vector +* @param strideX `X` stride length +* @param offsetX starting index for `X` +* @return output value +*/ +void API_SUFFIX(c_dtrsv_ndarray)( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + CBLAS_INT nonunit; + CBLAS_INT isrm; + CBLAS_INT ix1; + CBLAS_INT ix0; + CBLAS_INT sa0; + CBLAS_INT sa1; + CBLAS_INT i0; + CBLAS_INT i1; + CBLAS_INT oa; + CBLAS_INT ox; + double tmp; + + // Note on variable naming convention: sa#, ix#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + int64_t strides[] = { strideA1, strideA2 }; + isrm = stdlib_ndarray_is_row_major( 2, strides ); + nonunit = ( diag == CblasNonUnit ); + + 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; + + if ( + ( !isrm && trans == CblasNoTrans && uplo == CblasUpper ) || + ( isrm && trans != CblasNoTrans && uplo == CblasLower ) + ) { + ix1 = ox + ( ( N - 1 ) * strideX ); + for ( i1 = N-1; i1 >= 0; i1-- ) { + if ( X[ ix1 ] != 0.0 ) { + oa = offsetA + (sa1*i1); + if ( nonunit ) { + X[ ix1 ] /= A[ oa+(sa0*i1) ]; + } + tmp = X[ ix1 ]; + ix0 = ix1; + for ( i0 = i1-1; i0 >= 0; i0-- ) { + ix0 -= strideX; + X[ ix0 ] -= tmp * A[ oa+(sa0*i0) ]; + } + } + ix1 -= strideX; + } + return; + } + if ( + ( !isrm && trans == CblasNoTrans && uplo == CblasLower ) || + ( isrm && trans != CblasNoTrans && uplo == CblasUpper ) + ) { + ix1 = ox; + for ( i1 = 0; i1 < N; i1++ ) { + if ( X[ ix1 ] != 0.0 ) { + oa = offsetA + (sa1*i1); + if ( nonunit ) { + X[ ix1 ] /= A[ oa+(sa0*i1) ]; + } + tmp = X[ ix1 ]; + ix0 = ix1; + for ( i0 = i1+1; i0 < N; i0++ ) { + ix0 += strideX; + X[ ix0 ] -= tmp * A[ oa+(sa0*i0) ]; + } + } + ix1 += strideX; + } + return; + } + if ( + ( !isrm && trans != CblasNoTrans && uplo == CblasUpper ) || + ( isrm && trans == CblasNoTrans && uplo == CblasLower ) + ) { + ix1 = ox; + for ( i1 = 0; i1 < N; i1++ ) { + tmp = X[ ix1 ]; + oa = offsetA + (sa1*i1); + ix0 = ox; + for ( i0 = 0; i0 <= i1-1; i0++ ) { + tmp -= X[ ix0 ] * A[ oa+(sa0*i0) ]; + ix0 += strideX; + } + if ( nonunit ) { + tmp /= A[ oa+(sa0*i1) ]; + } + X[ ix1 ] = tmp; + ix1 += strideX; + } + return; + } + // ( !isrm && trans != CblasNoTrans && uplo == CblasLower ) || ( isrm && trans == CblasNoTrans && uplo == CblasUpper ) + ox += ( N - 1 ) * strideX; + ix1 = ox; + for ( i1 = N-1; i1 >= 0; i1-- ) { + tmp = X[ ix1 ]; + oa = offsetA + (sa1*i1); + ix0 = ox; + for ( i0 = N-1; i0 > i1; i0-- ) { + tmp -= X[ ix0 ] * A[ oa+(sa0*i0) ]; + ix0 -= strideX; + } + if ( nonunit ) { + tmp /= A[ oa+(sa0*i1) ]; + } + X[ ix1 ] = tmp; + ix1 -= strideX; + } + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.dtrsv.native.js b/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.dtrsv.native.js new file mode 100644 index 000000000000..52a4a1c65bc6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.dtrsv.native.js @@ -0,0 +1,554 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// FIXTURES // + +var rlntnu = require( './fixtures/row_major_l_nt_nu.json' ); +var rltnu = require( './fixtures/row_major_l_t_nu.json' ); +var rlntu = require( './fixtures/row_major_l_nt_u.json' ); +var rltu = require( './fixtures/row_major_l_t_u.json' ); +var runtnu = require( './fixtures/row_major_u_nt_nu.json' ); +var runtu = require( './fixtures/row_major_u_nt_u.json' ); +var rutnu = require( './fixtures/row_major_u_t_nu.json' ); +var rutu = require( './fixtures/row_major_u_t_u.json' ); +var rxt = require( './fixtures/row_major_xt.json' ); +var rxn = require( './fixtures/row_major_xn.json' ); + +var clntnu = require( './fixtures/column_major_l_nt_nu.json' ); +var cltnu = require( './fixtures/column_major_l_t_nu.json' ); +var clntu = require( './fixtures/column_major_l_nt_u.json' ); +var cltu = require( './fixtures/column_major_l_t_u.json' ); +var cuntnu = require( './fixtures/column_major_u_nt_nu.json' ); +var cuntu = require( './fixtures/column_major_u_nt_u.json' ); +var cutnu = require( './fixtures/column_major_u_t_nu.json' ); +var cutu = require( './fixtures/column_major_u_t_u.json' ); +var cxt = require( './fixtures/column_major_xt.json' ); +var cxn = require( './fixtures/column_major_xn.json' ); + + +// VARIABLES // + +var dtrsv = tryRequire( resolve( __dirname, './../lib/dtrsv.native.js' ) ); +var opts = { + 'skip': ( dtrsv instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dtrsv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', opts, function test( t ) { + t.strictEqual( dtrsv.length, 9, 'returns expected value' ); + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, lower, no transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rlntnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, lower, no transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = clntnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, lower, transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rltnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, lower, transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cltnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, lower, no transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rlntu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, lower, no transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = clntu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, lower, transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rltu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, lower, transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cltu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, upper, no transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = runtnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, upper, no transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cuntnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, upper, no transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = runtu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, upper, no transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cuntu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, upper, transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rutnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, upper, transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cutnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, upper, transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, upper, transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` stride (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rxt; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` stride (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cxt; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the input vector', opts, function test( t ) { + var data; + var out; + var a; + var x; + + data = rutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero, the function returns the input vector unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, 0, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero, the function returns the input vector unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, 0, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rxn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cxn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.ndarray.native.js new file mode 100644 index 000000000000..8a93c3ee05a5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.ndarray.native.js @@ -0,0 +1,818 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// FIXTURES // + +var rlntnu = require( './fixtures/row_major_l_nt_nu.json' ); +var rltnu = require( './fixtures/row_major_l_t_nu.json' ); +var rlntu = require( './fixtures/row_major_l_nt_u.json' ); +var rltu = require( './fixtures/row_major_l_t_u.json' ); +var runtnu = require( './fixtures/row_major_u_nt_nu.json' ); +var runtu = require( './fixtures/row_major_u_nt_u.json' ); +var rutnu = require( './fixtures/row_major_u_t_nu.json' ); +var rutu = require( './fixtures/row_major_u_t_u.json' ); +var rxt = require( './fixtures/row_major_xt.json' ); +var rxn = require( './fixtures/row_major_xn.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 clntnu = require( './fixtures/column_major_l_nt_nu.json' ); +var cltnu = require( './fixtures/column_major_l_t_nu.json' ); +var clntu = require( './fixtures/column_major_l_nt_u.json' ); +var cltu = require( './fixtures/column_major_l_t_u.json' ); +var cuntnu = require( './fixtures/column_major_u_nt_nu.json' ); +var cuntu = require( './fixtures/column_major_u_nt_u.json' ); +var cutnu = require( './fixtures/column_major_u_t_nu.json' ); +var cutu = require( './fixtures/column_major_u_t_u.json' ); +var cxt = require( './fixtures/column_major_xt.json' ); +var cxn = require( './fixtures/column_major_xn.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_sa1_sa2n.json' ); +var ccap = require( './fixtures/column_major_complex_access_pattern.json' ); + + +// VARIABLES // + +var dtrsv = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dtrsv instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dtrsv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', opts, function test( t ) { + t.strictEqual( dtrsv.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, lower, no transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rlntnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, lower, no transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = clntnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, lower, transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rltnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, lower, transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cltnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, lower, no transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rlntu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, lower, no transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = clntu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, lower, transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rltu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, lower, transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cltu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, upper, no transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = runtnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, upper, no transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cuntnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, upper, no transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = runtu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, upper, no transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cuntu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, upper, transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rutnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, upper, transpose, non-unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cutnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, upper, transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (column-major, upper, transpose, unit)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` stride (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rxt; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` stride (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cxt; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the input vector', opts, function test( t ) { + var data; + var out; + var a; + var x; + + data = rutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero, the function returns the input vector unchanged (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x ); + + out = dtrsv( data.uplo, data.trans, data.diag, 0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero, the function returns the input vector unchanged (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x ); + + out = dtrsv( data.uplo, data.trans, data.diag, 0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the strides of the first and second dimensions of `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rsa1sa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the strides of the first and second dimensions of `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = csa1sa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative stride for the first dimension of `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rsa1nsa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative stride for the first dimension of `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = csa1nsa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative stride for the second dimension of `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rsa1sa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative stride for the second dimension of `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = csa1sa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides for `A` (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rsa1nsa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative strides for `A` (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = csa1nsa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `A` offset (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = roa; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `A` offset (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = coa; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (row-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rxn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (column-major)', opts, function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cxn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, '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; + + data = rcap; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, '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; + + data = ccap; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrsv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); From f611329aad161a388d43f18ed5075aac6520f709 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 1 Jun 2025 21:08:58 +0530 Subject: [PATCH 02/21] chore: minor clean-up --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: 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/dtrsv/src/addon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c index 104b6121c75a..106455fa7910 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c @@ -16,7 +16,7 @@ * limitations under the License. */ -#include "stdlib/blas/base/strsv.h" +#include "stdlib/blas/base/dtrsv.h" #include "stdlib/blas/base/shared.h" #include "stdlib/napi/export.h" #include "stdlib/napi/argv.h" @@ -59,7 +59,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 7 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, N, N, sa1, sa2, argv, 5 ); - API_SUFFIX(c_strsv)( order, uplo, trans, diag, N, A, LDA, X, strideX ); + API_SUFFIX(c_dtrsv)( order, uplo, trans, diag, N, A, LDA, X, strideX ); return NULL; } @@ -88,7 +88,7 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 8 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, N, N, strideA1, strideA2, argv, 4 ); - API_SUFFIX(c_strsv_ndarray)( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, X, strideX, offsetX ); + API_SUFFIX(c_dtrsv_ndarray)( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, X, strideX, offsetX ); return NULL; } From 7bb0e4c28d11b35ec17b528113fba686085157ea Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 29 Jun 2025 17:47:00 +0530 Subject: [PATCH 03/21] chore: update implementation --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: 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 --- --- .../base/dtrsv/benchmark/benchmark.native.js | 2 +- .../benchmark/benchmark.ndarray.native.js | 2 +- .../base/dtrsv/benchmark/c/benchmark.length.c | 34 ++++++++++++++----- .../blas/base/dtrsv/examples/c/example.c | 11 ++++-- .../dtrsv/include/stdlib/blas/base/dtrsv.h | 2 +- .../@stdlib/blas/base/dtrsv/src/addon.c | 8 ++--- .../@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c | 2 +- .../blas/base/dtrsv/src/dtrsv_ndarray.c | 27 ++++++++++++--- 8 files changed, 65 insertions(+), 23 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.native.js index 2546e98b633d..a1ee3ff060b7 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.native.js @@ -104,7 +104,7 @@ function main() { for ( i = min; i <= max; i++ ) { N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); f = createBenchmark( N ); - bench( pkg+':size='+(N*N), opts, f ); + bench( pkg+'::native:size='+(N*N), opts, f ); } } diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.ndarray.native.js index 27ddcbc8fb63..c8823b74465e 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/benchmark.ndarray.native.js @@ -103,7 +103,7 @@ function main() { for ( i = min; i <= max; i++ ) { N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); f = createBenchmark( N ); - bench( pkg+':ndarray:size='+(N*N), opts, f ); + bench( pkg+'::native:ndarray:size='+(N*N), opts, f ); } } diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c index 40051ea1cd5b..b6ebe6d475dc 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c @@ -79,6 +79,16 @@ static double tic( void ) { return (double)now.tv_sec + (double)now.tv_usec/1.0e6; } +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + /** * Runs a benchmark. * @@ -92,19 +102,23 @@ static double benchmark1( int iterations, int len ) { double X[ len ]; double t; int i; + int j; - stdlib_strided_dfill( len, 1.0, X, 1 ); - stdlib_strided_dfill( len*len, 1.0, A, 1 ); + for ( i = 0, j = 0; i < N; i++, j += 2 ) { + X[ i ] = ( rand_double()*20.0 ) - 10.0; + A[ j ] = ( rand_double()*20.0 ) - 10.0; + A[ j+1 ] = ( rand_double()*20.0 ) - 10.0; + } t = tic(); for ( i = 0; i < iterations; i++ ) { c_dtrsv( CblasRowMajor, CblasLower, CblasNoTrans, CblasUnit, len, A, len, X, 1 ); - if ( X[ 0 ] != X[ 0 ] ) { + if ( X[ i%len ] != X[ i%len ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( X[ 0 ] != X[ 0 ] ) { + if ( X[ i%len ] != X[ i%len ] ) { printf( "should not return NaN\n" ); } return elapsed; @@ -123,19 +137,23 @@ static double benchmark2( int iterations, int len ) { double X[ len ]; double t; int i; + int j; - stdlib_strided_dfill( len, 1.0, X, 1 ); - stdlib_strided_dfill( len*len, 1.0, A, 1 ); + for ( i = 0, j = 0; i < N; i++, j += 2 ) { + X[ i ] = ( rand_double()*20.0 ) - 10.0; + A[ j ] = ( rand_double()*20.0 ) - 10.0; + A[ j+1 ] = ( rand_double()*20.0 ) - 10.0; + } t = tic(); for ( i = 0; i < iterations; i++ ) { c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasUnit, len, A, len, 1, 0, X, 1, 0 ); - if ( X[ 0 ] != X[ 0 ] ) { + if ( X[ i%len ] != X[ i%len ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( X[ 0 ] != X[ 0 ] ) { + if ( X[ i%len ] != X[ i%len ] ) { printf( "should not return NaN\n" ); } return elapsed; diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c index b0827ed71cb6..1b968d44db1b 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c @@ -21,8 +21,13 @@ #include int main( void ) { - // Create a strided array: - const double A[] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; + // Define a 3x3 matrix stored in row-major order: + const double A[] = { + 1.0, 0.0, 0.0, + 2.0, 1.0, 0.0, + 3.0, 2.0, 1.0 + }; + // Define `x` vector: double X[] = { 1.0, 2.0, 3.0 }; // Specify the number of elements along each dimension of `A`: @@ -36,7 +41,7 @@ int main( void ) { printf( "X[ %i ] = %f\n", i, X[ i ] ); } - // Perform the matrix-vector operations `A*X = b` for `lower` triangular matrix `A`: + // Perform the matrix-vector operations `A*X = b` for `lower` triangular matrix `A` using alternative indexing semantics: c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasNonUnit, N, A, N, 1, 0, X, 1, 0 ); // Print the result: diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/include/stdlib/blas/base/dtrsv.h b/lib/node_modules/@stdlib/blas/base/dtrsv/include/stdlib/blas/base/dtrsv.h index 637fa6f3a71d..462dba92b6a9 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/include/stdlib/blas/base/dtrsv.h +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/include/stdlib/blas/base/dtrsv.h @@ -37,7 +37,7 @@ extern "C" { void API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *X, const CBLAS_INT strideX ); /** -* Solves one of the systems of equations `A*x = b` or `A^T*x = b` using alternative indexing semantics, where `b` and `x` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. +* Solves one of the systems of equations `A*x = b` or `A^T*x = b`, using alternative indexing semantics and where `b` and `x` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. */ void API_SUFFIX(c_dtrsv_ndarray)( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c index 106455fa7910..9588cfd1abff 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c @@ -34,6 +34,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, 9 ); STDLIB_NAPI_ARGV_INT32( env, order, argv, 0 ); @@ -45,13 +48,10 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 8 ); STDLIB_NAPI_ARGV_INT64( env, LDA, argv, 6 ); - CBLAS_INT sa1; - CBLAS_INT sa2; - 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/dtrsv/src/dtrsv_cblas.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c index 4cf83056e65e..76c123a73364 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c @@ -46,7 +46,7 @@ double API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, con } /** -* Solves one of the systems of equations `A*X = b` or `A^T*X = b` using alternative indexing semantics, where `b` and `X` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. +* Solves one of the systems of equations `A*X = b` or `A^T*X = b`, using alternative indexing semantics and where `b` and `X` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. * * @param uplo specifies whether `A` is an upper or lower triangular matrix * @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c index d534749fd4e9..15445ecf3e07 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c @@ -21,7 +21,7 @@ #include "stdlib/ndarray/base/assert/is_row_major.h" /** -* Solves one of the systems of equations `A*X = b` or `A^T*X = b` using alternative indexing semantics, where `b` and `X` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. +* Solves one of the systems of equations `A*X = b` or `A^T*X = b`, using alternative indexing semantics and where `b` and `X` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. * * @param uplo specifies whether `A` is an upper or lower triangular matrix * @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed @@ -38,6 +38,7 @@ */ void API_SUFFIX(c_dtrsv_ndarray)( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { CBLAS_INT nonunit; + int64_t sa[ 2 ]; CBLAS_INT isrm; CBLAS_INT ix1; CBLAS_INT ix0; @@ -51,10 +52,28 @@ void API_SUFFIX(c_dtrsv_ndarray)( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE t // Note on variable naming convention: sa#, ix#, i# where # corresponds to the loop number, with `0` being the innermost loop... - int64_t strides[] = { strideA1, strideA2 }; - isrm = stdlib_ndarray_is_row_major( 2, strides ); + // Perform input argument validation... + if ( M < 0 ) { + c_xerbla( 1, "c_dger_ndarray", "Error: invalid argument. First argument must be a nonnegative integer. Value: `%d`.", M ); + return; + } + if ( N < 0 ) { + c_xerbla( 2, "c_dger_ndarray", "Error: invalid argument. Second argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 5, "c_dger_ndarray", "Error: invalid argument. Fifth argument must be a nonzero. Value: `%d`.", strideX ); + return; + } + if ( strideY == 0 ) { + c_xerbla( 8, "c_dger_ndarray", "Error: invalid argument. Eighth argument must be a nonzero. Value: `%d`.", strideY ); + return; + } nonunit = ( diag == CblasNonUnit ); - + // 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 73d1ae63535c2567e42b9ee77c847cf00264ca84 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Sun, 29 Jun 2025 23:59:03 +0530 Subject: [PATCH 04/21] chore: clean-up --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: 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/dtrsv/README.md | 46 +++-- .../base/dtrsv/benchmark/c/benchmark.length.c | 41 ++-- .../@stdlib/blas/base/dtrsv/docs/repl.txt | 18 +- .../blas/base/dtrsv/examples/c/example.c | 4 +- .../dtrsv/include/stdlib/blas/base/dtrsv.h | 2 +- .../include/stdlib/blas/base/dtrsv_cblas.h | 2 +- .../@stdlib/blas/base/dtrsv/lib/dtrsv.js | 7 +- .../blas/base/dtrsv/lib/dtrsv.native.js | 38 ++++ .../@stdlib/blas/base/dtrsv/lib/ndarray.js | 5 +- .../blas/base/dtrsv/lib/ndarray.native.js | 36 ++++ .../@stdlib/blas/base/dtrsv/manifest.json | 72 ++++--- .../@stdlib/blas/base/dtrsv/src/addon.c | 9 +- .../@stdlib/blas/base/dtrsv/src/dtrsv.c | 44 ++++- .../@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c | 40 +--- .../blas/base/dtrsv/src/dtrsv_ndarray.c | 29 ++- .../blas/base/dtrsv/test/test.dtrsv.native.js | 180 ++++++++++++++++++ .../base/dtrsv/test/test.ndarray.native.js | 172 +++++++++++++++++ 17 files changed, 612 insertions(+), 133 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/README.md b/lib/node_modules/@stdlib/blas/base/dtrsv/README.md index 2dd242edbfec..5dc35e073538 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/README.md +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/README.md @@ -194,15 +194,15 @@ console.log( x ); #include "stdlib/blas/base/dtrsv.h" ``` -#### c_dtrsv( order, uplo, trans, diag, N, \*A, LDA, \*X, strideX ) +#### c_dtrsv( order, uplo, trans, diag, N, \*A, LDA, \*X, sx ) Solves one of the systems of equations `A*x = b` or `A^T*x = b` where `b` and `x` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. ```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 A[] = { 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 }; +double x[] = { 1.0, 2.0, 3.0 }; c_dtrsv( CblasRowMajor, CblasUpper, CblasNoTrans, CblasUnit, 3, A, 3, x, 1 ); ``` @@ -214,25 +214,24 @@ The function accepts the following arguments: - **trans**: `[in] CBLAS_TRANSPOSE` specifies whether `A` should be transposed, conjugate-transposed, or not transposed. - **diag**: `[in] CBLAS_DIAG` specifies whether `A` has a unit diagonal. - **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. -- **A**: `[inout] double*` input matrix. +- **A**: `[in] double*` input matrix. - **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). -- **X**: `[in] double*` input vector. -- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **X**: `[inout] double*` input vector. +- **sx**: `[in] CBLAS_INT` stride length for `X`. ```c void c_dtrsv( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *x, const CBLAS_INT strideX ) ``` - -#### c_dtrsv_ndarray( uplo, trans, diag, N, \*A, strideA1, strideA2, offsetA, \*X, strideX, offsetA ) +#### c_dtrsv_ndarray( uplo, trans, diag, N, \*A, sa1, sa2, oa, \*X, sx, oa ) Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` using alternative indexing semantics, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. ```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 A[] = { 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 }; +double x[] = { 1.0, 2.0, 3.0 }; c_dtrsv_ndarray( CblasUpper, CblasNoTrans, CblasUnit, 3, A, 3, 1, 0, x, 1, 0 ); ``` @@ -243,13 +242,13 @@ The function accepts the following arguments: - **trans**: `[in] CBLAS_TRANSPOSE` specifies whether `A` should be transposed, conjugate-transposed, or not transposed. - **diag**: `[in] CBLAS_DIAG` specifies whether `A` has a unit diagonal. - **N**: `[in] CBLAS_INT` number of elements along each dimension of `A`. -- **A**: `[inout] double*` input matrix. -- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A`. -- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A`. -- **offsetA**: `[in] CBLAS_INT` starting index for `A`. -- **X**: `[in] double*` input vector. -- **strideX**: `[in] CBLAS_INT` index increment for `X`. -- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **A**: `[in] double*` input matrix. +- **sa1**: `[in] CBLAS_INT` stride of the first dimension of `A`. +- **sa2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **oa**: `[in] CBLAS_INT` starting index for `A`. +- **X**: `[inout] double*` input vector. +- **sx**: `[in] CBLAS_INT` stride length for `X`. +- **ox**: `[in] CBLAS_INT` starting index for `X`. ```c void c_dtrsv_ndarray( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *x, const CBLAS_INT strideX, const CBLAS_INT offsetX ) @@ -279,9 +278,14 @@ void c_dtrsv_ndarray( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const #include int main( void ) { - // Create a strided array: - const double A[] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; - double X[] = { 1.0, 2.0, 3.0 }; + // Define a 3x3 matrix stored in row-major order: + const double A[ 3*3 ] = { + 1.0, 0.0, 0.0, + 2.0, 1.0, 0.0, + 3.0, 2.0, 1.0 + }; + // Define `x` vector: + double X[ 3 ] = { 1.0, 2.0, 3.0 }; // Specify the number of elements along each dimension of `A`: const int N = 3; @@ -294,7 +298,7 @@ int main( void ) { printf( "X[ %i ] = %f\n", i, X[ i ] ); } - // Perform the matrix-vector operations `A*X = b` for `lower` triangular matrix `A`: + // Perform the matrix-vector operations `A*X = b` for `lower` triangular matrix `A` using alternative indexing semantics: c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasNonUnit, N, A, N, 1, 0, X, 1, 0 ); // Print the result: diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c index b6ebe6d475dc..84e48cd92cb6 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c @@ -18,7 +18,6 @@ #include "stdlib/blas/base/dtrsv.h" #include "stdlib/blas/ext/base/dfill.h" -#include "stdlib/math/base/special/floorf.h" #include #include #include @@ -93,13 +92,13 @@ static double rand_double( void ) { * Runs a benchmark. * * @param iterations number of iterations -* @param len array length +* @param N array dimension size * @return elapsed time in seconds */ -static double benchmark1( int iterations, int len ) { +static double benchmark1( int iterations, int N ) { double elapsed; - double A[ len*len ]; - double X[ len ]; + double A[ N*N ]; + double X[ N ]; double t; int i; int j; @@ -111,14 +110,14 @@ static double benchmark1( int iterations, int len ) { } t = tic(); for ( i = 0; i < iterations; i++ ) { - c_dtrsv( CblasRowMajor, CblasLower, CblasNoTrans, CblasUnit, len, A, len, X, 1 ); - if ( X[ i%len ] != X[ i%len ] ) { + c_dtrsv( CblasRowMajor, CblasLower, CblasNoTrans, CblasUnit, N, A, N, X, 1 ); + if ( X[ i%N ] != X[ i%N ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( X[ i%len ] != X[ i%len ] ) { + if ( X[ i%N ] != X[ i%N ] ) { printf( "should not return NaN\n" ); } return elapsed; @@ -128,13 +127,13 @@ static double benchmark1( int iterations, int len ) { * Runs a benchmark. * * @param iterations number of iterations -* @param len array length +* @param N array dimensions 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 A[ N*N ]; + double X[ N ]; double t; int i; int j; @@ -146,14 +145,14 @@ static double benchmark2( int iterations, int len ) { } t = tic(); for ( i = 0; i < iterations; i++ ) { - c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasUnit, len, A, len, 1, 0, X, 1, 0 ); - if ( X[ i%len ] != X[ i%len ] ) { + c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasUnit, N, A, N, 1, 0, X, 1, 0 ); + if ( X[ i%N ] != X[ i%N ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( X[ i%len ] != X[ i%len ] ) { + if ( X[ i%N ] != X[ i%N ] ) { printf( "should not return NaN\n" ); } return elapsed; @@ -166,7 +165,7 @@ int main( void ) { double elapsed; int count; int iter; - int len; + int N; int i; int j; @@ -176,19 +175,19 @@ int main( void ) { print_version(); count = 0; for ( i = MIN; i <= MAX; i++ ) { - len = stdlib_base_floorf( pow( pow( 10, i ), 1.0/2.0 ) ); + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); iter = ITERATIONS / pow( 10, i-1 ); for ( j = 0; j < REPEATS; j++ ) { count += 1; - printf( "# c::%s:len=%d\n", NAME, len ); - elapsed = benchmark1( iter, len ); + printf( "# c::%s:size=%d\n", NAME, N*N ); + elapsed = benchmark1( iter, N ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } for ( j = 0; j < REPEATS; j++ ) { count += 1; - printf( "# c::%s:ndarray:len=%d\n", NAME, len ); - elapsed = benchmark2( iter, len ); + printf( "# c::%s:ndarray:size=%d\n", NAME, N*N ); + elapsed = benchmark2( iter, N ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dtrsv/docs/repl.txt index 7358ba7b1025..8c1c47e801ed 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( ord, uplo, trans, diag, N, A, lda, x, sx ) +{{alias}}( order, uplo, trans, diag, N, A, lda, x, sx ) Solves one of the systems of equations `A*x = b` or `A^T*x = b` where `b` and `x` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. @@ -11,7 +11,7 @@ Parameters ---------- - ord: string + order: string Row-major (C-style) or column-major (Fortran-style) order. Must be either 'row-major' or 'column-major'. @@ -48,11 +48,25 @@ Examples -------- + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 1.0 ] ); > {{alias}}( 'row-major', 'upper', 'no-transpose', 'unit', 2, A, 2, x, 1 ) [ -1.0, 1.0 ] + // Advanced indexing: + > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 1.0 ] ); + > {{alias}}( 'row-major', 'upper', 'no-transpose', 'unit', 2, A, 2, x, -1 ) + [ 1.0, -1.0 ] + + // Using typed array views: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 1.0 ] ); + > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 1.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( 'row-major', 'upper', 'no-transpose', 'unit', 2, A, 2, x1, 1 ) + [ -1.0, 1.0 ] + {{alias}}.ndarray( uplo, trans, diag, N, A, sa1, sa2, oa, x, sx, ox ) Solves one of the systems of equations `A*x = b` or `A^T*x = b`, using diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c index 1b968d44db1b..98e7622c17db 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c @@ -22,13 +22,13 @@ int main( void ) { // Define a 3x3 matrix stored in row-major order: - const double A[] = { + const double A[ 3*3 ] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; // Define `x` vector: - double X[] = { 1.0, 2.0, 3.0 }; + double X[ 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/dtrsv/include/stdlib/blas/base/dtrsv.h b/lib/node_modules/@stdlib/blas/base/dtrsv/include/stdlib/blas/base/dtrsv.h index 462dba92b6a9..944c50c18553 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/include/stdlib/blas/base/dtrsv.h +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/include/stdlib/blas/base/dtrsv.h @@ -34,7 +34,7 @@ extern "C" { /** * Solves one of the systems of equations `A*x = b` or `A^T*x = b` where `b` and `x` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. */ -void API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *X, const CBLAS_INT strideX ); +void API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *X, const CBLAS_INT strideX ); /** * Solves one of the systems of equations `A*x = b` or `A^T*x = b`, using alternative indexing semantics and where `b` and `x` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/include/stdlib/blas/base/dtrsv_cblas.h b/lib/node_modules/@stdlib/blas/base/dtrsv/include/stdlib/blas/base/dtrsv_cblas.h index 67f31cab1385..50797f3a4515 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/include/stdlib/blas/base/dtrsv_cblas.h +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/include/stdlib/blas/base/dtrsv_cblas.h @@ -35,7 +35,7 @@ extern "C" { /** * Solves one of the systems of equations `A*x = b` or `A^T*x = b` where `b` and `x` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. */ -void API_SUFFIX(cblas_dtrsv)( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +void API_SUFFIX(cblas_dtrsv)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/lib/dtrsv.js b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/dtrsv.js index b6998b8e6f8c..62a15180cc29 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/lib/dtrsv.js +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/dtrsv.js @@ -20,13 +20,13 @@ // 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 isTransposeOperation = require( '@stdlib/blas/base/assert/is-transpose-operation' ); var isDiagonal = require( '@stdlib/blas/base/assert/is-diagonal-type' ); -var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var max = require( '@stdlib/math/base/special/fast/max' ); var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); @@ -50,7 +50,7 @@ var base = require( './base.js' ); * @throws {TypeError} third argument must be a valid transpose operation * @throws {TypeError} fourth argument must be a valid diagonal type * @throws {RangeError} fifth argument must be a nonnegative integer -* @throws {RangeError} seventh argument must be greater than or equal to max(1,N) +* @throws {RangeError} seventh argument must be a valid stride * @throws {RangeError} ninth argument must be non-zero * @returns {Float64Array} `x` * @@ -89,6 +89,7 @@ function dtrsv( order, uplo, trans, diag, N, A, LDA, x, strideX ) { if ( strideX === 0 ) { throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) ); } + // Check if we can early return... if ( N === 0 ) { return x; } diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/lib/dtrsv.native.js b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/dtrsv.native.js index b44d7d3dd92d..6419143bf703 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/lib/dtrsv.native.js +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/dtrsv.native.js @@ -20,10 +20,16 @@ // MODULES // +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var isTransposeOperation = require( '@stdlib/blas/base/assert/is-transpose-operation' ); +var isDiagonal = require( '@stdlib/blas/base/assert/is-diagonal-type' ); var resolveOrder = require( '@stdlib/blas/base/layout-resolve-enum' ); var resolveUplo = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); var resolveTrans = require( '@stdlib/blas/base/transpose-operation-resolve-enum' ); var resolveDiag = require( '@stdlib/blas/base/diagonal-type-resolve-enum' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); var addon = require( './../src/addon.node' ); @@ -41,6 +47,13 @@ var addon = require( './../src/addon.node' ); * @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float64Array} x - input vector * @param {integer} strideX - `x` stride length +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether a lower or upper triangular matrix is supplied +* @throws {TypeError} third argument must be a valid transpose operation +* @throws {TypeError} fourth argument must be a valid diagonal type +* @throws {RangeError} fifth argument must be a nonnegative integer +* @throws {RangeError} seventh argument must be a valid stride +* @throws {RangeError} ninth argument must be non-zero * @returns {Float64Array} `x` * * @example @@ -53,6 +66,31 @@ var addon = require( './../src/addon.node' ); * // x => [ 0.0, -4.0, 3.0 ] */ function dtrsv( order, uplo, trans, diag, N, A, LDA, x, strideX ) { + 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 the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + if ( !isTransposeOperation( trans ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be a valid transpose operation. Value: `%s`.', trans ) ); + } + if ( !isDiagonal( diag ) ) { + throw new TypeError( format( 'invalid argument. Fourth argument must be a valid diagonal type. Value: `%s`.', diag ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) ); + } + // Check if we can early return... + if ( N === 0 ) { + return x; + } addon( resolveOrder( order ), resolveUplo( uplo ), resolveTrans( trans ), resolveDiag( diag ), N, A, LDA, x, strideX ); // eslint-disable-line max-len return x; } diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.js index 6651f15baa51..6e8970b384f2 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.js @@ -75,14 +75,15 @@ function dtrsv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) ); } if ( strideA1 === 0 ) { - throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideA1 ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideA1 ) ); } if ( strideA2 === 0 ) { throw new RangeError( format( 'invalid argument. Seventh argument must be non-zero. Value: `%d`.', strideA2 ) ); } if ( strideX === 0 ) { - throw new RangeError( format( 'invalid argument. Tenth argument must be non-zero. Value: `%d`.', strideX ) ); + throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) ); } + // Check if we can early return... if ( N === 0 ) { return x; } diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.native.js index 3e5da6f792be..b98985237875 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.native.js @@ -20,9 +20,13 @@ // MODULES // +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var isTransposeOperation = require( '@stdlib/blas/base/assert/is-transpose-operation' ); +var isDiagonal = require( '@stdlib/blas/base/assert/is-diagonal-type' ); var resolveUplo = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); var resolveTrans = require( '@stdlib/blas/base/transpose-operation-resolve-enum' ); var resolveDiag = require( '@stdlib/blas/base/diagonal-type-resolve-enum' ); +var format = require( '@stdlib/string/format' ); var addon = require( './../src/addon.node' ); @@ -42,6 +46,13 @@ var addon = require( './../src/addon.node' ); * @param {Float64Array} x - input vector * @param {integer} strideX - `x` stride length * @param {NonNegativeInteger} offsetX - starting index for `x` +* @throws {TypeError} first argument must specify whether a lower or upper triangular matrix is supplied +* @throws {TypeError} second argument must be a valid transpose operation +* @throws {TypeError} third argument must be a valid diagonal type +* @throws {RangeError} fourth argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be non-zero +* @throws {RangeError} seventh argument must be non-zero +* @throws {RangeError} tenth argument must be non-zero * @returns {Float64Array} `x` * * @example @@ -54,6 +65,31 @@ var addon = require( './../src/addon.node' ); * // x => [ 0.0, -4.0, 3.0 ] */ function dtrsv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-params, max-len + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. First argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + if ( !isTransposeOperation( trans ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a valid transpose operation. Value: `%s`.', trans ) ); + } + if ( !isDiagonal( diag ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be a valid diagonal type. Value: `%s`.', diag ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideA1 === 0 ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideA1 ) ); + } + if ( strideA2 === 0 ) { + throw new RangeError( format( 'invalid argument. Seventh argument must be non-zero. Value: `%d`.', strideA2 ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Tenth argument must be non-zero. Value: `%d`.', strideX ) ); + } + // Check if we can early return... + if ( N === 0 ) { + return x; + } addon.ndarray( resolveUplo( uplo ), resolveTrans( trans ), resolveDiag( diag ), N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ); // eslint-disable-line max-len return x; } diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json b/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json index b6ecf25668a2..7add8c146104 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json @@ -103,7 +103,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dtrsv_cblas.c" + "./src/dtrsv_cblas.c", + "./src/dtrsv_ndarray.c" ], "include": [ "./include" @@ -115,8 +116,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", @@ -131,7 +133,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dtrsv_cblas.c" + "./src/dtrsv_cblas.c", + "./src/dtrsv_ndarray.c" ], "include": [ "./include" @@ -143,8 +146,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", "@stdlib/math/base/special/floorf", "@stdlib/blas/ext/base/dfill" @@ -156,7 +160,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dtrsv_cblas.c" + "./src/dtrsv_cblas.c", + "./src/dtrsv_ndarray.c" ], "include": [ "./include" @@ -168,8 +173,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" ] }, @@ -248,7 +254,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dtrsv_cblas.c" + "./src/dtrsv_cblas.c", + "./src/dtrsv_ndarray.c" ], "include": [ "./include" @@ -259,8 +266,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", @@ -275,7 +283,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dtrsv_cblas.c" + "./src/dtrsv_cblas.c", + "./src/dtrsv_ndarray.c" ], "include": [ "./include" @@ -286,8 +295,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", "@stdlib/math/base/special/floorf", "@stdlib/blas/ext/base/dfill" @@ -299,7 +309,8 @@ "blas": "apple_accelerate_framework", "wasm": false, "src": [ - "./src/dtrsv_cblas.c" + "./src/dtrsv_cblas.c", + "./src/dtrsv_ndarray.c" ], "include": [ "./include" @@ -310,8 +321,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" ] }, @@ -321,7 +333,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dtrsv_cblas.c" + "./src/dtrsv_cblas.c", + "./src/dtrsv_ndarray.c" ], "include": [ "./include" @@ -333,8 +346,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", @@ -349,7 +363,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dtrsv_cblas.c" + "./src/dtrsv_cblas.c", + "./src/dtrsv_ndarray.c" ], "include": [ "./include" @@ -361,8 +376,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", "@stdlib/math/base/special/floorf", "@stdlib/blas/ext/base/dfill" @@ -374,7 +390,8 @@ "blas": "openblas", "wasm": false, "src": [ - "./src/dtrsv_cblas.c" + "./src/dtrsv_cblas.c", + "./src/dtrsv_ndarray.c" ], "include": [ "./include" @@ -386,8 +403,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/dtrsv/src/addon.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c index 9588cfd1abff..16401e7a5b9b 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/addon.c @@ -39,7 +39,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 9 ); - 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_INT32( env, trans, argv, 2 ); STDLIB_NAPI_ARGV_INT32( env, diag, argv, 3 ); @@ -48,18 +48,17 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 8 ); STDLIB_NAPI_ARGV_INT64( env, LDA, argv, 6 ); - if ( order == CblasColMajor ) { + if ( layout == CblasColMajor ) { sa1 = 1; sa2 = LDA; - } else { // order == CblasRowMajor + } else { // layout == CblasRowMajor sa1 = LDA; sa2 = 1; } - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 7 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, N, N, sa1, sa2, argv, 5 ); - API_SUFFIX(c_dtrsv)( order, uplo, trans, diag, N, A, LDA, X, strideX ); + API_SUFFIX(c_dtrsv)( layout, uplo, trans, diag, N, A, LDA, X, strideX ); return NULL; } diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c index 35b407c085a6..b3a8eb66a3a0 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c @@ -18,12 +18,13 @@ #include "stdlib/blas/base/dtrsv.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/xerbla.h" #include "stdlib/strided/base/stride2offset.h" /** * Solves one of the systems of equations `A*X = b` or `A^T*X = b` where `b` and `X` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. * -* @param order storage layout +* @param layout storage layout * @param uplo specifies whether `A` is an upper or lower triangular matrix * @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed * @param diag specifies whether `A` has a unit diagonal @@ -34,19 +35,52 @@ * @param strideX `X` stride length * @return output value */ -void API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *X, const CBLAS_INT strideX ) { +void API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *X, const CBLAS_INT strideX ) { CBLAS_INT sa1; CBLAS_INT sa2; CBLAS_INT ox; - if ( order == CblasColMajor ) { + // Perform input argument validation... + if ( layout != CblasRowMajor && layout != CblasColMajor ) { + c_xerbla( 1, "c_dtrsv", "Error: invalid argument. First argument must be a valid layout. Value: `%d`.", layout ); + return; + } + if ( uplo != CblasLower && uplo != CblasUpper ) { + c_xerbla( 2, "c_dtrsv", "Error: invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%d`.", uplo ); + return; + } + if ( trans != CblasTrans && trans != CblasConjTrans && trans != CblasNoTrans ) { + c_xerbla( 3, "c_dtrsv", "Error: invalid argument. Third argument must be a valid transpose operation. Value: `%d`.", trans ); + return; + } + if ( diag != CblasNonUnit && diag != CblasUnit ) { + c_xerbla( 4, "c_dtrsv", "Error: invalid argument. Fourth argument must be a valid diagonal type. Value: `%d`.", diag ); + return; + } + if ( N < 0 ) { + c_xerbla( 5, "c_dtrsv", "Error: invalid argument. Fifth argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( LDA < max( 1, N ) ) { + c_xerbla( 7, "c_dtrsv", "Error: invalid argument. Seventh argument must be greater than or equal to max(1,%d). Value: `%d`.", N, LDA ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 9, "c_dtrsv", "Error: invalid argument. Ninth argument must be a nonzero. Value: `%d`.", strideX ); + return; + } + // Check whether we can avoid computation altogether... + if ( N == 0 ) { + return; + } + if ( layout == CblasColMajor ) { sa1 = 1; sa2 = LDA; - } else { // order == 'row-major' + } else { // layout == 'row-major' sa1 = LDA; sa2 = 1; } ox = stdlib_strided_stride2offset( N, strideX ); - API_SUFFIX(c_dtrsv_ndarray)( uplo, trans, diag, N, A, sa1, sa2, 0, X, strideX, ox ); + API_SUFFIX(c_dtrsv)( uplo, trans, diag, N, A, sa1, sa2, 0, X, strideX, ox ); return; } diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c index 76c123a73364..04e52b6dbd29 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_cblas.c @@ -20,13 +20,11 @@ #include "stdlib/blas/base/dtrsv.h" #include "stdlib/blas/base/dtrsv_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" /** * Solves one of the systems of equations `A*X = b` or `A^T*X = b` where `b` and `X` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. * -* @param order storage layout +* @param layout storage layout * @param uplo specifies whether `A` is an upper or lower triangular matrix * @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed * @param diag specifies whether `A` has a unit diagonal @@ -37,38 +35,6 @@ * @param strideX `X` stride length * @return output value */ -double API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *X, const CBLAS_INT strideX ) { - CBLAS_INT sx = strideX; - if ( sx < 0 ) { - sx = -sx; - } - return API_SUFFIX(cblas_dtrsv)( order, uplo, trans, diag, N, A, LDA, X, sx ); -} - -/** -* Solves one of the systems of equations `A*X = b` or `A^T*X = b`, using alternative indexing semantics and where `b` and `X` are `N` element vectors and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. -* -* @param uplo specifies whether `A` is an upper or lower triangular matrix -* @param trans specifies whether `A` should be transposed, conjugate-transposed, or not transposed -* @param diag specifies whether `A` has a unit diagonal -* @param N number of elements along each dimension of `A` -* @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` -* @param X input vector -* @param strideX `X` stride length -* @param offsetX starting index for `X` -* @return output value -*/ -double API_SUFFIX(c_dtrsv_ndarray)( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { - CBLAS_INT sx = strideX; - if ( sx < 0 ) { - sx = -sx; - } - X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // 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 - return API_SUFFIX(cblas_dtrsv)( order, uplo, trans, diag, N, A, LDA, X, sx ); +double API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *X, const CBLAS_INT strideX ) { + return API_SUFFIX(cblas_dtrsv)( layout, uplo, trans, diag, N, A, LDA, X, strideX ); } diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c index 15445ecf3e07..fa97bb4476b2 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c @@ -18,6 +18,7 @@ #include "stdlib/blas/base/dtrsv.h" #include "stdlib/blas/base/shared.h" +#include "stdlib/blas/base/xerbla.h" #include "stdlib/ndarray/base/assert/is_row_major.h" /** @@ -53,20 +54,36 @@ void API_SUFFIX(c_dtrsv_ndarray)( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE t // Note on variable naming convention: sa#, ix#, i# where # corresponds to the loop number, with `0` being the innermost loop... // Perform input argument validation... - if ( M < 0 ) { - c_xerbla( 1, "c_dger_ndarray", "Error: invalid argument. First argument must be a nonnegative integer. Value: `%d`.", M ); + if ( uplo != CblasLower && uplo != CblasUpper ) { + c_xerbla( 1, "c_dtrsv_ndarray", "Error: invalid argument. First argument must specify whether the lower or upper triangular matrix is supplied. Value: `%d`.", uplo ); + return; + } + if ( trans != CblasTrans && trans != CblasConjTrans && trans != CblasNoTrans ) { + c_xerbla( 2, "c_dtrsv_ndarray", "Error: invalid argument. Second argument must be a valid transpose operation. Value: `%d`.", trans ); + return; + } + if ( diag != CblasNonUnit && diag != CblasUnit ) { + c_xerbla( 3, "c_dtrsv_ndarray", "Error: invalid argument. Third argument must be a valid diagonal type. Value: `%d`.", diag ); return; } if ( N < 0 ) { - c_xerbla( 2, "c_dger_ndarray", "Error: invalid argument. Second argument must be a nonnegative integer. Value: `%d`.", N ); + c_xerbla( 4, "c_dtrsv_ndarray", "Error: invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideA1 == 0 ) { + c_xerbla( 6, "c_dtrsv_ndarray", "Error: invalid argument. Sixth argument must be a nonzero. Value: `%d`.", strideA1 ); + return; + } + if ( strideA2 == 0 ) { + c_xerbla( 7, "c_dtrsv_ndarray", "Error: invalid argument. Sixth argument must be a nonzero. Value: `%d`.", strideA2 ); return; } if ( strideX == 0 ) { - c_xerbla( 5, "c_dger_ndarray", "Error: invalid argument. Fifth argument must be a nonzero. Value: `%d`.", strideX ); + c_xerbla( 10, "c_dtrsv_ndarray", "Error: invalid argument. Tenth argument must be a nonzero. Value: `%d`.", strideX ); return; } - if ( strideY == 0 ) { - c_xerbla( 8, "c_dger_ndarray", "Error: invalid argument. Eighth argument must be a nonzero. Value: `%d`.", strideY ); + // Check whether we can avoid computation altogether... + if ( N == 0 ) { return; } nonunit = ( diag == CblasNonUnit ); diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.dtrsv.native.js b/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.dtrsv.native.js index 52a4a1c65bc6..47c14d2cedc0 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.dtrsv.native.js +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.dtrsv.native.js @@ -74,6 +74,186 @@ tape( 'the function has an arity of 9', 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 = rutu; + + 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() { + dtrsv( value, data.uplo, data.trans, data.diag, data.N, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rutu; + + 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() { + dtrsv( data.order, value, data.trans, data.diag, data.N, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rutu; + + 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() { + dtrsv( data.order, data.uplo, value, data.diag, data.N, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fourth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rutu; + + 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() { + dtrsv( data.order, data.uplo, data.trans, value, data.N, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rutu; + + 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() { + dtrsv( data.order, data.uplo, data.trans, data.diag, value, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid seventh argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rutu; + + 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() { + dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, new Float64Array( data.A ), value, new Float64Array( data.x ), data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid ninth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rutu; + + 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() { + dtrsv( data.order, data.uplo, data.trans, data.diag, data.N, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), value ); + }; + } +}); + tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, lower, no transpose, non-unit)', opts, function test( t ) { var expected; var data; diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.ndarray.native.js index 8a93c3ee05a5..a7edeb7d0109 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/test/test.ndarray.native.js @@ -86,6 +86,178 @@ tape( 'the function has an arity of 11', 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 = rutu; + + 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() { + dtrsv( value, data.trans, data.diag, data.N, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rutu; + + 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() { + dtrsv( data.uplo, value, data.diag, data.N, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rutu; + + 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() { + dtrsv( data.uplo, data.trans, value, data.N, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fourth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rutu; + + 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() { + dtrsv( data.uplo, data.trans, data.diag, value, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid sixth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rutu; + + 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() { + dtrsv( data.uplo, data.trans, data.diag, data.N, new Float64Array( data.A ), value, data.strideA2, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid seventh argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rutu; + + 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() { + dtrsv( data.uplo, data.trans, data.diag, data.N, new Float64Array( data.A ), data.strideA1, value, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid tenth argument', opts, function test( t ) { + var values; + var data; + var i; + + data = rutu; + + 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() { + dtrsv( data.uplo, data.trans, data.diag, data.N, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), value, data.offsetX ); + }; + } +}); + tape( 'the function solves one of the systems of equations `A*x = b` or `A^T*x = b` (row-major, lower, no transpose, non-unit)', opts, function test( t ) { var expected; var data; From 7ca5b4ed215d3a872189db0dff67adaddd8089bd Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 30 Jun 2025 00:02:35 +0530 Subject: [PATCH 05/21] chore: clean-up --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: 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 --- --- lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json b/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json index 7add8c146104..89afffac27d2 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/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", @@ -70,6 +71,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/math/base/special/floorf", @@ -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" ] @@ -195,6 +198,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", @@ -221,6 +225,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/math/base/special/floorf", @@ -243,6 +248,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major" ] @@ -425,6 +431,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", @@ -451,6 +458,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/math/base/special/floorf", @@ -473,6 +481,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major" ] @@ -494,6 +503,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major" ] From d0e12746d2a522215e891e72ae5efa4ec4f2b4ca Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 30 Jun 2025 00:04:09 +0530 Subject: [PATCH 06/21] chore: clean-up --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: 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/dtrsv/src/dtrsv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c index b3a8eb66a3a0..25528a48e4f7 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c @@ -61,7 +61,7 @@ void API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, cons c_xerbla( 5, "c_dtrsv", "Error: invalid argument. Fifth argument must be a nonnegative integer. Value: `%d`.", N ); return; } - if ( LDA < max( 1, N ) ) { + if ( LDA < N ) { c_xerbla( 7, "c_dtrsv", "Error: invalid argument. Seventh argument must be greater than or equal to max(1,%d). Value: `%d`.", N, LDA ); return; } From dcb85193e28bc9f7de89af7f237b54595183366b Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 30 Jun 2025 00:06:24 +0530 Subject: [PATCH 07/21] chore: clean-up --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: 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/dtrsv/src/dtrsv.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c index 25528a48e4f7..4a1b58aa325d 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c @@ -36,6 +36,7 @@ * @return output value */ void API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *X, const CBLAS_INT strideX ) { + CBLAS_INT vala; CBLAS_INT sa1; CBLAS_INT sa2; CBLAS_INT ox; @@ -61,8 +62,14 @@ void API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, cons c_xerbla( 5, "c_dtrsv", "Error: invalid argument. Fifth argument must be a nonnegative integer. Value: `%d`.", N ); return; } - if ( LDA < N ) { - c_xerbla( 7, "c_dtrsv", "Error: invalid argument. Seventh 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( 7, "c_dtrsv", "Error: invalid argument. Seventh argument must be greater than or equal to max(1,%d). Value: `%d`.", vala, LDA ); return; } if ( strideX == 0 ) { From 0e52825737ee18b938f8043179b436e05a7e587e Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 30 Jun 2025 00:09:48 +0530 Subject: [PATCH 08/21] chore: clean-up --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: 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/dtrsv/src/dtrsv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c index 4a1b58aa325d..6ebd0fa1a965 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv.c @@ -88,6 +88,6 @@ void API_SUFFIX(c_dtrsv)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, cons sa2 = 1; } ox = stdlib_strided_stride2offset( N, strideX ); - API_SUFFIX(c_dtrsv)( uplo, trans, diag, N, A, sa1, sa2, 0, X, strideX, ox ); + API_SUFFIX(c_dtrsv_ndarray)( uplo, trans, diag, N, A, sa1, sa2, 0, X, strideX, ox ); return; } From d46fe75ffcaabc60ea2387c73d1c77591d2740a0 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 30 Jun 2025 00:23:52 +0530 Subject: [PATCH 09/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c index 84e48cd92cb6..97ab2d7b83c8 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c @@ -110,6 +110,7 @@ static double benchmark1( int iterations, int N ) { } t = tic(); for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar c_dtrsv( CblasRowMajor, CblasLower, CblasNoTrans, CblasUnit, N, A, N, X, 1 ); if ( X[ i%N ] != X[ i%N ] ) { printf( "should not return NaN\n" ); @@ -145,6 +146,7 @@ static double benchmark2( int iterations, int N ) { } t = tic(); for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasUnit, N, A, N, 1, 0, X, 1, 0 ); if ( X[ i%N ] != X[ i%N ] ) { printf( "should not return NaN\n" ); From 46c032442414260155ca67c5eb760b2baf05a5a2 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 30 Jun 2025 10:21:24 +0530 Subject: [PATCH 10/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json b/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json index 89afffac27d2..d3d1e39905f2 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json @@ -74,7 +74,6 @@ "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/math/base/special/floorf", "@stdlib/blas/ext/base/dfill" ] }, @@ -152,8 +151,6 @@ "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/blas/ext/base/dfill", - "@stdlib/math/base/special/floorf", "@stdlib/blas/ext/base/dfill" ] }, @@ -228,7 +225,6 @@ "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/math/base/special/floorf", "@stdlib/blas/ext/base/dfill" ] }, @@ -305,8 +301,6 @@ "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/blas/ext/base/dfill", - "@stdlib/math/base/special/floorf", - "@stdlib/blas/ext/base/dfill" ] }, { @@ -385,8 +379,6 @@ "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/blas/ext/base/dfill", - "@stdlib/math/base/special/floorf", "@stdlib/blas/ext/base/dfill" ] }, @@ -461,7 +453,6 @@ "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/math/base/special/floorf", "@stdlib/blas/ext/base/dfill" ] }, From 234f40673671b7e52d49f5247ca16194f0c14dec Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 30 Jun 2025 11:23:38 +0530 Subject: [PATCH 11/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c index fa97bb4476b2..bec346f082df 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/src/dtrsv_ndarray.c @@ -75,7 +75,7 @@ void API_SUFFIX(c_dtrsv_ndarray)( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE t return; } if ( strideA2 == 0 ) { - c_xerbla( 7, "c_dtrsv_ndarray", "Error: invalid argument. Sixth argument must be a nonzero. Value: `%d`.", strideA2 ); + c_xerbla( 7, "c_dtrsv_ndarray", "Error: invalid argument. Seventh argument must be a nonzero. Value: `%d`.", strideA2 ); return; } if ( strideX == 0 ) { From 31c7cd6aae258de375787a3ce4dab0628d5441d0 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 30 Jun 2025 11:48:06 +0530 Subject: [PATCH 12/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/dtrsv/manifest.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json b/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json index d3d1e39905f2..0f6a5b968495 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json @@ -51,6 +51,7 @@ "@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" ] @@ -74,7 +75,6 @@ "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/blas/ext/base/dfill" ] }, { @@ -125,6 +125,7 @@ "@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" ] @@ -151,7 +152,6 @@ "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/blas/ext/base/dfill" ] }, { @@ -202,6 +202,7 @@ "@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" ] @@ -225,7 +226,6 @@ "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/blas/ext/base/dfill" ] }, { @@ -275,6 +275,7 @@ "@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" ] @@ -300,7 +301,6 @@ "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/blas/ext/base/dfill", ] }, { @@ -353,6 +353,7 @@ "@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" ] @@ -379,7 +380,6 @@ "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/blas/ext/base/dfill" ] }, { @@ -430,6 +430,7 @@ "@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" ] @@ -453,7 +454,6 @@ "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", "@stdlib/ndarray/base/assert/is-row-major", - "@stdlib/blas/ext/base/dfill" ] }, { From 47fbb8bd6d3e6c19c54aaa38b053e85c27a4cd01 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 30 Jun 2025 12:02:21 +0530 Subject: [PATCH 13/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json b/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json index 0f6a5b968495..d782eef919ea 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json @@ -51,7 +51,6 @@ "@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" ] @@ -125,7 +124,6 @@ "@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" ] @@ -202,7 +200,6 @@ "@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" ] @@ -275,7 +272,6 @@ "@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" ] @@ -353,7 +349,6 @@ "@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" ] @@ -430,7 +425,6 @@ "@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" ] From 7aeaf9ab2c122e75f04da50ff090ddeafcc38217 Mon Sep 17 00:00:00 2001 From: ShabiShett07 Date: Mon, 30 Jun 2025 12:05:47 +0530 Subject: [PATCH 14/21] chore: clean-up --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: 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/dtrsv/manifest.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json b/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json index d782eef919ea..cd5ab1f119ae 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/manifest.json @@ -73,7 +73,7 @@ "@stdlib/blas/base/shared", "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", - "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -149,7 +149,7 @@ "@stdlib/blas/base/shared", "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", - "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -222,7 +222,7 @@ "@stdlib/blas/base/shared", "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", - "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -296,7 +296,7 @@ "@stdlib/blas/base/shared", "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", - "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -374,7 +374,7 @@ "@stdlib/blas/base/shared", "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", - "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { @@ -447,7 +447,7 @@ "@stdlib/blas/base/shared", "@stdlib/blas/base/xerbla", "@stdlib/strided/base/stride2offset", - "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/ndarray/base/assert/is-row-major" ] }, { From 351cdf29d9d272f4197f822c22816641f4ad1615 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 30 Jun 2025 12:09:23 +0530 Subject: [PATCH 15/21] chore: remove unused package Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c index 97ab2d7b83c8..188ce7fc2eaf 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c @@ -17,7 +17,6 @@ */ #include "stdlib/blas/base/dtrsv.h" -#include "stdlib/blas/ext/base/dfill.h" #include #include #include From c0317595360115a9a78d9627c3fc737c6c5895de Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 30 Jun 2025 12:20:36 +0530 Subject: [PATCH 16/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c index 188ce7fc2eaf..9727e6b44516 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c @@ -109,7 +109,6 @@ static double benchmark1( int iterations, int N ) { } t = tic(); for ( i = 0; i < iterations; i++ ) { - // cppcheck-suppress uninitvar c_dtrsv( CblasRowMajor, CblasLower, CblasNoTrans, CblasUnit, N, A, N, X, 1 ); if ( X[ i%N ] != X[ i%N ] ) { printf( "should not return NaN\n" ); @@ -145,7 +144,6 @@ static double benchmark2( int iterations, int N ) { } t = tic(); for ( i = 0; i < iterations; i++ ) { - // cppcheck-suppress uninitvar c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasUnit, N, A, N, 1, 0, X, 1, 0 ); if ( X[ i%N ] != X[ i%N ] ) { printf( "should not return NaN\n" ); From b4bfb0ff7c0dad6f7a631c50bf3c64a706af71e2 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 30 Jun 2025 12:24:44 +0530 Subject: [PATCH 17/21] chore: revert changes Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.js index 6e8970b384f2..346e8313151e 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/lib/ndarray.js @@ -75,13 +75,13 @@ function dtrsv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) ); } if ( strideA1 === 0 ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideA1 ) ); + throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideA1 ) ); } if ( strideA2 === 0 ) { throw new RangeError( format( 'invalid argument. Seventh argument must be non-zero. Value: `%d`.', strideA2 ) ); } if ( strideX === 0 ) { - throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) ); + throw new RangeError( format( 'invalid argument. Tenth argument must be non-zero. Value: `%d`.', strideX ) ); } // Check if we can early return... if ( N === 0 ) { From 6f91b152514b311ca818ec3c32e5fe5859b2871d Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 30 Jun 2025 12:35:27 +0530 Subject: [PATCH 18/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c index 9727e6b44516..188ce7fc2eaf 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c @@ -109,6 +109,7 @@ static double benchmark1( int iterations, int N ) { } t = tic(); for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar c_dtrsv( CblasRowMajor, CblasLower, CblasNoTrans, CblasUnit, N, A, N, X, 1 ); if ( X[ i%N ] != X[ i%N ] ) { printf( "should not return NaN\n" ); @@ -144,6 +145,7 @@ static double benchmark2( int iterations, int N ) { } t = tic(); for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasUnit, N, A, N, 1, 0, X, 1, 0 ); if ( X[ i%N ] != X[ i%N ] ) { printf( "should not return NaN\n" ); From af06dc9727990cbcd8553d49affca86c6b952321 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 30 Jun 2025 13:11:10 +0530 Subject: [PATCH 19/21] chore: update variable name Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../@stdlib/blas/base/dtrsv/examples/c/example.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c index 98e7622c17db..a0b00ea86f48 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/examples/c/example.c @@ -28,24 +28,24 @@ int main( void ) { 3.0, 2.0, 1.0 }; // Define `x` vector: - double X[ 3 ] = { 1.0, 2.0, 3.0 }; + double x[ 3 ] = { 1.0, 2.0, 3.0 }; // Specify the number of elements along each dimension of `A`: const int N = 3; - // Perform the matrix-vector operations `A*X = b` for `lower` triangular matrix `A`: - c_dtrsv( CblasRowMajor, CblasLower, CblasNoTrans, CblasNonUnit, N, A, N, X, 1 ); + // Perform the matrix-vector operations `A*x = b` for `lower` triangular matrix `A`: + c_dtrsv( CblasRowMajor, CblasLower, CblasNoTrans, CblasNonUnit, N, A, N, x, 1 ); // Print the result: for ( int i = 0; i < N; i++ ) { - printf( "X[ %i ] = %f\n", i, X[ i ] ); + printf( "x[ %i ] = %f\n", i, x[ i ] ); } - // Perform the matrix-vector operations `A*X = b` for `lower` triangular matrix `A` using alternative indexing semantics: - c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasNonUnit, N, A, N, 1, 0, X, 1, 0 ); + // Perform the matrix-vector operations `A*x = b` for `lower` triangular matrix `A` using alternative indexing semantics: + c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasNonUnit, N, A, N, 1, 0, x, 1, 0 ); // Print the result: for ( int i = 0; i < N; i++ ) { - printf( "X[ %i ] = %f\n", i, X[ i ] ); + printf( "x[ %i ] = %f\n", i, x[ i ] ); } } From a80e4bf7a507d6b39b091ab32dcdc43a8ca19545 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 30 Jun 2025 13:12:02 +0530 Subject: [PATCH 20/21] chore: update variable name Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- .../base/dtrsv/benchmark/c/benchmark.length.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c index 188ce7fc2eaf..c45a720b62a6 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/benchmark/c/benchmark.length.c @@ -97,27 +97,27 @@ static double rand_double( void ) { static double benchmark1( int iterations, int N ) { double elapsed; double A[ N*N ]; - double X[ N ]; + double x[ N ]; double t; int i; int j; for ( i = 0, j = 0; i < N; i++, j += 2 ) { - X[ i ] = ( rand_double()*20.0 ) - 10.0; + x[ i ] = ( rand_double()*20.0 ) - 10.0; A[ j ] = ( rand_double()*20.0 ) - 10.0; A[ j+1 ] = ( rand_double()*20.0 ) - 10.0; } t = tic(); for ( i = 0; i < iterations; i++ ) { // cppcheck-suppress uninitvar - c_dtrsv( CblasRowMajor, CblasLower, CblasNoTrans, CblasUnit, N, A, N, X, 1 ); - if ( X[ i%N ] != X[ i%N ] ) { + c_dtrsv( CblasRowMajor, CblasLower, CblasNoTrans, CblasUnit, N, A, N, x, 1 ); + if ( x[ i%N ] != x[ i%N ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( X[ i%N ] != X[ i%N ] ) { + if ( x[ i%N ] != x[ i%N ] ) { printf( "should not return NaN\n" ); } return elapsed; @@ -133,27 +133,27 @@ static double benchmark1( int iterations, int N ) { static double benchmark2( int iterations, int N ) { double elapsed; double A[ N*N ]; - double X[ N ]; + double x[ N ]; double t; int i; int j; for ( i = 0, j = 0; i < N; i++, j += 2 ) { - X[ i ] = ( rand_double()*20.0 ) - 10.0; + x[ i ] = ( rand_double()*20.0 ) - 10.0; A[ j ] = ( rand_double()*20.0 ) - 10.0; A[ j+1 ] = ( rand_double()*20.0 ) - 10.0; } t = tic(); for ( i = 0; i < iterations; i++ ) { // cppcheck-suppress uninitvar - c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasUnit, N, A, N, 1, 0, X, 1, 0 ); - if ( X[ i%N ] != X[ i%N ] ) { + c_dtrsv_ndarray( CblasLower, CblasNoTrans, CblasUnit, N, A, N, 1, 0, x, 1, 0 ); + if ( x[ i%N ] != x[ i%N ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( X[ i%N ] != X[ i%N ] ) { + if ( x[ i%N ] != x[ i%N ] ) { printf( "should not return NaN\n" ); } return elapsed; From 7ea6c7302563644fa8fe4a9f8f71321ef99fab47 Mon Sep 17 00:00:00 2001 From: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Date: Mon, 30 Jun 2025 13:23:29 +0530 Subject: [PATCH 21/21] chore: minor clean-up Signed-off-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/base/dtrsv/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dtrsv/README.md b/lib/node_modules/@stdlib/blas/base/dtrsv/README.md index 5dc35e073538..6481339b8d1c 100644 --- a/lib/node_modules/@stdlib/blas/base/dtrsv/README.md +++ b/lib/node_modules/@stdlib/blas/base/dtrsv/README.md @@ -184,10 +184,6 @@ console.log( x );
- - -
- ### Usage ```c