diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/README.md b/lib/node_modules/@stdlib/lapack/base/dlaev2/README.md new file mode 100644 index 00000000000..7d501268dac --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/README.md @@ -0,0 +1,235 @@ + + +# dlaev2 + +> Compute the eigendecomposition of a 2x2 symmetric matrix. + +
+ +## Usage + +```javascript +var dlaev2 = require( '@stdlib/lapack/base/dlaev2' ); +``` + +#### dlaev2( A, B, C, out, ev ) + +Computes the eigendecomposition of a 2x2 symmetric matrix. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var ev = new Float64Array( 2 ); +var out = new Float64Array( 2 ); +out = dlaev2( 2.0, 3.0, 4.0, out, ev ); +// out => [ ~6.162, ~-0.162 ] +// ev => [ ~0.585, ~0.811 ] +``` + +The function has the following parameters: + +- **A**: the (0,0) element of a 2x2 symmetric matrix. +- **B**: the (0,1) and the conjugate of (1,0) element of a 2x2 symmetric matrix. +- **C**: the (1,1) element of a 2x2 symmetric matrix. +- **out**: output [`Float64Array`][mdn-float64array] containing the eigenvalues of larger and smaller absolute values respectively. +- **ev**: output [`Float64Array`][mdn-float64array] containing `CS1` and `SN1` which is unit right eigenvector for `RT1` giving the decomposition. + +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 out0 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +var ev0 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + +// Create offset views... +var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var ev1 = new Float64Array( ev0.buffer, ev0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dlaev2( 2.0, 3.0, 4.0, out1, ev1 ); +// out0 => [ 1.0, ~6.162, ~-0.162 ] +// ev0 => [ 1.0, ~0.585, ~0.811 ] +``` + +#### dlaev2.ndarray( A, B, C, out, sout, oout, ev, sev, oev ) + +Computes the eigendecomposition of a 2x2 symmetric matrix using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var ev = new Float64Array( 2 ); +var out = new Float64Array( 2 ); +out = dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, 0 ); +// out => [ ~6.162, ~-0.162 ] +// ev => [ ~0.585, ~0.811 ] +``` + +The function has the following additional parameters: + +- **sout**: stride length for `out`. +- **oout**: starting index of `out`. +- **sev**: stride length for `ev`. +- **oev**: starting index of `ev`. + +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 ev = new Float64Array( [ 999.9, 0.0, 999.9, 0.0 ] ); +var out = new Float64Array( [ 0.0, 999.9, 0.0 ] ); +out = dlaev2.ndarray( 2.0, 3.0, 4.0, out, -2, 2, ev, 2, 1 ); +// out => [ ~-0.162, 999.9, ~6.162 ] +// ev => [ 999.9, ~0.585, 999.9, ~0.811 ] +``` + +
+ + + +
+ +## Notes + +- `dlaev2()` corresponds to the [LAPACK][lapack] routine [`dlaev2`][lapack-dlaev2]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dlaev2 = require( '@stdlib/lapack/base/dlaev2' ); + +var ev = new Float64Array( 2 ); +var out = new Float64Array( 2 ); +out = dlaev2( 2.0, 3.0, 4.0, out, ev ); +console.log( 'out: ', out ); +console.log( 'ev: ', ev ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlaev2/benchmark/benchmark.js new file mode 100644 index 00000000000..344344b63cb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/benchmark/benchmark.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 randu = require( '@stdlib/random/base/randu' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var dlaev2 = require( './../lib/dlaev2.js' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var out; + var ev; + var A; + var B; + var C; + var i; + + out = new Float64Array( 2 ); + ev = new Float64Array( 2 ); + A = ( randu()*1000.0 ) - 500.0; + B = ( randu()*1000.0 ) - 500.0; + C = ( randu()*1000.0 ) - 500.0; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = dlaev2( A, B, C, out, ev ); + A = out[ i%out.length ]; + B = out[ i%out.length ]; + C = ev[ i%ev.length ]; + if ( isnan( out[ i%out.length ] || isnan( ev[ i%ev.length ] ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( out[ i%out.length ] || isnan( ev[ i%ev.length ] ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaev2/benchmark/benchmark.ndarray.js new file mode 100644 index 00000000000..ba8ae19ccd8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/benchmark/benchmark.ndarray.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 randu = require( '@stdlib/random/base/randu' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var dlaev2 = require( './../lib/ndarray.js' ); + + +// MAIN // + +bench( pkg+':ndarray', function benchmark( b ) { + var out; + var ev; + var A; + var B; + var C; + var i; + + out = new Float64Array( 2 ); + ev = new Float64Array( 2 ); + A = ( randu()*1000.0 ) - 500.0; + B = ( randu()*1000.0 ) - 500.0; + C = ( randu()*1000.0 ) - 500.0; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = dlaev2( A, B, C, out, 1, 0, ev, 1, 0 ); + A = out[ i%out.length ]; + B = out[ i%out.length ]; + C = ev[ i%ev.length ]; + if ( isnan( out[ i%out.length ] || isnan( ev[ i%ev.length ] ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( out[ i%out.length ] || isnan( ev[ i%ev.length ] ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaev2/docs/repl.txt new file mode 100644 index 00000000000..48616bc63cd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/docs/repl.txt @@ -0,0 +1,96 @@ + +{{alias}}( A, B, C, out, ev ) + Computes the eigendecomposition of a 2x2 symmetric matrix. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + Parameters + ---------- + A: number + The (0,0) element of a 2x2 symmetric matrix. + + B: number + The (0,1) and the conjugate of (1,0) element of a 2x2 symmetric matrix. + + C: number + The (1,1) element of a 2x2 symmetric matrix. + + out: Float64Array + Output array containing the eigenvalues of larger and smaller absolute + values respectively. + + ev: Float64Array + Output array containing `CS1` and `SN1` which is unit right eigenvector + for `RT1` giving the decomposition. + + Returns + ------- + out: Float64Array + Output array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float64}}( 2 ); + > var ev = new {{alias:@stdlib/array/float64}}( 2 ); + > {{alias}}( 2.0, 3.0, 4.0, out, ev ) + [ ~6.162, ~-0.162 ] + > ev + [ ~0.585, ~0.811 ] + + +{{alias}}.( A, B, C, out, sout, oout, ev, sev, oev ) + Computes the eigendecomposition of a 2x2 symmetric matrix using alternative + indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + A: number + The (0,0) element of a 2x2 symmetric matrix. + + B: number + The (0,1) and the conjugate of (1,0) element of a 2x2 symmetric matrix. + + C: number + The (1,1) element of a 2x2 symmetric matrix. + + out: Float64Array + Output array containing the eigenvalues of larger and smaller absolute + values respectively. + + sout: integer + Stride length for `out`. + + oout: integer + Starting index of `out`. + + ev: Float64Array + Output array containing `CS1` and `SN1` which is unit right eigenvector + for `RT1` giving the decomposition. + + sev: integer + Stride length for `ev`. + + oev: integer + Starting index of `ev`. + + Returns + ------- + out: Float64Array + Output array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0 ] ); + > var ev = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0 ] ); + > {{alias}}.ndarray( 2.0, 3.0, 4.0, out, 2, 0, ev, -1, 2 ) + [ ~6.162, 0.0, ~-0.162 ] + > ev + [ 0.0, ~0.811, ~0.585 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaev2/docs/types/index.d.ts new file mode 100644 index 00000000000..89504928b82 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/docs/types/index.d.ts @@ -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. +*/ + +// TypeScript Version: 4.1 + +/// + +/** +* Interface describing `dlaev2`. +*/ +interface Routine { + /** + * Computes the eigendecomposition of a 2x2 symmetric matrix. + * + * @param A - the (0,0) element of a 2x2 symmetric matrix + * @param B - the (0,1) and the conjugate of the (1,0) element of a 2x2 symmetric matrix + * @param C - the (1,1) element of a 2x2 symmetric matrix + * @param out - output array containing the eigenvalues of larger and smaller absolute values respectively + * @param ev - output array containing `CS1` and `SN1` which is unit right eigenvector for `RT1` giving the decomposition + * @returns out - output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var ev = new Float64Array( 2 ); + * var out = new Float64Array( 2 ); + * out = dlaev2( 2.0, 3.0, 4.0, out, ev ); + * // out => [ ~6.162, ~-0.162 ] + * // ev => [ ~0.585, ~0.811 ] + */ + ( A: number, B: number, C: number, out: Float64Array, ev: Float64Array ): Float64Array; + + /** + * Computes the eigendecomposition of a 2x2 symmetric matrix using alternative indexing semantics. + * + * @type {Function} + * @param A - the (0,0) element of a 2x2 symmetric matrix + * @param B - the (0,1) and the conjugate of the (1,0) element of a 2x2 symmetric matrix + * @param C - the (1,1) element of a 2x2 symmetric matrix + * @param out - output array containing the eigenvalues of larger and smaller absolute values respectively + * @param strideOut - stride length for `out` + * @param offsetOut - starting index of `out` + * @param ev - output array containing `CS1` and `SN1` which is unit right eigenvector for `RT1` giving the decomposition + * @param strideEv - stride length for `ev` + * @param offsetEv - starting index of `ev` + * @returns out - output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var ev = new Float64Array( 2 ); + * var out = new Float64Array( 2 ); + * out = dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, 0 ); + * // out => [ ~6.162, ~-0.162 ] + * // ev => [ ~0.585, ~0.811 ] + */ + ndarray( A: number, B: number, C: number, out: Float64Array, strideOut: number, offsetOut: number, ev: Float64Array, strideEv: number, offsetEv: number ): Float64Array; +} + +/** +* Computes the eigendecomposition of a 2x2 symmetric matrix. +* +* @param A - the (0,0) element of a 2x2 symmetric matrix +* @param B - the (0,1) and the conjugate of the (1,0) element of a 2x2 symmetric matrix +* @param C - the (1,1) element of a 2x2 symmetric matrix +* @param out - output array containing the eigenvalues of larger and smaller absolute values respectively +* @param ev - output array containing `CS1` and `SN1` which is unit right eigenvector for `RT1` giving the decomposition +* @returns out - output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var ev = new Float64Array( 2 ); +* var out = new Float64Array( 2 ); +* out = dlaev2( 2.0, 3.0, 4.0, out, ev ); +* // out => [ ~6.162, ~-0.162 ] +* // ev => [ ~0.585, ~0.811 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var ev = new Float64Array( 2 ); +* var out = new Float64Array( 2 ); +* out = dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, 0 ); +* // out => [ ~6.162, ~-0.162 ] +* // ev => [ ~0.585, ~0.811 ] +*/ +declare var dlaev2: Routine; + + +// EXPORTS // + +export = dlaev2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlaev2/docs/types/test.ts new file mode 100644 index 00000000000..2dc606f14ad --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/docs/types/test.ts @@ -0,0 +1,278 @@ +/* +* @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 dlaev2 = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2( 2.0, 3.0, 4.0, out, ev ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2( '5', 3.0, 4.0, out, ev ); // $ExpectError + dlaev2( true, 3.0, 4.0, out, ev ); // $ExpectError + dlaev2( false, 3.0, 4.0, out, ev ); // $ExpectError + dlaev2( null, 3.0, 4.0, out, ev ); // $ExpectError + dlaev2( void 0, 3.0, 4.0, out, ev ); // $ExpectError + dlaev2( [], 3.0, 4.0, out, ev ); // $ExpectError + dlaev2( {}, 3.0, 4.0, out, ev ); // $ExpectError + dlaev2( ( x: number ): number => x, 3.0, 4.0, out, ev ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2( 2.0, '5', 4.0, out, ev ); // $ExpectError + dlaev2( 2.0, true, 4.0, out, ev ); // $ExpectError + dlaev2( 2.0, false, 4.0, out, ev ); // $ExpectError + dlaev2( 2.0, null, 4.0, out, ev ); // $ExpectError + dlaev2( 2.0, void 0, 4.0, out, ev ); // $ExpectError + dlaev2( 2.0, [], 4.0, out, ev ); // $ExpectError + dlaev2( 2.0, {}, 4.0, out, ev ); // $ExpectError + dlaev2( 2.0, ( x: number ): number => x, 4.0, out, ev ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2( 2.0, 3.0, '5', out, ev ); // $ExpectError + dlaev2( 2.0, 3.0, true, out, ev ); // $ExpectError + dlaev2( 2.0, 3.0, false, out, ev ); // $ExpectError + dlaev2( 2.0, 3.0, null, out, ev ); // $ExpectError + dlaev2( 2.0, 3.0, void 0, out, ev ); // $ExpectError + dlaev2( 2.0, 3.0, [], out, ev ); // $ExpectError + dlaev2( 2.0, 3.0, {}, out, ev ); // $ExpectError + dlaev2( 2.0, 3.0, ( x: number ): number => x, out, ev ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2( 2.0, 3.0, 4.0, '5', ev ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, 5, ev ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, true, ev ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, false, ev ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, null, ev ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, void 0, ev ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, [], ev ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, {}, ev ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, ( x: number ): number => x, ev ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + + dlaev2( 2.0, 3.0, 4.0, out, '5' ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, out, 5 ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, out, true ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, out, false ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, out, null ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, out, void 0 ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, out, [] ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, out, {} ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, out, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2(); // $ExpectError + dlaev2( 2.0 ); // $ExpectError + dlaev2( 2.0, 3.0 ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0 ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, out ); // $ExpectError + dlaev2( 2.0, 3.0, 4.0, out, ev, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2.ndarray( '5', 3.0, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( true, 3.0, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( false, 3.0, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( null, 3.0, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( void 0, 3.0, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( [], 3.0, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( {}, 3.0, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( ( x: number ): number => x, 3.0, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2.ndarray( 2.0, '5', 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, true, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, false, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, null, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, void 0, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, [], 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, {}, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, ( x: number ): number => x, 4.0, out, 1, 0, ev, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2.ndarray( 2.0, 3.0, '5', out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, true, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, false, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, null, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, void 0, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, [], out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, {}, out, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, ( x: number ): number => x, out, 1, 0, ev, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2.ndarray( 2.0, 3.0, 4.0, '5', 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, 5, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, true, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, false, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, null, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, void 0, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, [], 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, {}, 1, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, ( x: number ): number => x, 1, 0, ev, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2.ndarray( 2.0, 3.0, 4.0, out, '5', 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, true, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, false, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, null, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, void 0, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, [], 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, {}, 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, ( x: number ): number => x, 0, ev, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, '5', ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, true, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, false, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, null, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, void 0, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, [], ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, {}, ev, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, ( x: number ): number => x, ev, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, '5', 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, 5, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, true, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, false, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, null, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, void 0, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, [], 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, {}, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, '5', 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, true, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, false, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, null, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, void 0, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, [], 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, {}, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, '5' ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, true ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, false ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, null ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, void 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, [] ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, {} ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + const ev = new Float64Array( [ 0.0, 0.0 ] ); + + dlaev2.ndarray(); // $ExpectError + dlaev2.ndarray( 2.0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1 ); // $ExpectError + dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlaev2/examples/index.js new file mode 100644 index 00000000000..8ab8456e5f7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/examples/index.js @@ -0,0 +1,28 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var dlaev2 = require( './../lib' ); + +var ev = new Float64Array( 2 ); +var out = new Float64Array( 2 ); +out = dlaev2( 2.0, 3.0, 4.0, out, ev ); +console.log( 'out: ', out ); +console.log( 'ev: ', ev ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/base.js new file mode 100644 index 00000000000..72fbbdd0dd6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/base.js @@ -0,0 +1,149 @@ +/** +* @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 sqrt = require( '@stdlib/math/base/special/sqrt' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var pow = require( '@stdlib/math/base/special/pow' ); + + +// MAIN // + +/** +* Computes the eigendecomposition of a 2x2 symmetric matrix. +* +* @private +* @param {number} A - the (0,0) element of a 2x2 symmetric matrix +* @param {number} B - the (0,1) and the conjugate of the (1,0) element of a 2x2 symmetric matrix +* @param {number} C - the (1,1) element of a 2x2 symmetric matrix +* @param {Float64Array} out - output array containing the eigenvalues of larger and smaller absolute values respectively +* @param {integer} strideOut - stride length for `out` +* @param {NonNegativeInteger} offsetOut - starting index of `out` +* @param {Float64Array} ev - output array containing `CS1` and `SN1` which is unit right eigenvector for `RT1` giving the decomposition +* @param {integer} strideEv - stride length for `ev` +* @param {NonNegativeInteger} offsetEv - starting index of `ev` +* @returns {Float64Array} out - output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var ev = new Float64Array( 2 ); +* var out = new Float64Array( 2 ); +* out = dlaev2( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, 0 ); +* // out => [ ~6.162, ~-0.162 ] +* // ev => [ ~0.585, ~0.811 ] +*/ +function dlaev2( A, B, C, out, strideOut, offsetOut, ev, strideEv, offsetEv ) { + var acmn; + var acmx; + var sgn1; + var sgn2; + var acs; + var adf; + var cs1; + var rt1; + var rt2; + var sn1; + var ab; + var cs; + var ct; + var df; + var rt; + var sm; + var tb; + var tn; + + sm = A + C; + df = A - C; + adf = abs( df ); + tb = B + B; + ab = abs( tb ); + if ( abs( A ) > abs( C ) ) { + acmx = A; + acmn = C; + } else { + acmx = C; + acmn = A; + } + if ( adf > ab ) { + rt = adf * sqrt( 1.0 + pow( ( ab / adf ), 2 ) ); + } else if ( adf < ab ) { + rt = ab * sqrt( 1.0 + pow( ( adf / ab ), 2 ) ); + } else { + // Includes case AB = ADF = 0 + rt = ab * sqrt( 2.0 ); + } + if ( sm < 0.0 ) { + rt1 = 0.5 * ( sm - rt ); + sgn1 = -1; + + // Order of execution is important. To get fully accurate smaller eigenvalue, next line needs to be executed in higher precision. + rt2 = ( ( acmx / rt1 ) * acmn ) - ( ( B / rt1 ) * B ); + } else if ( sm > 0.0 ) { + rt1 = 0.5 * ( sm + rt ); + sgn1 = 1; + + // Order of execution is important. To get fully accurate smaller eigenvalue, next line needs to be executed in higher precision. + rt2 = ( ( acmx / rt1 ) * acmn ) - ( ( B / rt1 ) * B ); + } else { + // Includes case RT1 = RT2 = 0 + rt1 = 0.5 * rt; + rt2 = -0.5 * rt; + sgn1 = 1; + } + + // Compute the eigenvector + if ( df > 0.0 ) { + cs = df + rt; + sgn2 = 1; + } else { + cs = df - rt; + sgn2 = -1; + } + acs = abs( cs ); + if ( acs > ab ) { + ct = -tb / cs; + sn1 = 1.0 / sqrt( 1.0 + ( ct * ct ) ); + cs1 = ct * sn1; + } else if ( ab === 0.0 ) { + cs1 = 1.0; + sn1 = 0.0; + } else { + tn = -cs / tb; + cs1 = 1.0 / sqrt( 1.0 + ( tn * tn ) ); + sn1 = tn * cs1; + } + if ( sgn1 === sgn2 ) { + tn = cs1; + cs1 = -sn1; + sn1 = tn; + } + out[ offsetOut ] = rt1; + out[ offsetOut + strideOut ] =rt2; + ev[ offsetEv ] = cs1; + ev[ offsetEv + strideEv ] = sn1; + return out; +} + + +// EXPORTS // + +module.exports = dlaev2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/dlaev2.js b/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/dlaev2.js new file mode 100644 index 00000000000..67046fe7fd8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/dlaev2.js @@ -0,0 +1,54 @@ +/** +* @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 base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the eigendecomposition of a 2x2 symmetric matrix. +* +* @param {number} A - the (0,0) element of a 2x2 symmetric matrix +* @param {number} B - the (0,1) and the conjugate of the (1,0) element of a 2x2 symmetric matrix +* @param {number} C - the (1,1) element of a 2x2 symmetric matrix +* @param {Float64Array} out - output array containing the eigenvalues of larger and smaller absolute values respectively +* @param {Float64Array} ev - output array containing `CS1` and `SN1` which is unit right eigenvector for `RT1` giving the decomposition +* @returns {Float64Array} out - output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var ev = new Float64Array( 2 ); +* var out = new Float64Array( 2 ); +* out = dlaev2( 2.0, 3.0, 4.0, out, ev ); +* // out => [ ~6.162, ~-0.162 ] +* // ev => [ ~0.585, ~0.811 ] +*/ +function dlaev2( A, B, C, out, ev ) { + return base( A, B, C, out, 1, 0, ev, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dlaev2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/index.js new file mode 100644 index 00000000000..83a58b26c5a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/index.js @@ -0,0 +1,68 @@ +/** +* @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'; + +/** +* LAPACK routine to compute the eigendecomposition of a 2x2 symmetric matrix. +* +* @module @stdlib/lapack/base/dlaev2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlaev2 = require( '@stdlib/lapack/base/dlaev2' ); +* +* var ev = new Float64Array( 2 ); +* var out = new Float64Array( 2 ); +* out = dlaev2( 2.0, 3.0, 4.0, out, ev ); +* // out => [ ~6.162, ~-0.162 ] +* // ev => [ ~0.585, ~0.811 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlaev2 = require( '@stdlib/lapack/base/dlaev2' ); +* +* var ev = new Float64Array( 2 ); +* var out = new Float64Array( 2 ); +* out = dlaev2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, 0 ); +* // out => [ ~6.162, ~-0.162 ] +* // ev => [ ~0.585, ~0.811 ] +*/ + +// 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 dlaev2; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlaev2 = main; +} else { + dlaev2 = tmp; +} + + +// EXPORTS // + +module.exports = dlaev2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/main.js new file mode 100644 index 00000000000..b5269ecb8e1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/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 dlaev2 = require( './dlaev2.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlaev2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlaev2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/ndarray.js new file mode 100644 index 00000000000..05b9fa65b6e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/lib/ndarray.js @@ -0,0 +1,58 @@ +/** +* @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 base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the eigendecomposition of a 2x2 symmetric matrix using alternative indexing semantics. +* +* @name dlaev2 +* @type {Function} +* @param {number} A - the (0,0) element of a 2x2 symmetric matrix +* @param {number} B - the (0,1) and the conjugate of the (1,0) element of a 2x2 symmetric matrix +* @param {number} C - the (1,1) element of a 2x2 symmetric matrix +* @param {Float64Array} out - output array containing the eigenvalues of larger and smaller absolute values respectively +* @param {integer} strideOut - stride length for `out` +* @param {NonNegativeInteger} offsetOut - starting index of `out` +* @param {Float64Array} ev - output array containing `CS1` and `SN1` which is unit right eigenvector for `RT1` giving the decomposition +* @param {integer} strideEv - stride length for `ev` +* @param {NonNegativeInteger} offsetEv - starting index of `ev` +* @returns {Float64Array} out - output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var ev = new Float64Array( 2 ); +* var out = new Float64Array( 2 ); +* out = dlaev2( 2.0, 3.0, 4.0, out, 1, 0, ev, 1, 0 ); +* // out => [ ~6.162, ~-0.162 ] +* // ev => [ ~0.585, ~0.811 ] +*/ +var dlaev2 = base; + + +// EXPORTS // + +module.exports = dlaev2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/package.json b/lib/node_modules/@stdlib/lapack/base/dlaev2/package.json new file mode 100644 index 00000000000..d6247846f36 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dlaev2", + "version": "0.0.0", + "description": "Compute the eigendecomposition of a 2x2 symmetric matrix.", + "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", + "lapack", + "dlaev2", + "eigendecomposition", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/test/test.dlaev2.js b/lib/node_modules/@stdlib/lapack/base/dlaev2/test/test.dlaev2.js new file mode 100644 index 00000000000..96d6e790cf2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/test/test.dlaev2.js @@ -0,0 +1,123 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlaev2 = require( './../lib/dlaev2.js' ); + + +// 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 dlaev2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( dlaev2.length, 5, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the eigenvalues of a 2x2 symmetric matrix', function test( t ) { + var expected; + var out; + var ev; + + out = new Float64Array( 2 ); + ev = new Float64Array( 2 ); + out = dlaev2( 2.0, 3.0, 4.0, out, ev ); + expected = new Float64Array( [ 6.16227766016838, -0.1622776601683793 ] ); + isApprox( t, out, expected, 1.0 ); + isApprox( t, ev, new Float64Array( [ 0.584710284663765, 0.8112421851755609 ] ), 1.0 ); + + out = dlaev2( -1.0, 3.0, 9.4, out, ev ); + expected = new Float64Array( [ 10.203332407921454, -1.8033324079214537 ] ); + isApprox( t, out, expected, 1.0 ); + isApprox( t, ev, new Float64Array( [ 0.2586642746412805, 0.9659672836200511 ] ), 1.0 ); + + out = dlaev2( -99.9, -67.124, -4.24, out, ev ); + expected = new Float64Array( [ -134.49172211255961, 30.35172211255962 ] ); + isApprox( t, out, expected, 1.0 ); + isApprox( t, ev, new Float64Array( [ -0.8889061214324745, -0.4580894097006336 ] ), 1.0 ); + t.end(); +}); + +tape( 'the function computes eigenvalues of a 2x2 diagonal matrix', function test( t ) { + var expected; + var out; + var ev; + + out = new Float64Array( 2 ); + ev = new Float64Array( 2 ); + out = dlaev2( 2.0, 0.0, 4.0, out, ev ); + expected = new Float64Array( [ 4.0, 2.0 ] ); + isApprox( t, out, expected, 1.0 ); + isApprox( t, ev, new Float64Array( [ 0.0, 1.0 ] ), 1.0 ); + + out = dlaev2( -1.0, 0.0, 9.4, out, ev ); + expected = new Float64Array( [ 9.4, -1.0 ] ); + isApprox( t, out, expected, 1.0 ); + isApprox( t, ev, new Float64Array( [ 0.0, 1.0 ] ), 1.0 ); + + out = dlaev2( -99.9, 0.0, -4.24, out, ev ); + expected = new Float64Array( [ -99.9, -4.24 ] ); + isApprox( t, out, expected, 1.0 ); + isApprox( t, ev, new Float64Array( [ -1.0, 0.0 ] ), 1.0 ); + + out = dlaev2( 1.0, 0.0, 1.0, out, ev ); + expected = new Float64Array( [ 1.0, 1.0 ] ); + isApprox( t, out, expected, 1.0 ); + isApprox( t, ev, new Float64Array( [ 1.0, 0.0 ] ), 1.0 ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlaev2/test/test.js new file mode 100644 index 00000000000..b24dffbf5b2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/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 dlaev2 = 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 dlaev2, '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 dlaev2.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 dlaev2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlaev2, 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 dlaev2; + var main; + + main = require( './../lib/dlaev2.js' ); + + dlaev2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlaev2, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaev2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaev2/test/test.ndarray.js new file mode 100644 index 00000000000..a617541008a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaev2/test/test.ndarray.js @@ -0,0 +1,98 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlae2 = require( './../lib/ndarray.js' ); + + +// 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 dlae2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( dlae2.length, 9, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access pattern to store computed values', function test( t ) { + var expected; + var out; + var ev; + + out = new Float64Array( [ 999.9, 999.9, 0.0, 999.9, 999.9, 0.0 ] ); + expected = new Float64Array( [ 999.9, 999.9, 6.16227766016838, 999.9, 999.9, -0.1622776601683793 ] ); + ev = new Float64Array( [ 999.9, 999.9, 999.9, 0.0, 999.9, 999.9, 999.9, 0.0 ] ); + out = dlae2( 2.0, 3.0, 4.0, out, 3, 2, ev, 4, 3 ); + isApprox( t, out, expected, 1.0 ); + isApprox( t, ev, new Float64Array( [ 999.9, 999.9, 999.9, 0.584710284663765, 999.9, 999.9, 999.9, 0.8112421851755609 ] ), 1.0 ); + t.end(); +}); + +tape( 'the function supports accessing elements in reverse order to store computed values', function test( t ) { + var expected; + var out; + var ev; + + out = new Float64Array( [ 999.9, 999.9, 0.0, 999.9, 999.9, 0.0 ] ); + expected = new Float64Array( [ 999.9, 999.9, -0.1622776601683793, 999.9, 999.9, 6.16227766016838 ] ); + ev = new Float64Array( [ 999.9, 999.9, 0.0, 999.9, 999.9, 999.9, 0.0 ] ); + out = dlae2( 2.0, 3.0, 4.0, out, -3, out.length-1, ev, -4, ev.length-1); + isApprox( t, out, expected, 1.0 ); + isApprox( t, ev, new Float64Array( [ 999.9, 999.9, 0.8112421851755609, 999.9, 999.9, 999.9, 0.584710284663765 ] ), 1.0 ); + t.end(); +});