From fefe9a747df6b2d2bfb2335bce2f28dfe423d8e2 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 22 Aug 2024 18:51:20 +0530 Subject: [PATCH 1/6] feat: init lapack/base/dlae2 --- .../lapack/base/dlae2/examples/index.js | 26 ++++ .../@stdlib/lapack/base/dlae2/lib/base.js | 112 ++++++++++++++++++ .../@stdlib/lapack/base/dlae2/lib/dlae2.js | 51 ++++++++ .../@stdlib/lapack/base/dlae2/lib/main.js | 35 ++++++ .../@stdlib/lapack/base/dlae2/lib/ndarray.js | 52 ++++++++ 5 files changed, 276 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/lib/dlae2.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlae2/examples/index.js new file mode 100644 index 00000000000..809d814032a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/examples/index.js @@ -0,0 +1,26 @@ +/** +* @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 dlae2 = require( './../lib/base.js' ); + +var out = new Float64Array( 2 ); +out = dlae2( 2.0, 3.0, 4.0, out, 1, 0 ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/base.js new file mode 100644 index 00000000000..5615f9166e9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/base.js @@ -0,0 +1,112 @@ +/** +* @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 eignevalues of a 2x2 symmetric matrix. +* +* @private +* @param {number} A - the (0,0) element of matrix +* @param {number} B - the (0,1) & (1,0) element of matrix +* @param {number} C - the (1,1) element of matrix +* @param {number} out - output array containing eigenvalue of larger and smaller absolute value respectively. +* @param {integer} strideOut - stride length for `out` +* @param {NonNegativeInteger} offsetOut - starting index of `out` +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 2 ); +* out = dlae2( 2.0, 3.0, 4.0, out, 1, 0 ); +* // out => [ 6.16227766016838, -0.1622776601683793 ] +*/ +function dlae2( A, B, C, out, strideOut, offsetOut ) { + var acmx; + var acmn; + var adf; + var rt1; + var rt2; + var ab; + var df; + var sm; + var rt; + var tb; + + 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.0 + rt = ab * sqrt( 2.0 ); + } + if ( sm < 0.0 ) { + rt1 = 0.5 * ( sm - rt ); + + /* + 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 ); + + /* + 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.0 + rt1 = 0.5 * rt; + rt2 = -0.5 * rt; + } + out[ offsetOut ] = rt1; + out[ offsetOut + strideOut ] = rt2; + return out; +} + + +// EXPORTS // + +module.exports = dlae2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/dlae2.js b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/dlae2.js new file mode 100644 index 00000000000..df911495fa7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/dlae2.js @@ -0,0 +1,51 @@ +/** +* @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 eignevalues of a 2x2 symmetric matrix. +* +* @param {number} A - the (0,0) element of matrix +* @param {number} B - the (0,1) & (1,0) element of matrix +* @param {number} C - the (1,1) element of matrix +* @param {number} out - output array containing eigenvalue of larger and smaller absolute value respectively. +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 2 ); +* out = dlae2( 2.0, 3.0, 4.0, out ); +* // out => [ 6.16227766016838, -0.1622776601683793 ] +*/ +function dlae2( A, B, C, out ) { + return base( A, B, C, out, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dlae2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/main.js new file mode 100644 index 00000000000..57ca56c9189 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/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 dlae2 = require( './dlae2.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlae2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlae2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js new file mode 100644 index 00000000000..e60ff8e02c9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js @@ -0,0 +1,52 @@ +/** +* @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 eignevalues of a 2x2 symmetric matrix using alternative indexing semantics. +* +* @type {Function} +* @param {number} A - the (0,0) element of matrix +* @param {number} B - the (0,1) & (1,0) element of matrix +* @param {number} C - the (1,1) element of matrix +* @param {number} out - output array containing eigenvalue of larger and smaller absolute value respectively. +* @param {integer} strideOut - stride length for `out` +* @param {NonNegativeInteger} offsetOut - starting index of `out` +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 2 ); +* out = dlae2( 2.0, 3.0, 4.0, out, 1, 0 ); +* // out => [ 6.16227766016838, -0.1622776601683793 ] +*/ +var dlae2 = base; + + +// EXPORTS // + +module.exports = dlae2; From f709b7adba7a918816b7a697e4da6e4eadc01c43 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 22 Aug 2024 19:15:28 +0530 Subject: [PATCH 2/6] docs: add readme --- .../@stdlib/lapack/base/dlae2/README.md | 221 ++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/README.md diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/README.md b/lib/node_modules/@stdlib/lapack/base/dlae2/README.md new file mode 100644 index 00000000000..8bab3442fd8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/README.md @@ -0,0 +1,221 @@ + + +# dlae2 + +> Compute the eigenvalues of a 2x2 symmetric matrix. + +
+ +## Usage + +```javascript +var dlae2 = require( '@stdlib/lapack/base/dlae2' ); +``` + +#### dlae2( A, B, C, out ) + +Computes the eigenvalues of a 2x2 symmetric matrix. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var out = new Float64Array( 2 ); +out = dlae2( 2.0, 3.0, 4.0, out ); +// out => [ 6.16227766016838, -0.1622776601683793 ] +``` + +The function has the following parameters: + +- **A**: the (0,0) element of matrix. +- **B**: the (0,1) & (1,0) element of matrix. +- **C**: the (1,1) element of matrix. +- **out**: output [`Float64Array`][mdn-float64array] containing eigenvalue of larger and smaller absolute value respectively. + +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( [ 0.0, 0.0, 0.0 ] ); + +// Create offset views... +var OUT1 = new Float64Array( OUT0.buffer, OUT0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dlae2( 2.0, 3.0, 4.0, OUT1 ); +// OUT0 => [ 0.0, 6.16227766016838, -0.1622776601683793 ] +``` + +#### dlae2.ndarray( A, B, C, out, strideOut, offsetOut ) + +Computes the eigenvalues of a 2x2 symmetric matrix using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var out = new Float64Array( 2 ); +out = dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); +// out => [ 6.16227766016838, -0.1622776601683793 ] +``` + +The function has the following additional parameters: + +- **strideOut**: stride length for `Out`. +- **offsetOut**: starting index of `out` + +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 out = new Float64Array( [ 0.0, 0.0, 0.0 ] ); +out = dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, 1 ); +// out => [ 0.0, 6.16227766016838, -0.1622776601683793 ] +``` + +
+ + + +
+ +## Notes + +- `dlae2()` corresponds to the [LAPACK][lapack] routine [`dlae2`][lapack-dlae2]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dlae2 = require( '@stdlib/lapack/base/dlae2' ); + +var out = new Float64Array( 2 ); +out = dlae2( 2.0, 3.0, 4.0, out ); +console.log( out ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + From e8994cad0fdc857d0734913547896527ffc63921 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 22 Aug 2024 19:35:40 +0530 Subject: [PATCH 3/6] chore: add other files --- .../@stdlib/lapack/base/dlae2/README.md | 8 +- .../lapack/base/dlae2/benchmark/benchmark.js | 57 +++++ .../base/dlae2/benchmark/benchmark.ndarray.js | 57 +++++ .../lapack/base/dlae2/docs/types/index.d.ts | 94 ++++++++ .../lapack/base/dlae2/docs/types/test.ts | 200 ++++++++++++++++++ .../lapack/base/dlae2/examples/index.js | 4 +- .../@stdlib/lapack/base/dlae2/lib/base.js | 4 +- .../@stdlib/lapack/base/dlae2/lib/dlae2.js | 4 +- .../@stdlib/lapack/base/dlae2/lib/index.js | 64 ++++++ .../@stdlib/lapack/base/dlae2/lib/ndarray.js | 4 +- .../@stdlib/lapack/base/dlae2/package.json | 70 ++++++ .../lapack/base/dlae2/test/test.dlae2.js | 112 ++++++++++ .../@stdlib/lapack/base/dlae2/test/test.js | 82 +++++++ .../lapack/base/dlae2/test/test.ndarray.js | 92 ++++++++ 14 files changed, 840 insertions(+), 12 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/package.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/test/test.dlae2.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/README.md b/lib/node_modules/@stdlib/lapack/base/dlae2/README.md index 8bab3442fd8..d47f26ec739 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/README.md @@ -30,7 +30,7 @@ limitations under the License. var dlae2 = require( '@stdlib/lapack/base/dlae2' ); ``` -#### dlae2( A, B, C, out ) +#### dlae2( A, B, C, Out ) Computes the eigenvalues of a 2x2 symmetric matrix. @@ -45,9 +45,9 @@ out = dlae2( 2.0, 3.0, 4.0, out ); The function has the following parameters: - **A**: the (0,0) element of matrix. -- **B**: the (0,1) & (1,0) element of matrix. +- **B**: the (0,1) & (1,0) elements of matrix. - **C**: the (1,1) element of matrix. -- **out**: output [`Float64Array`][mdn-float64array] containing eigenvalue of larger and smaller absolute value respectively. +- **Out**: output [`Float64Array`][mdn-float64array] containing eigenvalue of larger and smaller absolute value respectively. Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -66,7 +66,7 @@ dlae2( 2.0, 3.0, 4.0, OUT1 ); // OUT0 => [ 0.0, 6.16227766016838, -0.1622776601683793 ] ``` -#### dlae2.ndarray( A, B, C, out, strideOut, offsetOut ) +#### dlae2.ndarray( A, B, C, Out, strideOut, offsetOut ) Computes the eigenvalues of a 2x2 symmetric matrix using alternative indexing semantics. diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.js new file mode 100644 index 00000000000..dba0da6030c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.js @@ -0,0 +1,57 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var dlae2 = require( './../lib/dlae2.js' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var out; + var A; + var B; + var C; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + A = ( randu() * 100.0 ) - 50.0; + B = ( randu() * 100.0 ) - 50.0; + C = ( randu() * 100.0 ) - 50.0; + out = new Float64Array( 2 ); + out = dlae2( A, B, C, out ); + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.ndarray.js new file mode 100644 index 00000000000..0e90eebf1ee --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.ndarray.js @@ -0,0 +1,57 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var dlae2 = require( './../lib/ndarray.js' ); + + +// MAIN // + +bench( pkg+':ndarray', function benchmark( b ) { + var out; + var A; + var B; + var C; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + A = ( randu() * 100.0 ) - 50.0; + B = ( randu() * 100.0 ) - 50.0; + C = ( randu() * 100.0 ) - 50.0; + out = new Float64Array( 2 ); + out = dlae2( A, B, C, out, 1, 0 ); + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlae2/docs/types/index.d.ts new file mode 100644 index 00000000000..ee367e79271 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/docs/types/index.d.ts @@ -0,0 +1,94 @@ +/** +* @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 `dlae2`. +*/ +interface Routine { + /** + * Computes the eigenvalues of a 2x2 symmetric matrix. + * + * @param A - the (0,0) element of matrix + * @param B - the (0,1) & (1,0) element of matrix + * @param C - the (1,1) element of matrix + * @param out - output array containing eigenvalue of larger and smaller absolute value respectively. + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var out = new Float64Array( 2 ); + * out = dlae2( 2.0, 3.0, 4.0, out ); + * // out => [ 6.16227766016838, -0.1622776601683793 ] + */ + ( A: number, B: number, C: number, out: Float64Array ): Float64Array; + + /** + * Computes the eigenvalues of a 2x2 symmetric matrix using alternative indexing semantics. + * + * @type {Function} + * @param A - the (0,0) element of matrix + * @param B - the (0,1) & (1,0) element of matrix + * @param C - the (1,1) element of matrix + * @param out - output array containing eigenvalue of larger and smaller absolute value respectively. + * @param strideOut - stride length for `out` + * @param offsetOut - starting index of `out` + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var out = new Float64Array( 2 ); + * out = dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); + * // out => [ 6.16227766016838, -0.1622776601683793 ] + */ + ndarray( A: number, B: number, C: number, out: Float64Array, strideOut: number, offsetOut: number ): Float64Array; +} + +/** +* Computes the eigenvalues of a 2x2 symmetric matrix. +* +* @param A - the (0,0) element of matrix +* @param B - the (0,1) & (1,0) element of matrix +* @param C - the (1,1) element of matrix +* @param out - output array containing eigenvalue of larger and smaller absolute value respectively. +* @returns output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 2 ); +* out = dlae2( 2.0, 3.0, 4.0, out ); +* // out => [ 6.16227766016838, -0.1622776601683793 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 2 ); +* out = dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); +* // out => [ 6.16227766016838, -0.1622776601683793 ] +*/ +declare var dlae2: Routine; + + +// EXPORTS // + +export = dlae2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlae2/docs/types/test.ts new file mode 100644 index 00000000000..1917d97a752 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/docs/types/test.ts @@ -0,0 +1,200 @@ +/* +* @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 dlae2 = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + + dlae2( 2.0, 3.0, 4.0, out ); // $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 ] ); + + dlae2( '5', 3.0, 4.0, out ); // $ExpectError + dlae2( true, 3.0, 4.0, out ); // $ExpectError + dlae2( false, 3.0, 4.0, out ); // $ExpectError + dlae2( null, 3.0, 4.0, out ); // $ExpectError + dlae2( void 0, 3.0, 4.0, out ); // $ExpectError + dlae2( [], 3.0, 4.0, out ); // $ExpectError + dlae2( {}, 3.0, 4.0, out ); // $ExpectError + dlae2( ( x: number ): number => x, 3.0, 4.0, out ); // $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 ] ); + + dlae2( 2.0, '5', 4.0, out ); // $ExpectError + dlae2( 2.0, true, 4.0, out ); // $ExpectError + dlae2( 2.0, false, 4.0, out ); // $ExpectError + dlae2( 2.0, null, 4.0, out ); // $ExpectError + dlae2( 2.0, void 0, 4.0, out ); // $ExpectError + dlae2( 2.0, [], 4.0, out ); // $ExpectError + dlae2( 2.0, {}, 4.0, out ); // $ExpectError + dlae2( 2.0, ( x: number ): number => x, 4.0, out ); // $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 ] ); + + dlae2( 2.0, 3.0, '5', out ); // $ExpectError + dlae2( 2.0, 3.0, true, out ); // $ExpectError + dlae2( 2.0, 3.0, false, out ); // $ExpectError + dlae2( 2.0, 3.0, null, out ); // $ExpectError + dlae2( 2.0, 3.0, void 0, out ); // $ExpectError + dlae2( 2.0, 3.0, [], out ); // $ExpectError + dlae2( 2.0, 3.0, {}, out ); // $ExpectError + dlae2( 2.0, 3.0, ( x: number ): number => x, out ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + + dlae2( 2.0, 3.0, 4.0, '5' ); // $ExpectError + dlae2( 2.0, 3.0, 4.0, 5 ); // $ExpectError + dlae2( 2.0, 3.0, 4.0, true ); // $ExpectError + dlae2( 2.0, 3.0, 4.0, false ); // $ExpectError + dlae2( 2.0, 3.0, 4.0, null ); // $ExpectError + dlae2( 2.0, 3.0, 4.0, void 0 ); // $ExpectError + dlae2( 2.0, 3.0, 4.0, [] ); // $ExpectError + dlae2( 2.0, 3.0, 4.0, {} ); // $ExpectError + dlae2( 2.0, 3.0, 4.0, ( 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 ] ); + + dlae2(); // $ExpectError + dlae2( 2.0 ); // $ExpectError + dlae2( 2.0, 3.0 ); // $ExpectError + dlae2( 2.0, 3.0, 4.0 ); // $ExpectError + dlae2( 2.0, 3.0, 4.0, out, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const out = new Float64Array( [ 1.0, 2.0 ] ); + + dlae2.ndarray( 2.0, 3.0, 4.0, out, 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 ] ); + + dlae2.ndarray( '5', 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( true, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( false, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( null, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( void 0, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( [], 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( {}, 3.0, 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( ( x: number ): number => x, 3.0, 4.0, out, 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 ] ); + + dlae2.ndarray( 2.0, '5', 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, true, 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, false, 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, null, 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, void 0, 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, [], 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, {}, 4.0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, ( x: number ): number => x, 4.0, out, 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 ] ); + + dlae2.ndarray( 2.0, 3.0, '5', out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, true, out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, false, out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, null, out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, void 0, out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, [], out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, {}, out, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + + dlae2.ndarray( 2.0, 3.0, 4.0, '5', 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, 5, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, true, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, false, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, null, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, void 0, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, [], 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, {}, 1, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, ( x: number ): number => x, 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 ] ); + + dlae2.ndarray( 2.0, 3.0, 4.0, out, '5', 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, true, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, false, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, null, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, void 0, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, [], 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, {}, 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, ( x: number ): number => x, 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 ] ); + + dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, '5' ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, true ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, false ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, null ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, void 0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, [] ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, {} ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, 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 ] ); + + dlae2.ndarray(); // $ExpectError + dlae2.ndarray( 2.0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, 1 ); // $ExpectError + dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlae2/examples/index.js index 809d814032a..e113aa25be6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/examples/index.js @@ -19,8 +19,8 @@ 'use strict'; var Float64Array = require( '@stdlib/array/float64' ); -var dlae2 = require( './../lib/base.js' ); +var dlae2 = require( './../lib' ); var out = new Float64Array( 2 ); -out = dlae2( 2.0, 3.0, 4.0, out, 1, 0 ); +out = dlae2( 2.0, 3.0, 4.0, out ); console.log( out ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/base.js index 5615f9166e9..0a4a10a2659 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/base.js @@ -28,13 +28,13 @@ var pow = require( '@stdlib/math/base/special/pow' ); // MAIN // /** -* Computes the eignevalues of a 2x2 symmetric matrix. +* Computes the eigenvalues of a 2x2 symmetric matrix. * * @private * @param {number} A - the (0,0) element of matrix * @param {number} B - the (0,1) & (1,0) element of matrix * @param {number} C - the (1,1) element of matrix -* @param {number} out - output array containing eigenvalue of larger and smaller absolute value respectively. +* @param {Float64Array} out - output array containing eigenvalue of larger and smaller absolute value respectively. * @param {integer} strideOut - stride length for `out` * @param {NonNegativeInteger} offsetOut - starting index of `out` * @returns {Float64Array} output array diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/dlae2.js b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/dlae2.js index df911495fa7..f9d8a1c2e84 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/dlae2.js +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/dlae2.js @@ -26,12 +26,12 @@ var base = require( './base.js' ); // MAIN // /** -* Computes the eignevalues of a 2x2 symmetric matrix. +* Computes the eigenvalues of a 2x2 symmetric matrix. * * @param {number} A - the (0,0) element of matrix * @param {number} B - the (0,1) & (1,0) element of matrix * @param {number} C - the (1,1) element of matrix -* @param {number} out - output array containing eigenvalue of larger and smaller absolute value respectively. +* @param {Float64Array} out - output array containing eigenvalue of larger and smaller absolute value respectively. * @returns {Float64Array} output array * * @example diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/index.js new file mode 100644 index 00000000000..fe5f5b71de1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/index.js @@ -0,0 +1,64 @@ +/** +* @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 eigenvalues of a 2x2 symmetric matrix. +* +* @module @stdlib/lapack/base/dlae2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlae2 = require( '@stdlib/lapack/base/dlae2' ); +* +* var out = new Float64Array( 2 ); +* out = dlae2( 2.0, 3.0, 4.0, out ); +* // out => [ 6.16227766016838, -0.1622776601683793 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlae2 = require( '@stdlib/lapack/base/dlae2' ); +* +* var out = new Float64Array( 2 ); +* out = dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); +* // out => [ 6.16227766016838, -0.1622776601683793 ] +*/ + +// 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 dlae2; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlae2 = main; +} else { + dlae2 = tmp; +} + + +// EXPORTS // + +module.exports = dlae2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js index e60ff8e02c9..ddbcb8c1a0b 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js @@ -26,13 +26,13 @@ var base = require( './base.js' ); // MAIN // /** -* Computes the eignevalues of a 2x2 symmetric matrix using alternative indexing semantics. +* Computes the eigenvalues of a 2x2 symmetric matrix using alternative indexing semantics. * * @type {Function} * @param {number} A - the (0,0) element of matrix * @param {number} B - the (0,1) & (1,0) element of matrix * @param {number} C - the (1,1) element of matrix -* @param {number} out - output array containing eigenvalue of larger and smaller absolute value respectively. +* @param {Float64Array} out - output array containing eigenvalue of larger and smaller absolute value respectively. * @param {integer} strideOut - stride length for `out` * @param {NonNegativeInteger} offsetOut - starting index of `out` * @returns {Float64Array} output array diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/package.json b/lib/node_modules/@stdlib/lapack/base/dlae2/package.json new file mode 100644 index 00000000000..bc128a81664 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/lapack/base/dlae2", + "version": "0.0.0", + "description": "Compute the eigenvalues 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", + "dlae2", + "eigenvalues", + "symmetric", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/test/test.dlae2.js b/lib/node_modules/@stdlib/lapack/base/dlae2/test/test.dlae2.js new file mode 100644 index 00000000000..1ebcb369a6f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/test/test.dlae2.js @@ -0,0 +1,112 @@ +/** +* @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/dlae2.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 4', function test( t ) { + t.strictEqual( dlae2.length, 4, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the eigenvalues of a 2x2 symmetric matrix', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + out = dlae2( 2.0, 3.0, 4.0, out ); + expected = new Float64Array( [ 6.16227766016838, -0.1622776601683793 ] ); + isApprox( t, out, expected, 1.0 ); + + out = dlae2( -1.0, 3.0, 9.4, out ); + expected = new Float64Array( [ 10.203332407921454, -1.8033324079214537 ] ); + isApprox( t, out, expected, 1.0 ); + + out = dlae2( -99.9, -67.124, -4.24, out ); + expected = new Float64Array( [ -134.49172211255961, 30.35172211255962 ] ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function computes eigenvalues of a 2x2 diagonal matrix', function test( t ) { + var expected; + var out; + + out = new Float64Array( 2 ); + out = dlae2( 2.0, 0.0, 4.0, out ); + expected = new Float64Array( [ 4.0, 2.0 ] ); + isApprox( t, out, expected, 1.0 ); + + out = dlae2( -1.0, 0.0, 9.4, out ); + expected = new Float64Array( [ 9.4, -1.0 ] ); + isApprox( t, out, expected, 1.0 ); + + out = dlae2( -99.9, 0.0, -4.24, out ); + expected = new Float64Array( [ -99.9, -4.24 ] ); + isApprox( t, out, expected, 1.0 ); + + out = dlae2( 1.0, 0.0, 1.0, out ); + expected = new Float64Array( [ 1.0, 1.0 ] ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlae2/test/test.js new file mode 100644 index 00000000000..f5d8e78e8e7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/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 dlae2 = 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 dlae2, '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 dlae2.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 dlae2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlae2, 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 dlae2; + var main; + + main = require( './../lib/dlae2.js' ); + + dlae2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlae2, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlae2/test/test.ndarray.js new file mode 100644 index 00000000000..388014e5a83 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/test/test.ndarray.js @@ -0,0 +1,92 @@ +/** +* @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 6', function test( t ) { + t.strictEqual( dlae2.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access pattern to store computed values', function test( t ) { + var expected; + var out; + + 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 ] ); + out = dlae2( 2.0, 3.0, 4.0, out, 3, 2 ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); + +tape( 'the function supports accessing elements in reverse order to store computed values', function test( t ) { + var expected; + var out; + + 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 ] ); + out = dlae2( 2.0, 3.0, 4.0, out, -3, out.length-1 ); + isApprox( t, out, expected, 1.0 ); + t.end(); +}); From ac97322f7130838bad0a187fb500c33d7c1381c2 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 22 Aug 2024 19:42:15 +0530 Subject: [PATCH 4/6] docs: add repl --- .../@stdlib/lapack/base/dlae2/docs/repl.txt | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlae2/docs/repl.txt diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlae2/docs/repl.txt new file mode 100644 index 00000000000..d1511b17b25 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/docs/repl.txt @@ -0,0 +1,76 @@ + +{{alias}}( A, B, C, Out ) + Computes the eigenvalues 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 matrix. + + B: number + The (0,1) & (1,0) elements of matrix. + + C: number + The (1,1) element of matrix. + + Out: Float64Array + Output array containing eigenvalue of larger and smaller absolute value + respectively. + + Returns + ------- + Out: Float64Array + Output array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float64}}( 2 ); + > {{alias}}( 2.0, 3.0, 4.0, out ) + [ 6.16227766016838, -0.1622776601683793 ] + + +{{alias}}.ndarray( A, B, C, Out, strideOut, offsetOut ) + Computes the eigenvalues 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 matrix. + + B: number + The (0,1) & (1,0) elements of matrix. + + C: number + The (1,1) element of matrix. + + Out: Float64Array + Output array containing eigenvalue of larger and smaller absolute value + respectively. + + strideOut: integer + Stride length for `Out`. + + offsetOut: integer + Starting index of `Out`. + + Returns + ------- + B: Float64Array + Output matrix. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0 ] ); + > {{alias}}.ndarray( 2.0, 3.0, 4.0, out, 1, 1 ) + [ 0.0, 6.16227766016838, -0.1622776601683793 ] + + See Also + -------- From dd99524a3f619f477aa00012e9af7009804f060e Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 24 Aug 2024 11:35:50 +0530 Subject: [PATCH 5/6] chore: apply suggestion from code review --- .../@stdlib/lapack/base/dlae2/README.md | 34 ++++++++-------- .../lapack/base/dlae2/benchmark/benchmark.js | 11 +++-- .../base/dlae2/benchmark/benchmark.ndarray.js | 12 ++++-- .../@stdlib/lapack/base/dlae2/docs/repl.txt | 40 +++++++++---------- .../lapack/base/dlae2/docs/types/index.d.ts | 32 +++++++-------- .../@stdlib/lapack/base/dlae2/lib/base.js | 22 ++++------ .../@stdlib/lapack/base/dlae2/lib/dlae2.js | 10 ++--- .../@stdlib/lapack/base/dlae2/lib/index.js | 4 +- .../@stdlib/lapack/base/dlae2/lib/ndarray.js | 10 ++--- 9 files changed, 87 insertions(+), 88 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/README.md b/lib/node_modules/@stdlib/lapack/base/dlae2/README.md index d47f26ec739..5cdcf96b865 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/README.md @@ -30,7 +30,7 @@ limitations under the License. var dlae2 = require( '@stdlib/lapack/base/dlae2' ); ``` -#### dlae2( A, B, C, Out ) +#### dlae2( A, B, C, out ) Computes the eigenvalues of a 2x2 symmetric matrix. @@ -39,15 +39,15 @@ var Float64Array = require( '@stdlib/array/float64' ); var out = new Float64Array( 2 ); out = dlae2( 2.0, 3.0, 4.0, out ); -// out => [ 6.16227766016838, -0.1622776601683793 ] +// out => [ ~6.162, ~-0.162 ] ``` The function has the following parameters: -- **A**: the (0,0) element of matrix. -- **B**: the (0,1) & (1,0) elements of matrix. -- **C**: the (1,1) element of matrix. -- **Out**: output [`Float64Array`][mdn-float64array] containing eigenvalue of larger and smaller absolute value respectively. +- **A**: the (0,0) element of a 2x2 symmetric matrix. +- **B**: the (0,1) and (1,0) elements of a 2x2 symmetric matrix. +- **C**: the (1,1) element of a 2x2 symmetric matrix. +- **out**: output [`Float64Array`][mdn-float64array] containing the eigenvalues of the larger and smaller absolute values, respectively. Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -56,17 +56,17 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -// Initial arrays... -var OUT0 = new Float64Array( [ 0.0, 0.0, 0.0 ] ); +// Initial array: +var out0 = new Float64Array( [ 0.0, 0.0, 0.0 ] ); -// Create offset views... -var OUT1 = new Float64Array( OUT0.buffer, OUT0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +// Create an offset view... +var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -dlae2( 2.0, 3.0, 4.0, OUT1 ); -// OUT0 => [ 0.0, 6.16227766016838, -0.1622776601683793 ] +dlae2( 2.0, 3.0, 4.0, out1 ); +// out0 => [ 0.0, ~6.162, ~-0.162 ] ``` -#### dlae2.ndarray( A, B, C, Out, strideOut, offsetOut ) +#### dlae2.ndarray( A, B, C, out, strideOut, offsetOut ) Computes the eigenvalues of a 2x2 symmetric matrix using alternative indexing semantics. @@ -75,12 +75,12 @@ var Float64Array = require( '@stdlib/array/float64' ); var out = new Float64Array( 2 ); out = dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); -// out => [ 6.16227766016838, -0.1622776601683793 ] +// out => [ ~6.162, ~-0.162 ] ``` The function has the following additional parameters: -- **strideOut**: stride length for `Out`. +- **strideOut**: stride length for `out`. - **offsetOut**: starting index of `out` 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, @@ -89,8 +89,8 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the var Float64Array = require( '@stdlib/array/float64' ); var out = new Float64Array( [ 0.0, 0.0, 0.0 ] ); -out = dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, 1 ); -// out => [ 0.0, 6.16227766016838, -0.1622776601683793 ] +out = dlae2.ndarray( 2.0, 3.0, 4.0, out, -2, 2 ); +// out => [ ~-0.162, 0.0, ~6.162 ] ``` diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.js index dba0da6030c..19662b2fade 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.js @@ -38,12 +38,15 @@ bench( pkg, function benchmark( b ) { var i; b.tic(); + A = ( randu() * 100.0 ) - 50.0; + B = ( randu() * 100.0 ) - 50.0; + C = ( randu() * 100.0 ) - 50.0; + out = new Float64Array( 2 ); for ( i = 0; i < b.iterations; i++ ) { - A = ( randu() * 100.0 ) - 50.0; - B = ( randu() * 100.0 ) - 50.0; - C = ( randu() * 100.0 ) - 50.0; - out = new Float64Array( 2 ); out = dlae2( A, B, C, out ); + A = out[ i%out.length ]; + B = out[ i%out.length ]; + C = out[ i%out.length ]; if ( isnan( out[ i%out.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.ndarray.js index 0e90eebf1ee..25b81eebf0b 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/benchmark/benchmark.ndarray.js @@ -37,13 +37,17 @@ bench( pkg+':ndarray', function benchmark( b ) { var C; var i; + A = ( randu() * 100.0 ) - 50.0; + B = ( randu() * 100.0 ) - 50.0; + C = ( randu() * 100.0 ) - 50.0; + out = new Float64Array( 2 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - A = ( randu() * 100.0 ) - 50.0; - B = ( randu() * 100.0 ) - 50.0; - C = ( randu() * 100.0 ) - 50.0; - out = new Float64Array( 2 ); out = dlae2( A, B, C, out, 1, 0 ); + A = out[ i%out.length ]; + B = out[ i%out.length ]; + C = out[ i%out.length ]; if ( isnan( out[ i%out.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlae2/docs/repl.txt index d1511b17b25..df9bacaa7bc 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( A, B, C, Out ) +{{alias}}( A, B, C, out ) Computes the eigenvalues of a 2x2 symmetric matrix. Indexing is relative to the first index. To introduce an offset, use typed @@ -8,31 +8,31 @@ Parameters ---------- A: number - The (0,0) element of matrix. + The (0,0) element of a 2x2 symmetric matrix. B: number - The (0,1) & (1,0) elements of matrix. + The (0,1) and (1,0) elements of a 2x2 symmetric matrix. C: number - The (1,1) element of matrix. + The (1,1) element of a 2x2 symmetric matrix. - Out: Float64Array - Output array containing eigenvalue of larger and smaller absolute value - respectively. + out: Float64Array + Output array containing eigenvalues of the larger and smaller absolute + values, respectively. Returns ------- - Out: Float64Array + out: Float64Array Output array. Examples -------- > var out = new {{alias:@stdlib/array/float64}}( 2 ); > {{alias}}( 2.0, 3.0, 4.0, out ) - [ 6.16227766016838, -0.1622776601683793 ] + [ ~6.162, ~-0.162 ] -{{alias}}.ndarray( A, B, C, Out, strideOut, offsetOut ) +{{alias}}.ndarray( A, B, C, out, strideOut, offsetOut ) Computes the eigenvalues of a 2x2 symmetric matrix using alternative indexing semantics. @@ -43,34 +43,34 @@ Parameters ---------- A: number - The (0,0) element of matrix. + The (0,0) element of a 2x2 symmetric matrix matrix. B: number - The (0,1) & (1,0) elements of matrix. + The (0,1) and (1,0) elements of a 2x2 symmetric matrix matrix. C: number - The (1,1) element of matrix. + The (1,1) element of a 2x2 symmetric matrix matrix. - Out: Float64Array - Output array containing eigenvalue of larger and smaller absolute value - respectively. + out: Float64Array + Output array containing eigenvalues of the larger and smaller absolute + values, respectively. strideOut: integer - Stride length for `Out`. + Stride length for `out`. offsetOut: integer - Starting index of `Out`. + Starting index of `out`. Returns ------- - B: Float64Array + out: Float64Array Output matrix. Examples -------- > var out = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0 ] ); > {{alias}}.ndarray( 2.0, 3.0, 4.0, out, 1, 1 ) - [ 0.0, 6.16227766016838, -0.1622776601683793 ] + [ 0.0, ~6.162, ~-0.162 ] See Also -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlae2/docs/types/index.d.ts index ee367e79271..9a2bca4e136 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/docs/types/index.d.ts @@ -26,10 +26,10 @@ interface Routine { /** * Computes the eigenvalues of a 2x2 symmetric matrix. * - * @param A - the (0,0) element of matrix - * @param B - the (0,1) & (1,0) element of matrix - * @param C - the (1,1) element of matrix - * @param out - output array containing eigenvalue of larger and smaller absolute value respectively. + * @param A - the (0,0) element of a 2x2 symmetric matrix + * @param B - the (0,1) and (1,0) element of a 2x2 symmetric matrix + * @param C - the (1,1) element of a 2x2 symmetric matrix + * @param out - output array containing eigenvalues of the larger and smaller absolute values, respectively * @returns output array * * @example @@ -37,7 +37,7 @@ interface Routine { * * var out = new Float64Array( 2 ); * out = dlae2( 2.0, 3.0, 4.0, out ); - * // out => [ 6.16227766016838, -0.1622776601683793 ] + * // out => [ ~6.162, ~-0.162 ] */ ( A: number, B: number, C: number, out: Float64Array ): Float64Array; @@ -45,10 +45,10 @@ interface Routine { * Computes the eigenvalues of a 2x2 symmetric matrix using alternative indexing semantics. * * @type {Function} - * @param A - the (0,0) element of matrix - * @param B - the (0,1) & (1,0) element of matrix - * @param C - the (1,1) element of matrix - * @param out - output array containing eigenvalue of larger and smaller absolute value respectively. + * @param A - the (0,0) element of a 2x2 symmetric matrix + * @param B - the (0,1) and (1,0) element of a 2x2 symmetric matrix + * @param C - the (1,1) element of a 2x2 symmetric matrix + * @param out - output array containing eigenvalues of the larger and smaller absolute values, respectively * @param strideOut - stride length for `out` * @param offsetOut - starting index of `out` * @returns output array @@ -58,7 +58,7 @@ interface Routine { * * var out = new Float64Array( 2 ); * out = dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); - * // out => [ 6.16227766016838, -0.1622776601683793 ] + * // out => [ ~6.162, ~-0.162 ] */ ndarray( A: number, B: number, C: number, out: Float64Array, strideOut: number, offsetOut: number ): Float64Array; } @@ -66,10 +66,10 @@ interface Routine { /** * Computes the eigenvalues of a 2x2 symmetric matrix. * -* @param A - the (0,0) element of matrix -* @param B - the (0,1) & (1,0) element of matrix -* @param C - the (1,1) element of matrix -* @param out - output array containing eigenvalue of larger and smaller absolute value respectively. +* @param A - the (0,0) element of a 2x2 symmetric matrix +* @param B - the (0,1) and (1,0) element of a 2x2 symmetric matrix +* @param C - the (1,1) element of a 2x2 symmetric matrix +* @param out - output array containing eigenvalues of the larger and smaller absolute values, respectively * @returns output array * * @example @@ -77,14 +77,14 @@ interface Routine { * * var out = new Float64Array( 2 ); * out = dlae2( 2.0, 3.0, 4.0, out ); -* // out => [ 6.16227766016838, -0.1622776601683793 ] +* // out => [ ~6.162, ~-0.162 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var out = new Float64Array( 2 ); * out = dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); -* // out => [ 6.16227766016838, -0.1622776601683793 ] +* // out => [ ~6.162, ~-0.162 ] */ declare var dlae2: Routine; diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/base.js index 0a4a10a2659..8e3d9f8aa1f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/base.js @@ -31,10 +31,10 @@ var pow = require( '@stdlib/math/base/special/pow' ); * Computes the eigenvalues of a 2x2 symmetric matrix. * * @private -* @param {number} A - the (0,0) element of matrix -* @param {number} B - the (0,1) & (1,0) element of matrix -* @param {number} C - the (1,1) element of matrix -* @param {Float64Array} out - output array containing eigenvalue of larger and smaller absolute value respectively. +* @param {number} A - the (0,0) element of a 2x2 symmetric matrix +* @param {number} B - the (0,1) and (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 eigenvalues of the larger and smaller absolute values, respectively * @param {integer} strideOut - stride length for `out` * @param {NonNegativeInteger} offsetOut - starting index of `out` * @returns {Float64Array} output array @@ -44,7 +44,7 @@ var pow = require( '@stdlib/math/base/special/pow' ); * * var out = new Float64Array( 2 ); * out = dlae2( 2.0, 3.0, 4.0, out, 1, 0 ); -* // out => [ 6.16227766016838, -0.1622776601683793 ] +* // out => [ ~6.162, ~-0.162 ] */ function dlae2( A, B, C, out, strideOut, offsetOut ) { var acmx; @@ -81,20 +81,12 @@ function dlae2( A, B, C, out, strideOut, offsetOut ) { if ( sm < 0.0 ) { rt1 = 0.5 * ( sm - rt ); - /* - Order of execution is important. - To get fully accurate smaller eigenvalue, - next line needs to be executed in higher precision. - */ + // 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 ); - /* - Order of execution is important. - To get fully accurate smaller eigenvalue, - next line needs to be executed in higher precision. - */ + // 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.0 diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/dlae2.js b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/dlae2.js index f9d8a1c2e84..13b40b96e6c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/dlae2.js +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/dlae2.js @@ -28,10 +28,10 @@ var base = require( './base.js' ); /** * Computes the eigenvalues of a 2x2 symmetric matrix. * -* @param {number} A - the (0,0) element of matrix -* @param {number} B - the (0,1) & (1,0) element of matrix -* @param {number} C - the (1,1) element of matrix -* @param {Float64Array} out - output array containing eigenvalue of larger and smaller absolute value respectively. +* @param {number} A - the (0,0) element of a 2x2 symmetric matrix +* @param {number} B - the (0,1) and (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 eigenvalues of the larger and smaller absolute values, respectively * @returns {Float64Array} output array * * @example @@ -39,7 +39,7 @@ var base = require( './base.js' ); * * var out = new Float64Array( 2 ); * out = dlae2( 2.0, 3.0, 4.0, out ); -* // out => [ 6.16227766016838, -0.1622776601683793 ] +* // out => [ ~6.162, ~-0.162 ] */ function dlae2( A, B, C, out ) { return base( A, B, C, out, 1, 0 ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/index.js index fe5f5b71de1..769f4741775 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/index.js @@ -29,7 +29,7 @@ * * var out = new Float64Array( 2 ); * out = dlae2( 2.0, 3.0, 4.0, out ); -* // out => [ 6.16227766016838, -0.1622776601683793 ] +* // out => [ ~6.162, ~-0.162 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -37,7 +37,7 @@ * * var out = new Float64Array( 2 ); * out = dlae2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 ); -* // out => [ 6.16227766016838, -0.1622776601683793 ] +* // out => [ ~6.162, ~-0.162 ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js index ddbcb8c1a0b..0cf6f31a252 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js @@ -29,10 +29,10 @@ var base = require( './base.js' ); * Computes the eigenvalues of a 2x2 symmetric matrix using alternative indexing semantics. * * @type {Function} -* @param {number} A - the (0,0) element of matrix -* @param {number} B - the (0,1) & (1,0) element of matrix -* @param {number} C - the (1,1) element of matrix -* @param {Float64Array} out - output array containing eigenvalue of larger and smaller absolute value respectively. +* @param {number} A - the (0,0) element of a 2x2 symmetric matrix +* @param {number} B - the (0,1) and (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 eigenvalues of the larger and smaller absolute values, respectively * @param {integer} strideOut - stride length for `out` * @param {NonNegativeInteger} offsetOut - starting index of `out` * @returns {Float64Array} output array @@ -42,7 +42,7 @@ var base = require( './base.js' ); * * var out = new Float64Array( 2 ); * out = dlae2( 2.0, 3.0, 4.0, out, 1, 0 ); -* // out => [ 6.16227766016838, -0.1622776601683793 ] +* // out => [ ~6.162, ~-0.162 ] */ var dlae2 = base; From cd7aa30c3fd89afe4c8d8bd12486eb2b3bced433 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 26 Aug 2024 12:38:12 +0530 Subject: [PATCH 6/6] chore: apply suggestion from code review --- lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js index 0cf6f31a252..7aa2fb01dcd 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlae2/lib/ndarray.js @@ -28,6 +28,7 @@ var base = require( './base.js' ); /** * Computes the eigenvalues of a 2x2 symmetric matrix using alternative indexing semantics. * +* @name dlae2 * @type {Function} * @param {number} A - the (0,0) element of a 2x2 symmetric matrix * @param {number} B - the (0,1) and (1,0) element of a 2x2 symmetric matrix