|
| 1 | +/** |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2025 The Stdlib Authors. |
| 5 | +* |
| 6 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +* you may not use this file except in compliance with the License. |
| 8 | +* You may obtain a copy of the License at |
| 9 | +* |
| 10 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +* |
| 12 | +* Unless required by applicable law or agreed to in writing, software |
| 13 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +* See the License for the specific language governing permissions and |
| 16 | +* limitations under the License. |
| 17 | +*/ |
| 18 | + |
| 19 | +'use strict'; |
| 20 | + |
| 21 | +// MODULES // |
| 22 | + |
| 23 | +var base = require( './base.js' ); |
| 24 | + |
| 25 | + |
| 26 | +// MAIN // |
| 27 | + |
| 28 | +/** |
| 29 | +* Computes the Schur factorization of a real 2-by-2 nonsymmetric matrix `A` in standard form. |
| 30 | +* |
| 31 | +* Given a real 2×2 matrix: |
| 32 | +* |
| 33 | +* ```tex |
| 34 | +* \begin{bmatrix} |
| 35 | +* A & B \\ |
| 36 | +* C & D |
| 37 | +* \end{bmatrix} |
| 38 | +* ``` |
| 39 | +* |
| 40 | +* this routine computes an orthogonal matrix: |
| 41 | +* |
| 42 | +* ```tex |
| 43 | +* \begin{bmatrix} |
| 44 | +* \text{CS} & \text{SN} \\ |
| 45 | +* -\text{SN} & \text{CS} |
| 46 | +* \end{bmatrix} |
| 47 | +* ``` |
| 48 | +* |
| 49 | +* such that the matrix is reduced to Schur (quasi-triangular) form: |
| 50 | +* |
| 51 | +* ```tex |
| 52 | +* \begin{bmatrix} |
| 53 | +* \text{AA} & \text{BB} \\ |
| 54 | +* 0 & \text{DD} |
| 55 | +* \end{bmatrix} |
| 56 | +* ``` |
| 57 | +* |
| 58 | +* @param {Float64Array} A - array containing the element A(1,1) |
| 59 | +* @param {NonNegativeInteger} offsetA - index in `A` of the element A(1,1) |
| 60 | +* @param {Float64Array} B - array containing the element A(1,2) |
| 61 | +* @param {NonNegativeInteger} offsetB - index in `B` of the element A(1,2) |
| 62 | +* @param {Float64Array} C - array containing the element A(2,1) |
| 63 | +* @param {NonNegativeInteger} offsetC - index in `C` of the element A(2,1) |
| 64 | +* @param {Float64Array} D - array containing the element A(2,2) |
| 65 | +* @param {NonNegativeInteger} offsetD - index in `D` of the element A(2,2) |
| 66 | +* @param {Float64Array} RT1R - output array for the real part of the first eigenvalue |
| 67 | +* @param {NonNegativeInteger} offsetRT1R - index in `RT1R` at which to store the value |
| 68 | +* @param {Float64Array} RT1I - output array for the imaginary part of the first eigenvalue |
| 69 | +* @param {NonNegativeInteger} offsetRT1I - index in `RT1I` at which to store the value |
| 70 | +* @param {Float64Array} RT2R - output array for the real part of the second eigenvalue |
| 71 | +* @param {NonNegativeInteger} offsetRT2R - index in `RT2R` at which to store the value |
| 72 | +* @param {Float64Array} RT2I - output array for the imaginary part of the second eigenvalue |
| 73 | +* @param {NonNegativeInteger} offsetRT2I - index in `RT2I` at which to store the value |
| 74 | +* @param {Float64Array} CS - output array for cosine of the rotation |
| 75 | +* @param {NonNegativeInteger} offsetCS - index in `CS` at which to store the value |
| 76 | +* @param {Float64Array} SN - output array for sine of the rotation |
| 77 | +* @param {NonNegativeInteger} offsetSN - index in `SN` at which to store the value |
| 78 | +* @returns {void} |
| 79 | +* |
| 80 | +* @example |
| 81 | +* var Float64Array = require( '@stdlib/array/float64' ); |
| 82 | +* |
| 83 | +* var A = new Float64Array( [ 4.0 ] ); |
| 84 | +* var B = new Float64Array( [ -5.0 ] ); |
| 85 | +* var C = new Float64Array( [ 2.0 ] ); |
| 86 | +* var D = new Float64Array( [ -3.0 ] ); |
| 87 | +* var RT1R = new Float64Array( 1 ); |
| 88 | +* var RT1I = new Float64Array( 1 ); |
| 89 | +* var RT2R = new Float64Array( 1 ); |
| 90 | +* var RT2I = new Float64Array( 1 ); |
| 91 | +* var CS = new Float64Array( 1 ); |
| 92 | +* var SN = new Float64Array( 1 ); |
| 93 | +* |
| 94 | +* dlanv2( A, 0, B, 0, C, 0, D, 0, RT1R, 0, RT1I, 0, RT2R, 0, RT2I, 0, CS, 0, SN, 0 ); |
| 95 | +* // A => <Float64Array>[ 2.0 ] |
| 96 | +* // B => <Float64Array>[ -7.0 ] |
| 97 | +* // C => <Float64Array>[ 0.0 ] |
| 98 | +* // D => <Float64Array>[ -1.0 ] |
| 99 | +* // RT1R => <Float64Array>[ 2.0 ] |
| 100 | +* // RT1I => <Float64Array>[ 0.0 ] |
| 101 | +* // RT2R => <Float64Array>[ -1.0 ] |
| 102 | +* // RT2I => <Float64Array>[ 0.0 ] |
| 103 | +* // CS => <Float64Array>[ ~0.93 ] |
| 104 | +* // SN => <Float64Array>[ ~0.34 ] |
| 105 | +*/ |
| 106 | +function dlanv2( A, offsetA, B, offsetB, C, offsetC, D, offsetD, RT1R, offsetRT1R, RT1I, offsetRT1I, RT2R, offsetRT2R, RT2I, offsetRT2I, CS, offsetCS, SN, offsetSN ) { // eslint-disable-line max-len, max-params |
| 107 | + return base( A, offsetA, B, offsetB, C, offsetC, D, offsetD, RT1R, offsetRT1R, RT1I, offsetRT1I, RT2R, offsetRT2R, RT2I, offsetRT2I, CS, offsetCS, SN, offsetSN ); // eslint-disable-line max-len |
| 108 | +} |
| 109 | + |
| 110 | + |
| 111 | +// EXPORTS // |
| 112 | + |
| 113 | +module.exports = dlanv2; |
0 commit comments