diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/README.md b/lib/node_modules/@stdlib/blas/ext/base/ctril/README.md new file mode 100644 index 000000000000..a1d4fcb78db3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/README.md @@ -0,0 +1,360 @@ + + +# ctril + +> Copy the lower triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. + +
+ +
+ + + +
+ +## Usage + +```javascript +var ctril = require( '@stdlib/blas/ext/base/ctril' ); +``` + +#### ctril( order, M, N, k, A, LDA, B, LDB ) + +Copies the lower triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var B = new Complex64Array( 4 ); + +ctril( 'row-major', 2, 2, 0, A, 2, B, 2 ); +// B => [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **k**: diagonal above which to ignore. A value of `k = 0` refers to the main diagonal, `k < 0` refers to a diagonal below the main diagonal, and `k > 0` refers to a diagonal above the main diagonal. Accordingly, when `k > 0`, the function copies the lower triangle **and** one or more super-diagonals (i.e., part of the upper triangle), and, when `k < 0`, the function copies only part of the lower triangle. +- **A**: input matrix. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **B**: output matrix. +- **LDB**: stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`). + +Setting the `k` parameter to a value other than `0` allows including and excluding super- and sub-diagonals, respectively. For example, to copy the lower triangle and the first super-diagonal, + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var B = new Complex64Array( 4 ); + +ctril( 'row-major', 2, 2, 1, A, 2, B, 2 ); +// B => [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +// Initial arrays... +var A0 = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); +var B0 = new Complex64Array( 5 ); + +// Create offset views... +var A1 = new Complex64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var B1 = new Complex64Array( B0.buffer, B0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +ctril( 'row-major', 2, 2, 0, A1, 2, B1, 2 ); +// B0 => [ 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0, 9.0, 10.0 ] +``` + +#### ctril.ndarray( M, N, k, A, sa1, sa2, oa, B, sb1, sb2, ob ) + +Copies the lower triangular part of a single-precision complex floating-point matrix `A` to another matrix `B` using alternative indexing semantics. + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var B = new Complex64Array( 4 ); + +ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); +// B => [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] +``` + +The function has the following parameters: + +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **k**: diagonal above which to ignore. +- **A**: input matrix. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. +- **B**: output matrix. +- **sb1**: stride of the first dimension of `B`. +- **sb2**: stride of the second dimension of `B`. +- **ob**: starting index for `B`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + + + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 2 ); +// B => [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] +``` + +
+ + + +
+ +## Notes + +- Elements outside of the copied region are left unchanged. + +
+ + + +
+ +## Examples + + + +```javascript +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var uniform = require( '@stdlib/random/array/discrete-uniform' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var ctril = require( '@stdlib/blas/ext/base/ctril' ); + +var shape = [ 5, 8 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var N = numel( shape ); + +var opts = { + 'dtype': 'float32' +}; +var A = new Complex64Array( uniform( N*2, -10, 10, opts ) ); +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var B = new Complex64Array( uniform( N*2, -10, 10, opts ) ); +console.log( ndarray2array( B, shape, strides, 0, order ) ); + +ctril( order, shape[ 0 ], shape[ 1 ], 0, A, strides[ 0 ], B, strides[ 0 ] ); +console.log( ndarray2array( B, shape, strides, 0, order ) ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/ext/base/ctril.h" +``` + +#### stdlib_strided_ctril( layout, M, N, k, \*A, LDA, \*B, LDB ) + +Copies the lower triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. + +```c +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float32/ctor.h" + +const float A[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; +float B[] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + +stdlib_strided_ctril( CblasRowMajor, 2, 2, 0, (stdlib_complex64_t *)A, 2, (stdlib_complex64_t *)B, 2 ); +``` + +The function accepts the following arguments: + +- **layout**: `[in] CBLAS_LAYOUT` storage layout. +- **M**: `[in] CBLAS_INT` number of rows in `A`. +- **N**: `[in] CBLAS_INT` number of columns in `A`. +- **k**: `[in] CBLAS_INT` diagonal above which to ignore. +- **A**: `[in] stdlib_complex64_t*` input matrix. +- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **B**: `[out] stdlib_complex64_t*` output matrix. +- **LDB**: `[in] CBLAS_INT` stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`). + +```c +void API_SUFFIX(stdlib_strided_ctril)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const CBLAS_INT k, const stdlib_complex64_t *A, const CBLAS_INT LDA, stdlib_complex64_t *B, const CBLAS_INT LDB ); +``` + +#### stdlib_strided_ctril_ndarray( M, N, k, \*A, sa1, sa2, oa, \*B, sb1, sb2, ob ) + +Copies the lower triangular part of a single-precision complex floating-point matrix `A` to another matrix `B` using alternative indexing semantics. + +```c +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float32/ctor.h" + +const float A[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; +float B[] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + +stdlib_strided_ctril_ndarray( 2, 2, 0, (stdlib_complex64_t *)A, 2, 1, 0, (stdlib_complex64_t *)B, 2, 1, 0 ); +``` + +The function accepts the following arguments: + +- **M**: `[in] CBLAS_INT` number of rows in `A`. +- **N**: `[in] CBLAS_INT` number of columns in `A`. +- **k**: `[in] CBLAS_INT` diagonal above which to ignore. +- **A**: `[in] stdlib_complex64_t*` input matrix. +- **sa1**: `[in] CBLAS_INT` stride of the first dimension of `A`. +- **sa2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **oa**: `[in] CBLAS_INT` starting index for `A`. +- **B**: `[out] stdlib_complex64_t*` output matrix. +- **sb1**: `[in] CBLAS_INT` stride of the first dimension of `B`. +- **sb2**: `[in] CBLAS_INT` stride of the second dimension of `B`. +- **ob**: `[in] CBLAS_INT` starting index for `B`. + +```c +void API_SUFFIX(stdlib_strided_ctril_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const CBLAS_INT k, const stdlib_complex64_t *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, stdlib_complex64_t *B, const CBLAS_INT strideB1, const CBLAS_INT strideB2, const CBLAS_INT offsetB ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/ext/base/ctril.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float32/ctor.h" +#include + +int main( void ) { + // Define a 3x3 input matrix stored in row-major order: + const float A[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f }; + + // Define a 3x3 output matrix: + float B[] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + + // Specify the number of elements along each dimension of `A`: + const CBLAS_INT M = 3; + const CBLAS_INT N = 3; + + // Copy the lower triangular part of `A` to `B`: + stdlib_strided_ctril( CblasRowMajor, M, N, 0, (stdlib_complex64_t *)A, N, (stdlib_complex64_t *)B, N ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + int idx = ( (i*N) + j ) * 2; + printf( "B[ %i,%i ] = %f + %fi\n", i, j, B[ idx ], B[ idx+1 ] ); + } + } + + // Copy the lower triangular part of `A`, including the first super-diagonal, to `B` using alternative indexing semantics: + stdlib_strided_ctril_ndarray( M, N, 1, (stdlib_complex64_t *)A, N, 1, 0, (stdlib_complex64_t *)B, N, 1, 0 ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + int idx = ( (i*N) + j ) * 2; + printf( "B[ %i,%i ] = %f + %fi\n", i, j, B[ idx ], B[ idx+1 ] ); + } + } +} +``` + +
+ + + +
+ + + +
+ +
+ + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/benchmark.js new file mode 100644 index 000000000000..9ee2d8f34b27 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/benchmark.js @@ -0,0 +1,113 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var realf = require( '@stdlib/complex/float32/real' ); +var zeros = require( '@stdlib/array/zeros' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var ctril = require( './../lib' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var A = zeros( N*N, 'complex64' ); + var B = zeros( N*N, 'complex64' ); + 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 = ctril( order, N, N, 0, A, N, B, N ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( isnanf( realf( z.get( 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 ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::square_matrix:order=%s,size=%d', pkg, ord, N*N ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/benchmark.native.js new file mode 100644 index 000000000000..66cb36ecd4eb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/benchmark.native.js @@ -0,0 +1,118 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var realf = require( '@stdlib/complex/float32/real' ); +var zeros = require( '@stdlib/array/zeros' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var ctril = tryRequire( resolve( __dirname, './../lib/ctril.native.js' ) ); +var opts = { + 'skip': ( ctril instanceof Error ) +}; +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var A = zeros( N*N, 'complex64' ); + var B = zeros( N*N, 'complex64' ); + 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 = ctril( order, N, N, 0, A, N, B, N ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( isnanf( realf( z.get( 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 ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::native,square_matrix:order=%s,size=%d', pkg, ord, N*N ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..4e19d158a23b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/benchmark.ndarray.js @@ -0,0 +1,127 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var realf = require( '@stdlib/complex/float32/real' ); +var zeros = require( '@stdlib/array/zeros' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var ctril = require( './../lib' ).ndarray; + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var sa1; + var sa2; + var A; + var B; + + A = zeros( N*N, 'complex64' ); + B = zeros( N*N, 'complex64' ); + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + } else { // order === 'row-major' + sa1 = N; + sa2 = 1; + } + 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 = ctril( N, N, 0, A, sa1, sa2, 0, B, sa1, sa2, 0 ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( isnanf( realf( z.get( 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 ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::square_matrix:ndarray:order=%s,size=%d', pkg, ord, N*N ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..bbed0ee08f86 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,132 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var realf = require( '@stdlib/complex/float32/real' ); +var zeros = require( '@stdlib/array/zeros' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var ctril = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( ctril instanceof Error ) +}; +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var sa1; + var sa2; + var A; + var B; + + A = zeros( N*N, 'complex64' ); + B = zeros( N*N, 'complex64' ); + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + } else { // order === 'row-major' + sa1 = N; + sa2 = 1; + } + 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 = ctril( N, N, 0, A, sa1, sa2, 0, B, sa1, sa2, 0 ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( isnanf( realf( z.get( 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 ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::native,square_matrix:ndarray:order=%s,size=%d', pkg, ord, N*N ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/c/Makefile new file mode 100644 index 000000000000..0756dc7da20a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/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.length.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..73e63e860230 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/benchmark/c/benchmark.length.c @@ -0,0 +1,212 @@ +/** +* @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/blas/ext/base/ctril.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float32/ctor.h" +#include +#include +#include +#include +#include + +#define NAME "ctril" +#define ITERATIONS 1000000 +#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 [min,max). +* +* @param min minimum value (inclusive) +* @param max maximum value (exclusive) +* @return random number +*/ +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v*(max-min) ); +} + +/** +* 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; + float *A; + float *B; + double t; + int i; + + A = (float *)malloc( 2 * N * N * sizeof( float ) ); + B = (float *)malloc( 2 * N * N * sizeof( float ) ); + for ( i = 0; i < 2 * N * N; i++ ) { + A[ i ] = (float)random_uniform( -10.0, 10.0 ); + B[ i ] = 0.0f; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + stdlib_strided_ctril( CblasRowMajor, N, N, 0, (stdlib_complex64_t *)A, N, (stdlib_complex64_t *)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" ); + } + free( A ); + free( B ); + 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; + float *A; + float *B; + double t; + int i; + + A = (float *)malloc( 2 * N * N * sizeof( float ) ); + B = (float *)malloc( 2 * N * N * sizeof( float ) ); + for ( i = 0; i < 2 * N * N; i++ ) { + A[ i ] = (float)random_uniform( -10.0, 10.0 ); + B[ i ] = 0.0f; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + stdlib_strided_ctril_ndarray( N, N, 0, (stdlib_complex64_t *)A, N, 1, 0, (stdlib_complex64_t *)B, N, 1, 0 ); + 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" ); + } + free( A ); + free( B ); + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int len; + 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++ ) { + len = pow( 10, i ); + N = (int)sqrt( (double)len ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s::square_matrix:order=row-major,size=%d\n", NAME, N*N ); + elapsed = benchmark1( iter, N ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + N = (int)sqrt( (double)len ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s::square_matrix:ndarray:order=row-major,size=%d\n", NAME, N*N ); + elapsed = benchmark2( iter, N ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/binding.gyp b/lib/node_modules/@stdlib/blas/ext/base/ctril/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/binding.gyp @@ -0,0 +1,170 @@ +# @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', + + # 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/blas/ext/base/ctril/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ctril/docs/repl.txt new file mode 100644 index 000000000000..161b26cc08b5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/docs/repl.txt @@ -0,0 +1,113 @@ + +{{alias}}( order, M, N, k, A, LDA, B, LDB ) + Copies the lower triangular part of a single-precision complex floating- + point matrix `A` to another matrix `B`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + The diagonal parameter `k` specifies the diagonal above which to ignore. A + value of `k = 0` refers to the main diagonal, `k < 0` refers to a diagonal + below the main diagonal, and `k > 0` refers to a diagonal above the main + diagonal. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + k: integer + Diagonal above which to ignore. + + A: Complex64Array + Input matrix `A`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + B: Complex64Array + Output matrix `B`. + + LDB: integer + Stride of the first dimension of `B` (a.k.a., leading dimension of the + matrix `B`). + + Returns + ------- + B: Complex64Array + Output matrix. + + Examples + -------- + > var A = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var B = new {{alias:@stdlib/array/complex64}}( 4 ); + > {{alias}}( 'row-major', 2, 2, 0, A, 2, B, 2 ) + [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] + + +{{alias}}.ndarray( M, N, k, A, sa1, sa2, oa, B, sb1, sb2, ob ) + Copies the lower triangular part of a single-precision complex floating- + point matrix `A` to another matrix `B` using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + k: integer + Diagonal above which to ignore. + + A: Complex64Array + Input matrix `A`. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: integer + Starting index for `A`. + + B: Complex64Array + Output matrix `B`. + + sb1: integer + Stride of the first dimension of `B`. + + sb2: integer + Stride of the second dimension of `B`. + + ob: integer + Starting index for `B`. + + Returns + ------- + B: Complex64Array + Output matrix. + + Examples + -------- + > var A = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var B = new {{alias:@stdlib/array/complex64}}( 4 ); + > {{alias}}.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ) + [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ctril/docs/types/index.d.ts new file mode 100644 index 000000000000..c0bb920dc0ae --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/docs/types/index.d.ts @@ -0,0 +1,118 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout } from '@stdlib/types/blas'; +import { Complex64Array } from '@stdlib/types/array'; + +/** +* Interface describing `ctril`. +*/ +interface Routine { + /** + * Copies the lower triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. + * + * @param order - storage layout of `A` and `B` + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param k - diagonal above which to ignore + * @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`) + * @returns `B` + * + * @example + * var Complex64Array = require( '@stdlib/array/complex64' ); + * + * var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + * var B = new Complex64Array( 4 ); + * + * ctril( 'row-major', 2, 2, 0, A, 2, B, 2 ); + * // B => [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] + */ + ( order: Layout, M: number, N: number, k: number, A: Complex64Array, LDA: number, B: Complex64Array, LDB: number ): Complex64Array; + + /** + * Copies the lower triangular part of a single-precision complex floating-point matrix `A` to another matrix `B` using alternative indexing semantics. + * + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param k - diagonal above which to ignore + * @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` + * @returns `B` + * + * @example + * var Complex64Array = require( '@stdlib/array/complex64' ); + * + * var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + * var B = new Complex64Array( 4 ); + * + * ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); + * // B => [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] + */ + ndarray( M: number, N: number, k: number, A: Complex64Array, strideA1: number, strideA2: number, offsetA: number, B: Complex64Array, strideB1: number, strideB2: number, offsetB: number ): Complex64Array; +} + +/** +* Copies the lower triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. +* +* @param order - storage layout of `A` and `B` +* @param M - number of rows in matrix `A` +* @param N - number of columns in matrix `A` +* @param k - diagonal above which to ignore +* @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`) +* @returns `B` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctril( 'row-major', 2, 2, 0, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] +*/ +declare var ctril: Routine; + + +// EXPORTS // + +export = ctril; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ctril/docs/types/test.ts new file mode 100644 index 000000000000..37c1ec316811 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/docs/types/test.ts @@ -0,0 +1,355 @@ +/* +* @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. +*/ + +import Complex64Array = require( '@stdlib/array/complex64' ); +import ctril = require( './index' ); + + +// TESTS // + +// The function returns a Complex64Array... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril( 'row-major', 2, 2, 0, A, 2, B, 2 ); // $ExpectType Complex64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a valid order... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril( 5, 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( true, 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( false, 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( null, 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( void 0, 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( [], 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( {}, 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( ( x: number ): number => x, 2, 2, 0, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril( 'row-major', '5', 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', true, 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', false, 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', null, 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', void 0, 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', [], 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', {}, 2, 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', ( x: number ): number => x, 2, 0, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril( 'row-major', 2, '5', 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, true, 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, false, 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, null, 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, void 0, 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, [], 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, {}, 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, ( x: number ): number => x, 0, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril( 'row-major', 2, 2, '5', A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, true, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, false, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, null, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, void 0, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, [], A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, {}, A, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, ( x: number ): number => x, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Complex64Array... +{ + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril( 'row-major', 2, 2, 0, 5, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, true, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, false, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, null, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, void 0, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, [], 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, {}, 2, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, ( x: number ): number => x, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril( 'row-major', 2, 2, 0, A, '5', B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, true, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, false, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, null, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, void 0, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, [], B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, {}, B, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, ( x: number ): number => x, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Complex64Array... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + ctril( 'row-major', 2, 2, 0, A, 2, 5, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, true, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, false, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, null, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, void 0, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, [], 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, {}, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, ( x: number ): number => x, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril( 'row-major', 2, 2, 0, A, 2, B, '5' ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, B, true ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, B, false ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, B, null ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, B, void 0 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, B, [] ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, B, {} ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, B, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril(); // $ExpectError + ctril( 'row-major' ); // $ExpectError + ctril( 'row-major', 2 ); // $ExpectError + ctril( 'row-major', 2, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2 ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, B ); // $ExpectError + ctril( 'row-major', 2, 2, 0, A, 2, B, 2, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Complex64Array... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectType Complex64Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril.ndarray( '5', 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( true, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( false, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( null, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( void 0, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( [], 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( {}, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( ( x: number ): number => x, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril.ndarray( 2, '5', 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, true, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, false, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, null, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, void 0, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, [], 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, {}, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, ( x: number ): number => x, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril.ndarray( 2, 2, '5', A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, true, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, false, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, null, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, void 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, [], A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, {}, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, ( x: number ): number => x, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a Complex64Array... +{ + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril.ndarray( 2, 2, 0, 5, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, true, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, false, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, null, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, void 0, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, [], 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, {}, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, ( x: number ): number => x, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril.ndarray( 2, 2, 0, A, '5', 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, true, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, false, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, null, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, void 0, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, [], 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, {}, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, ( x: number ): number => x, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril.ndarray( 2, 2, 0, A, 2, '5', 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, true, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, false, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, null, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, void 0, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, [], 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, {}, 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, ( x: number ): number => x, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril.ndarray( 2, 2, 0, A, 2, 1, '5', B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, true, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, false, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, null, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, void 0, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, [], B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, {}, B, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, ( x: number ): number => x, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a Complex64Array... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, 5, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, true, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, false, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, null, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, void 0, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, [], 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, {}, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, ( x: number ): number => x, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, '5', 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, true, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, false, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, null, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, void 0, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, [], 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, {}, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, '5', 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, true, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, false, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, null, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, void 0, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, [], 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, {}, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eleventh argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, '5' ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, true ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, false ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, null ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, void 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, [] ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, {} ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctril.ndarray(); // $ExpectError + ctril.ndarray( 2 ); // $ExpectError + ctril.ndarray( 2, 2 ); // $ExpectError + ctril.ndarray( 2, 2, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1 ); // $ExpectError + ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0, 0 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/examples/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/ctril/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/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/blas/ext/base/ctril/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/ctril/examples/c/example.c new file mode 100644 index 000000000000..23ca19119e20 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/examples/c/example.c @@ -0,0 +1,56 @@ +/** +* @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/blas/ext/base/ctril.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float32/ctor.h" +#include + +int main( void ) { + // Define a 3x3 input matrix stored in row-major order: + const float A[ 3*3*2 ] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f }; + + // Define a 3x3 output matrix: + float B[ 3*3*2 ] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + + // Specify the number of elements along each dimension of `A`: + const CBLAS_INT M = 3; + const CBLAS_INT N = 3; + + // Copy the lower triangular part of `A` to `B`: + stdlib_strided_ctril( CblasRowMajor, M, N, 0, (stdlib_complex64_t *)A, N, (stdlib_complex64_t *)B, N ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + int idx = ( (i*N) + j ) * 2; + printf( "B[ %i,%i ] = %f + %fi\n", i, j, B[ idx ], B[ idx+1 ] ); + } + } + + // Copy the lower triangular part of `A`, including the first sub-diagonal, to `B` using alternative indexing semantics: + stdlib_strided_ctril_ndarray( M, N, -1, (stdlib_complex64_t *)A, N, 1, 0, (stdlib_complex64_t *)B, N, 1, 0 ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + int idx = ( (i*N) + j ) * 2; + printf( "B[ %i,%i ] = %f + %fi\n", i, j, B[ idx ], B[ idx+1 ] ); + } + } +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/examples/index.js new file mode 100644 index 000000000000..a2db87052d80 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/examples/index.js @@ -0,0 +1,44 @@ +/** +* @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'; + +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var uniform = require( '@stdlib/random/array/discrete-uniform' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var ctril = require( './../lib' ); + +var shape = [ 5, 8 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var N = numel( shape ); + +var opts = { + 'dtype': 'float32' +}; +var A = new Complex64Array( uniform( N*2, -10, 10, opts ) ); +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var B = new Complex64Array( uniform( N*2, -10, 10, opts ) ); +console.log( ndarray2array( B, shape, strides, 0, order ) ); + +ctril( order, shape[ 0 ], shape[ 1 ], 0, A, strides[ 0 ], B, strides[ 0 ] ); +console.log( ndarray2array( B, shape, strides, 0, order ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/ctril/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/include.gypi @@ -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. + +# 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, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctril( 2, 2, 1, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] +*/ +function ctril( M, N, k, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { + var viewA; + var viewB; + var sa1; + var sa2; + var sb1; + var sb2; + var ia; + var ib; + var ja; + var jb; + var i0; + var i1; + + viewA = reinterpret( A, 0 ); + viewB = reinterpret( B, 0 ); + + sa1 = strideA1 * 2; + sa2 = strideA2 * 2; + sb1 = strideB1 * 2; + sb2 = strideB2 * 2; + ia = offsetA * 2; + ib = offsetB * 2; + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = 0; i0 <= min( i1+k, N-1 ); i0++ ) { + ja = ia + ( i0*sa2 ); + jb = ib + ( i0*sb2 ); + viewB[ jb ] = viewA[ ja ]; + viewB[ jb+1 ] = viewA[ ja+1 ]; + } + ia += sa1; + ib += sb1; + } + return B; + } + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = max( 0, i1-k ); i0 < M; i0++ ) { + ja = ia + ( i0*sa1 ); + jb = ib + ( i0*sb1 ); + viewB[ jb ] = viewA[ ja ]; + viewB[ jb+1 ] = viewA[ ja+1 ]; + } + ia += sa2; + ib += sb2; + } + return B; +} + + +// EXPORTS // + +module.exports = ctril; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/ctril.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/ctril.js new file mode 100644 index 000000000000..4f209ce3e5dd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/ctril.js @@ -0,0 +1,105 @@ +/** +* @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 isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Copies the lower triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. +* +* @param {string} order - storage layout of `A` and `B` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {integer} k - diagonal above which to ignore +* @param {Complex64Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Complex64Array} B - output matrix +* @param {PositiveInteger} LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} sixth argument must be a valid stride +* @throws {RangeError} eighth argument must be a valid stride +* @returns {Complex64Array} `B` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctril( 'row-major', 2, 2, 0, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctril( 'row-major', 2, 2, 1, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] +*/ +function ctril( order, M, N, k, A, LDA, B, LDB ) { + var isrm; + var sa1; + var sa2; + var sb1; + var sb2; + var s; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + isrm = isRowMajor( order ); + if ( isrm ) { + s = N; + } else { + s = M; + } + if ( LDA < max( 1, s ) ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); + } + if ( LDB < max( 1, s ) ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDB ) ); + } + if ( isrm ) { + sa1 = LDA; + sa2 = 1; + sb1 = LDB; + sb2 = 1; + } else { // order === 'column-major' + sa1 = 1; + sa2 = LDA; + sb1 = 1; + sb2 = LDB; + } + return base( M, N, k, A, sa1, sa2, 0, B, sb1, sb2, 0 ); +} + + +// EXPORTS // + +module.exports = ctril; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/ctril.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/ctril.native.js new file mode 100644 index 000000000000..0220b7f6d592 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/ctril.native.js @@ -0,0 +1,86 @@ +/** +* @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 isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var resolveOrder = require( '@stdlib/blas/base/layout-resolve-enum' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Copies the lower triangular part of a single-precision floating-point matrix `A` to another matrix `B`. +* +* @param {string} order - storage layout of `A` and `B` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {integer} k - diagonal above which to ignore +* @param {Complex64Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Complex64Array} B - output matrix +* @param {PositiveInteger} LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} sixth argument must be a valid stride +* @throws {RangeError} eighth argument must be a valid stride +* @returns {Complex64Array} `B` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctril( 'row-major', 2, 2, 0, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] +*/ +function ctril( order, M, N, k, A, LDA, B, LDB ) { + var viewA; + var viewB; + var s; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( isRowMajor( order ) ) { + s = N; + } else { + s = M; + } + if ( LDA < max( 1, s ) ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); + } + if ( LDB < max( 1, s ) ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDB ) ); + } + viewA = reinterpret( A, 0 ); + viewB = reinterpret( B, 0 ); + addon( resolveOrder( order ), M, N, k, viewA, LDA, viewB, LDB ); + return B; +} + + +// EXPORTS // + +module.exports = ctril; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/index.js new file mode 100644 index 000000000000..cb95145deb2e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/index.js @@ -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. +*/ + +'use strict'; + +/** +* Copy the lower triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. +* +* @module @stdlib/blas/ext/base/ctril +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var ctril = require( '@stdlib/blas/ext/base/ctril' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctril( 'row-major', 2, 2, 0, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var ctril = require( '@stdlib/blas/ext/base/ctril' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctril.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var ctril; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + ctril = main; +} else { + ctril = tmp; +} + + +// EXPORTS // + +module.exports = ctril; + +// exports: { "ndarray": "ctril.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/main.js new file mode 100644 index 000000000000..20d96f1fef2e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/main.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 ctril = require( './ctril.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( ctril, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = ctril; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/native.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/native.js new file mode 100644 index 000000000000..880a3fd317bd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/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 main = require( './ctril.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( main, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/ndarray.js new file mode 100644 index 000000000000..150312cbbbd4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/ndarray.js @@ -0,0 +1,69 @@ +/** +* @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 base = require( './base.js' ); + + +// MAIN // + +/** +* Copies the lower triangular part of a single-precision complex floating-point matrix `A` to another matrix `B` using alternative indexing semantics. +* +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {integer} k - diagonal above which to ignore +* @param {Complex64Array} 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 {Complex64Array} 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 {Complex64Array} `B` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctril( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctril( 2, 2, -1, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 0.0, 0.0, 0.0, 0.0, 5.0, 6.0, 0.0, 0.0 ] +*/ +function ctril( M, N, k, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params + return base( M, N, k, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = ctril; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/ndarray.native.js new file mode 100644 index 000000000000..c603db358493 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/lib/ndarray.native.js @@ -0,0 +1,64 @@ +/** +* @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 reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Copies the lower triangular part of a single-precision floating-point matrix `A` to another matrix `B` using alternative indexing semantics. +* +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {integer} k - diagonal above which to ignore +* @param {Complex64Array} 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 {Complex64Array} 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 {Complex64Array} `B` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctril( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] +*/ +function ctril( M, N, k, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params + var viewA = reinterpret( A, 0 ); + var viewB = reinterpret( B, 0 ); + addon.ndarray( M, N, k, viewA, strideA1, strideA2, offsetA, viewB, strideB1, strideB2, offsetB ); // eslint-disable-line max-len + return B; +} + + +// EXPORTS // + +module.exports = ctril; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/ctril/manifest.json new file mode 100644 index 000000000000..e6bb20543ae9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/manifest.json @@ -0,0 +1,82 @@ +{ + "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", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-complex64array2d", + "@stdlib/complex/float32/ctor" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/complex/float32/ctor" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/complex/float32/ctor" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/package.json b/lib/node_modules/@stdlib/blas/ext/base/ctril/package.json new file mode 100644 index 000000000000..eef54fdfbf02 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/package.json @@ -0,0 +1,79 @@ +{ + "name": "@stdlib/blas/ext/base/ctril", + "version": "0.0.0", + "description": "Copy the lower triangular part of a single-precision complex floating-point matrix A to another matrix B.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "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", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "blas", + "extended", + "ext", + "linear", + "algebra", + "matrix", + "triangular", + "triangle", + "lower", + "tril", + "ctril", + "copy", + "array", + "ndarray", + "complex64", + "complex", + "single", + "complex64array" + ], + "__stdlib__": { + "wasm": false + } +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/src/Makefile b/lib/node_modules/@stdlib/blas/ext/base/ctril/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/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/blas/ext/base/ctril/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ctril/src/addon.c new file mode 100644 index 000000000000..620d4de49c1a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/src/addon.c @@ -0,0 +1,100 @@ +/** +* @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/blas/ext/base/ctril.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_int32.h" +#include "stdlib/napi/argv_strided_complex64array2d.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; + CBLAS_INT sb1; + CBLAS_INT sb2; + + STDLIB_NAPI_ARGV( env, info, argv, argc, 8 ); + + STDLIB_NAPI_ARGV_INT32( env, layout, argv, 0 ); + + STDLIB_NAPI_ARGV_INT64( env, M, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, k, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, LDA, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, LDB, argv, 7 ); + + if ( layout == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + sb1 = 1; + sb2 = LDB; + } else { // layout == CblasRowMajor + sa1 = LDA; + sa2 = 1; + sb1 = LDB; + sb2 = 1; + } + STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY2D( env, A, M, N, sa1, sa2, argv, 4 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY2D( env, B, M, N, sb1, sb2, argv, 6 ); + + API_SUFFIX(stdlib_strided_ctril)( layout, M, N, k, (stdlib_complex64_t *)A, LDA, (stdlib_complex64_t *)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_INT64( env, M, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, k, 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_COMPLEX64ARRAY2D( env, A, M, N, strideA1, strideA2, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY2D( env, B, M, N, strideB1, strideB2, argv, 7 ); + + API_SUFFIX(stdlib_strided_ctril_ndarray)( M, N, k, (stdlib_complex64_t *)A, strideA1, strideA2, offsetA, (stdlib_complex64_t *)B, strideB1, strideB2, offsetB ); + + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ctril/src/main.c new file mode 100644 index 000000000000..03d81839d195 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/src/main.c @@ -0,0 +1,108 @@ +/** +* @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/blas/ext/base/ctril.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/ndarray/base/assert/is_row_major.h" +#include "stdlib/complex/float32/ctor.h" +#include + +// Define macros for computing the minimum and maximum values: +#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) +#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y)) + +/** +* Copies the lower triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. +* +* @param layout storage layout +* @param M number of rows in the matrix `A` +* @param N number of columns in the matrix `A` +* @param k diagonal above which to ignore +* @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(stdlib_strided_ctril)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const CBLAS_INT k, const stdlib_complex64_t *A, const CBLAS_INT LDA, stdlib_complex64_t *B, const CBLAS_INT LDB ) { + CBLAS_INT sa1; + CBLAS_INT sa2; + CBLAS_INT sb1; + CBLAS_INT sb2; + + if ( layout == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + sb1 = 1; + sb2 = LDB; + } else { // layout == CblasRowMajor + sa1 = LDA; + sa2 = 1; + sb1 = LDB; + sb2 = 1; + } + API_SUFFIX(stdlib_strided_ctril_ndarray)( M, N, k, A, sa1, sa2, 0, B, sb1, sb2, 0 ); +} + +/** +* Copies the lower triangular part of a single-precision complex floating-point matrix `A` to another matrix `B` using alternative indexing semantics. +* +* @param M number of rows in the matrix `A` +* @param N number of columns in the matrix `A` +* @param k diagonal above which to ignore +* @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(stdlib_strided_ctril_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const CBLAS_INT k, const stdlib_complex64_t *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, stdlib_complex64_t *B, const CBLAS_INT strideB1, const CBLAS_INT strideB2, const CBLAS_INT offsetB ) { + int64_t sa[ 2 ]; + CBLAS_INT ia; + CBLAS_INT ib; + CBLAS_INT i0; + CBLAS_INT i1; + + ia = offsetA; + ib = offsetB; + + sa[ 0 ] = strideA1; + sa[ 1 ] = strideA2; + if ( stdlib_ndarray_is_row_major( 2, sa ) ) { + // Copy row-by-row in order to ensure cache-optimal traversal... + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = 0; i0 <= MIN( i1+k, N-1 ); i0++ ) { + B[ ib+(i0*strideB2) ] = A[ ia+(i0*strideA2) ]; + } + ia += strideA1; + ib += strideB1; + } + return; + } + // Copy column-by-column in order to ensure cache-optimal traversal... + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = MAX( 0, i1-k ); i0 < M; i0++ ) { + B[ ib+(i0*strideB1) ] = A[ ia+(i0*strideA1) ]; + } + ia += strideA2; + ib += strideB2; + } + return; +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.ctril.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.ctril.js new file mode 100644 index 000000000000..519f8bec1688 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.ctril.js @@ -0,0 +1,377 @@ +/** +* @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 tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var ctril = require( './../lib/ctril' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ctril, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( ctril.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 i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + 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() { + var A = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + var B = new Complex64Array( 4 ); + ctril( value, 2, 2, 0, A, 2, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided a sixth argument which is not a valid LDA value (row-major)', function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctril( 'row-major', 2, 2, 0, A, value, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an eighth argument which is not a valid LDB value (row-major)', function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctril( 'row-major', 2, 2, 0, A, 2, B, value ); + }; + } +}); + +tape( 'the function throws an error if provided a sixth argument which is not a valid LDA value (column-major)', function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctril( 'column-major', 2, 2, 0, A, value, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an eighth argument which is not a valid LDB value (column-major)', function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctril( 'column-major', 2, 2, 0, A, 2, B, value ); + }; + } +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (row-major, k=0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 'row-major', 3, 3, 0, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0, 0.0, 0.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.strictEqual( out, B, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (row-major, k>0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 'row-major', 3, 3, 1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (row-major, k<0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 'row-major', 3, 3, -1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 7.0, 7.0, 8.0, 8.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (column-major, k=0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 'column-major', 3, 3, 0, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 0.0, 0.0, 5.0, 5.0, 8.0, 8.0, 0.0, 0.0, 0.0, 0.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (column-major, k<0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 'column-major', 3, 3, -1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 0.0, 0.0, 4.0, 4.0, 7.0, 7.0, 0.0, 0.0, 0.0, 0.0, 8.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (column-major, k>0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 'column-major', 3, 3, 1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 0.0, 0.0, 6.0, 6.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (row-major)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 'row-major', 2, 3, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 'row-major', 3, 2, 0, A, 2, B, 2 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports non-square matrices (column-major)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 2.0, 2.0, 5.0, 5.0, 3.0, 3.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 'column-major', 2, 3, 0, A, 2, B, 2 ); + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 0.0, 0.0, 5.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 2.0, 2.0, 4.0, 4.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 'column-major', 3, 2, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 0.0, 0.0, 4.0, 4.0, 6.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a leading dimension greater than the number of rows/columns (padded matrix)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 9.0, 9.0, 3.0, 3.0, 4.0, 4.0, 9.0, 9.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 'row-major', 2, 2, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 4.0, 4.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 9.0, 9.0, 2.0, 2.0, 4.0, 4.0, 9.0, 9.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 'column-major', 2, 2, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function leaves elements outside of the copied region unchanged', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( [ -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0 ] ); + + out = ctril( 'row-major', 3, 3, 0, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 4.0, 4.0, 5.0, 5.0, -1.0, -1.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is sufficiently negative, the function copies nothing', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + + out = ctril( 'row-major', 2, 2, 2, A, 2, B, 2 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is sufficiently positive, the function copies the entire matrix', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( 4 ); + + out = ctril( 'row-major', 2, 2, 2, A, 2, B, 2 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves `B` unchanged when `M` or `N` is equal to zero', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctril( 'row-major', 0, 2, 0, A, 2, B, 2 ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctril( 'row-major', 2, 0, 0, A, 2, B, 2 ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.ctril.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.ctril.native.js new file mode 100644 index 000000000000..89d62162d7ff --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.ctril.native.js @@ -0,0 +1,386 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var ctril = tryRequire( resolve( __dirname, './../lib/ctril.native.js' ) ); +var opts = { + 'skip': ( ctril instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ctril, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', opts, function test( t ) { + t.strictEqual( ctril.length, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', opts, function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + 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() { + var A = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + var B = new Complex64Array( 4 ); + ctril( value, 2, 2, 0, A, 2, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided a sixth argument which is not a valid LDA value (row-major)', opts, function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctril( 'row-major', 2, 2, 0, A, value, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an eighth argument which is not a valid LDB value (row-major)', opts, function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctril( 'row-major', 2, 2, 0, A, 2, B, value ); + }; + } +}); + +tape( 'the function throws an error if provided a sixth argument which is not a valid LDA value (column-major)', opts, function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctril( 'column-major', 2, 2, 0, A, value, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an eighth argument which is not a valid LDB value (column-major)', opts, function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctril( 'column-major', 2, 2, 0, A, 2, B, value ); + }; + } +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (row-major, k=0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 'row-major', 3, 3, 0, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0, 0.0, 0.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.strictEqual( out, B, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (row-major, k>0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 'row-major', 3, 3, 1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (row-major, k<0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 'row-major', 3, 3, -1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 7.0, 7.0, 8.0, 8.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (column-major, k=0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 'column-major', 3, 3, 0, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 0.0, 0.0, 5.0, 5.0, 8.0, 8.0, 0.0, 0.0, 0.0, 0.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (column-major, k<0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 'column-major', 3, 3, -1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 0.0, 0.0, 4.0, 4.0, 7.0, 7.0, 0.0, 0.0, 0.0, 0.0, 8.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (column-major, k>0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 'column-major', 3, 3, 1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 0.0, 0.0, 6.0, 6.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (row-major)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 'row-major', 2, 3, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 'row-major', 3, 2, 0, A, 2, B, 2 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports non-square matrices (column-major)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 2.0, 2.0, 5.0, 5.0, 3.0, 3.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 'column-major', 2, 3, 0, A, 2, B, 2 ); + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 0.0, 0.0, 5.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 2.0, 2.0, 4.0, 4.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 'column-major', 3, 2, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 0.0, 0.0, 4.0, 4.0, 6.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a leading dimension greater than the number of rows/columns (padded matrix)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 9.0, 9.0, 3.0, 3.0, 4.0, 4.0, 9.0, 9.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 'row-major', 2, 2, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 4.0, 4.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 9.0, 9.0, 2.0, 2.0, 4.0, 4.0, 9.0, 9.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 'column-major', 2, 2, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function leaves elements outside of the copied region unchanged', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( [ -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0 ] ); + + out = ctril( 'row-major', 3, 3, 0, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 4.0, 4.0, 5.0, 5.0, -1.0, -1.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is greater than or equal to `N`, the function copies nothing', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + + out = ctril( 'row-major', 2, 2, 2, A, 2, B, 2 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is sufficiently negative, the function copies the entire matrix', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( 4 ); + + out = ctril( 'row-major', 2, 2, 2, A, 2, B, 2 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves `B` unchanged when `M` or `N` is equal to zero', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctril( 'row-major', 0, 2, 0, A, 2, B, 2 ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctril( 'row-major', 2, 0, 0, A, 2, B, 2 ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.js new file mode 100644 index 000000000000..197ca27b5df8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.js @@ -0,0 +1,82 @@ +/** +* @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 tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var ctril = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ctril, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof ctril.ndarray, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var ctril = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( ctril, mock, 'returns native implementation' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var ctril; + var main; + + main = require( './../lib/main.js' ); + + ctril = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( ctril, main, 'returns JavaScript implementation' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.ndarray.js new file mode 100644 index 000000000000..4acd722b12de --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.ndarray.js @@ -0,0 +1,297 @@ +/** +* @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 tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var ctril = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ctril, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( ctril.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (row-major, k=0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 3, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0, 0.0, 0.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.strictEqual( out, B, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (row-major, k>0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 3, 3, 1, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (row-major, k<0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 3, 3, -1, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 7.0, 7.0, 8.0, 8.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (column-major, k=0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 3, 3, 0, A, 1, 3, 0, B, 1, 3, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 0.0, 0.0, 5.0, 5.0, 8.0, 8.0, 0.0, 0.0, 0.0, 0.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (column-major, k<0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 3, 3, -1, A, 1, 3, 0, B, 1, 3, 0 ); + + expected = new Complex64Array( [ 0.0, 0.0, 4.0, 4.0, 7.0, 7.0, 0.0, 0.0, 0.0, 0.0, 8.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (column-major, k>0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 3, 3, 1, A, 1, 3, 0, B, 1, 3, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 0.0, 0.0, 6.0, 6.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (row-major)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 2, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (column-major)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 2.0, 2.0, 4.0, 4.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 3, 2, 0, A, 1, 3, 0, B, 1, 3, 0 ); + expected = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 0.0, 0.0, 4.0, 4.0, 6.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `A` offset', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 0.0, 0.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0 ] ); + B = new Complex64Array( 4 ); + + out = ctril( 2, 2, 0, A, 2, 1, 1, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 2.0, 2.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `B` offset', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + B = new Complex64Array( 6 ); + + out = ctril( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 2 ); + + expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 9.0, 9.0, 0.0, 0.0, 9.0, 9.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 2.0, 2.0, 1.0, 1.0, 4.0, 4.0, 3.0, 3.0 ] ); + B = new Complex64Array( 4 ); + + out = ctril( 2, 2, 0, A, 2, -1, 1, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves elements outside of the copied region unchanged', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( [ -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0 ] ); + + out = ctril( 3, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 4.0, 4.0, 5.0, 5.0, -1.0, -1.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is sufficiently negative, the function copies nothing', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + + out = ctril( 2, 2, -2, A, 2, 1, 0, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is sufficiently positive, the function copies the entire matrix', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( 4 ); + + out = ctril( 2, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves `B` unchanged when `M` or `N` is equal to zero', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctril( 0, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctril( 2, 0, 0, A, 2, 1, 0, B, 2, 1, 0 ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (non-unit strides and offsets on both `A` and `B`)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 9.0, 9.0, 1.0, 1.0, 9.0, 9.0, 2.0, 2.0, 9.0, 9.0, 3.0, 3.0, 9.0, 9.0, 4.0, 4.0 ] ); + B = new Complex64Array( 8 ); + + out = ctril( 2, 2, 0, A, 4, 2, 1, B, 4, 2, 1 ); + + expected = new Complex64Array( [ 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 0.0, 0.0, 4.0, 4.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.ndarray.native.js new file mode 100644 index 000000000000..83039b64d628 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctril/test/test.ndarray.native.js @@ -0,0 +1,311 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var ctril = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( ctril instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ctril, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', opts, function test( t ) { + t.strictEqual( ctril.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (row-major, k=0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 3, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0, 0.0, 0.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.strictEqual( out, B, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (row-major, k>0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 3, 3, 1, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (row-major, k<0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 3, 3, -1, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0, 0.0, 0.0, 7.0, 7.0, 8.0, 8.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (column-major, k=0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 3, 3, 0, A, 1, 3, 0, B, 1, 3, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 0.0, 0.0, 5.0, 5.0, 8.0, 8.0, 0.0, 0.0, 0.0, 0.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (column-major, k<0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 3, 3, -1, A, 1, 3, 0, B, 1, 3, 0 ); + + expected = new Complex64Array( [ 0.0, 0.0, 4.0, 4.0, 7.0, 7.0, 0.0, 0.0, 0.0, 0.0, 8.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the lower triangular part of `A` to `B` (column-major, k>0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctril( 3, 3, 1, A, 1, 3, 0, B, 1, 3, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 0.0, 0.0, 6.0, 6.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (row-major)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + // 2x3 row-major + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 2, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0, 0.0, 0.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (column-major)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + // 3x2 column-major + A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 2.0, 2.0, 4.0, 4.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctril( 3, 2, 0, A, 1, 3, 0, B, 1, 3, 0 ); + expected = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 0.0, 0.0, 4.0, 4.0, 6.0, 6.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `A` offset', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + // 2x2 with A offset=1 (start from 2nd element) + A = new Complex64Array( [ 0.0, 0.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0 ] ); + B = new Complex64Array( 4 ); + + out = ctril( 2, 2, 0, A, 2, 1, 1, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 2.0, 2.0, 0.0, 0.0, 4.0, 4.0, 5.0, 5.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `B` offset', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + // 2x2 with B offset=2 (start writing from 3rd element) + A = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + B = new Complex64Array( 6 ); + + out = ctril( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 2 ); + + expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 9.0, 9.0, 0.0, 0.0, 9.0, 9.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + // 2x2 row-major with negative stride for columns (reversed columns) + A = new Complex64Array( [ 2.0, 2.0, 1.0, 1.0, 4.0, 4.0, 3.0, 3.0 ] ); + B = new Complex64Array( 4 ); + + out = ctril( 2, 2, 0, A, 2, -1, 1, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves elements outside of the copied region unchanged', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( [ -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0 ] ); + + out = ctril( 3, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 4.0, 4.0, 5.0, 5.0, -1.0, -1.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is greater than or equal to `N`, the function copies nothing', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + + out = ctril( 2, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is sufficiently negative, the function copies the entire matrix', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( 4 ); + + out = ctril( 2, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves `B` unchanged when `M` or `N` is equal to zero', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctril( 0, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctril( 2, 0, 0, A, 2, 1, 0, B, 2, 1, 0 ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (non-unit strides and offsets on both `A` and `B`)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 9.0, 9.0, 1.0, 1.0, 9.0, 9.0, 2.0, 2.0, 9.0, 9.0, 3.0, 3.0, 9.0, 9.0, 4.0, 4.0 ] ); + B = new Complex64Array( 8 ); + + out = ctril( 2, 2, 0, A, 4, 2, 1, B, 4, 2, 1 ); + + expected = new Complex64Array( [ 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 0.0, 0.0, 4.0, 4.0 ] ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); + t.end(); +});