|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 The Stdlib Authors. |
| 6 | +
|
| 7 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +you may not use this file except in compliance with the License. |
| 9 | +You may obtain a copy of the License at |
| 10 | +
|
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +
|
| 13 | +Unless required by applicable law or agreed to in writing, software |
| 14 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +See the License for the specific language governing permissions and |
| 17 | +limitations under the License. |
| 18 | +
|
| 19 | +--> |
| 20 | + |
| 21 | +# dlaqr1 |
| 22 | + |
| 23 | +> Given a 2-by-2 or a 3-by-3 matrix, this LAPACK routine sets `V` to a scalar multiple of the first column of `K` where `K = (H - (sr1 + i*si1)*I)*(H - (sr2 + i*si2)*I)`. |
| 24 | +
|
| 25 | +<section class="usage"> |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```javascript |
| 30 | +var dlaqr1 = require( '@stdlib/lapack/base/dlaqr1' ); |
| 31 | +``` |
| 32 | + |
| 33 | +#### dlaqr1( order, N, H, LDH, sr1, si1, sr2, si2, V ) |
| 34 | + |
| 35 | +Given a 2-by-2 or a 3-by-3 matrix, this function sets `V` to a scalar multiple of the first column of `K` where `K = (H - (sr1 + i*si1)*I)*(H - (sr2 + i*si2)*I)`. |
| 36 | + |
| 37 | +```javascript |
| 38 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 39 | + |
| 40 | +var H = new Float64Array( [ 1.0, 3.0, 2.0, 2.0, 4.0, 6.0, 0.0, 5.0, 7.0 ] ); // => [ [ 1.0, 3.0, 2.0 ], [ 2.0, 4.0, 6.0 ], [ 0.0, 5.0, 7.0 ] ] |
| 41 | +var V = new Float64Array( 3 ); |
| 42 | + |
| 43 | +var out = dlaqr1( 'row-major', 3, H, 3, 1.5, 0.0, 2.5, 0.0, V ); |
| 44 | +// returns <Float64Array>[ ~1.93, ~0.57, ~2.86 ] |
| 45 | +``` |
| 46 | + |
| 47 | +The function has the following parameters: |
| 48 | + |
| 49 | +- **order**: storage layout. |
| 50 | +- **N**: number of row/columns in `H`. |
| 51 | +- **H**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. |
| 52 | +- **LDH**: stride of the first dimension of `H` (a.k.a., leading dimension of the matrix `H`). |
| 53 | +- **sr1**: real part of the first conjugate complex shift. |
| 54 | +- **si1**: imaginary part of the first conjugate complex shift. |
| 55 | +- **sr2**: real part of the second conjugate complex shift. |
| 56 | +- **si2**: imaginary part of the second conjugate complex shift. |
| 57 | +- **V**: output [`Float64Array`][mdn-float64array]. |
| 58 | + |
| 59 | +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. |
| 60 | + |
| 61 | +<!-- eslint-disable max-len --> |
| 62 | + |
| 63 | +```javascript |
| 64 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 65 | + |
| 66 | +// Initial arrays... |
| 67 | +var H = new Float64Array( [ 0.0, 1.0, 3.0, 2.0, 2.0, 4.0, 6.0, 0.0, 5.0, 7.0 ] ); // => [ [ 1.0, 3.0, 2.0 ], [ 2.0, 4.0, 6.0 ], [ 0.0, 5.0, 7.0 ] ] |
| 68 | +var V = new Float64Array( 4 ); |
| 69 | + |
| 70 | +// Create offset views... |
| 71 | +var H1 = new Float64Array( H.buffer, H.BYTES_PER_ELEMENT*1 ); // start at 2nd element |
| 72 | +var V1 = new Float64Array( V.buffer, V.BYTES_PER_ELEMENT*1 ); // start at 2nd element |
| 73 | + |
| 74 | +dlaqr1( 'row-major', 3, H1, 3, 1.5, 0.0, 2.5, 0.0, V1 ); |
| 75 | +// V => <Float64Array>[ 0.0, ~1.93, ~0.57, ~2.86 ] |
| 76 | +``` |
| 77 | + |
| 78 | +#### dlaqr1.ndarray( N, H, sh1, sh2, oh, sr1, si1, sr2, si2, V, sv, ov ) |
| 79 | + |
| 80 | +Given a 2-by-2 or a 3-by-3 matrix, this function sets `V` to a scalar multiple of the first column of `K` where `K = (H - (sr1 + i*si1)*I)*(H - (sr2 + i*si2)*I)` using alternative indexing semantics. |
| 81 | + |
| 82 | +```javascript |
| 83 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 84 | + |
| 85 | +var H = new Float64Array( [ 1.0, 3.0, 2.0, 2.0, 4.0, 6.0, 0.0, 5.0, 7.0 ] ); // => [ [ 1.0, 3.0, 2.0 ], [ 2.0, 4.0, 6.0 ], [ 0.0, 5.0, 7.0 ] ] |
| 86 | +var V = new Float64Array( 3 ); |
| 87 | + |
| 88 | +var out = dlaqr1.ndarray( 3, H, 3, 1, 0, 1.5, 0.0, 2.5, 0.0, V, 1, 0 ); |
| 89 | +// returns <Float64Array>[ ~1.93, ~0.57, ~2.86 ] |
| 90 | +``` |
| 91 | + |
| 92 | +The function has the following additional parameters: |
| 93 | + |
| 94 | +- **N**: number of row/columns in `H`. |
| 95 | +- **H**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. |
| 96 | +- **sh1**: stride of the first dimension of `H`. |
| 97 | +- **sh2**: stride of the second dimension of `H`. |
| 98 | +- **oh**: index offset for `H`. |
| 99 | +- **sr1**: real part of the first conjugate complex shift. |
| 100 | +- **si1**: imaginary part of the first conjugate complex shift. |
| 101 | +- **sr2**: real part of the second conjugate complex shift. |
| 102 | +- **si2**: imaginary part of the second conjugate complex shift. |
| 103 | +- **V**: output [`Float64Array`][mdn-float64array]. |
| 104 | +- **sv**: stride length for `V`. |
| 105 | +- **ov**: index offset for `V`. |
| 106 | + |
| 107 | +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, |
| 108 | + |
| 109 | +<!-- eslint-disable max-len --> |
| 110 | + |
| 111 | +```javascript |
| 112 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 113 | + |
| 114 | +var H = new Float64Array( [ 0.0, 1.0, 3.0, 2.0, 2.0, 4.0, 6.0, 0.0, 5.0, 7.0 ] ); // => [ [ 1.0, 3.0, 2.0 ], [ 2.0, 4.0, 6.0 ], [ 0.0, 5.0, 7.0 ] ] |
| 115 | +var V = new Float64Array( 4 ); |
| 116 | + |
| 117 | +var out = dlaqr1.ndarray( 3, H, 3, 1, 1, 1.5, 0.0, 2.5, 0.0, V, 1, 1 ); |
| 118 | +// returns <Float64Array>[ 0.0, ~1.93, ~0.57, ~2.86 ] |
| 119 | +``` |
| 120 | + |
| 121 | +</section> |
| 122 | + |
| 123 | +<!-- /.usage --> |
| 124 | + |
| 125 | +<section class="notes"> |
| 126 | + |
| 127 | +## Notes |
| 128 | + |
| 129 | +- It is expected that either `sr1 = sr2` and `si1 + si2 = 0` or `si1 = si2 = 0` (i.e., they represent complex conjugate values). |
| 130 | +- This is useful for starting double implicit shift bulges in the QR algorithm. |
| 131 | +- `V` should have at least `N` indexed elements. |
| 132 | +- `dlaqr1()` corresponds to the [LAPACK][LAPACK] function [`dlaqr1`][lapack-dlaqr1]. |
| 133 | + |
| 134 | +</section> |
| 135 | + |
| 136 | +<!-- /.notes --> |
| 137 | + |
| 138 | +<section class="examples"> |
| 139 | + |
| 140 | +## Examples |
| 141 | + |
| 142 | +<!-- eslint no-undef: "error" --> |
| 143 | + |
| 144 | +```javascript |
| 145 | +var uniform = require( '@stdlib/random/array/uniform' ); |
| 146 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 147 | +var dlaqr1 = require( '@stdlib/lapack/base/dlaqr1' ); |
| 148 | + |
| 149 | +// Create a random 3x3 matrix: |
| 150 | +var H = uniform( 9, -10.0, 10.0, { |
| 151 | + 'dtype': 'float64' |
| 152 | +}); |
| 153 | + |
| 154 | +// Create an output vector: |
| 155 | +var V = new Float64Array( 3 ); |
| 156 | + |
| 157 | +dlaqr1( 'row-major', 3, H, 3, 1.5, 0.0, 2.5, 0.0, V ); |
| 158 | + |
| 159 | +// Print the result: |
| 160 | +console.log( V ); |
| 161 | +``` |
| 162 | + |
| 163 | +</section> |
| 164 | + |
| 165 | +<!-- /.examples --> |
| 166 | + |
| 167 | +<!-- C interface documentation. --> |
| 168 | + |
| 169 | +* * * |
| 170 | + |
| 171 | +<section class="c"> |
| 172 | + |
| 173 | +## C APIs |
| 174 | + |
| 175 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 176 | + |
| 177 | +<section class="intro"> |
| 178 | + |
| 179 | +</section> |
| 180 | + |
| 181 | +<!-- /.intro --> |
| 182 | + |
| 183 | +<!-- C usage documentation. --> |
| 184 | + |
| 185 | +<section class="usage"> |
| 186 | + |
| 187 | +### Usage |
| 188 | + |
| 189 | +```c |
| 190 | +TODO |
| 191 | +``` |
| 192 | + |
| 193 | +#### TODO |
| 194 | + |
| 195 | +TODO. |
| 196 | + |
| 197 | +```c |
| 198 | +TODO |
| 199 | +``` |
| 200 | + |
| 201 | +TODO |
| 202 | + |
| 203 | +```c |
| 204 | +TODO |
| 205 | +``` |
| 206 | + |
| 207 | +</section> |
| 208 | + |
| 209 | +<!-- /.usage --> |
| 210 | + |
| 211 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 212 | + |
| 213 | +<section class="notes"> |
| 214 | + |
| 215 | +</section> |
| 216 | + |
| 217 | +<!-- /.notes --> |
| 218 | + |
| 219 | +<!-- C API usage examples. --> |
| 220 | + |
| 221 | +<section class="examples"> |
| 222 | + |
| 223 | +### Examples |
| 224 | + |
| 225 | +```c |
| 226 | +TODO |
| 227 | +``` |
| 228 | + |
| 229 | +</section> |
| 230 | + |
| 231 | +<!-- /.examples --> |
| 232 | + |
| 233 | +</section> |
| 234 | + |
| 235 | +<!-- /.c --> |
| 236 | + |
| 237 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 238 | + |
| 239 | +<section class="related"> |
| 240 | + |
| 241 | +</section> |
| 242 | + |
| 243 | +<!-- /.related --> |
| 244 | + |
| 245 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 246 | + |
| 247 | +<section class="links"> |
| 248 | + |
| 249 | +[lapack]: https://www.netlib.org/lapack/explore-html/ |
| 250 | + |
| 251 | +[lapack-dlaqr1]: https://www.netlib.org/lapack/explore-html/d1/d72/dlaqr1_8f.html |
| 252 | + |
| 253 | +[mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array |
| 254 | + |
| 255 | +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray |
| 256 | + |
| 257 | +</section> |
| 258 | + |
| 259 | +<!-- /.links --> |
0 commit comments