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
318 changes: 318 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dorgbr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@
<!--

@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.

-->

# dorgbr

> Generate one of the real orthogonal matrices `Q` or `P^T` determined by `dgebrd` when reducing a real matrix `A` to bidiagonal form.

<section class="intro">

The `dorgbr` routine generates one of the real orthogonal matrices `Q` or `P^T` determined by `dgebrd` when reducing a real matrix `A` to bidiagonal form: `A = Q * B * P^T`. `Q` and `P^T` are defined as products of elementary reflectors `H(i)` or `G(i)` respectively.

<!-- <equation class="equation" label="eq:A" align="center" raw="A = Q B P^{T}" alt="Equation for the bidiagonal reduction."> -->

```math
A = Q B P^{T}
```

<!-- </equation> -->

If `vect = 'Q'`, `A` is assumed to have been an `M-by-K` matrix, and `Q` is of order `M`:

<!-- <equation class="equation" label="eq:Q" align="center" raw="Q = H(1) H(2) \ldots H(k)" alt="Equation for the product of elementary reflectors defining Q."> -->

```math
Q = H(1) H(2) \ldots H(k)
```

<!-- </equation> -->

If `vect = 'P'`, `A` is assumed to have been a `K-by-N` matrix, and `P^T` is of order `N`:

<!-- <equation class="equation" label="eq:PT" align="center" raw="P^{T} = G(k) \ldots G(2) G(1)" alt="Equation for the product of elementary reflectors defining P^T."> -->

```math
P^{T} = G(k) \ldots G(2) G(1)
```

<!-- </equation> -->

</section>

<!-- /.intro -->

<section class="usage">

## Usage

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

#### dorgbr( order, vect, M, N, K, A, LDA, TAU, WORK, LWORK )

Generates one of the real orthogonal matrices `Q` or `P^T` determined by `dgebrd` when reducing a real matrix `A` to bidiagonal form.

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

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

var A = new Float64Array( [ 1.0, 0.2, -0.1, 0.3, 0.0, 1.0, 0.4, -0.2, 0.0, 0.0, 1.0, 0.5 ] );
var TAU = new Float64Array( [ 1.3, 0.9, 1.1 ] );
var WORK = new Float64Array( 10 );

dorgbr( 'column-major', 'Q', 4, 3, 3, A, 4, TAU, WORK, 10 );
// A => <Float64Array>[ -0.3, -0.26, 0.13, -0.39, -0.143, 0.0714, -0.3457, 0.1371, ~0.21, ~-0.021, ~-0.146, ~-0.474 ]
// WORK[ 0 ] => 96.0
```

The function has the following parameters:

- **order**: storage layout. Must be `'row-major'` or `'column-major'`.
- **vect**: specifies whether the matrix `Q` or the matrix `P^T` is returned in `A`. Must be `'Q'` or `'P'`.
- **M**: number of rows of `Q` or `P^T`.
- **N**: number of columns of `Q` or `P^T`. If `vect` is `'Q'`, must be greater than or equal to `min(M,K)` and smaller than or equal to `M`. If `vect` is `'P'`, must be greater than or equal to `M`, and `M` must be greater than or equal to `min(N,K)`.
- **K**: if `vect` is `'Q'`, the number of columns in the original `M-by-K` matrix reduced by `dgebrd`; if `vect` is `'P'`, the number of rows in the original `K-by-N` matrix reduced by `dgebrd`.
- **A**: input/output matrix of size `M×N` stored in linear memory as a [`Float64Array`][@stdlib/array/float64]. On entry, `A` contains the vectors which define the elementary reflectors, as returned by `dgebrd`. On exit, `A` is overwritten by the `M-by-N` matrix `Q` or `P^T`.
- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). Must be at least `max(1,M)` when `order` is `'column-major'` and at least `max(1,N)` when `order` is `'row-major'`.
- **TAU**: scalar factors of the elementary reflectors as a [`Float64Array`][@stdlib/array/float64]. Must have length `min(M,K)` if `vect` is `'Q'` and length `min(N,K)` if `vect` is `'P'`.
- **WORK**: workspace array as a [`Float64Array`][@stdlib/array/float64].
- **LWORK**: dimension of the array `WORK`. Must be at least `max(1,min(M,N))`, unless equal to `-1`, in which case a workspace query is performed and the optimal size of `WORK` is returned in `WORK[0]`.

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 A0 = new Float64Array( [ 0.0, 1.0, 0.2, -0.1, 0.3, 0.0, 1.0, 0.4, -0.2, 0.0, 0.0, 1.0, 0.5 ] );
var TAU0 = new Float64Array( [ 0.0, 1.3, 0.9, 1.1 ] );
var WORK0 = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );

// Create offset views...
var A = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var TAU = new Float64Array( TAU0.buffer, TAU0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var WORK = new Float64Array( WORK0.buffer, WORK0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

dorgbr( 'column-major', 'Q', 4, 3, 3, A, 4, TAU, WORK, 10 );
// A0 => <Float64Array>[ 0.0, -0.3, -0.26, 0.13, -0.39, -0.143, 0.0714, -0.3457, 0.1371, ~0.21, ~-0.021, ~-0.146, ~-0.474 ]
// WORK0[ 1 ] => 96.0
```

<!-- lint disable maximum-heading-length -->

#### dorgbr.ndarray( vect, M, N, K, A, strideA1, strideA2, offsetA, TAU, strideTAU, offsetTAU, WORK, strideWORK, offsetWORK, LWORK )

Generates one of the real orthogonal matrices `Q` or `P^T` determined by `dgebrd` when reducing a real matrix `A` to bidiagonal form using alternative indexing semantics.

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

var A = new Float64Array( [ 1.0, 0.2, -0.1, 0.3, 0.0, 1.0, 0.4, -0.2, 0.0, 0.0, 1.0, 0.5 ] );
var TAU = new Float64Array( [ 1.3, 0.9, 1.1 ] );
var WORK = new Float64Array( 10 );

dorgbr.ndarray( 'Q', 4, 3, 3, A, 1, 4, 0, TAU, 1, 0, WORK, 1, 0, 10 );
// A => <Float64Array>[ -0.3, -0.26, 0.13, -0.39, -0.143, 0.0714, -0.3457, 0.1371, ~0.21, ~-0.021, ~-0.146, ~-0.474 ]
// WORK[ 0 ] => 96.0
```

The function has the following additional parameters:

- **strideA1**: stride length for the first dimension of `A`.
- **strideA2**: stride length for the second dimension of `A`.
- **offsetA**: starting index for `A`.
- **strideTAU**: stride length for `TAU`.
- **offsetTAU**: starting index for `TAU`.
- **strideWORK**: stride length for `WORK`.
- **offsetWORK**: starting index for `WORK`.

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 A = new Float64Array( [ 0.0, 1.0, 0.2, -0.1, 0.3, 0.0, 1.0, 0.4, -0.2, 0.0, 0.0, 1.0, 0.5 ] );
var TAU = new Float64Array( [ 0.0, 1.3, 0.9, 1.1 ] );
var WORK = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );

dorgbr.ndarray( 'Q', 4, 3, 3, A, 1, 4, 1, TAU, 1, 1, WORK, 1, 1, 10 );
// A => <Float64Array>[ -0.3, -0.26, 0.13, -0.39, -0.143, 0.0714, -0.3457, 0.1371, ~0.21, ~-0.021, ~-0.146, ~-0.474 ]
// WORK[ 1 ] => 96.0
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- Both functions mutate the input arrays `A` and `WORK`.

- Both functions return a status code indicating success (`0`) or failure.

- `dorgbr()` corresponds to the [LAPACK][LAPACK] routine [`dorgbr`][lapack-dorgbr].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

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

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var ndarray2array = require( '@stdlib/ndarray/base/to-array' );
var shape2strides = require( '@stdlib/ndarray/base/shape2strides' );
var dorgbr = require( '@stdlib/lapack/base/dorgbr' );

// Define matrix dimensions:
var M = 4;
var N = 3;
var K = 3;
var shape = [ M, N ];
var order = 'column-major';
var strides = shape2strides( shape, order );

// Create the matrix A containing the elementary reflector vectors returned by dgebrd:
var A = new Float64Array( [ 1.0, 0.2, -0.1, 0.3, 0.0, 1.0, 0.4, -0.2, 0.0, 0.0, 1.0, 0.5 ] );
console.log( ndarray2array( A, shape, strides, 0, order ) );

// Define the scalar factors and workspace array:
var TAU = new Float64Array( [ 1.3, 0.9, 1.1 ] );
var WORK = new Float64Array( 10 );

// Generate the orthogonal matrix Q:
var info = dorgbr( order, 'Q', M, N, K, A, strides[ 1 ], TAU, WORK, WORK.length );
console.log( ndarray2array( A, shape, strides, 0, order ) );
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-dorgbr]: https://www.netlib.org/lapack/explore-html/dc/d45/group__ungbr_gae61b2be52b4a8e82f4cf8ec3779b8a90.html

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

[@stdlib/lapack/base/dgebrd]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/lapack/base/dgebrd

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

</section>

<!-- /.links -->
Loading
Loading