diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/README.md b/lib/node_modules/@stdlib/lapack/base/dlaset/README.md index 1db695aa3218..767600c46ba4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/README.md @@ -176,21 +176,70 @@ console.log( ndarray2array( A, shape, strides, 0, order ) ); ### Usage ```c -TODO +#include "stdlib/lapack/base/dlaset.h" ``` -#### TODO +#### c_dlaset( layout, uplo, M, N, alpha, beta, \*A, LDA ) -TODO. +Sets the off-diagonal elements and the diagonal elements of a double-precision floating-point matrix to specified values. ```c -TODO +#include "stdlib/lapack/base/dlaset.h" +#include "stdlib/lapack/base/shared.h" + +double A[] = { + 1.0, 2.0, + 3.0, 4.0 +}; + +c_dlaset( LAPACK_ROW_MAJOR, -1, 2, 2, 1.0, 2.0, A, 2 ); ``` -TODO +The function accepts the following arguments: + +- **layout**: `[in] LAPACK_LAYOUT` storage layout. +- **uplo**: `[in] int` specifies whether to set the upper or lower triangular/trapezoidal part of a matrix `A`. +- **M**: `[in] LAPACK_INT` number of rows in `A`. +- **N**: `[in] LAPACK_INT` number of columns in `A`. +- **alpha**: `[in] double` value assigned to off-diagonal elements. +- **beta**: `[in] double` value assigned to diagonal elements. +- **A**: `[out] double*` output matrix. +- **LDA**: `[in] LAPACK_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). + +```c +LAPACK_INT c_dlaset( const LAPACK_LAYOUT layout, const int uplo, const LAPACK_INT M, const LAPACK_INT N, const double alpha, const double beta, double *A, const LAPACK_INT LDA ); +``` + +#### c_dlaset_ndarray( uplo, M, N, alpha, beta, \*A, sa1, sa2, oa ) + +Sets the off-diagonal elements and the diagonal elements of a double-precision floating-point matrix to specified values using alternative indexing semantics. + +```c +#include "stdlib/lapack/base/dlaset.h" +#include "stdlib/lapack/base/shared.h" + +double A[] = { + 1.0, 2.0, + 3.0, 4.0 +}; + +c_dlaset_ndarray( -1, 2, 2, 1.0, 2.0, A, 2, 1, 0 ); +``` + +The function accepts the following arguments: + +- **uplo**: `[in] int` specifies whether to set the upper or lower triangular/trapezoidal part of a matrix `A`. +- **M**: `[in] LAPACK_INT` number of rows in `A`. +- **N**: `[in] LAPACK_INT` number of columns in `A`. +- **alpha**: `[in] double` value assigned to off-diagonal elements. +- **beta**: `[in] double` value assigned to diagonal elements. +- **A**: `[out] double*` output matrix. +- **sa1**: `[in] LAPACK_INT` stride of the first dimension of `A`. +- **sa2**: `[in] LAPACK_INT` stride of the second dimension of `A`. +- **oa**: `[in] LAPACK_INT` starting index for `A`. ```c -TODO +LAPACK_INT c_dlaset_ndarray( const int uplo, const LAPACK_INT M, const LAPACK_INT N, const double alpha, const double beta, double *A, const LAPACK_INT strideA1, const LAPACK_INT strideA2, const LAPACK_INT offsetA ); ``` @@ -212,7 +261,42 @@ TODO ### Examples ```c -TODO +#include "stdlib/lapack/base/dlaset.h" +#include "stdlib/lapack/base/shared.h" +#include + +int main( void ) { + // Define a 3x3 matrix: + double A[ 3*3 ] = { + 1.0, 2.0, 3.0, + 4.0, 5.0, 6.0, + 7.0, 8.0, 9.0 + }; + + // Specify the number of elements along each dimension of `A`: + const int M = 3; + const int N = 3; + + // Set elements of the upper triangle of `A` to 1.0 (off-diagonal) and 2.0 (diagonal): + c_dlaset( LAPACK_ROW_MAJOR, LAPACK_UPPER_TRIANGLE, M, N, 1.0, 2.0, A, N ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + printf( "A[ %i, %i ] = %lf\n", i, j, A[ (i*N)+j ] ); + } + } + + // Set elements of the lower triangle of `A` to 3.0 (off-diagonal) and 4.0 (diagonal) using alternative indexing semantics: + c_dlaset_ndarray( LAPACK_LOWER_TRIANGLE, M, N, 3.0, 4.0, A, N, 1, 0 ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + printf( "A[ %i, %i ] = %lf\n", i, j, A[ (i*N)+j ] ); + } + } +} ``` diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/c/Makefile b/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/c/Makefile new file mode 100644 index 000000000000..c8f741a095c6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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.size.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/lapack/base/dlaset/benchmark/c/benchmark.size.c b/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/c/benchmark.size.c new file mode 100644 index 000000000000..5fd90f8ac49a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/c/benchmark.size.c @@ -0,0 +1,182 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/lapack/base/dlaset.h" +#include "stdlib/lapack/base/shared.h" +#include +#include +#include +#include +#include + +#define NAME "dlaset" +#define ITERATIONS 10000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param iterations number of iterations +* @param elapsed elapsed time in seconds +*/ +static void print_results( int iterations, double elapsed ) { + double rate = (double)iterations / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", iterations ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param N array dimension size +* @return elapsed time in seconds +*/ +static double benchmark1( int iterations, int N ) { + double elapsed; + double *A = (double*)malloc( N * N * sizeof(double) ); + double t; + int i; + + for ( i = 0; i < N * N; i++ ) { + A[ i ] = 0.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + c_dlaset( LAPACK_ROW_MAJOR, -1, N, N, 1.0, 2.0, A, N ); + if ( A[ 0 ] != 2.0 ) { + printf( "should not return unexpected value\n" ); + break; + } + } + elapsed = tic() - t; + if ( A[ 0 ] != 2.0 ) { + printf( "should not return unexpected value\n" ); + } + free( A ); + return elapsed; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param N array dimension size +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int N ) { + double elapsed; + double *A = (double*)malloc( N * N * sizeof(double) ); + double t; + int i; + + for ( i = 0; i < N * N; i++ ) { + A[ i ] = 0.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + c_dlaset_ndarray( -1, N, N, 1.0, 2.0, A, N, 1, 0 ); + if ( A[ 0 ] != 2.0 ) { + printf( "should not return unexpected value\n" ); + break; + } + } + elapsed = tic() - t; + if ( A[ 0 ] != 2.0 ) { + printf( "should not return unexpected value\n" ); + } + free( A ); + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int N; + int i; + int j; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + for ( i = MIN; i <= MAX; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:size=%d\n", NAME, N*N ); + elapsed = benchmark1( iter, N ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:ndarray:size=%d\n", NAME, N*N ); + elapsed = benchmark2( iter, N ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/binding.gyp b/lib/node_modules/@stdlib/lapack/base/dlaset/binding.gyp new file mode 100644 index 000000000000..60dce9d0b31a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/binding.gyp @@ -0,0 +1,265 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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/lapack/base/dlaset/examples/c/Makefile b/lib/node_modules/@stdlib/lapack/base/dlaset/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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/lapack/base/dlaset/examples/c/example.c b/lib/node_modules/@stdlib/lapack/base/dlaset/examples/c/example.c new file mode 100644 index 000000000000..7bcc72af3fe4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/examples/c/example.c @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/lapack/base/dlaset.h" +#include "stdlib/lapack/base/shared.h" +#include + +int main( void ) { + // Define a 3x3 matrix: + double A[ 3*3 ] = { + 1.0, 2.0, 3.0, + 4.0, 5.0, 6.0, + 7.0, 8.0, 9.0 + }; + + // Specify the number of elements along each dimension of `A`: + const int M = 3; + const int N = 3; + + // Set elements of the upper triangle of `A` to 1.0 (off-diagonal) and 2.0 (diagonal): + c_dlaset( LAPACK_ROW_MAJOR, LAPACK_UPPER_TRIANGLE, M, N, 1.0, 2.0, A, N ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + printf( "A[ %i, %i ] = %lf\n", i, j, A[ (i*N)+j ] ); + } + } + + // Set elements of the lower triangle of `A` to 3.0 (off-diagonal) and 4.0 (diagonal) using alternative indexing semantics: + c_dlaset_ndarray( LAPACK_LOWER_TRIANGLE, M, N, 3.0, 4.0, A, N, 1, 0 ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + printf( "A[ %i, %i ] = %lf\n", i, j, A[ (i*N)+j ] ); + } + } +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/include.gypi b/lib/node_modules/@stdlib/lapack/base/dlaset/include.gypi new file mode 100644 index 000000000000..dcb556d250e8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/include.gypi @@ -0,0 +1,70 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Note that nesting variables is required due to how GYP processes a configuration. Any variables defined within a nested 'variables' section is defined in the outer scope. Thus, conditions in the outer variable scope are free to use these variables without running into "variable undefined" errors. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +# +# Variable nesting hacks: +# +# [3]: https://chromium.googlesource.com/external/skia/gyp/+/master/common_variables.gypi +# [4]: https://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004 +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + 'variables': { + # Host BLAS library (to override -Dblas=): + 'blas%': '', + + # Path to BLAS library (to override -Dblas_dir=): + 'blas_dir%': '', + }, # end variables + + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '<@(blas_dir)', + ' [ 1.0, 2.0, 2.0, 1.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( 4 ); +* +* dlaset( 'row-major', 'upper', 2, 2, 2.0, 1.0, A, 2 ); +* // A => [ 1.0, 2.0, 0.0, 1.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( 4 ); +* +* dlaset( 'row-major', 'lower', 2, 2, 2.0, 1.0, A, 2 ); +* // A => [ 1.0, 0.0, 2.0, 1.0 ] +*/ +function dlaset( order, uplo, M, N, alpha, beta, A, LDA ) { + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( isRowMajor( order ) ) { + if ( LDA < N ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to %d. Value: `%d`.', N, LDA ) ); + } + } + addon( resolveOrder( order ), resolveTriangle( uplo ) || -1, M, N, alpha, beta, A, LDA ); // eslint-disable-line max-len + return A; +} + + +// EXPORTS // + +module.exports = dlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/native.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/native.js new file mode 100644 index 000000000000..b5ae0a6ffef6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/native.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dlaset = require( './dlaset.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( dlaset, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.native.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.native.js new file mode 100644 index 000000000000..42d1769a600d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.native.js @@ -0,0 +1,75 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 resolveTriangle = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Sets elements of matrix `A` to specified values using alternative indexing semantics. +* +* @param {string} uplo - specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {number} alpha - value to assign to off-diagonal elements +* @param {number} beta - value to assign to diagonal elements +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @returns {Float64Array} `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( 4 ); +* +* dlaset( 'all', 2, 2, 2.0, 1.0, A, 2, 1, 0 ); +* // A => [ 1.0, 2.0, 2.0, 1.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( 4 ); +* +* dlaset( 'upper', 2, 2, 2.0, 1.0, A, 2, 1, 0 ); +* // A => [ 1.0, 2.0, 0.0, 1.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( 4 ); +* +* dlaset( 'lower', 2, 2, 2.0, 1.0, A, 2, 1, 0 ); +* // A => [ 1.0, 0.0, 2.0, 1.0 ] +*/ +function dlaset( uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { + addon.ndarray( resolveTriangle( uplo ) || -1, M, N, alpha, beta, A, strideA1, strideA2, offsetA ); // eslint-disable-line max-len + return A; +} + + +// EXPORTS // + +module.exports = dlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/manifest.json b/lib/node_modules/@stdlib/lapack/base/dlaset/manifest.json new file mode 100644 index 000000000000..21c8e98e757c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/manifest.json @@ -0,0 +1,253 @@ +{ + "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/dlaset.c", + "./src/dlaset_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/lapack/base/shared", + "@stdlib/lapack/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dlaset.c", + "./src/dlaset_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/lapack/base/shared", + "@stdlib/lapack/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/dlaset.c", + "./src/dlaset_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/lapack/base/shared", + "@stdlib/lapack/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/dlaset.c", + "./src/dlaset_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/lapack/base/shared", + "@stdlib/lapack/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/dlaset.c", + "./src/dlaset_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/lapack/base/shared", + "@stdlib/lapack/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/dlaset.c", + "./src/dlaset_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/lapack/base/shared", + "@stdlib/lapack/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/dlaset.c", + "./src/dlaset_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/lapack/base/shared", + "@stdlib/lapack/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-strided-float64array2d" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/dlaset.c", + "./src/dlaset_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/lapack/base/shared", + "@stdlib/lapack/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/dlaset.c", + "./src/dlaset_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/lapack/base/shared", + "@stdlib/lapack/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + + { + "task": "build", + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/dlaset.c", + "./src/dlaset_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/lapack/base/shared", + "@stdlib/lapack/base/xerbla", + "@stdlib/ndarray/base/assert/is-row-major" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/package.json b/lib/node_modules/@stdlib/lapack/base/dlaset/package.json index b3441af8bcd6..7b452c1640e6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/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/lapack/base/dlaset/src/Makefile b/lib/node_modules/@stdlib/lapack/base/dlaset/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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/lapack/base/dlaset/src/addon.c b/lib/node_modules/@stdlib/lapack/base/dlaset/src/addon.c new file mode 100644 index 000000000000..945bde1fb0bb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/src/addon.c @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/lapack/base/dlaset.h" +#include "stdlib/lapack/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_int32.h" +#include "stdlib/napi/argv_double.h" +#include "stdlib/napi/argv_strided_float64array2d.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + CBLAS_INT sa1; + CBLAS_INT sa2; + + STDLIB_NAPI_ARGV( env, info, argv, argc, 8 ); + + STDLIB_NAPI_ARGV_INT32( env, layout, argv, 0 ); + STDLIB_NAPI_ARGV_INT32( env, uplo, argv, 1 ); + + STDLIB_NAPI_ARGV_INT64( env, M, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 3 ); + + STDLIB_NAPI_ARGV_DOUBLE( env, alpha, argv, 4 ); + STDLIB_NAPI_ARGV_DOUBLE( env, beta, argv, 5 ); + + STDLIB_NAPI_ARGV_INT64( env, LDA, argv, 7 ); + + if ( layout == LAPACK_COL_MAJOR ) { + sa1 = 1; + sa2 = LDA; + } else { // layout == LAPACK_ROW_MAJOR + sa1 = LDA; + sa2 = 1; + } + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, M, N, sa1, sa2, argv, 6 ); + + API_SUFFIX(c_dlaset)( layout, uplo, M, N, alpha, beta, A, LDA ); + + 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, 9 ); + + STDLIB_NAPI_ARGV_INT32( env, uplo, argv, 0 ); + + STDLIB_NAPI_ARGV_INT64( env, M, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 2 ); + + STDLIB_NAPI_ARGV_DOUBLE( env, alpha, argv, 3 ); + STDLIB_NAPI_ARGV_DOUBLE( env, beta, argv, 4 ); + + STDLIB_NAPI_ARGV_INT64( env, strideA1, argv, 6 ); + STDLIB_NAPI_ARGV_INT64( env, strideA2, argv, 7 ); + STDLIB_NAPI_ARGV_INT64( env, offsetA, argv, 8 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, A, M, N, strideA1, strideA2, argv, 5 ); + + API_SUFFIX(c_dlaset_ndarray)( uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ); + + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/src/dlaset.c b/lib/node_modules/@stdlib/lapack/base/dlaset/src/dlaset.c new file mode 100644 index 000000000000..5c3acbb65dc5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/src/dlaset.c @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/lapack/base/dlaset.h" +#include "stdlib/lapack/base/shared.h" +#include "stdlib/lapack/base/xerbla.h" + +/** +* Sets the off-diagonal elements and the diagonal elements of a double-precision floating-point matrix to specified values. +* +* @param layout storage layout +* @param uplo specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` +* @param M number of rows in matrix `A` +* @param N number of columns in matrix `A` +* @param alpha value assigned to off-diagonal elements +* @param beta value assigned to diagonal elements +* @param A input matrix +* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @return status code +*/ +LAPACK_INT API_SUFFIX(c_dlaset)( const LAPACK_LAYOUT layout, const int uplo, const LAPACK_INT M, const LAPACK_INT N, const double alpha, const double beta, double *A, const LAPACK_INT LDA ) { + LAPACK_INT sa1; + LAPACK_INT sa2; + + // Perform input argument validation... + if ( layout != LAPACK_ROW_MAJOR && layout != LAPACK_COL_MAJOR ) { + lapack_xerbla( "c_dlaset", -1 ); + return -1; + } + if ( layout == LAPACK_COL_MAJOR ) { + sa1 = 1; + sa2 = LDA; + } else { // layout == CblasRowMajor + sa1 = LDA; + sa2 = 1; + } + return API_SUFFIX(c_dlaset_ndarray)( uplo, M, N, alpha, beta, A, sa1, sa2, 0 ); +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/src/dlaset_ndarray.c b/lib/node_modules/@stdlib/lapack/base/dlaset/src/dlaset_ndarray.c new file mode 100644 index 000000000000..0751ce023bd7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/src/dlaset_ndarray.c @@ -0,0 +1,222 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/lapack/base/dlaset.h" +#include "stdlib/lapack/base/shared.h" +#include "stdlib/ndarray/base/assert/is_row_major.h" +#include + +// Define a macro for computing the minimum value: +#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) + +/** +* Sets the diagonal of a double-precision floating-point matrix `A` to a specified value. +* +* @param M number of rows in matrix `A` +* @param N number of columns in matrix `A` +* @param beta value assigned to diagonal elements +* @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` +*/ +static void set_diagonal( const LAPACK_INT M, const LAPACK_INT N, const double beta, double *A, const LAPACK_INT strideA1, const LAPACK_INT strideA2, const LAPACK_INT offsetA ) { + LAPACK_INT sa; + LAPACK_INT ia; + LAPACK_INT i; + LAPACK_INT n_diag; + + sa = strideA1 + strideA2; + ia = offsetA; + n_diag = MIN( M, N ); + for ( i = 0; i < n_diag; i++ ) { + A[ ia ] = beta; + ia += sa; + } +} + +/** +* Sets all elements of a double-precision floating-point matrix `A` to specified values. +* +* @param M number of rows in matrix `A` +* @param N number of columns in matrix `A` +* @param alpha value assigned to off-diagonal elements +* @param beta value assigned to diagonal elements +* @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` +* @return status code +*/ +static LAPACK_INT stdlib_lapack_base_set_all( const LAPACK_INT M, const LAPACK_INT N, const double alpha, const double beta, double *A, const LAPACK_INT strideA1, const LAPACK_INT strideA2, const LAPACK_INT offsetA ) { + int64_t sa[ 2 ]; + LAPACK_INT da0; + LAPACK_INT da1; + LAPACK_INT S0; + LAPACK_INT S1; + LAPACK_INT ia; + LAPACK_INT i0; + LAPACK_INT i1; + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + sa[ 0 ] = strideA1; + sa[ 1 ] = strideA2; + if ( stdlib_ndarray_is_row_major( 2, sa ) ) { + // For row-major matrices, the last dimension has the fastest changing index... + S0 = N; + S1 = M; + da0 = strideA2; // offset increment for innermost loop + da1 = strideA1 - ( S0*strideA2 ); // offset increment for outermost loop + } else { // column-major + // For column-major matrices, the first dimension has the fastest changing index... + S0 = M; + S1 = N; + da0 = strideA1; // offset increment for innermost loop + da1 = strideA2 - ( S0*strideA1 ); // offset increment for outermost loop + } + + // Set the pointer to the first indexed element... + ia = offsetA; + + // Iterate over the matrix dimensions... + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + A[ ia ] = alpha; + ia += da0; + } + ia += da1; + } + set_diagonal( M, N, beta, A, strideA1, strideA2, offsetA ); + return 0; +} + +/** +* Sets the upper triangular/trapezoidal part of a double-precision floating-point matrix `A` to specified values. +* +* @param M number of rows in matrix `A` +* @param N number of columns in matrix `A` +* @param alpha value assigned to off-diagonal elements +* @param beta value assigned to diagonal elements +* @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` +* @return status code +*/ +static LAPACK_INT stdlib_lapack_base_set_upper( const LAPACK_INT M, const LAPACK_INT N, const double alpha, const double beta, double *A, const LAPACK_INT strideA1, const LAPACK_INT strideA2, const LAPACK_INT offsetA ) { + int64_t sa[ 2 ]; + LAPACK_INT ia; + LAPACK_INT idx; + LAPACK_INT i0; + LAPACK_INT i1; + + ia = offsetA; + sa[ 0 ] = strideA1; + sa[ 1 ] = strideA2; + if ( stdlib_ndarray_is_row_major( 2, sa ) ) { + for ( i1 = 0; i1 < M; i1++ ) { + idx = ia + ( i1*strideA2 ); + for ( i0 = i1; i0 < N; i0++ ) { + A[ idx ] = alpha; + idx += strideA2; + } + ia += strideA1; + } + } else { + for ( i1 = 0; i1 < N; i1++ ) { + idx = ia; + for ( i0 = 0; i0 <= MIN( i1, M-1 ); i0++ ) { + A[ idx ] = alpha; + idx += strideA1; + } + ia += strideA2; + } + } + set_diagonal( M, N, beta, A, strideA1, strideA2, offsetA ); + return 0; +} + +/** +* Sets the lower triangular/trapezoidal part of a double-precision floating-point matrix `A` to specified values. +* +* @param M number of rows in matrix `A` +* @param N number of columns in matrix `A` +* @param alpha value assigned to off-diagonal elements +* @param beta value assigned to diagonal elements +* @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` +* @return status code +*/ +static LAPACK_INT stdlib_lapack_base_set_lower( const LAPACK_INT M, const LAPACK_INT N, const double alpha, const double beta, double *A, const LAPACK_INT strideA1, const LAPACK_INT strideA2, const LAPACK_INT offsetA ) { + int64_t sa[ 2 ]; + LAPACK_INT ia; + LAPACK_INT idx; + LAPACK_INT i0; + LAPACK_INT i1; + + ia = offsetA; + sa[ 0 ] = strideA1; + sa[ 1 ] = strideA2; + if ( stdlib_ndarray_is_row_major( 2, sa ) ) { + for ( i1 = 0; i1 < M; i1++ ) { + idx = ia; + for ( i0 = 0; i0 <= MIN( i1, N-1 ); i0++ ) { + A[ idx ] = alpha; + idx += strideA2; + } + ia += strideA1; + } + } else { + for ( i1 = 0; i1 < N; i1++ ) { + idx = ia + ( i1*strideA1 ); + for ( i0 = i1; i0 < M; i0++ ) { + A[ idx ] = alpha; + idx += strideA1; + } + ia += strideA2; + } + } + set_diagonal( M, N, beta, A, strideA1, strideA2, offsetA ); + return 0; +} + +/** +* Sets the off-diagonal elements and the diagonal elements of a double-precision floating-point matrix to specified values using alternative indexing semantics. +* +* @param uplo specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` +* @param M number of rows in matrix `A` +* @param N number of columns in matrix `A` +* @param alpha value assigned to off-diagonal elements +* @param beta value assigned to diagonal elements +* @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` +* @return status code +*/ +LAPACK_INT API_SUFFIX(c_dlaset_ndarray)( const int uplo, const LAPACK_INT M, const LAPACK_INT N, const double alpha, const double beta, double *A, const LAPACK_INT strideA1, const LAPACK_INT strideA2, const LAPACK_INT offsetA ) { + if ( uplo == LAPACK_UPPER_TRIANGLE ) { + return stdlib_lapack_base_set_upper( M, N, alpha, beta, A, strideA1, strideA2, offsetA ); + } + if ( uplo == LAPACK_LOWER_TRIANGLE ) { + return stdlib_lapack_base_set_lower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ); + } + return stdlib_lapack_base_set_all( M, N, alpha, beta, A, strideA1, strideA2, offsetA ); +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.dlaset.native.js b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.dlaset.native.js new file mode 100644 index 000000000000..99ffdedc0a07 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.dlaset.native.js @@ -0,0 +1,197 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dlaset = require( './../lib/dlaset.native.js' ); + + +// FIXTURES // + +var ALL_ROW_MAJOR = require( './fixtures/all_row_major.json' ); +var ALL_COL_MAJOR = require( './fixtures/all_col_major.json' ); +var LOWER_ROW_MAJOR = require( './fixtures/lower_row_major.json' ); +var LOWER_COL_MAJOR = require( './fixtures/lower_col_major.json' ); +var UPPER_ROW_MAJOR = require( './fixtures/upper_row_major.json' ); +var UPPER_COL_MAJOR = require( './fixtures/upper_col_major.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlaset, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( dlaset.length, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dlaset( value, 'all', 2, 2, 2.0, 3.0, A, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid sixth argument (row-major)', function test( t ) { + var values; + var A; + var i; + + values = [ + 0, + 1 + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dlaset( 'row-major', 'all', 2, 2, 2.0, 3.0, A, value ); + }; + } +}); + +tape( 'the function returns expected value when setting all values (row-major)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = ALL_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.order, data.uplo, data.M, data.N, data.alpha, data.beta, A, data.LDA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting all values (column-major)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = ALL_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.order, data.uplo, data.M, data.N, data.alpha, data.beta, A, data.LDA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting lower triangular values (row-major)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = LOWER_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.order, data.uplo, data.M, data.N, data.alpha, data.beta, A, data.LDA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting lower triangular values (column-major)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = LOWER_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.order, data.uplo, data.M, data.N, data.alpha, data.beta, A, data.LDA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting upper triangular values (row-major)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = UPPER_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.order, data.uplo, data.M, data.N, data.alpha, data.beta, A, data.LDA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting upper triangular values (column-major)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = UPPER_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.order, data.uplo, data.M, data.N, data.alpha, data.beta, A, data.LDA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.native.js b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.native.js new file mode 100644 index 000000000000..03b43c5d527a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.native.js @@ -0,0 +1,555 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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, id-length */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dlaset = require( './../lib/ndarray.native.js' ); + + +// FIXTURES // + +var ALL_ROW_MAJOR = require( './fixtures/all_row_major.json' ); +var ALL_COL_MAJOR = require( './fixtures/all_col_major.json' ); +var LOWER_ROW_MAJOR = require( './fixtures/lower_row_major.json' ); +var LOWER_COL_MAJOR = require( './fixtures/lower_col_major.json' ); +var UPPER_ROW_MAJOR = require( './fixtures/upper_row_major.json' ); +var UPPER_COL_MAJOR = require( './fixtures/upper_col_major.json' ); +var OFFSET_ALL_ROW_MAJOR = require( './fixtures/offsets/all_row_major.json' ); +var OFFSET_ALL_COL_MAJOR = require( './fixtures/offsets/all_col_major.json' ); +var OFFSET_LOWER_ROW_MAJOR = require( './fixtures/offsets/lower_row_major.json' ); +var OFFSET_LOWER_COL_MAJOR = require( './fixtures/offsets/lower_col_major.json' ); +var OFFSET_UPPER_ROW_MAJOR = require( './fixtures/offsets/upper_row_major.json' ); +var OFFSET_UPPER_COL_MAJOR = require( './fixtures/offsets/upper_col_major.json' ); +var MIXED_STRIDES_ALL_ROW_MAJOR = require( './fixtures/mixed_strides/all_row_major.json' ); +var MIXED_STRIDES_ALL_COL_MAJOR = require( './fixtures/mixed_strides/all_col_major.json' ); +var MIXED_STRIDES_LOWER_ROW_MAJOR = require( './fixtures/mixed_strides/lower_row_major.json' ); +var MIXED_STRIDES_LOWER_COL_MAJOR = require( './fixtures/mixed_strides/lower_col_major.json' ); +var MIXED_STRIDES_UPPER_ROW_MAJOR = require( './fixtures/mixed_strides/upper_row_major.json' ); +var MIXED_STRIDES_UPPER_COL_MAJOR = require( './fixtures/mixed_strides/upper_col_major.json' ); +var NEGATIVE_STRIDES_ALL_ROW_MAJOR = require( './fixtures/negative_strides/all_row_major.json' ); +var NEGATIVE_STRIDES_ALL_COL_MAJOR = require( './fixtures/negative_strides/all_col_major.json' ); +var NEGATIVE_STRIDES_LOWER_ROW_MAJOR = require( './fixtures/negative_strides/lower_row_major.json' ); +var NEGATIVE_STRIDES_LOWER_COL_MAJOR = require( './fixtures/negative_strides/lower_col_major.json' ); +var NEGATIVE_STRIDES_UPPER_ROW_MAJOR = require( './fixtures/negative_strides/upper_row_major.json' ); +var NEGATIVE_STRIDES_UPPER_COL_MAJOR = require( './fixtures/negative_strides/upper_col_major.json' ); +var LARGE_STRIDES_ALL_ROW_MAJOR = require( './fixtures/large_strides/all_row_major.json' ); +var LARGE_STRIDES_ALL_COL_MAJOR = require( './fixtures/large_strides/all_col_major.json' ); +var LARGE_STRIDES_LOWER_ROW_MAJOR = require( './fixtures/large_strides/lower_row_major.json' ); +var LARGE_STRIDES_LOWER_COL_MAJOR = require( './fixtures/large_strides/lower_col_major.json' ); +var LARGE_STRIDES_UPPER_ROW_MAJOR = require( './fixtures/large_strides/upper_row_major.json' ); +var LARGE_STRIDES_UPPER_COL_MAJOR = require( './fixtures/large_strides/upper_col_major.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlaset, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( dlaset.length, 9, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting all values (row-major)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = ALL_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting all values (column-major)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = ALL_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting lower triangular values (row-major)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = LOWER_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting lower triangular values (column-major)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = LOWER_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting upper triangular values (row-major)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = UPPER_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting upper triangular values (column-major)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = UPPER_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting all values (row-major) (offsets)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = OFFSET_ALL_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting all values (column-major) (offsets)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = OFFSET_ALL_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting lower triangular values (row-major) (offsets)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = OFFSET_LOWER_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting lower triangular values (column-major) (offsets)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = OFFSET_LOWER_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting upper triangular values (row-major) (offsets)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = OFFSET_UPPER_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting upper triangular values (column-major) (offsets)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = OFFSET_UPPER_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting all values (row-major) (mixed strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = MIXED_STRIDES_ALL_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting all values (column-major) (mixed strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = MIXED_STRIDES_ALL_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting lower triangular values (row-major) (mixed strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = MIXED_STRIDES_LOWER_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting lower triangular values (column-major) (mixed strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = MIXED_STRIDES_LOWER_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting upper triangular values (row-major) (mixed strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = MIXED_STRIDES_UPPER_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting upper triangular values (column-major) (mixed strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = MIXED_STRIDES_UPPER_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting all values (row-major) (negative strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = NEGATIVE_STRIDES_ALL_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting all values (column-major) (negative strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = NEGATIVE_STRIDES_ALL_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting lower triangular values (row-major) (negative strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = NEGATIVE_STRIDES_LOWER_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting lower triangular values (column-major) (negative strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = NEGATIVE_STRIDES_LOWER_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting upper triangular values (row-major) (negative strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = NEGATIVE_STRIDES_UPPER_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting upper triangular values (column-major) (negative strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = NEGATIVE_STRIDES_UPPER_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting all values (row-major) (large strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = LARGE_STRIDES_ALL_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting all values (column-major) (large strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = LARGE_STRIDES_ALL_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting lower triangular values (row-major) (large strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = LARGE_STRIDES_LOWER_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting lower triangular values (column-major) (large strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = LARGE_STRIDES_LOWER_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting upper triangular values (row-major) (large strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = LARGE_STRIDES_UPPER_ROW_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected value when setting upper triangular values (column-major) (large strides)', function test( t ) { + var expectedOut; + var actualOut; + var data; + var A; + + data = LARGE_STRIDES_UPPER_COL_MAJOR; + + A = new Float64Array( data.A ); + actualOut = dlaset( data.uplo, data.M, data.N, data.alpha, data.beta, A, data.strideA1, data.strideA2, data.offsetA ); + expectedOut = new Float64Array( data.A_out ); + + t.deepEqual( actualOut, expectedOut, 'returns expected value' ); + t.end(); +});