From 640278bc95b4f9f87e58c328b5238606635052e6 Mon Sep 17 00:00:00 2001 From: Aman Bhansali <92033532+aman-095@users.noreply.github.com> Date: Fri, 2 Aug 2024 01:53:57 +0530 Subject: [PATCH] feat: add `blas/base/dtrmv` PR-URL: https://github.com/stdlib-js/stdlib/pull/2540 Ref: https://github.com/stdlib-js/stdlib/issues/2039 Co-authored-by: Athan Reines Reviewed-by: Athan Reines --- .../@stdlib/blas/base/dtrmv/README.md | 258 +++++ .../blas/base/dtrmv/benchmark/benchmark.js | 104 ++ .../base/dtrmv/benchmark/benchmark.ndarray.js | 104 ++ .../@stdlib/blas/base/dtrmv/docs/repl.txt | 118 +++ .../blas/base/dtrmv/docs/types/index.d.ts | 119 +++ .../blas/base/dtrmv/docs/types/test.ts | 374 +++++++ .../@stdlib/blas/base/dtrmv/examples/index.js | 37 + .../@stdlib/blas/base/dtrmv/lib/base.js | 171 ++++ .../@stdlib/blas/base/dtrmv/lib/dtrmv.js | 108 ++ .../@stdlib/blas/base/dtrmv/lib/index.js | 70 ++ .../@stdlib/blas/base/dtrmv/lib/main.js | 35 + .../@stdlib/blas/base/dtrmv/lib/ndarray.js | 87 ++ .../@stdlib/blas/base/dtrmv/package.json | 68 ++ .../column_major_complex_access_pattern.json | 14 + .../test/fixtures/column_major_l_nt_nu.json | 16 + .../test/fixtures/column_major_l_nt_u.json | 16 + .../test/fixtures/column_major_l_t_nu.json | 16 + .../test/fixtures/column_major_l_t_u.json | 16 + .../dtrmv/test/fixtures/column_major_oa.json | 14 + .../test/fixtures/column_major_sa1_sa2.json | 14 + .../test/fixtures/column_major_sa1_sa2n.json | 14 + .../test/fixtures/column_major_sa1n_sa2.json | 14 + .../test/fixtures/column_major_sa1n_sa2n.json | 14 + .../test/fixtures/column_major_u_nt_nu.json | 16 + .../test/fixtures/column_major_u_nt_u.json | 16 + .../test/fixtures/column_major_u_t_nu.json | 16 + .../test/fixtures/column_major_u_t_u.json | 16 + .../dtrmv/test/fixtures/column_major_xn.json | 16 + .../dtrmv/test/fixtures/column_major_xt.json | 16 + .../row_major_complex_access_pattern.json | 14 + .../test/fixtures/row_major_l_nt_nu.json | 16 + .../dtrmv/test/fixtures/row_major_l_nt_u.json | 16 + .../dtrmv/test/fixtures/row_major_l_t_nu.json | 16 + .../dtrmv/test/fixtures/row_major_l_t_u.json | 16 + .../dtrmv/test/fixtures/row_major_oa.json | 14 + .../test/fixtures/row_major_sa1_sa2.json | 14 + .../test/fixtures/row_major_sa1_sa2n.json | 14 + .../test/fixtures/row_major_sa1n_sa2.json | 14 + .../test/fixtures/row_major_sa1n_sa2n.json | 14 + .../test/fixtures/row_major_u_nt_nu.json | 16 + .../dtrmv/test/fixtures/row_major_u_nt_u.json | 16 + .../dtrmv/test/fixtures/row_major_u_t_nu.json | 16 + .../dtrmv/test/fixtures/row_major_u_t_u.json | 16 + .../dtrmv/test/fixtures/row_major_xn.json | 16 + .../dtrmv/test/fixtures/row_major_xt.json | 16 + .../blas/base/dtrmv/test/test.dtrmv.js | 756 ++++++++++++++ .../@stdlib/blas/base/dtrmv/test/test.js | 82 ++ .../blas/base/dtrmv/test/test.ndarray.js | 966 ++++++++++++++++++ 48 files changed, 3945 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/lib/base.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/lib/dtrmv.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_complex_access_pattern.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_nt_nu.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_nt_u.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_t_nu.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_t_u.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_oa.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1n_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1n_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_nt_nu.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_nt_u.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_t_nu.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_t_u.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_xn.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_xt.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_complex_access_pattern.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_nt_nu.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_nt_u.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_t_nu.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_t_u.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_oa.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1n_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1n_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_nt_nu.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_nt_u.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_t_nu.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_t_u.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_xn.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_xt.json create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/test.dtrmv.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/dtrmv/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/README.md b/lib/node_modules/@stdlib/blas/base/dtrmv/README.md new file mode 100644 index 00000000000..5a4f30f9aab --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/README.md @@ -0,0 +1,258 @@ + + +# dtrmv + +> Perform one of the matrix-vector operations `x = A*x` or `x = A^T*x`. + +
+ +## Usage + +```javascript +var dtrmv = require( '@stdlib/blas/base/dtrmv' ); +``` + +#### dtrmv( order, uplo, trans, diag, N, A, LDA, x, sx ) + +Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + +dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 3, A, 3, x, 1 ); +// x => [ 14.0, 8.0, 3.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **uplo**: specifies whether `A` is an upper or lower triangular matrix. +- **trans**: specifies whether `A` should be transposed, conjugate-transposed, or not transposed. +- **diag**: specifies whether `A` has a unit diagonal. +- **N**: number of elements along each dimension of `A`. +- **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **lda**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **x**: input vector [`Float64Array`][mdn-float64array]. +- **sx**: `x` stride length. + +The stride parameters determine how elements in the input arrays are accessed at runtime. For example, to iterate over the elements of `x` in reverse order, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + +dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 3, A, 3, x, -1 ); +// x => [ 1.0, 4.0, 10.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var x0 = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); + +// Create offset views... +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 3, A, 3, x1, 1 ); +// x0 => [ 1.0, 6.0, 3.0, 1.0 ] +``` + +#### dtrmv.ndarray( uplo, trans, diag, N, A, sa1, sa2, oa, x, sx, ox ) + +Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, using alternative indexing semantics and where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + +dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 3, A, 3, 1, 0, x, 1, 0 ); +// x => [ 14.0, 8.0, 3.0 ] +``` + +The function has the following additional parameters: + +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. +- **ox**: starting index for `x`. + +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 Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + +dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 3, A, 3, 1, 0, x, -1, 2 ); +// x => [ 1.0, 4.0, 10.0 ] +``` + +
+ + + +
+ +## Notes + +- `dtrmv()` corresponds to the [BLAS][blas] level 2 function [`dtrmv`][blas-dtrmv]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var dtrmv = require( '@stdlib/blas/base/dtrmv' ); + +var opts = { + 'dtype': 'float64' +}; + +var N = 5; + +var A = discreteUniform( N*N, -10.0, 10.0, opts ); +var x = discreteUniform( N, -10.0, 10.0, opts ); + +dtrmv( 'column-major', 'upper', 'no-transpose', 'unit', N, A, N, x, 1 ); +console.log( x ); + +dtrmv.ndarray( 'upper', 'no-transpose', 'unit', N, A, 1, N, 0, x, 1, 0 ); +console.log( x ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dtrmv/benchmark/benchmark.js new file mode 100644 index 00000000000..d0d2fbb1cf8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/benchmark/benchmark.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var ones = require( '@stdlib/array/ones' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dtrmv = require( './../lib/dtrmv.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = ones( N, options.dtype ); + var A = ones( N*N, options.dtype ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dtrmv( 'row-major', 'upper', 'transpose', 'non-unit', N, A, N, x, 1 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dtrmv/benchmark/benchmark.ndarray.js new file mode 100644 index 00000000000..46840080337 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/benchmark/benchmark.ndarray.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var ones = require( '@stdlib/array/ones' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dtrmv = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = ones( N, options.dtype ); + var A = ones( N*N, options.dtype ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dtrmv( 'upper', 'transpose', 'non-unit', N, A, N, 1, 0, x, 1, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':ndarray:size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dtrmv/docs/repl.txt new file mode 100644 index 00000000000..b171e52b184 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/docs/repl.txt @@ -0,0 +1,118 @@ + +{{alias}}( ord, uplo, trans, diag, N, A, lda, x, sx ) + Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, + where `x` is an `N` element vector and `A` is an `N` by `N` unit, or + non-unit, upper or lower triangular matrix. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N` is equal to `0`, the function returns `x` unchanged. + + Parameters + ---------- + ord: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + Specifies whether `A` is an upper or lower triangular matrix. + + trans: string + Specifies whether `A` should be transposed, conjugate-transposed, or not + transposed. + + diag: string + Specifies whether `A` has a unit diagonal. + + N: integer + Number of elements along each dimension of `A`. + + A: Float64Array + Input matrix. + + lda: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + x: Float64Array + Input vector. + + sx: integer + Index increment for `x`. + + Returns + ------- + x: Float64Array + Input vector. + + Examples + -------- + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 1.0 ] ); + > {{alias}}( 'row-major', 'upper', 'no-transpose', 'unit', 2, A, 2, x, 1 ) + [ 3.0, 1.0 ] + + +{{alias}}.ndarray( uplo, trans, diag, N, A, sa1, sa2, oa, x, sx, ox ) + Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, + using alternative indexing semantics and where `x` is an `N` element vector + and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular + matrix. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + uplo: string + Specifies whether `A` is an upper or lower triangular matrix. + + trans: string + Specifies whether `A` should be transposed, conjugate-transposed, or not + transposed. + + diag: string + Specifies whether `A` has a unit diagonal. + + N: integer + Number of elements along each dimension of `A`. + + A: Float64Array + Input matrix. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: integer + Starting index for `A`. + + x: Float64Array + Input vector. + + sx: integer + Index increment for `x`. + + ox: integer + Starting index for `x`. + + Returns + ------- + x: Float64Array + Input vector. + + Examples + -------- + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 1.0 ] ); + > var uplo = 'upper'; + > var trans = 'no-transpose'; + > {{alias}}.ndarray( uplo, trans, 'unit', 2, A, 2, 1, 0, x, 1, 0 ) + [ 3.0, 1.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dtrmv/docs/types/index.d.ts new file mode 100644 index 00000000000..81e994ec341 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/docs/types/index.d.ts @@ -0,0 +1,119 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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, MatrixTriangle, TransposeOperation, DiagonalType } from '@stdlib/types/blas'; + +/** +* Interface describing `dtrmv`. +*/ +interface Routine { + /** + * Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. + * + * @param order - storage layout + * @param uplo - specifies whether `A` is an upper or lower triangular matrix + * @param trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed + * @param diag - specifies whether `A` has a unit diagonal + * @param N - number of elements along each dimension in the matrix `A` + * @param A - input matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param x - input vector + * @param strideX - `x` stride length + * @returns `x` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); + * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + * + * dtrmv( row-major', 'upper', 'no-transpose', 'non-unit', 3, A, 3, x, 1 ); + * // x => [ 14.0, 8.0, 3.0 ] + */ + ( order: Layout, uplo: MatrixTriangle, trans: TransposeOperation, diag: DiagonalType, N: number, A: Float64Array, LDA: number, x: Float64Array, strideX: number ): Float64Array; + + /** + * Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, using alternative indexing semantics and where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. + * + * @param uplo - specifies whether `A` is an upper or lower triangular matrix + * @param trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed + * @param diag - specifies whether `A` has a unit diagonal + * @param N - number of elements along each dimension in the matrix `A` + * @param A - input matrix + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the first dimension of `A` + * @param offsetA - starting index for `A` + * @param x - input vector + * @param strideX - `x` stride length + * @param offsetX - starting index for `x` + * @returns `x` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); + * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + * + * dtrmv.ndarray( 'upper', 'no-transpose', 'non-unit', 3, A, 3, 1, 0, x, 1, 0 ); + * // x => [ 14.0, 8.0, 3.0 ] + */ + ndarray( uplo: MatrixTriangle, trans: TransposeOperation, diag: DiagonalType, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, x: Float64Array, strideX: number, offsetX: number ): Float64Array; +} + +/** +* Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. +* +* @param order - storage layout +* @param uplo - specifies whether `A` is an upper or lower triangular matrix +* @param trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param diag - specifies whether `A` has a unit diagonal +* @param N - number of elements along each dimension in the matrix `A` +* @param A - input matrix +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param x - input vector +* @param strideX - `x` stride length +* @returns `x` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 3.0, 0.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* +* dtrmv( 'row-major', 'lower', 'no-transpose', 'non-unit', 3, A, 3, x, 1 ); +* // x => [ 1.0, 5.0, 15.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 3.0, 0.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* +* dtrmv.ndarray( 'lower', 'no-transpose', 'non-unit', 3, A, 3, 1, 0, x, 1, 0 ); +* // x => [ 1.0, 5.0, 15.0 ] +*/ +declare var dtrmv: Routine; + + +// EXPORTS // + +export = dtrmv; diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dtrmv/docs/types/test.ts new file mode 100644 index 00000000000..2b1d14fd827 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/docs/types/test.ts @@ -0,0 +1,374 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dtrmv = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv( 10, 'upper', 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( true, 'upper', 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( false, 'upper', 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( null, 'upper', 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( undefined, 'upper', 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( [], 'upper', 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( {}, 'upper', 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( ( x: number ): number => x, 'upper', 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv( 'row-major', 10, 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', true, 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', false, 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', null, 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', undefined, 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', [], 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', {}, 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', ( x: number ): number => x, 'no-transpose', 'unit', 10, A, 10, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a string... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv( 'row-major', 'upper', 10, 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', true, 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', false, 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', null, 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', undefined, 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', [], 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', {}, 'unit', 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', ( x: number ): number => x, 'unit', 10, A, 10, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a string... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv( 'row-major', 'upper', 'no-transpose', 10, 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', true, 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', false, 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', null, 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', undefined, 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', [], 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', {}, 10, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', ( x: number ): number => x, 10, A, 10, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', '10', A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', true, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', false, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', null, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', undefined, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', [], A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', {}, A, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', ( x: number ): number => x, A, 10, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, 10, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, '10', 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, true, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, false, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, null, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, undefined, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, [ '1' ], 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, {}, 10, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, ( x: number ): number => x, 10, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, '10', x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, true, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, false, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, null, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, undefined, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, [], x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, {}, x, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, ( x: number ): number => x, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a Float64Array... +{ + const A = new Float64Array( 20 ); + + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, 10, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, '10', 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, true, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, false, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, null, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, undefined, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, [ '1' ], 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, {}, 1 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, x, '10' ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, x, true ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, x, false ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, x, null ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, x, undefined ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, x, [] ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, x, {} ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv(); // $ExpectError + dtrmv( 'row-major' ); // $ExpectError + dtrmv( 'row-major', 'upper' ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose' ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit' ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10 ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, x ); // $ExpectError + dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 10, A, 10, x, 1, 1 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv.ndarray( 10, 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( true, 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( false, 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( null, 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( undefined, 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( [], 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( {}, 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( ( x: number ): number => x, 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv.ndarray( 'upper', 10, 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', true, 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', false, 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', null, 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', undefined, 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', [], 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', {}, 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', ( x: number ): number => x, 'unit', 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a string... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv.ndarray( 'upper', 'no-transpose', 10, 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', true, 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', false, 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', null, 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', undefined, 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', [], 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', {}, 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', ( x: number ): number => x, 10, A, 10, 1, 0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', '10', A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', true, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', false, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', null, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', undefined, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', [], A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', {}, A, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', ( x: number ): number => x, A, 10, 1, 0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, 10, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, '10', 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, true, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, false, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, null, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, undefined, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, [ '1' ], 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, {}, 10, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, ( x: number ): number => x, 10, 1, 0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, '10', 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, true, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, false, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, null, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, undefined, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, [], 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, {}, 1, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, ( x: number ): number => x, 1, 0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, '10', 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, true, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, false, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, null, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, undefined, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, [], 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, {}, 0, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, ( x: number ): number => x, 0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, '10', x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, true, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, false, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, null, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, undefined, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, [], x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, {}, x, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, ( x: number ): number => x, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a Float64Array... +{ + const A = new Float64Array( 20 ); + + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, 10, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, '10', 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, true, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, false, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, null, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, undefined, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, [ '1' ], 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, {}, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, '10', 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, true, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, false, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, null, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, undefined, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, [], 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, {}, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, '10' ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, true ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, false ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, null ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, undefined ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, [] ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, {} ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dtrmv.ndarray(); // $ExpectError + dtrmv.ndarray( 'upper' ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose' ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit' ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1 ); // $ExpectError + dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 10, A, 10, 1, 0, x, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/examples/index.js b/lib/node_modules/@stdlib/blas/base/dtrmv/examples/index.js new file mode 100644 index 00000000000..79ad63ee323 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/examples/index.js @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var dtrmv = require( './../lib' ); + +var opts = { + 'dtype': 'float64' +}; + +var N = 5; + +var A = discreteUniform( N*N, -10.0, 10.0, opts ); +var x = discreteUniform( N, -10.0, 10.0, opts ); + +dtrmv( 'column-major', 'upper', 'no-transpose', 'unit', N, A, N, x, 1 ); +console.log( x ); + +dtrmv.ndarray( 'upper', 'no-transpose', 'unit', N, A, 1, N, 0, x, 1, 0 ); +console.log( x ); diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/lib/base.js b/lib/node_modules/@stdlib/blas/base/dtrmv/lib/base.js new file mode 100644 index 00000000000..b137a81fde7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/lib/base.js @@ -0,0 +1,171 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); + + +// MAIN // + +/** +* Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. +* +* @private +* @param {string} uplo - specifies whether `A` is an upper or lower triangular matrix +* @param {string} trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param {string} diag - specifies whether `A` has a unit diagonal +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} x - input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @returns {Float64Array} `x` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dtrmv( 'upper', 'no-transpose', 'unit', 3, A, 3, 1, 0, x, 1, 0 ); +* // x => [ 14.0, 8.0, 3.0 ] +*/ +function dtrmv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-params, max-len + var nonunit; + var isrm; + var tmp; + var sa0; + var sa1; + var ix0; + var ix1; + var i0; + var i1; + var oa; + var ox; + + // Note on variable naming convention: sa#, ix#, i# where # corresponds to the loop number, with `0` being the innermost loop... + + isrm = isRowMajor( [ strideA1, strideA2 ] ); + nonunit = ( diag === 'non-unit' ); + + if ( isrm ) { + // For row-major matrices, the last dimension has the fastest changing index... + sa0 = strideA2; // stride for innermost loop + sa1 = strideA1; // stride for outermost loop + } else { // isColMajor + // For column-major matrices, the first dimension has the fastest changing index... + sa0 = strideA1; // stride for innermost loop + sa1 = strideA2; // stride for outermost loop + } + ox = offsetX; + + if ( + ( !isrm && trans === 'no-transpose' && uplo === 'upper' ) || + ( isrm && trans !== 'no-transpose' && uplo === 'lower' ) + ) { + ix1 = ox; + for ( i1 = 0; i1 < N; i1++ ) { + if ( x[ ix1 ] !== 0.0 ) { + tmp = x[ ix1 ]; + oa = offsetA + (sa1*i1); + ix0 = ox; + for ( i0 = 0; i0 < i1; i0++ ) { + x[ ix0 ] += tmp * A[ oa+(sa0*i0) ]; + ix0 += strideX; + } + if ( nonunit ) { + x[ ix1 ] *= A[ oa+(sa0*i1) ]; + } + } + ix1 += strideX; + } + return x; + } + if ( + ( !isrm && trans === 'no-transpose' && uplo === 'lower' ) || + ( isrm && trans !== 'no-transpose' && uplo === 'upper' ) + ) { + ox += ( N - 1 ) * strideX; + ix1 = ox; + for ( i1 = N-1; i1 >= 0; i1-- ) { + if ( x[ ix1 ] !== 0.0 ) { + tmp = x[ ix1 ]; + oa = offsetA + (sa1*i1); + ix0 = ox; + for ( i0 = N-1; i0 > i1; i0-- ) { + x[ ix0 ] += tmp * A[ oa+(sa0*i0) ]; + ix0 -= strideX; + } + if ( nonunit ) { + x[ ix1 ] *= A[ oa+(sa0*i1) ]; + } + } + ix1 -= strideX; + } + return x; + } + if ( + ( !isrm && trans !== 'no-transpose' && uplo === 'upper' ) || + ( isrm && trans === 'no-transpose' && uplo === 'lower' ) + ) { + ix1 = ox + ( ( N - 1 ) * strideX ); + for ( i1 = N-1; i1 >= 0; i1-- ) { + tmp = x[ ix1 ]; + oa = offsetA + (sa1*i1); + ix0 = ix1; + if ( nonunit ) { + tmp *= A[ oa+(sa0*i1) ]; + } + for ( i0 = i1-1; i0 >= 0; i0-- ) { + ix0 -= strideX; + tmp += x[ ix0 ] * A[ oa+(sa0*i0) ]; + } + x[ ix1 ] = tmp; + ix1 -= strideX; + } + return x; + } + // ( !isrm && trans !== 'no-transpose' && uplo === 'lower' ) || ( isrm && trans === 'no-transpose' && uplo === 'upper' ) + ix1 = ox; + for ( i1 = 0; i1 < N; i1++ ) { + tmp = x[ ix1 ]; + oa = offsetA + (sa1*i1); + ix0 = ix1; + if ( nonunit ) { + tmp *= A[ oa+(sa0*i1) ]; + } + for ( i0 = i1+1; i0 < N; i0++ ) { + ix0 += strideX; + tmp += x[ ix0 ] * A[ oa+(sa0*i0) ]; + } + x[ ix1 ] = tmp; + ix1 += strideX; + } + return x; +} + + +// EXPORTS // + +module.exports = dtrmv; diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/lib/dtrmv.js b/lib/node_modules/@stdlib/blas/base/dtrmv/lib/dtrmv.js new file mode 100644 index 00000000000..987510e68c1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/lib/dtrmv.js @@ -0,0 +1,108 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 max = require( '@stdlib/math/base/special/fast/max' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var isTransposeOperation = require( '@stdlib/blas/base/assert/is-transpose-operation' ); +var isDiagonal = require( '@stdlib/blas/base/assert/is-diagonal-type' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether `A` is an upper or lower triangular matrix +* @param {string} trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param {string} diag - specifies whether `A` has a unit diagonal +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` +* @param {Float64Array} A - input matrix +* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float64Array} x - input vector +* @param {integer} strideX - `x` stride length +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether a lower or upper triangular matrix is supplied +* @throws {TypeError} third argument must be a valid transpose operation +* @throws {TypeError} fourth argument must be a valid diagonal type +* @throws {RangeError} fifth argument must be a nonnegative integer +* @throws {RangeError} seventh argument must be greater than or equal to max(1,N) +* @throws {RangeError} ninth argument must be non-zero +* @returns {Float64Array} `x` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 3, A, 3, x, 1 ); +* // x => [ 14.0, 8.0, 3.0 ] +*/ +function dtrmv( order, uplo, trans, diag, N, A, LDA, x, strideX ) { + var sa1; + var sa2; + var ox; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + if ( !isTransposeOperation( trans ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be a valid transpose operation. Value: `%s`.', trans ) ); + } + if ( !isDiagonal( diag ) ) { + throw new TypeError( format( 'invalid argument. Fourth argument must be a valid diagonal type. Value: `%s`.', diag ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( N === 0 ) { + return x; + } + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + ox = stride2offset( N, strideX ); + return base( uplo, trans, diag, N, A, sa1, sa2, 0, x, strideX, ox ); +} + + +// EXPORTS // + +module.exports = dtrmv; diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/lib/index.js b/lib/node_modules/@stdlib/blas/base/dtrmv/lib/index.js new file mode 100644 index 00000000000..e6cc7d7d20d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/lib/index.js @@ -0,0 +1,70 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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'; + +/** +* BLAS level 2 routine to perform one of the matrix-vector operations `x = A*x` or `x = A^T*x`, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. +* +* @module @stdlib/blas/base/dtrmv +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dtrmv = require( '@stdlib/blas/base/dtrmv' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dtrmv( 'row-major', 'upper', 'no-transpose', 'unit', 3, A, 3, x, 1 ); +* // x => [ 14.0, 8.0, 3.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dtrmv = require( '@stdlib/blas/base/dtrmv' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dtrmv.ndarray( 'upper', 'no-transpose', 'unit', 3, A, 3, 1, 0, x, 1, 0 ); +* // x => [ 14.0, 8.0, 3.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 dtrmv; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dtrmv = main; +} else { + dtrmv = tmp; +} + + +// EXPORTS // + +module.exports = dtrmv; + +// exports: { "ndarray": "dtrmv.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/lib/main.js b/lib/node_modules/@stdlib/blas/base/dtrmv/lib/main.js new file mode 100644 index 00000000000..2318cb22a5a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dtrmv = require( './dtrmv.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dtrmv, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dtrmv; diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dtrmv/lib/ndarray.js new file mode 100644 index 00000000000..9036d43cb70 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/lib/ndarray.js @@ -0,0 +1,87 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var isTransposeOperation = require( '@stdlib/blas/base/assert/is-transpose-operation' ); +var isDiagonal = require( '@stdlib/blas/base/assert/is-diagonal-type' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix. +* +* @param {string} uplo - specifies whether `A` is an upper or lower triangular matrix +* @param {string} trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed +* @param {string} diag - specifies whether `A` has a unit diagonal +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} x - input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @throws {TypeError} first argument must specify whether a lower or upper triangular matrix is supplied +* @throws {TypeError} second argument must be a valid transpose operation +* @throws {TypeError} third argument must be a valid diagonal type +* @throws {RangeError} fourth argument must be a nonnegative integer +* @throws {RangeError} tenth argument must be non-zero +* @returns {Float64Array} `x` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dtrmv( 'upper', 'no-transpose', 'unit', 3, A, 3, 1, 0, x, 1, 0 ); +* // x => [ 14.0, 8.0, 3.0 ] +*/ +function dtrmv( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-params, max-len + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. First argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + if ( !isTransposeOperation( trans ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a valid transpose operation. Value: `%s`.', trans ) ); + } + if ( !isDiagonal( diag ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be a valid diagonal type. Value: `%s`.', diag ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Tenth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( N === 0 ) { + return x; + } + return base( uplo, trans, diag, N, A, strideA1, strideA2, offsetA, x, strideX, offsetX ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dtrmv; diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/package.json b/lib/node_modules/@stdlib/blas/base/dtrmv/package.json new file mode 100644 index 00000000000..ecf9053fd04 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/blas/base/dtrmv", + "version": "0.0.0", + "description": "Perform one of the matrix-vector operations `x = A*x` or `x = A^T*x`.", + "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", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "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", + "stdmath", + "mathematics", + "math", + "blas", + "level 2", + "dtrmv", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_complex_access_pattern.json new file mode 100644 index 00000000000..fbfeb4e86d8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_complex_access_pattern.json @@ -0,0 +1,14 @@ +{ + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideA1": -2, + "strideA2": -5, + "offsetA": 14, + "strideX": -1, + "offsetX": 2, + "N": 3, + "A": [ 6, 999, 0, 999, 0, 5, 999, 4, 999, 0, 3, 999, 2, 999, 1 ], + "x": [ 3.0, 2.0, 1.0 ], + "x_out": [ 31.0, 10.0, 1.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_nt_nu.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_nt_nu.json new file mode 100644 index 00000000000..1f85b5550d9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_nt_nu.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "N": 3, + "A": [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0, 0.0, 0.0, 6.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 10.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_nt_u.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_nt_u.json new file mode 100644 index 00000000000..026735b9bad --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_nt_u.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "trans": "no-transpose", + "diag": "unit", + "uplo": "lower", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "N": 3, + "A": [ 1.0, 2.0, 2.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 4.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_t_nu.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_t_nu.json new file mode 100644 index 00000000000..f43bed3bcf4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_t_nu.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "trans": "transpose", + "diag": "non-unit", + "uplo": "lower", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "N": 3, + "A": [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0, 0.0, 0.0, 6.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 14.0, 23.0, 18.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_t_u.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_t_u.json new file mode 100644 index 00000000000..8f1400bc40e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_l_t_u.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "trans": "transpose", + "diag": "unit", + "uplo": "lower", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "N": 3, + "A": [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 14.0, 8.0, 3.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_oa.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_oa.json new file mode 100644 index 00000000000..d2c2ab29e07 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_oa.json @@ -0,0 +1,14 @@ +{ + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideA1": 2, + "strideA2": 6, + "offsetA": 7, + "strideX": 1, + "offsetX": 0, + "N": 3, + "A": [ 999, 999, 999, 999, 999, 999, 999, 1, 999, 2, 999, 3, 999, 0, 999, 4, 999, 5, 999, 0, 999, 0, 999, 6, 999, 999, 999, 999, 999, 999 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 10.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1_sa2.json new file mode 100644 index 00000000000..3653ba1b270 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1_sa2.json @@ -0,0 +1,14 @@ +{ + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideA1": 2, + "strideA2": 5, + "offsetA": 0, + "strideX": 1, + "offsetX": 0, + "N": 3, + "A": [ 1, 999, 2, 999, 3, 0, 999, 4, 999, 5, 0, 999, 0, 999, 6 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 10.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1_sa2n.json new file mode 100644 index 00000000000..69a3f6b4166 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1_sa2n.json @@ -0,0 +1,14 @@ +{ + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideA1": 2, + "strideA2": -5, + "offsetA": 10, + "strideX": 1, + "offsetX": 0, + "N": 3, + "A": [ 0, 999, 0, 999, 6, 0, 999, 4, 999, 5, 1, 999, 2, 999, 3 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 10.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1n_sa2.json new file mode 100644 index 00000000000..5262cb1d4da --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1n_sa2.json @@ -0,0 +1,14 @@ +{ + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideA1": -2, + "strideA2": 5, + "offsetA": 4, + "strideX": 1, + "offsetX": 0, + "N": 3, + "A": [ 3, 999, 2, 999, 1, 5, 999, 4, 999, 0, 6, 999, 0, 999, 0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 10.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1n_sa2n.json new file mode 100644 index 00000000000..9e26fe112a9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_sa1n_sa2n.json @@ -0,0 +1,14 @@ +{ + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideA1": -2, + "strideA2": -5, + "offsetA": 14, + "strideX": 1, + "offsetX": 0, + "N": 3, + "A": [ 6, 999, 0, 999, 0, 5, 999, 4, 999, 0, 3, 999, 2, 999, 1 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 10.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_nt_nu.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_nt_nu.json new file mode 100644 index 00000000000..cbbc1b3e3d8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_nt_nu.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "upper", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "N": 3, + "A": [ 1.0, 0.0, 0.0, 2.0, 4.0, 0.0, 3.0, 5.0, 6.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 14.0, 23.0, 18.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_nt_u.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_nt_u.json new file mode 100644 index 00000000000..28367ca0cc0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_nt_u.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "trans": "no-transpose", + "diag": "unit", + "uplo": "upper", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "N": 3, + "A": [ 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 14.0, 8.0, 3.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_t_nu.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_t_nu.json new file mode 100644 index 00000000000..92c5e1acd39 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_t_nu.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "trans": "transpose", + "diag": "non-unit", + "uplo": "upper", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "N": 3, + "A": [ 1.0, 0.0, 0.0, 2.0, 4.0, 0.0, 3.0, 5.0, 6.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 10.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_t_u.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_t_u.json new file mode 100644 index 00000000000..c395300a07a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_u_t_u.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "trans": "transpose", + "diag": "unit", + "uplo": "upper", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "N": 3, + "A": [ 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 4.0, 10.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_xn.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_xn.json new file mode 100644 index 00000000000..90fd6cefe03 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_xn.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "trans": "transpose", + "diag": "unit", + "uplo": "upper", + "strideX": -1, + "offsetA": 0, + "offsetX": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "N": 3, + "A": [ 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 ], + "x": [ 3.0, 2.0, 1.0 ], + "x_out": [ 10.0, 4.0, 1.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_xt.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_xt.json new file mode 100644 index 00000000000..2a993cbf7c5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/column_major_xt.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "trans": "transpose", + "diag": "unit", + "uplo": "upper", + "strideX": 2, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "N": 3, + "A": [ 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 ], + "x": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "x_out": [ 1.0, 0.0, 4.0, 0.0, 10.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_complex_access_pattern.json new file mode 100644 index 00000000000..c2aed04ac97 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_complex_access_pattern.json @@ -0,0 +1,14 @@ +{ + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideA1": -6, + "strideA2": -1, + "offsetA": 14, + "strideX": -1, + "offsetX": 2, + "N": 3, + "A": [ 6, 5, 3, 999, 999, 999, 0, 4, 2, 999, 999, 999, 0, 0, 1 ], + "x": [ 3.0, 2.0, 1.0 ], + "x_out": [ 31.0, 10.0, 1.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_nt_nu.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_nt_nu.json new file mode 100644 index 00000000000..07cb4c70bfb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_nt_nu.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "N": 3, + "A": [ 1.0, 0.0, 0.0, 2.0, 3.0, 0.0, 4.0, 5.0, 6.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 8.0, 32.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_nt_u.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_nt_u.json new file mode 100644 index 00000000000..94e7a6c28a0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_nt_u.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "trans": "no-transpose", + "diag": "unit", + "uplo": "lower", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "N": 3, + "A": [ 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 2.0, 1.0, 1.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 4.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_t_nu.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_t_nu.json new file mode 100644 index 00000000000..d6429a1ee23 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_t_nu.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "trans": "transpose", + "diag": "non-unit", + "uplo": "lower", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "N": 3, + "A": [ 1.0, 0.0, 0.0, 2.0, 3.0, 0.0, 4.0, 5.0, 6.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 17.0, 21.0, 18.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_t_u.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_t_u.json new file mode 100644 index 00000000000..2cd0a30d3c8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_l_t_u.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "trans": "transpose", + "diag": "unit", + "uplo": "lower", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "N": 3, + "A": [ 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 4.0, 1.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 14.0, 14.0, 3.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_oa.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_oa.json new file mode 100644 index 00000000000..fdbc41a7994 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_oa.json @@ -0,0 +1,14 @@ +{ + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideA1": 10, + "strideA2": 1, + "offsetA": 6, + "strideX": 1, + "offsetX": 0, + "N": 3, + "A": [ 999, 999, 999, 999, 999, 999, 1, 0, 0, 999, 999, 999, 999, 999, 999, 999, 2, 4, 0, 999, 999, 999, 999, 999, 999, 999, 3, 5, 6, 999 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 10.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1_sa2.json new file mode 100644 index 00000000000..bd2a70b5739 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1_sa2.json @@ -0,0 +1,14 @@ +{ + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideA1": 6, + "strideA2": 1, + "offsetA": 0, + "strideX": 1, + "offsetX": 0, + "N": 3, + "A": [ 1, 0, 0, 999, 999, 999, 2, 4, 0, 999, 999, 999, 3, 5, 6 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 10.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1_sa2n.json new file mode 100644 index 00000000000..87d03686138 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1_sa2n.json @@ -0,0 +1,14 @@ +{ + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideA1": 6, + "strideA2": -1, + "offsetA": 2, + "strideX": 1, + "offsetX": 0, + "N": 3, + "A": [ 0, 0, 1, 999, 999, 999, 0, 4, 2, 999, 999, 999, 6, 5, 3 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 10.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1n_sa2.json new file mode 100644 index 00000000000..954c9c09556 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1n_sa2.json @@ -0,0 +1,14 @@ +{ + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideA1": -6, + "strideA2": 1, + "offsetA": 12, + "strideX": 1, + "offsetX": 0, + "N": 3, + "A": [ 3, 5, 6, 999, 999, 999, 2, 4, 0, 999, 999, 999, 1, 0, 0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 10.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1n_sa2n.json new file mode 100644 index 00000000000..44d83b8a3bf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_sa1n_sa2n.json @@ -0,0 +1,14 @@ +{ + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "lower", + "strideA1": -6, + "strideA2": -1, + "offsetA": 14, + "strideX": 1, + "offsetX": 0, + "N": 3, + "A": [ 6, 5, 3, 999, 999, 999, 0, 4, 2, 999, 999, 999, 0, 0, 1 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 10.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_nt_nu.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_nt_nu.json new file mode 100644 index 00000000000..9d0ffaf6926 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_nt_nu.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "trans": "no-transpose", + "diag": "non-unit", + "uplo": "upper", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "N": 3, + "A": [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0, 0.0, 0.0, 6.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 14.0, 23.0, 18.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_nt_u.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_nt_u.json new file mode 100644 index 00000000000..0bef3befccd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_nt_u.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "trans": "no-transpose", + "diag": "unit", + "uplo": "upper", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "N": 3, + "A": [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 14.0, 8.0, 3.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_t_nu.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_t_nu.json new file mode 100644 index 00000000000..350bc599d05 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_t_nu.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "trans": "transpose", + "diag": "non-unit", + "uplo": "upper", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "N": 3, + "A": [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0, 0.0, 0.0, 6.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 10.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_t_u.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_t_u.json new file mode 100644 index 00000000000..3216211b81a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_u_t_u.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "trans": "transpose", + "diag": "unit", + "uplo": "upper", + "strideX": 1, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "N": 3, + "A": [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 1.0, 4.0, 10.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_xn.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_xn.json new file mode 100644 index 00000000000..6f9608e918a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_xn.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "trans": "transpose", + "diag": "unit", + "uplo": "upper", + "strideX": -1, + "offsetA": 0, + "offsetX": 2, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "N": 3, + "A": [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "x_out": [ 14.0, 8.0, 3.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_xt.json b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_xt.json new file mode 100644 index 00000000000..6e31d5f93c7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/fixtures/row_major_xt.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "trans": "transpose", + "diag": "unit", + "uplo": "upper", + "strideX": 2, + "offsetA": 0, + "offsetX": 0, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "N": 3, + "A": [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ], + "x": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "x_out": [ 1.0, 0.0, 4.0, 0.0, 10.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/test.dtrmv.js b/lib/node_modules/@stdlib/blas/base/dtrmv/test/test.dtrmv.js new file mode 100644 index 00000000000..7f8351f0f02 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/test.dtrmv.js @@ -0,0 +1,756 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dtrmv = require( './../lib/dtrmv.js' ); + + +// FIXTURES // + +var rlntnu = require( './fixtures/row_major_l_nt_nu.json' ); +var rltnu = require( './fixtures/row_major_l_t_nu.json' ); +var rlntu = require( './fixtures/row_major_l_nt_u.json' ); +var rltu = require( './fixtures/row_major_l_t_u.json' ); +var runtnu = require( './fixtures/row_major_u_nt_nu.json' ); +var runtu = require( './fixtures/row_major_u_nt_u.json' ); +var rutnu = require( './fixtures/row_major_u_t_nu.json' ); +var rutu = require( './fixtures/row_major_u_t_u.json' ); +var rxt = require( './fixtures/row_major_xt.json' ); +var rxn = require( './fixtures/row_major_xn.json' ); + +var clntnu = require( './fixtures/column_major_l_nt_nu.json' ); +var cltnu = require( './fixtures/column_major_l_t_nu.json' ); +var clntu = require( './fixtures/column_major_l_nt_u.json' ); +var cltu = require( './fixtures/column_major_l_t_u.json' ); +var cuntnu = require( './fixtures/column_major_u_nt_nu.json' ); +var cuntu = require( './fixtures/column_major_u_nt_u.json' ); +var cutnu = require( './fixtures/column_major_u_t_nu.json' ); +var cutu = require( './fixtures/column_major_u_t_u.json' ); +var cxt = require( './fixtures/column_major_xt.json' ); +var cxn = require( './fixtures/column_major_xn.json' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dtrmv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( dtrmv.length, 9, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var data; + var i; + + data = rutu; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dtrmv( value, data.uplo, data.trans, data.diag, data.N, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var data; + var i; + + data = rutu; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dtrmv( data.order, value, data.trans, data.diag, data.N, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var data; + var i; + + data = rutu; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dtrmv( data.order, data.uplo, value, data.diag, data.N, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fourth argument', function test( t ) { + var values; + var data; + var i; + + data = rutu; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dtrmv( data.order, data.uplo, data.trans, value, data.N, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument', function test( t ) { + var values; + var data; + var i; + + data = rutu; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dtrmv( data.order, data.uplo, data.trans, data.diag, value, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid seventh argument', function test( t ) { + var values; + var data; + var i; + + data = rutu; + + values = [ + 2, + 1, + 0, + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, new Float64Array( data.A ), value, new Float64Array( data.x ), data.strideX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid ninth argument', function test( t ) { + var values; + var data; + var i; + + data = rutu; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, new Float64Array( data.A ), data.LDA, new Float64Array( data.x ), value ); + }; + } +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, lower, no-transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rlntnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, lower, no-transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = clntnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, lower, transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rltnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, lower, transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cltnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, lower, no-transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rlntu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, lower, no-transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = clntu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, lower, transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rltu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, lower, transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cltu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, upper, no-transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = runtnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, upper, no-transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cuntnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, upper, no-transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = runtu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, upper, no-transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cuntu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, upper, transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rutnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, upper, transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cutnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, upper, transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, upper, transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rxt; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cxt; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function returns a reference to the input vector', function test( t ) { + var data; + var out; + var a; + var x; + + data = rutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero, the function returns the input vector unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, 0, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero, the function returns the input vector unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, 0, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rxn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cxn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.order, data.uplo, data.trans, data.diag, data.N, a, data.LDA, x, data.strideX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/test.js b/lib/node_modules/@stdlib/blas/base/dtrmv/test/test.js new file mode 100644 index 00000000000..f10cb164883 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dtrmv = 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 dtrmv, '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 dtrmv.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 dtrmv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dtrmv, mock, 'returns expected value' ); + 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 dtrmv; + var main; + + main = require( './../lib/dtrmv.js' ); + + dtrmv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dtrmv, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/dtrmv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dtrmv/test/test.ndarray.js new file mode 100644 index 00000000000..34c08cbbb68 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrmv/test/test.ndarray.js @@ -0,0 +1,966 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dtrmv = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var rlntnu = require( './fixtures/row_major_l_nt_nu.json' ); +var rltnu = require( './fixtures/row_major_l_t_nu.json' ); +var rlntu = require( './fixtures/row_major_l_nt_u.json' ); +var rltu = require( './fixtures/row_major_l_t_u.json' ); +var runtnu = require( './fixtures/row_major_u_nt_nu.json' ); +var runtu = require( './fixtures/row_major_u_nt_u.json' ); +var rutnu = require( './fixtures/row_major_u_t_nu.json' ); +var rutu = require( './fixtures/row_major_u_t_u.json' ); +var rxt = require( './fixtures/row_major_xt.json' ); +var rxn = require( './fixtures/row_major_xn.json' ); +var roa = require( './fixtures/row_major_oa.json' ); +var rsa1sa2 = require( './fixtures/row_major_sa1_sa2.json' ); +var rsa1nsa2 = require( './fixtures/row_major_sa1n_sa2.json' ); +var rsa1sa2n = require( './fixtures/row_major_sa1_sa2n.json' ); +var rsa1nsa2n = require( './fixtures/row_major_sa1n_sa2n.json' ); +var rcap = require( './fixtures/row_major_complex_access_pattern.json' ); + +var clntnu = require( './fixtures/column_major_l_nt_nu.json' ); +var cltnu = require( './fixtures/column_major_l_t_nu.json' ); +var clntu = require( './fixtures/column_major_l_nt_u.json' ); +var cltu = require( './fixtures/column_major_l_t_u.json' ); +var cuntnu = require( './fixtures/column_major_u_nt_nu.json' ); +var cuntu = require( './fixtures/column_major_u_nt_u.json' ); +var cutnu = require( './fixtures/column_major_u_t_nu.json' ); +var cutu = require( './fixtures/column_major_u_t_u.json' ); +var cxt = require( './fixtures/column_major_xt.json' ); +var cxn = require( './fixtures/column_major_xn.json' ); +var coa = require( './fixtures/column_major_oa.json' ); +var csa1sa2 = require( './fixtures/column_major_sa1_sa2.json' ); +var csa1nsa2 = require( './fixtures/column_major_sa1n_sa2.json' ); +var csa1sa2n = require( './fixtures/column_major_sa1_sa2n.json' ); +var csa1nsa2n = require( './fixtures/column_major_sa1_sa2n.json' ); +var ccap = require( './fixtures/column_major_complex_access_pattern.json' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dtrmv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( dtrmv.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var data; + var i; + + data = rutu; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dtrmv( value, data.trans, data.diag, data.N, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var data; + var i; + + data = rutu; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dtrmv( data.uplo, value, data.diag, data.N, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var data; + var i; + + data = rutu; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dtrmv( data.uplo, data.trans, value, data.N, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fourth argument', function test( t ) { + var values; + var data; + var i; + + data = rutu; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dtrmv( data.uplo, data.trans, data.diag, value, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), data.strideX, data.offsetX ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid tenth argument', function test( t ) { + var values; + var data; + var i; + + data = rutu; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dtrmv( data.uplo, data.trans, data.diag, data.N, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.x ), value, data.offsetX ); + }; + } +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, lower, no-transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rlntnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, lower, no-transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = clntnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, lower, transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rltnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, lower, transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cltnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, lower, no-transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rlntu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, lower, no-transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = clntu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, lower, transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rltu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, lower, transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cltu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, upper, no-transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = runtnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, upper, no-transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cuntnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, upper, no-transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = runtu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, upper, no-transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cuntu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, upper, transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rutnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, upper, transpose, non-unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cutnu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (row-major, upper, transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` (column-major, upper, transpose, unit)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rxt; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cxt; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function returns a reference to the input vector', function test( t ) { + var data; + var out; + var a; + var x; + + data = rutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero, the function returns the input vector unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x ); + + out = dtrmv( data.uplo, data.trans, data.diag, 0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero, the function returns the input vector unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cutu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x ); + + out = dtrmv( data.uplo, data.trans, data.diag, 0, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the strides of the first and second dimensions of `A` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rsa1sa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying the strides of the first and second dimensions of `A` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = csa1sa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports a negative stride for the first dimension of `A` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rsa1nsa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports a negative stride for the first dimension of `A` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = csa1nsa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports a negative stride for the second dimension of `A` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rsa1sa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports a negative stride for the second dimension of `A` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = csa1sa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports negative strides for both dimensions of `A` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rsa1nsa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports negative strides for both dimensions of `A` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = csa1nsa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports an `A` offset (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = roa; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports an `A` offset (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = coa; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rxn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports a negative `x` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cxn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rcap; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = ccap; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.x_out ); + + out = dtrmv( data.uplo, data.trans, data.diag, data.N, a, data.strideA1, data.strideA2, data.offsetA, x, data.strideX, data.offsetX ); + t.strictEqual( out, x, 'returns expected value' ); + isApprox( t, x, expected, 2.0 ); + + t.end(); +});