diff --git a/lib/node_modules/@stdlib/blas/base/strsv/README.md b/lib/node_modules/@stdlib/blas/base/strsv/README.md index 35278437b1b9..1e2fcb6e974d 100644 --- a/lib/node_modules/@stdlib/blas/base/strsv/README.md +++ b/lib/node_modules/@stdlib/blas/base/strsv/README.md @@ -184,24 +184,75 @@ console.log( x );
+ + +
+ ### Usage ```c -TODO +#include "stdlib/blas/base/strsv.h" +``` + +#### c_strsv( 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" + +float A[] = { 1.0f, 2.0f, 3.0f, 0.0f, 1.0f, 2.0f, 0.0f, 0.0f, 1.0f }; +const float x[] = { 1.0f, 2.0f, 3.0f }; + +c_strsv( 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] float*` input matrix. +- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **X**: `[in] float*` input vector. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. + +```c +void c_strsv( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const float *A, const CBLAS_INT LDA, float *x, const CBLAS_INT strideX ) ``` -#### TODO + +#### c_strsv_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" + +float A[] = { 1.0f, 2.0f, 3.0f, 0.0f, 1.0f, 2.0f, 0.0f, 0.0f, 1.0f }; +const float x[] = { 1.0f, 2.0f, 3.0f }; + +c_strsv_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] float*` input matrix. +- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A`. +- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **offsetA**: `[in] CBLAS_INT` starting index for `A`. +- **X**: `[in] float*` input vector. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. ```c -TODO +void c_strsv_ndarray( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, float *x, const CBLAS_INT strideX, const CBLAS_INT offsetX ) ```
@@ -223,7 +274,34 @@ TODO ### Examples ```c -TODO +#include "stdlib/blas/base/strsv.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Create a strided array: + const float A[] = { 1.0f, 0.0f, 0.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f }; + float X[] = { 1.0f, 2.0f, 3.0f }; + + // 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_strsv( 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_strsv_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/strsv/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/strsv/benchmark/benchmark.native.js new file mode 100644 index 000000000000..2d260603318f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/benchmark/benchmark.native.js @@ -0,0 +1,110 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +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 strsv = tryRequire( resolve( __dirname, './../lib/strsv.native.js' ) ); +var opts = { + 'skip': ( strsv instanceof Error ) +}; +var options = { + 'dtype': 'float32' +}; + + +// 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 = strsv( 'row-major', 'upper', 'transpose', 'non-unit', N, A, N, x, 1 ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( 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/strsv/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/strsv/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..c6cb670bf3f3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +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 strsv = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( strsv instanceof Error ) +}; +var options = { + 'dtype': 'float32' +}; + + +// 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 = strsv( 'upper', 'transpose', 'non-unit', N, A, N, 1, 0, x, 1, 0 ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( 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/strsv/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/base/strsv/benchmark/c/Makefile new file mode 100644 index 000000000000..cce2c865d7ad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/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/strsv/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/strsv/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..d0a7d9386138 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/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/strsv.h" +#include "stdlib/blas/ext/base/sfill.h" +#include "stdlib/math/base/special/floorf.h" +#include +#include +#include +#include +#include + +#define NAME "strsv" +#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; + float A[ len*len ]; + float X[ len ]; + double t; + int i; + + stdlib_strided_sfill( len, 1.0f, X, 1 ); + stdlib_strided_sfill( len*len, 1.0f, A, 1 ); + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_strsv( 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; + float A[ len*len ]; + float X[ len ]; + double t; + int i; + + stdlib_strided_sfill( len, 1.0f, X, 1 ); + stdlib_strided_sfill( len*len, 1.0f, A, 1 ); + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_strsv_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/strsv/binding.gyp b/lib/node_modules/@stdlib/blas/base/strsv/binding.gyp new file mode 100644 index 000000000000..08de71a2020e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/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/strsv/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/strsv/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/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/strsv/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/strsv/examples/c/example.c new file mode 100644 index 000000000000..2f58ea6196b4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/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/strsv.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Create a strided array: + const float A[] = { 1.0f, 0.0f, 0.0f, 2.0f, 1.0f, 0.0f, 3.0f, 2.0f, 1.0f }; + float X[] = { 1.0f, 2.0f, 3.0f }; + + // 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_strsv( 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_strsv_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/strsv/include.gypi b/lib/node_modules/@stdlib/blas/base/strsv/include.gypi new file mode 100644 index 000000000000..4217944b5d20 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/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)', + ' [ 0.0, -4.0, 3.0 ] +*/ +function strsv( 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 = strsv; diff --git a/lib/node_modules/@stdlib/blas/base/strsv/lib/strsv.native.js b/lib/node_modules/@stdlib/blas/base/strsv/lib/strsv.native.js new file mode 100644 index 000000000000..bb4ed7a12329 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/lib/strsv.native.js @@ -0,0 +1,63 @@ +/** +* @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 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 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} order - storage layout +* @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 {Float32Array} A - input matrix +* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float32Array} x - input vector +* @param {integer} strideX - `x` stride length +* @returns {Float32Array} `x` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* strsv( 'row-major', 'upper', 'no-transpose', 'unit', 3, A, 3, x, 1 ); +* // x => [ 0.0, -4.0, 3.0 ] +*/ +function strsv( 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 = strsv; diff --git a/lib/node_modules/@stdlib/blas/base/strsv/manifest.json b/lib/node_modules/@stdlib/blas/base/strsv/manifest.json new file mode 100644 index 000000000000..16b983b1be38 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/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/strsv.c", + "./src/strsv_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-float32array", + "@stdlib/napi/argv-strided-float32array2d" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/strsv.c", + "./src/strsv_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/sfill" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/strsv.c", + "./src/strsv_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/strsv_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-float32array", + "@stdlib/napi/argv-strided-float32array2d" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/strsv_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/sfill", + "@stdlib/math/base/special/floorf", + "@stdlib/blas/ext/base/sfill" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/strsv_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/strsv.c", + "./src/strsv_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-float32array", + "@stdlib/napi/argv-strided-float32array2d" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/strsv.c", + "./src/strsv_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/sfill" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/strsv.c", + "./src/strsv_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/strsv_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-float32array", + "@stdlib/napi/argv-strided-float32array2d" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/strsv_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/sfill", + "@stdlib/math/base/special/floorf", + "@stdlib/blas/ext/base/sfill" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/strsv_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/strsv_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-float32array", + "@stdlib/napi/argv-strided-float32array2d" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/strsv_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/sfill", + "@stdlib/math/base/special/floorf", + "@stdlib/blas/ext/base/sfill" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/strsv_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/strsv.c", + "./src/strsv_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-float32array", + "@stdlib/napi/argv-strided-float32array2d" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/strsv.c", + "./src/strsv_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/sfill" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/strsv.c", + "./src/strsv_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/strsv.c", + "./src/strsv_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/strsv/package.json b/lib/node_modules/@stdlib/blas/base/strsv/package.json index e2bdd76d81a3..88eb48e4d52c 100644 --- a/lib/node_modules/@stdlib/blas/base/strsv/package.json +++ b/lib/node_modules/@stdlib/blas/base/strsv/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/strsv/src/Makefile b/lib/node_modules/@stdlib/blas/base/strsv/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/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/strsv/src/addon.c b/lib/node_modules/@stdlib/blas/base/strsv/src/addon.c new file mode 100644 index 000000000000..42d2d14f4437 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/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_float32array.h" +#include "stdlib/napi/argv_strided_float32array2d.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 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_FLOAT32ARRAY( env, X, N, strideX, argv, 7 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( 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_FLOAT32ARRAY( env, X, N, strideX, argv, 8 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( 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/strsv/src/strsv.c b/lib/node_modules/@stdlib/blas/base/strsv/src/strsv.c new file mode 100644 index 000000000000..f0b340729a1f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/src/strsv.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/strsv.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_strsv)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const float *A, const CBLAS_INT LDA, float *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_strsv_ndarray)( uplo, trans, diag, N, A, sa1, sa2, 0, X, strideX, ox ); + return; +} diff --git a/lib/node_modules/@stdlib/blas/base/strsv/src/strsv_cblas.c b/lib/node_modules/@stdlib/blas/base/strsv/src/strsv_cblas.c new file mode 100644 index 000000000000..247b1af42478 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/src/strsv_cblas.c @@ -0,0 +1,73 @@ +/** +* @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/strsv_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 +*/ +float API_SUFFIX(c_strsv)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const float *A, const CBLAS_INT LDA, float *X, const CBLAS_INT strideX ) { + CBLAS_INT sx = strideX; + if ( sx < 0 ) { + sx = -sx; + } + return API_SUFFIX(cblas_strsv)( 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 +*/ +float API_SUFFIX(c_strsv_ndarray)( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, float *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_strsv)( order, uplo, trans, diag, N, A, LDA, X, sx ); +} diff --git a/lib/node_modules/@stdlib/blas/base/strsv/src/strsv_ndarray.c b/lib/node_modules/@stdlib/blas/base/strsv/src/strsv_ndarray.c new file mode 100644 index 000000000000..d1e4203a485b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/src/strsv_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/strsv.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_strsv_ndarray)( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const float *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, float *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; + float tmp; + + // Note on variable naming convention: sa#, ix#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + int64_t strides[] = { strideA1, strideA2 }; + 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.0f ) { + 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.0f ) { + 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/strsv/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/strsv/test/test.ndarray.native.js new file mode 100644 index 000000000000..361c6b7ed5f2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/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 Float32Array = require( '@stdlib/array/float32' ); +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 strsv = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( strsv instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof strsv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', opts, function test( t ) { + t.strictEqual( strsv.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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/strsv/test/test.strsv.native.js b/lib/node_modules/@stdlib/blas/base/strsv/test/test.strsv.native.js new file mode 100644 index 000000000000..aa39835f31d1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/strsv/test/test.strsv.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 Float32Array = require( '@stdlib/array/float32' ); +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 strsv = tryRequire( resolve( __dirname, './../lib/strsv.native.js' ) ); +var opts = { + 'skip': ( strsv instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof strsv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', opts, function test( t ) { + t.strictEqual( strsv.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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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 Float32Array( data.A ); + x = new Float32Array( data.x ); + + expected = new Float32Array( data.x_out ); + + out = strsv( 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(); +});