Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
356 changes: 356 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlarft/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,356 @@
<!--

@license Apache-2.0

Copyright (c) 2026 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.

-->

# dlarft

> Form the triangular factor `T` of a real block reflector `H` of order `N`, which is defined as a product of `K` elementary reflectors.

<section class="intro">

A **block reflector** `H` is a product of `k` elementary reflectors `H = H(1) H(2) ... H(k)` (forward direction) or `H = H(k) ... H(2) H(1)` (backward direction). It can be represented as `H = I - V * T * V^T` (columnwise storage) or `H = I - V^T * T * V` (rowwise storage), where `T` is a triangular matrix. This routine computes `T`.

The shape of the matrix `V` and the storage of the vectors which define the `H(i)` is best illustrated by the following example with `n = 5` and `k = 3`. The elements equal to `1` are not stored.

<!-- <equation class="equation" label="eq:v_forward_columnwise" align="center" raw="V = \left[\begin{array}{ccc}1 & 0 & 0 \\v_1 & 1 & 0 \\v_1 & v_2 & 1 \\v_1 & v_2 & v_3 \\v_1 & v_2 & v_3\end{array}\right]" alt="Matrix V for forward direction with columnwise storage"> -->

```math
V = \left[
\begin{array}{ccc}
1 & 0 & 0 \\
v_1 & 1 & 0 \\
v_1 & v_2 & 1 \\
v_1 & v_2 & v_3 \\
v_1 & v_2 & v_3
\end{array}
\right], \quad \text{forward, columnwise}
```

<!-- </equation> -->

<!-- <equation class="equation" label="eq:v_forward_rowwise" align="center" raw="V = \left[\begin{array}{ccccc}1 & v_1 & v_1 & v_1 & v_1 \\0 & 1 & v_2 & v_2 & v_2 \\0 & 0 & 1 & v_3 & v_3\end{array}\right]" alt="Matrix V for forward direction with rowwise storage"> -->

```math
V = \left[
\begin{array}{ccccc}
1 & v_1 & v_1 & v_1 & v_1 \\
0 & 1 & v_2 & v_2 & v_2 \\
0 & 0 & 1 & v_3 & v_3
\end{array}
\right], \quad \text{forward, rowwise}
```

<!-- </equation> -->

<!-- <equation class="equation" label="eq:v_backward_columnwise" align="center" raw="V = \left[\begin{array}{ccc}v_1 & v_2 & v_3 \\v_1 & v_2 & v_3 \\1 & v_2 & v_3 \\0 & 1 & v_3 \\0 & 0 & 1\end{array}\right]" alt="Matrix V for backward direction with columnwise storage"> -->

```math
V = \left[
\begin{array}{ccc}
v_1 & v_2 & v_3 \\
v_1 & v_2 & v_3 \\
1 & v_2 & v_3 \\
0 & 1 & v_3 \\
0 & 0 & 1
\end{array}
\right], \quad \text{backward, columnwise}
```

<!-- </equation> -->

<!-- <equation class="equation" label="eq:v_backward_rowwise" align="center" raw="V = \left[\begin{array}{ccccc}v_1 & v_1 & 1 & 0 & 0 \\v_2 & v_2 & v_2 & 1 & 0 \\v_3 & v_3 & v_3 & v_3 & 1\end{array}\right]" alt="Matrix V for backward direction with rowwise storage"> -->

```math
V = \left[
\begin{array}{ccccc}
v_1 & v_1 & 1 & 0 & 0 \\
v_2 & v_2 & v_2 & 1 & 0 \\
v_3 & v_3 & v_3 & v_3 & 1
\end{array}
\right], \quad \text{backward, rowwise}
```

<!-- </equation> -->

</section>

<!-- /.intro -->

<section class="usage">

## Usage

```javascript
var dlarft = require( '@stdlib/lapack/base/dlarft' );
```

#### dlarft( order, direct, storev, N, K, V, LDV, TAU, T, LDT )

Forms the triangular factor `T` of a real block reflector `H` of order `N`, which is defined as a product of `K` elementary reflectors.

<!-- eslint-disable max-len -->

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 1.0, 2.0, 3.0 ] );
var TAU = new Float64Array( [ 2.0/55.0, 2.0/30.0, 2.0/14.0 ] );
var T = new Float64Array( 9 );

dlarft( 'column-major', 'forward', 'columnwise', 5, 3, V, 5, TAU, T, 3 );
// T => <Float64Array>[ ~0.036, 0.0, 0.0, ~-0.097, ~0.067, 0.0, ~0.142, ~-0.1905, ~0.143 ]
```

The function has the following parameters:

- **order**: storage layout.
- **direct**: direction in which the elementary reflectors are multiplied. Must be `'forward'` or `'backward'`.
- **storev**: how the vectors defining the elementary reflectors are stored. Must be `'columnwise'` or `'rowwise'`.
- **N**: order of the block reflector `H`.
- **K**: number of elementary reflectors (order of `T`).
- **V**: matrix of reflector vectors as a [`Float64Array`][@stdlib/array/float64].
- **LDV**: leading dimension of `V`.
- **TAU**: array of scalar factors as a [`Float64Array`][@stdlib/array/float64].
- **T**: output triangular matrix as a [`Float64Array`][@stdlib/array/float64].
- **LDT**: leading dimension of `T`.

If `storev` is `'columnwise'`:

- `V` should have `K` columns.
- `LDV` must be at least `max(1,N)`.
- `H = I - V * T * V^T`.

If `storev` is `'rowwise'`:

- `V` should have `K` rows.
- `LDV` must be at least `K`.
- `H = I - V^T * T * V`.

If `direct` is `'forward'`, `T` is upper triangular. If `direct` is `'backward'`, `T` is lower triangular.

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, max-len -->

```javascript
var Float64Array = require( '@stdlib/array/float64' );

// Initial arrays...
var V0 = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 1.0, 2.0, 3.0 ] );
var TAU0 = new Float64Array( [ 0.0, 2.0/55.0, 2.0/30.0, 2.0/14.0 ] );
var T0 = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );

// Create offset views...
var V1 = new Float64Array( V0.buffer, V0.BYTES_PER_ELEMENT*2 ); // start at 3rd element
var TAU1 = new Float64Array( TAU0.buffer, TAU0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var T1 = new Float64Array( T0.buffer, T0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

dlarft( 'column-major', 'forward', 'columnwise', 5, 3, V1, 5, TAU1, T1, 3 );
// T0 => <Float64Array>[ 0.0, ~0.036, 0.0, 0.0, ~-0.097, ~0.067, 0.0, ~0.142, ~-0.1905, ~0.143 ]
```

#### dlarft.ndarray( direct,storev,N,K,V,sV1,sV2,oV,TAU,sTAU,oTAU,T,sT1,sT2,oT )

Forms the triangular factor `T` of a real block reflector `H` of order `N` using alternative indexing semantics.

<!-- eslint-disable max-len -->

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 1.0, 2.0, 3.0 ] );
var TAU = new Float64Array( [ 2.0/55.0, 2.0/30.0, 2.0/14.0 ] );
var T = new Float64Array( 9 );

dlarft.ndarray( 'forward', 'columnwise', 5, 3, V, 1, 5, 0, TAU, 1, 0, T, 1, 3, 0 );
// T => <Float64Array>[ ~0.036, 0.0, 0.0, ~-0.097, ~0.067, 0.0, ~0.142, ~-0.1905, ~0.143 ]
```

The function has the following additional parameters:

- **direct**: direction in which the elementary reflectors are multiplied.
- **storev**: how the vectors defining the elementary reflectors are stored.
- **N**: order of the block reflector `H`.
- **K**: number of elementary reflectors.
- **V**: matrix of reflector vectors as a [`Float64Array`][@stdlib/array/float64].
- **sV1**: stride of the first dimension of `V`.
- **sV2**: stride of the second dimension of `V`.
- **oV**: starting index for `V`.
- **TAU**: array of scalar factors as a [`Float64Array`][@stdlib/array/float64].
- **sTAU**: stride for `TAU`.
- **oTAU**: starting index for `TAU`.
- **T**: output triangular matrix as a [`Float64Array`][@stdlib/array/float64].
- **sT1**: stride of the first dimension of `T`.
- **sT2**: stride of the second dimension of `T`.
- **oT**: starting index for `T`.

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 V = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 1.0, 2.0, 3.0 ] );
var TAU = new Float64Array( [ 2.0/55.0, 2.0/30.0, 2.0/14.0 ] );
var T = new Float64Array( 9 );

dlarft.ndarray( 'forward', 'columnwise', 5, 3, V, 1, 5, 2, TAU, 1, 0, T, 1, 3, 0 );
// T => <Float64Array>[ ~0.036, 0.0, 0.0, ~-0.097, ~0.067, 0.0, ~0.142, ~-0.1905, ~0.143 ]
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- `dlarft()` corresponds to the [LAPACK][LAPACK] function [`dlarft`][lapack-dlarft].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

<!-- eslint-disable max-len -->

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var dlarft = require( '@stdlib/lapack/base/dlarft' );

// Construct V and TAU for a block reflector from a QR-like decomposition:
var N = 5;
var K = 3;
var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 1.0, 2.0, 3.0 ] );
var TAU = new Float64Array( [ 2.0/55.0, 2.0/30.0, 2.0/14.0 ] );

// Compute T:
var T = new Float64Array( K*K );
dlarft( 'column-major', 'forward', 'columnwise', N, K, V, N, TAU, T, K );

console.log( 'T:' );
console.log( T[0].toFixed(4), T[3].toFixed(4), T[6].toFixed(4) );
console.log( T[1].toFixed(4), T[4].toFixed(4), T[7].toFixed(4) );
console.log( T[2].toFixed(4), T[5].toFixed(4), T[8].toFixed(4) );
```

</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-dlarft]: https://www.netlib.org/lapack/explore-html/d7/d0d/group__larft_ga5ff52d1f414c82955e4372cda75484d9.html#ga5ff52d1f414c82955e4372cda75484d9

[@stdlib/array/float64]: https://stdlib.io/docs/api/latest/@stdlib/array/float64

[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray

</section>

<!-- /.links -->
Loading