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

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

-->

# dgelqf

> LAPACK routine to compute an LQ factorization of a real `M`-by-`N` matrix `A`.

<section class="intro">

`dgelqf` computes an LQ factorization of a real `M`-by-`N` matrix `A`:

```math
A = \begin{pmatrix} L & 0 \end{pmatrix} \cdot Q
```

where

- **Q** is an `N`-by-`N` orthogonal matrix,
- **L** is a lower-triangular `M`-by-`M` matrix, and
- **0** is an `M`-by-`(N-M)` zero matrix if `M < N`.

The matrix `Q` is represented as a product of elementary reflectors

```math
Q = H(k) . . . H(2) H(1)
```

where `k = min(m,n)`.

Each `H(i)` has the form

```math
H(i) = I - \tau \cdot v \cdot v^T
```

where `\tau` is a real scalar, and `v` is a real vector with `v(1:i-1) = 0` and `v(i) = 1`; `v(i+1:n)` is stored on exit in `A(i,i+1:n)`, and `\tau` in `TAU(i)`.

</section>

<!-- /.intro -->

<section class="usage">

## Usage

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

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

Computes an LQ factorization of a real `M`-by-`N` matrix `A`.

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

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

var A = new Float64Array( [ 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] );
var TAU = new Float64Array( 3 );
var WORK = new Float64Array( 4 );

dgelqf( 'column-major', 3, 4, A, 3, TAU, WORK, 4 );
// A => <Float64Array>[ ~-5.477, ~-12.78, ~-20.083, ~0.309, ~-3.266, ~-6.532, ~0.463, ~-0.327, ~0.0, ~0.618, ~-0.789, ~0.618 ]
// TAU => <Float64Array>[ ~1.183, ~1.156, ~1.447 ]
// WORK => <Float64Array>[ 3.0, ~24.593, 0.0, 0.0 ]
```

The function has the following parameters:

- **order**: storage layout.
- **M**: number of rows in `A`.
- **N**: number of columns in `A`.
- **A**: input/output matrix.
- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`).
- **TAU**: output array.
- **WORK**: workspace array.
- **LWORK**: dimension of the array `WORK`. If `min(M,N) = 0`, `LWORK` must be at least `1`; otherwise, `LWORK` must be at least `max(1,M)`. For optimal performance, `LWORK` should be at least `M * NB` where `NB` is the optimal block size. If `LWORK = -1`, a workspace query is assumed; the routine only calculates the optimal size of the `WORK` array, returns this value as the first entry of the `WORK` array.

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, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] );
var TAU0 = new Float64Array( [ 0.0, 0.0, 0.0 ] );
var WORK0 = new Float64Array( [ 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*0 );
var WORK = new Float64Array( WORK0.buffer, WORK0.BYTES_PER_ELEMENT*0 );

dgelqf( 'column-major', 3, 4, A, 3, TAU, WORK, 4 );
// A0 => <Float64Array>[ 0.0, ~-5.477, ~-12.78, ~-20.083, ~0.309, ~-3.266, ~-6.532, ~0.463, ~-0.327, ~0.0, ~0.618, ~-0.789, ~0.618 ]
// TAU0 => <Float64Array>[ ~1.183, ~1.156, ~1.447 ]
// WORK0 => <Float64Array>[ 3.0, ~24.593, 0.0, 0.0 ]
```

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

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

Computes an LQ factorization of a real `M`-by-`N` matrix `A` using alternative indexing semantics.

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

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

var A = new Float64Array( [ 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] );
var TAU = new Float64Array( 3 );
var WORK = new Float64Array( 4 );

dgelqf.ndarray( 3, 4, A, 1, 3, 0, TAU, 1, 0, WORK, 1, 0, 4 );
// A => <Float64Array>[ ~-5.477, ~-12.78, ~-20.083, ~0.309, ~-3.266, ~-6.532, ~0.463, ~-0.327, ~0.0, ~0.618, ~-0.789, ~0.618 ]
// TAU => <Float64Array>[ ~1.183, ~1.156, ~1.447 ]
// WORK => <Float64Array>[ 3.0, ~24.593, 0.0, 0.0 ]
```

The function has the following additional parameters:

- **M**: number of rows in `A`.
- **N**: number of columns in `A`.
- **A**: input/output matrix as a [`Float64Array`][@stdlib/array/float64].
- **strideA1**: stride of the first dimension of `A`.
- **strideA2**: stride of the second dimension of `A`.
- **offsetA**: starting index for `A`.
- **TAU**: output array as a [`Float64Array`][@stdlib/array/float64].
- **strideTAU**: stride for `TAU`.
- **offsetTAU**: starting index for `TAU`.
- **WORK**: workspace array as a [`Float64Array`][@stdlib/array/float64].
- **strideWORK**: stride for `WORK`.
- **offsetWORK**: starting index for `WORK`.
- **LWORK**: dimension of the array `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, 0.0, 0.0, 0.0, 1.0, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0 ] );
var TAU = new Float64Array( [ 0.0, 0.0, 0.0 ] );
var WORK = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] );

dgelqf.ndarray( 3, 4, A, 1, 3, 4, TAU, 1, 0, WORK, 1, 0, 4 );
// A => <Float64Array>[ 0.0, ~-5.477, ~-12.78, ~-20.083, ~0.309, ~-3.266, ~-6.532, ~0.463, ~-0.327, ~0.0, ~0.618, ~-0.789, ~0.618 ]
// TAU => <Float64Array>[ ~1.183, ~1.156, ~1.447 ]
// WORK => <Float64Array>[ 3.0, ~24.593, 0.0, 0.0 ]
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

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

</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 min = require( '@stdlib/math/base/special/min' );
var dgelqf = require( '@stdlib/lapack/base/dgelqf' );

// 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, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
console.log( ndarray2array( A, shape, strides, 0, order ) );

// Output arrays:
var TAU = new Float64Array( min( shape[ 0 ], shape[ 1 ] ) );
var WORK = new Float64Array( shape[ 1 ] );

// Compute the LQ factorization in-place:
var info = dgelqf( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ], TAU, WORK, WORK.length );
console.log( ndarray2array( A, shape, strides, 0, order ) );
console.log( TAU );
console.log( WORK );
```

</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-dgelqf]: https://www.netlib.org/lapack/explore-html/dc/dc1/group__gelqf_ga4c447bceb0a6a307f0eb746f40e9fe28.html

[@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
Loading