diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/README.md b/lib/node_modules/@stdlib/lapack/base/dlacpy/README.md index 33e43898d079..2505dc78f735 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacpy/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/README.md @@ -188,21 +188,68 @@ console.log( ndarray2array( B, shape, strides, 0, order ) ); ### Usage ```c -TODO +#include "stdlib/lapack/base/dlacpy.h" ``` -#### TODO +#### c_dlacpy( order, uplo, M, N, \*A, LDA, \*B, LDB ) -TODO. +Copies all or part of a matrix `A` to another matrix `B`. ```c -TODO +#include "stdlib/blas/base/shared.h" + +double A[] = { 1.0, 2.0, 3.0, 4.0 }; +double B[] = { 0.0, 0.0, 0.0, 0.0 }; + +c_dlacpy( CblasColMajor, CblasUpper, 2, 2, A, 2, B, 2 ); ``` -TODO +The function accepts the following arguments: + +- **order**: `[in] CBLAS_LAYOUT` storage layout of `A` and `B` +- **uplo**: `[in] CBLAS_UPLO` specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +- **M**: `[in] CBLAS_INT` number of rows in matrix `A` +- **N**: `[in] CBLAS_INT` number of columns in matrix `A` +- **A**: `[in] double*` input matrix +- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +- **B**: `[in] double*` output matrix +- **LDB**: `[in] CBLAS_INT` stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) ```c -TODO +void c_dlacpy( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT M, const CBLAS_INT N, double *A, const CBLAS_INT LDA, double *B, const CBLAS_INT LDB ) +``` + + + +#### c_dlacpy_ndarray( uplo, M, N, \*A, strideA1, strideA2, offsetA, \*B, strideB1, strideB2, offsetB ) + +Copies all or part of a matrix `A` to another matrix `B` using alternative indexing semantics. + +```c +#include "stdlib/blas/base/shared.h" + +double A[] = { 1.0, 2.0, 3.0, 4.0, 5.0 }; +double B[] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; + +c_dlacpy_ndarray( CblasUpper, 2, 2, A, 2, 1, 1, B, 2, 1, 2 ); +``` + +The function accepts the following arguments: + +- **uplo**: `[in] CBLAS_UPLO` specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +- **M**: `[in] CBLAS_INT` number of rows in matrix `A` +- **N**: `[in] CBLAS_INT` number of columns in matrix `A` +- **A**: `[in] double*` input matrix +- **strideA1**: `[in] CBLAS_INT` stride of the first dimension of `A` +- **strideA2**: `[in] CBLAS_INT` stride of the second dimension of `A` +- **offsetB**: `[in] CBLAS_INT` starting index for `A` +- **B**: `[in] double*` output matrix +- **strideB1**: `[in] CBLAS_INT` stride of the first dimension of `B` +- **strideB2**: `[in] CBLAS_INT` stride of the second dimension of `B` +- **offsetB**: `[in] CBLAS_INT` starting index for `B` + +```c +void c_dlacpy_ndarray( const CBLAS_UPLO uplo, const CBLAS_INT M, const CBLAS_INT N, double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *B, const CBLAS_INT strideB1, const CBLAS_INT strideB2, const CBLAS_INT offsetB ) ``` @@ -224,7 +271,35 @@ TODO ### Examples ```c -TODO +#include "stdlib/lapack/base/dlacpy.h" +#include "stdlib/blas/base/shared.h" + +int main( void ) { + // Create strided arrays: + const double A[] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; + double B[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + + // Specify the number of elements along each dimension of `A`: + const int N = 3; + + // Copies all or part of a matrix `A` to another matrix `B`: + c_dlacpy( CblasColMajor, CblasUpper, N, N, A, N, B, N ); + + // Print the result: + for ( int i = 0; i < N*N; i++ ) { + printf( "B[ %i ] = %f\n", i, B[ i ] ); + } + + // Copies all or part of a matrix `A` to another matrix `B` using alternative indexing semantics: + c_dlacpy_ndarray( CblasLower, N, N, A, 1, N, 0, B, 1, N, 0 ); + + // Print the result: + for ( int i = 0; i < N*N; i++ ) { + printf( "B[ %i ] = %f\n", i, B[ i ] ); + } + + return 0; +} ``` diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/benchmark.native.js new file mode 100644 index 000000000000..d1ee26fafa51 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/benchmark.native.js @@ -0,0 +1,114 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var dlacpy = tryRequire( resolve( __dirname, './../lib/dlacpy.native.js' ) ); +var opts = { + 'skip': ( dlacpy instanceof Error ) +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var options; + var A; + var B; + + options = { + 'dtype': 'float64' + }; + + A = uniform( N*N, -10.0, 10.0, options ); + B = uniform( N*N, -10.0, 10.0, options ); + 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 = dlacpy( 'column-major', 'all', N, N, A, N, B, N ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':native::order=column-major,size='+(N*N), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..24ae40b725aa --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,114 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( '@stdlib/lapack/base/dlacpy/package.json' ).name; + + +// VARIABLES // + +var dlacpy = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dlacpy instanceof Error ) +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var options; + var A; + var B; + + options = { + 'dtype': 'float64' + }; + + A = uniform( N*N, -10.0, 10.0, options ); + B = uniform( N*N, -10.0, 10.0, options ); + 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 = dlacpy( 'all', N, N, A, 1, N, 0, B, 1, N, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+'::native:ndarray:order=column-major,size='+(N*N), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/c/Makefile b/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/c/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/c/benchmark.c new file mode 100644 index 000000000000..08018eb6726a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/benchmark/c/benchmark.c @@ -0,0 +1,194 @@ +/** +* @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/lapack/base/dlacpy.h" +#include "stdlib/blas/base/shared.h" +#include +#include +#include +#include +#include + +#define NAME "dlacpy" +#define ITERATIONS 10000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param iterations number of iterations +* @param elapsed elapsed time in seconds +*/ +static void print_results( int iterations, double elapsed ) { + double rate = (double)iterations / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", iterations ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param N number of elements along each dimension +* @return elapsed time in seconds +*/ +static double benchmark1( int iterations, int N ) { + double elapsed; + double *A; + double *B; + double t; + int i; + + A = (double *)malloc( N*N * sizeof(double) ); + B = (double *)malloc( N*N * sizeof(double) ); + for ( i = 0; i < N*N; i++ ) { + A[ i ] = ( rand_double()*20.0 ) - 10.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_dlacpy( CblasColMajor, CblasUpper, N, N, A, N, B, N ); + if ( B[ 0 ] != B[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( B[ 0 ] != B[ 0 ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param N number of elements along each dimension +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int N ) { + double elapsed; + double *A; + double *B; + double t; + int i; + + A = (double *)malloc( N*N * sizeof(double) ); + B = (double *)malloc( N*N * sizeof(double) ); + for ( i = 0; i < N*N; i++ ) { + A[ i ] = ( rand_double()*20.0 ) - 10.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + c_dlacpy_ndarray( CblasUpper, N, N, A, N, 1, 0, B, N, 1, 0 ); + if ( A[ 0 ] != A[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( A[ 0 ] != A[ 0 ] ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int i; + int j; + int N; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + for ( i = MIN; i <= MAX; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:size=%d\n", NAME, N*N ); + elapsed = benchmark1( iter, N ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:ndarray:size=%d\n", NAME, N*N ); + elapsed = benchmark2( iter, N ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/binding.gyp b/lib/node_modules/@stdlib/lapack/base/dlacpy/binding.gyp new file mode 100644 index 000000000000..68a1ca11d160 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/binding.gyp @@ -0,0 +1,170 @@ +# @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', + + # 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 + }, # 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/dlacpy/examples/c/Makefile b/lib/node_modules/@stdlib/lapack/base/dlacpy/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/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/lapack/base/dlacpy/examples/c/example.c b/lib/node_modules/@stdlib/lapack/base/dlacpy/examples/c/example.c new file mode 100644 index 000000000000..065c11ff6d48 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/examples/c/example.c @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/lapack/base/dlacpy.h" +#include "stdlib/blas/base/shared.h" + +int main( void ) { + // Create strided arrays: + const double A[] = { 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 }; + double B[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + + // Specify the number of elements along each dimension of `A`: + const int N = 3; + + // Copies all or part of a matrix `A` to another matrix `B`: + c_dlacpy( CblasColMajor, CblasUpper, N, N, A, N, B, N ); + + // Print the result: + for ( int i = 0; i < N*N; i++ ) { + printf( "B[ %i ] = %f\n", i, B[ i ] ); + } + + // Copies all or part of a matrix `A` to another matrix `B` using alternative indexing semantics: + c_dlacpy_ndarray( CblasLower, N, N, A, 1, N, 0, B, 1, N, 0 ); + + // Print the result: + for ( int i = 0; i < N*N; i++ ) { + printf( "B[ %i ] = %f\n", i, B[ i ] ); + } + + return 0; +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/include.gypi b/lib/node_modules/@stdlib/lapack/base/dlacpy/include.gypi new file mode 100644 index 000000000000..ecfaf82a3279 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/include.gypi @@ -0,0 +1,53 @@ +# @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. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' [ 1.0, 2.0, 3.0, 4.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float64Array( 4 ); +* +* dlacpy( 'row-major', 'upper', 2, 2, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 0.0, 4.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float64Array( 4 ); +* +* dlacpy( 'row-major', 'lower', 2, 2, A, 2, B, 2 ); +* // B => [ 1.0, 0.0, 3.0, 4.0 ] +*/ +function dlacpy( order, uplo, M, N, A, LDA, B, LDB ) { + var resolvedUplo = resolveUplo( uplo ); + if ( resolvedUplo === null ) { + resolvedUplo = 0; // fallback + } + addon( resolveOrder( order ), resolvedUplo, M, N, A, LDA, B, LDB ); + return B; +} + + +// EXPORTS // + +module.exports = dlacpy; diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/native.js b/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/native.js new file mode 100644 index 000000000000..e5847913315c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/native.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dlacpy = require( './dlacpy.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( dlacpy, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlacpy; diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/ndarray.native.js b/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/ndarray.native.js new file mode 100644 index 000000000000..5434a7fa4880 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/ndarray.native.js @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolveUplo = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Copies all or part of a matrix `A` to another matrix `B` using alternative indexing semantics. +* +* @param {string} uplo - specifies whether to copy 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 {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} B - output matrix +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` +* @returns {Float64Array} `B` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var B = new Float64Array( 6 ); +* +* dlacpy( 'all', 2, 2, A, 2, 1, 1, B, 2, 1, 2 ); +* // B => [ 0.0, 0.0, 2.0, 3.0, 4.0, 5.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var B = new Float64Array( 6 ); +* +* dlacpy( 'upper', 2, 2, A, 2, 1, 1, B, 2, 1, 2 ); +* // B => [ 0.0, 0.0, 2.0, 3.0, 0.0, 5.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var B = new Float64Array( 6 ); +* +* dlacpy( 'lower', 2, 2, A, 2, 1, 1, B, 2, 1, 2 ); +* // B => [ 0.0, 0.0, 2.0, 0.0, 4.0, 5.0 ] +*/ +function dlacpy( uplo, M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params + var resolvedUplo = resolveUplo( uplo ); + if ( resolvedUplo === null ) { + resolvedUplo = 0; // fallback + } + addon.ndarray( resolvedUplo, M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); // eslint-disable-line max-len + return B; +} + + +// EXPORTS // + +module.exports = dlacpy; diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/manifest.json b/lib/node_modules/@stdlib/lapack/base/dlacpy/manifest.json new file mode 100644 index 000000000000..3d66828906cf --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/manifest.json @@ -0,0 +1,88 @@ +{ + "options": { + "task": "build" + }, + "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", + "wasm": false, + "src": [ + "./src/dlacpy.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/strided/base/stride2offset", + "@stdlib/math/base/special/fast/min", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "benchmark", + "wasm": false, + "src": [ + "./src/dlacpy.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/math/base/special/fast/min", + "@stdlib/ndarray/base/assert/is-row-major" + ] + }, + { + "task": "examples", + "wasm": false, + "src": [ + "./src/dlacpy.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/math/base/special/fast/min", + "@stdlib/ndarray/base/assert/is-row-major" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/package.json b/lib/node_modules/@stdlib/lapack/base/dlacpy/package.json index 7eed92e7512e..ac5f6ebc2f2d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacpy/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/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/dlacpy/src/Makefile b/lib/node_modules/@stdlib/lapack/base/dlacpy/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/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/lapack/base/dlacpy/src/addon.c b/lib/node_modules/@stdlib/lapack/base/dlacpy/src/addon.c new file mode 100644 index 000000000000..92c1e93f1686 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/src/addon.c @@ -0,0 +1,83 @@ +/** +* @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/lapack/base/dlacpy.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int32.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_float64array.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 8 ); + + STDLIB_NAPI_ARGV_INT32( env, order, 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_INT64( env, LDA, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, LDB, argv, 7 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, A, M*N, 1, argv, 4 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, B, M*N, 1, argv, 6 ); + + API_SUFFIX(c_dlacpy)( order, uplo, M, N, A, LDA, B, LDB ); + + 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_INT64( env, M, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, strideA1, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, strideA2, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, offsetA, argv, 6 ); + STDLIB_NAPI_ARGV_INT64( env, strideB1, argv, 8 ); + STDLIB_NAPI_ARGV_INT64( env, strideB2, argv, 9 ); + STDLIB_NAPI_ARGV_INT64( env, offsetB, argv, 10 ); + + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, A, M*N, 1, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, B, M*N, 1, argv, 7 ); + + API_SUFFIX(c_dlacpy_ndarray)( uplo, M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); + + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/src/dlacpy.c b/lib/node_modules/@stdlib/lapack/base/dlacpy/src/dlacpy.c new file mode 100644 index 000000000000..beabdceca981 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/src/dlacpy.c @@ -0,0 +1,212 @@ +/** +* @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/lapack/base/dlacpy.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" +#include "stdlib/math/base/special/fast/min.h" +#include "stdlib/ndarray/base/assert/is_row_major.h" + +/** +* Copies all of a matrix `A` to another matrix `B`. +* +* @param M number of rows in matrix `A` +* @param N number of columns in matrix `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 B output matrix +* @param strideB1 stride of the first dimension of `B` +* @param strideB2 stride of the second dimension of `B` +* @param offsetB starting index for `B` +*/ +void API_SUFFIX(c_copy_all)( const CBLAS_INT M, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *B, const CBLAS_INT strideB1, const CBLAS_INT strideB2, const CBLAS_INT offsetB ) { + CBLAS_INT ia; + CBLAS_INT ib; + CBLAS_INT i0; + CBLAS_INT i1; + + ia = offsetA; + ib = offsetB; + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = 0; i0 < N; i0++ ) { + B[ ib+(i0*strideB2) ] = A[ ia+(i0*strideA2) ]; + } + ia += strideA1; + ib += strideB1; + } + return; +} + +/** +* Copies all of a matrix `A` to another matrix `B`. +* +* @param M number of rows in matrix `A` +* @param N number of columns in matrix `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 B output matrix +* @param strideB1 stride of the first dimension of `B` +* @param strideB2 stride of the second dimension of `B` +* @param offsetB starting index for `B` +*/ +void API_SUFFIX(c_copy_upper)( const CBLAS_INT M, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *B, const CBLAS_INT strideB1, const CBLAS_INT strideB2, const CBLAS_INT offsetB ) { + CBLAS_INT ia; + CBLAS_INT ib; + CBLAS_INT i0; + CBLAS_INT i1; + + CBLAS_INT strides[] = { strideA1, strideA2 }; + + ia = offsetA; + ib = offsetB; + if ( stdlib_ndarray_is_row_major( 2, strides ) ) { + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = i1; i0 < N; i0++ ) { + B[ ib+(i0*strideB2) ] = A[ ia+(i0*strideA2) ]; + } + ia += strideA1; + ib += strideB1; + } + return; + } + + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = 0; i0 <= stdlib_base_fast_min( i1, M-1 ); i0++ ) { + B[ ib+(i0*strideB1) ] = A[ ia+(i0*strideA1) ]; + } + ia += strideA2; + ib += strideB2; + } + return; +} + +/** +* Copies all of a matrix `A` to another matrix `B`. +* +* @param M number of rows in matrix `A` +* @param N number of columns in matrix `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 B output matrix +* @param strideB1 stride of the first dimension of `B` +* @param strideB2 stride of the second dimension of `B` +* @param offsetB starting index for `B` +*/ +void API_SUFFIX(c_copy_lower)( const CBLAS_INT M, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *B, const CBLAS_INT strideB1, const CBLAS_INT strideB2, const CBLAS_INT offsetB ) { + CBLAS_INT ia; + CBLAS_INT ib; + CBLAS_INT i0; + CBLAS_INT i1; + + CBLAS_INT strides[] = { strideA1, strideA2 }; + + ia = offsetA; + ib = offsetB; + if ( stdlib_ndarray_is_row_major( 2, strides ) ) { + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = 0; i0 <= stdlib_base_fast_min( i1, N-1 ); i0++ ) { + B[ ib+(i0*strideB2) ] = A[ ia+(i0*strideA2) ]; + } + ia += strideA1; + ib += strideB1; + } + return; + } + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = i1; i0 < M; i0++ ) { + B[ ib+(i0*strideB1) ] = A[ ia+(i0*strideA1) ]; + } + ia += strideA2; + ib += strideB2; + } + return; +} + +/** +* Copies all or part of a matrix `A` to another matrix `B`. +* +* @param order storage layout of `A` and `B` +* @param uplo specifies whether to copy 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 A input matrix +* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param B output matrix +* @param LDB stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +*/ +void API_SUFFIX(c_dlacpy)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_INT M, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *B, const CBLAS_INT LDB ) { + CBLAS_INT sa1; + CBLAS_INT sa2; + CBLAS_INT sb1; + CBLAS_INT sb2; + + if ( order == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + sb1 = 1; + sb2 = LDB; + } else { // order === 'row-major' + if ( LDA < N ) { + return; + } + if ( LDB < N ) { + return; + } + sa1 = LDA; + sa2 = 1; + sb1 = LDB; + sb2 = 1; + } + API_SUFFIX(c_dlacpy_ndarray)( uplo, M, N, A, sa1, sa2, 0, B, sb1, sb2, 0 ); + return; +} + +/** +* Copies all or part of a matrix `A` to another matrix `B` using alternative indexing semantics. +* +* @private +* @param uplo specifies whether to copy 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 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 B output matrix +* @param strideB1 stride of the first dimension of `B` +* @param strideB2 stride of the second dimension of `B` +* @param offsetB starting index for `B` +*/ +void API_SUFFIX(c_dlacpy_ndarray)( const CBLAS_UPLO uplo, const CBLAS_INT M, const CBLAS_INT N, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *B, const CBLAS_INT strideB1, const CBLAS_INT strideB2, const CBLAS_INT offsetB ) { + if ( uplo == CblasUpper ) { + c_copy_upper( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); + return; + } + if ( uplo == CblasLower ) { + c_copy_lower( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); + return; + } + c_copy_all( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); + return; +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/test/test.dlacpy.native.js b/lib/node_modules/@stdlib/lapack/base/dlacpy/test/test.dlacpy.native.js new file mode 100644 index 000000000000..033d824e74fa --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/test/test.dlacpy.native.js @@ -0,0 +1,213 @@ +/** +* @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 tape = require( 'tape' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); +var str2enumLayout = require( '@stdlib/blas/base/layout-str2enum' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var dlacpy = tryRequire( resolve( __dirname, './../lib/dlacpy.native.js' ) ); +var opts = { + 'skip': ( dlacpy instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlacpy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', opts, function test( t ) { + t.strictEqual( dlacpy.length, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies all of a matrix `A` to another matrix `B` (row-major)', function test( t ) { + var opts; + var out; + var A; + var B; + var M; + var N; + + M = 5; + N = 8; + + opts = { + 'dtype': 'float64' + }; + + A = uniform( M*N, -10.0, 10.0, opts ); + B = new Float64Array( M*N ); + + out = dlacpy( str2enumLayout( 'row-major' ), str2enum( 'all' ), M, N, A, N, B, N ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies a part of a matrix `A` to another matrix `B` (row-major, upper)', opts, function test( t ) { + var options; + var out; + var A; + var B; + var M; + var N; + + M = 5; + N = 8; + + options = { + 'dtype': 'float64' + }; + + A = uniform( M*N, -10.0, 10.0, options ); + B = new Float64Array( M*N ); + + out = dlacpy( str2enumLayout( 'row-major' ), str2enum( 'lower' ), M, N, A, N, B, N ); + t.strictEqual( out, B, 'returns expected value' ); + + out = dlacpy( str2enumLayout( 'row-major' ), str2enum( 'upper' ), M, N, A, N, B, N ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies a part of a matrix `A` to another matrix `B` (row-major, lower)', opts, function test( t ) { + var options; + var out; + var A; + var B; + var M; + var N; + + M = 5; + N = 8; + + options = { + 'dtype': 'float64' + }; + + A = uniform( M*N, -10.0, 10.0, options ); + B = new Float64Array( M*N ); + + out = dlacpy( str2enumLayout( 'row-major' ), str2enum( 'upper' ), M, N, A, N, B, N ); + t.strictEqual( out, B, 'returns expected value' ); + + out = dlacpy( str2enumLayout( 'row-major' ), str2enum( 'lower' ), M, N, A, N, B, N ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies all of a matrix `A` to another matrix `B` (column-major)', function test( t ) { + var opts; + var out; + var A; + var B; + var M; + var N; + + M = 5; + N = 8; + + opts = { + 'dtype': 'float64' + }; + + A = uniform( M*N, -10.0, 10.0, opts ); + B = new Float64Array( M*N ); + + out = dlacpy( str2enumLayout( 'column-major' ), str2enum( 'all' ), M, N, A, M, B, M ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies a part of a matrix `A` to another matrix `B` (column-major, upper)', opts, function test( t ) { + var options; + var out; + var A; + var B; + var M; + var N; + + M = 5; + N = 8; + + options = { + 'dtype': 'float64' + }; + + A = uniform( M*N, -10.0, 10.0, options ); + B = new Float64Array( M*N ); + + out = dlacpy( str2enumLayout( 'column-major' ), str2enum( 'lower' ), M, N, A, M, B, M ); + t.strictEqual( out, B, 'returns expected value' ); + + out = dlacpy( str2enumLayout( 'column-major' ), str2enum( 'upper' ), M, N, A, M, B, M ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies a part of a matrix `A` to another matrix `B` (column-major, lower)', opts, function test( t ) { + var options; + var out; + var A; + var B; + var M; + var N; + + M = 5; + N = 8; + + options = { + 'dtype': 'float64' + }; + + A = uniform( M*N, -10.0, 10.0, options ); + B = new Float64Array( M*N ); + + out = dlacpy( str2enumLayout( 'column-major' ), str2enum( 'upper' ), M, N, A, M, B, M ); + t.strictEqual( out, B, 'returns expected value' ); + + out = dlacpy( str2enumLayout( 'column-major' ), str2enum( 'lower' ), M, N, A, M, B, M ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlacpy/test/test.js index 1f315ed93079..c451406f42ab 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacpy/test/test.js +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/test/test.js @@ -22,14 +22,14 @@ var tape = require( 'tape' ); var proxyquire = require( 'proxyquire' ); -var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var isBrowser = require( '@stdlib/assert/is-browser' ); var dlacpy = require( './../lib' ); // VARIABLES // var opts = { - 'skip': IS_BROWSER + 'skip': isBrowser }; diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/test/test.ndarray.native.js b/lib/node_modules/@stdlib/lapack/base/dlacpy/test/test.ndarray.native.js new file mode 100644 index 000000000000..2ae4824975b2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/test/test.ndarray.native.js @@ -0,0 +1,280 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var str2enum = require( '@stdlib/blas/base/matrix-triangle-str2enum' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var dlacpy = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dlacpy instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlacpy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', opts, function test( t ) { + t.strictEqual( dlacpy.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies all of a matrix `A` to another matrix `B` (row-major)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + + out = dlacpy( str2enum( 'all' ), 2, 3, A, 3, 1, 1, B, 3, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 16.0, 15.0, 14.0, 13.0, 12.0, 11.0 ] ); + + out = dlacpy( str2enum( 'all' ), 2, 3, A, -3, -1, 6, B, 3, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + + out = dlacpy( str2enum( 'all' ), 3, 2, A, 2, 1, 1, B, 2, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies part of a matrix `A` to another matrix `B` (row-major, upper)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 11.0, 12.0, 13.0, 0.0, 15.0, 16.0 ] ); + + out = dlacpy( str2enum( 'upper' ), 2, 3, A, 3, 1, 1, B, 3, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 13.0, 12.0, 11.0, 0.0, 15.0, 14.0 ] ); + + out = dlacpy( str2enum( 'upper' ), 2, 3, A, 3, -1, 3, B, 3, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 11.0, 12.0, 0.0, 14.0, 0.0, 0.0 ] ); + + out = dlacpy( str2enum( 'upper' ), 3, 2, A, 2, 1, 1, B, 2, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies part of a matrix `A` to another matrix `B` (row-major, lower)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 11.0, 0.0, 0.0, 14.0, 15.0, 0.0 ] ); + + out = dlacpy( str2enum( 'lower' ), 2, 3, A, 3, 1, 1, B, 3, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 14.0, 0.0, 0.0, 11.0, 12.0, 0.0 ] ); + + out = dlacpy( str2enum( 'lower' ), 2, 3, A, -3, 1, 4, B, 3, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 11.0, 0.0, 13.0, 14.0, 15.0, 16.0 ] ); + + out = dlacpy( str2enum( 'lower' ), 3, 2, A, 2, 1, 1, B, 2, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies all of a matrix `A` to another matrix `B` (column-major)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + + out = dlacpy( str2enum( 'all' ), 2, 3, A, 1, 2, 1, B, 1, 2, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 16.0, 15.0, 14.0, 13.0, 12.0, 11.0 ] ); + + out = dlacpy( str2enum( 'all' ), 2, 3, A, 1, 2, 1, B, -1, -2, 8 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + + out = dlacpy( str2enum( 'all' ), 3, 2, A, 1, 3, 1, B, 1, 3, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies part of a matrix `A` to another matrix `B` (column-major, upper)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 11.0, 0.0, 13.0, 14.0, 15.0, 16.0 ] ); + + out = dlacpy( str2enum( 'upper' ), 2, 3, A, 1, 2, 1, B, 1, 2, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 11.0, 14.0, 13.0, 16.0, 15.0 ] ); + + out = dlacpy( str2enum( 'upper' ), 2, 3, A, 1, 2, 1, B, -1, 2, 4 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 11.0, 0.0, 0.0, 14.0, 15.0, 0.0 ] ); + + out = dlacpy( str2enum( 'upper' ), 3, 2, A, 1, 3, 1, B, 1, 3, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies part of a matrix `A` to another matrix `B` (column-major, lower)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 11.0, 12.0, 0.0, 14.0, 0.0, 0.0 ] ); + + out = dlacpy( str2enum( 'lower' ), 2, 3, A, 1, 2, 1, B, 1, 2, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 14.0, 11.0, 12.0 ] ); + + out = dlacpy( str2enum( 'lower' ), 2, 3, A, 1, 2, 1, B, 1, -2, 7 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float64Array( [ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 11.0, 12.0, 13.0, 0.0, 15.0, 16.0 ] ); + + out = dlacpy( str2enum( 'lower' ), 3, 2, A, 1, 3, 1, B, 1, 3, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies all of a matrix `A` to another matrix `B` (column-major, lower, complex access patterns)', function test( t ) { + var out; + var A; + var B; + + /* eslint-disable array-element-newline, no-multi-spaces */ + + A = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, 2, 999, 3, + 999, 0, 999, 4, 999, 5, + 999, 0, 999, 0, 999, 6, + 999, 999, 999, 999, 999, 999 + ]); + B = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 999, 999, 999, 999, 999, + 999, 999, 999, 999, 999, 999, + 999, 999, 999, 999, 999, 999, + 999, 999, 999, 999, 999, 999 + ]); + + /* eslint-enable array-element-newline, no-multi-spaces */ + + out = dlacpy( str2enum( 'all' ), 3, 3, A, 2, 6, 7, B, 2, 6, 7 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +});