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

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

-->

# dorglq

> LAPACK routine to generate an `M-by-N` real orthogonal matrix `Q` from the elementary reflectors returned by `DGELQF`.

<section class="intro">

The `dorglq` routine generates an `M-by-N` real orthogonal matrix `Q` with orthonormal rows, where `Q` is defined as the product of `K` elementary reflectors of order `M` returned by the LQ factorization routine `DGELQF`.

</section>

<!-- /.intro -->

<section class="usage">

## Usage

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

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

Generates an `M-by-N` real orthogonal matrix `Q` from the elementary reflectors returned by `DGELQF`.

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

var A = new Float64Array( [ 1, 0, 0, -1, -2, 0 ] );
var TAU = new Float64Array( [ 1, 1 ] );
var WORK = new Float64Array( 10 );

var info = dorglq( 'column-major', 2, 3, 2, A, 2, TAU, WORK, 10 );
// A => <Float64Array>[ 0, 0, 0, 0, 2, 0 ]
// info => 0
// WORK[ 0 ] => 2
```

The function has the following parameters:

- **order**: storage layout. Must be either `'row-major'` or `'column-major'`.
- **M**: number of rows of `Q`.
- **N**: number of columns of `Q`.
- **K**: number of elementary reflectors.
- **A**: input/output matrix as a [`Float64Array`][mdn-float64array]. On entry, the i-th row must contain the vector which defines the elementary reflector `H(i)`, for `i = 1,2,...,K`, as returned by `DGELQF` in the first `K` rows of its array argument `A`. On exit, the `M-by-N` orthogonal matrix `Q`.
- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`).
- **TAU**: scalar factors of the elementary reflectors as a [`Float64Array`][mdn-float64array].
- **WORK**: workspace [`Float64Array`][mdn-float64array].
- **LWORK**: dimension of the array `WORK`. If `LWORK = -1`, a workspace query is performed and the optimal workspace size is returned in `WORK[0]`.

By default, the function accesses elements of `A` starting from the first index. To use an offset view of `A`, 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, 1, 0, 0, -1, -2, 0 ] );
var TAU0 = new Float64Array( [ 0, 1, 1 ] );
var WORK0 = new Float64Array( 11 );

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

var info = dorglq( 'column-major', 2, 3, 2, A1, 2, TAU1, WORK1, 10 );
// A0 => <Float64Array>[ 0, 0, 0, 0, 0, 2, 0 ]
// info => 0
// WORK0[ 0 ] => 0
// WORK0[ 1 ] => 2
```

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

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

Generates an `M-by-N` real orthogonal matrix `Q` from the elementary reflectors returned by `DGELQF` using alternative indexing semantics.

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

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

var A = new Float64Array( [ 1, 0, 0, -1, -2, 0 ] );
var TAU = new Float64Array( [ 1, 1 ] );
var WORK = new Float64Array( 10 );

var info = dorglq.ndarray( 2, 3, 2, A, 1, 2, 0, TAU, 1, 0, WORK, 1, 0, 10 );
// A => <Float64Array>[ 0, 0, 0, 0, 2, 0 ]
// info => 0
// WORK[ 0 ] => 2
```

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,

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

var A = new Float64Array( [ 0, 1, 0, 0, -1, -2, 0 ] );
var TAU = new Float64Array( [ 0, 1, 1 ] );
var WORK = new Float64Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] );

var info = dorglq.ndarray( 2, 3, 2, A, 1, 2, 1, TAU, 1, 1, WORK, 1, 1, 10 );
// A => <Float64Array>[ 0, 0, 0, 0, 0, 2, 0 ]
// info => 0
// WORK[ 1 ] => 2
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- On entry, the i-th row of `A` must contain the vector which defines the elementary reflector `H(i)`, for `i = 1,2,...,K`, as returned by `DGELQF` in the first `K` rows of its array argument `A`.

- The function mutates the input array `A`. On exit, `A` contains the `M-by-N` orthogonal matrix `Q`.

- Both functions return a status code indicating success or failure. A status code of `0` indicates success.

- `WORK` must have length `LWORK >= max(1,M)`. For optimum performance `LWORK >= M*NB`, where `NB` is the optimal block size (derived internally as `32`).

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

</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 dorglq = require( '@stdlib/lapack/base/dorglq' );

// Specify matrix meta data:
var shape = [ 3, 4 ];
var order = 'row-major';
var strides = shape2strides( shape, order );

// Create a matrix stored in linear memory:
var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, -2.0, 1.0, 0.0, 0.0, -3.0, -4.0, 1.0, 0.0 ] ); // eslint-disable-line max-len
console.log( 'Matrix A (before):' );
console.log( ndarray2array( A, shape, strides, 0, order ) );

// Define the scalar factors of reflectors and a workspace array:
var TAU = new Float64Array( [ 1.0, 1.0, 1.0 ] );
var WORK = new Float64Array( 20 );

// Generate the orthogonal matrix Q:
var info = dorglq( order, shape[ 0 ], shape[ 1 ], shape[ 0 ], A, strides[ 0 ], TAU, WORK, 20 );
console.log( 'Matrix Q (after):' );
console.log( ndarray2array( A, shape, strides, 0, order ) );
console.log( 'Status code:', info );
console.log( 'Optimal workspace size:', WORK[ 0 ] );
```

</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-dorglq]: https://www.netlib.org/lapack/explore-html/dd/d4b/group__orglq_ga2de3a16658028d2251e53e28b5b6839c.html

[mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array

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

</section>

<!-- /.links -->
Loading