-
-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathREADME.md
308 lines (203 loc) · 8.87 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<!--
@license Apache-2.0
Copyright (c) 2025 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.
-->
# dgttrf
> Compute an `LU` factorization of a real tri diagonal matrix `A` using elimination with partial pivoting and row interchanges.
<section class="usage">
## Usage
```javascript
var dgttrf = require( '@stdlib/lapack/base/dgttrf' );
```
#### dgttrf( N, DL, D, DU, DU2, IPIV )
Computes an `LU` factorization of a real tri diagonal matrix `A` using elimination with partial pivoting and row interchanges.
```javascript
var Float64Array = require( '@stdlib/array/float64' );
var Int32Array = require( '@stdlib/array/int32' );
var DL = new Float64Array( [ 1.0, 1.0 ] );
var D = new Float64Array( [ 2.0, 3.0, 1.0 ] );
var DU = new Float64Array( [ 1.0, 1.0 ] );
var DU2 = new Float64Array( 1 );
var IPIV = new Int32Array( 3 );
dgttrf( 3, DL, D, DU, DU2, IPIV );
// DL => <Float64Array>[ 0.5, 0.4 ]
// D => <Float64Array>[ 2, 2.5, 0.6 ]
// DU => <Float64Array>[ 1, 1 ]
// DU2 => <Float64Array>[ 0 ]
// IPIV => <Int32Array>[ 0, 1, 2 ]
```
The function has the following parameters:
- **N**: order of matrix `A`.
- **DL**: the sub diagonal elements of `A` as a [`Float64Array`][mdn-float64array]. On exit, DL is overwritten by the multipliers that define the matrix `L` from the `LU` factorization of `A`.
- **D**: the diagonal elements of `A` as a [`Float64Array`][mdn-float64array]. On exit, D is overwritten by the diagonal elements of the upper triangular matrix `U` from the `LU` factorization of `A`.
- **DU**: the super diagonal elements of `A` as a [`Float64Array`][mdn-float64array]. On exit, DU is overwritten by the elements of the first super-diagonal of `U`.
- **DU2**: On exit, DU2 is overwritten by the elements of the second super-diagonal of `U` as a [`Float64Array`][mdn-float64array].
- **IPIV**: vector of pivot indices as a [`Int32Array`][mdn-int32array].
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
<!-- eslint-disable stdlib/capitalized-comments -->
```javascript
var Float64Array = require( '@stdlib/array/float64' );
var Int32Array = require( '@stdlib/array/int32' );
// Initial arrays...
var DL0 = new Float64Array( [ 0.0, 1.0, 1.0 ] );
var D0 = new Float64Array( [ 0.0, 2.0, 3.0, 1.0 ] );
var DU0 = new Float64Array( [ 0.0, 1.0, 1.0 ] );
var DU20 = new Float64Array( 2 );
var IPIV0 = new Int32Array( 4 );
// Create offset views...
var DL = new Float64Array( DL0.buffer, DL0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var D = new Float64Array( D0.buffer, D0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var DU = new Float64Array( DU0.buffer, DU0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var DU2 = new Float64Array( DU20.buffer, DU20.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var IPIV = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
dgttrf( 3, DL, D, DU, DU2, IPIV );
// DL0 => <Float64Array>[ 0, 0.5, 0.4 ]
// D0 => <Float64Array>[ 0, 2, 2.5, 0.6 ]
// DU0 => <Float64Array>[ 0, 1, 1 ]
// DU20 => <Float64Array>[ 0, 0 ]
// IPIV0 => <Int32Array>[ 0, 0, 1, 2 ]
```
<!-- lint disable maximum-heading-length -->
#### dgttrf.ndarray( N, DL, sdl, odl, D, sd, od, DU, sdu, odu, DU2, sdu2, odu2, IPIV, si, oi )
Computes an `LU` factorization of a real tri diagonal matrix `A` using elimination with partial pivoting and row interchanges and alternative indexing semantics.
```javascript
var Float64Array = require( '@stdlib/array/float64' );
var Int32Array = require( '@stdlib/array/int32' );
var dgttrf = require( '@stdlib/lapack/base/dgttrf' );
var DL = new Float64Array( [ 1.0, 1.0 ] );
var D = new Float64Array( [ 2.0, 3.0, 1.0 ] );
var DU = new Float64Array( [ 1.0, 1.0 ] );
var DU2 = new Float64Array( 1 );
var IPIV = new Int32Array( 3 );
dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 );
// DL => <Float64Array>[ 0.5, 0.4 ]
// D => <Float64Array>[ 2, 2.5, 0.6 ]
// DU => <Float64Array>[ 1, 1 ]
// DU2 => <Float64Array>[ 0 ]
// IPIV => <Int32Array>[ 0, 1, 2 ]
```
The function has the following additional parameters:
- **sdl**: stride length for `DL`.
- **odl**: starting index for `DL`.
- **sd**: stride length for `D`.
- **od**: starting index for `D`.
- **sdu**: stride length for `DU`.
- **odu**: starting index for `DU`.
- **sdu2**: stride length for `DU2`.
- **odu2**: starting index for `DU2`.
- **si**: stride length for `IPIV`.
- **oi**: starting index for `IPIV`.
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,
<!-- eslint-disable max-len -->
```javascript
var Float64Array = require( '@stdlib/array/float64' );
var Int32Array = require( '@stdlib/array/int32' );
var DL = new Float64Array( [ 0.0, 1.0, 1.0 ] );
var D = new Float64Array( [ 0.0, 2.0, 3.0, 1.0 ] );
var DU = new Float64Array( [ 0.0, 1.0, 1.0 ] );
var DU2 = new Float64Array( 2 );
var IPIV = new Int32Array( 4 );
dgttrf.ndarray( 3, DL, 1, 1, D, 1, 1, DU, 1, 1, DU2, 1, 1, IPIV, 1, 1 );
// DL => <Float64Array>[ 0, 0.5, 0.4 ]
// D => <Float64Array>[ 0, 2, 2.5, 0.6 ]
// DU => <Float64Array>[ 0, 1, 1 ]
// DU2 => <Float64Array>[ 0, 0 ]
// IPIV => <Int32Array>[ 0, 0, 1, 2 ]
```
</section>
<!-- /.usage -->
<section class="notes">
## Notes
- Both functions mutate the input arrays `DL`, `D`, `DU`, `DU2` and `IPIV`.
- Both functions return a status code indicating success or failure. A status code indicates the following conditions:
- `0`: factorization was successful.
- `<0`: the k-th argument had an illegal value, where `-k` equals the status code value.
- `>0`: `U( k, k )` is exactly zero the factorization has been completed, but the factor `U` is exactly singular, and division by zero will occur if it is used to solve a system of equations, where `k` equals the status code value.
- `dgttrf()` corresponds to the [LAPACK][LAPACK] routine [`dgttrf`][lapack-dgttrf].
</section>
<!-- /.notes -->
<section class="examples">
## Examples
<!-- eslint no-undef: "error" -->
```javascript
var Int32Array = require( '@stdlib/array/int32' );
var Float64Array = require( '@stdlib/array/float64' );
var dgttrf = require( '@stdlib/lapack/base/dgttrf' );
var N = 9;
var DL = new Float64Array( [ 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 ] );
var D = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] );
var DU = new Float64Array( [ 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] );
var DU2 = new Float64Array( N-2 );
var IPIV = new Int32Array( N );
// Perform the `A = LU` factorization:
var info = dgttrf( N, DL, D, DU, DU2, IPIV );
console.log( DL );
console.log( D );
console.log( DU );
console.log( DU2 );
console.log( IPIV );
console.log( info );
```
</section>
<!-- /.examples -->
<!-- C interface documentation. -->
* * *
<section class="c">
## C APIs
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
<section class="intro">
</section>
<!-- /.intro -->
<!-- C usage documentation. -->
<section class="usage">
### Usage
```c
TODO
```
#### TODO
TODO.
```c
TODO
```
TODO
```c
TODO
```
</section>
<!-- /.usage -->
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
<section class="notes">
</section>
<!-- /.notes -->
<!-- C API usage examples. -->
<section class="examples">
### Examples
```c
TODO
```
</section>
<!-- /.examples -->
</section>
<!-- /.c -->
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
<section class="related">
</section>
<!-- /.related -->
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
<section class="links">
[lapack]: https://www.netlib.org/lapack/explore-html/
[lapack-dgttrf]: https://www.netlib.org/lapack/explore-html/d6/d46/group__gttrf_ga8d1e46216e6c861c89bd4328b8be52a1.html#ga8d1e46216e6c861c89bd4328b8be52a1
[mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array
[mdn-int32array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
</section>
<!-- /.links -->