Skip to content

Commit f3e10ec

Browse files
committed
docs: add repl.txt and readme
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent a08782b commit f3e10ec

File tree

2 files changed

+369
-0
lines changed

2 files changed

+369
-0
lines changed
Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# dorg2r
22+
23+
> LAPACK routine to generate an M-by-N real matrix Q with orthonormal columns.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var dorg2r = require( '@stdlib/lapack/base/dorg2r' );
31+
```
32+
33+
#### dorg2r( order, M, N, K, A, LDA, tau, work )
34+
35+
Generates an M-by-N real matrix Q with orthonormal columns. The matrix Q is defined as the first N columns of a product of K elementary reflectors of order M. `Q = H(1) H(2) . . . H(K)` as returned by `dgeqrf`.
36+
37+
```javascript
38+
var Float64Array = require( '@stdlib/array/float64' );
39+
40+
var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
41+
var tau = new Float64Array( [ 0.0, 0.0 ] );
42+
var work = new Float64Array( 10 );
43+
44+
dorg2r( 'column-major', 3, 2, 2, A, 3, tau, work );
45+
// A => <Float64Array>[ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ]
46+
```
47+
48+
The function has the following parameters:
49+
50+
- **order**: storage layout.
51+
- **M**: number of rows in matrix `A`.
52+
- **N**: number of columns in matrix `A`.
53+
- **K**: number of elementary reflectors whose product defines the matrix Q.
54+
- **A**: input matrix (overwritten by Householder vectors from `dgeqrf`) stored in linear memory as a [`Float64Array`][mdn-float64array].
55+
- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`).
56+
- **tau**: vector of K scalar factors of the elementary reflectors as a [`Float64Array`][mdn-float64array].
57+
- **work**: workspace array as a [`Float64Array`][mdn-float64array].
58+
59+
The function returns the input matrix `A` overwritten with the orthogonal matrix Q.
60+
61+
#### dorg2r.ndarray( M, N, K, A, sa1, sa2, oa, tau, st, ot, work, sw, ow )
62+
63+
Generates an M-by-N real matrix Q with orthonormal columns using alternative indexing semantics. The matrix Q is defined as the first N columns of a product of K elementary reflectors of order M. `Q = H(1) H(2) . . . H(K)` as returned by `dgeqrf`.
64+
65+
```javascript
66+
var Float64Array = require( '@stdlib/array/float64' );
67+
68+
var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
69+
var tau = new Float64Array( [ 0.0, 0.0 ] );
70+
var work = new Float64Array( 10 );
71+
72+
dorg2r.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 );
73+
// A => <Float64Array>[ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ]
74+
```
75+
76+
The function has the following additional parameters:
77+
78+
- **M**: number of rows in matrix `A`.
79+
- **N**: number of columns in matrix `A`.
80+
- **K**: number of elementary reflectors whose product defines the matrix Q.
81+
- **A**: input matrix (overwritten by Householder vectors from `dgeqrf`) stored in linear memory as a [`Float64Array`][mdn-float64array].
82+
- **sa1**: stride of the first dimension of `A`.
83+
- **sa2**: stride of the second dimension of `A`.
84+
- **oa**: index offset for `A`.
85+
- **tau**: vector of K scalar factors of the elementary reflectors as a [`Float64Array`][mdn-float64array].
86+
- **st**: stride length for `tau`.
87+
- **ot**: index offset for `tau`.
88+
- **work**: workspace array as a [`Float64Array`][mdn-float64array].
89+
- **sw**: stride length for `work`.
90+
- **ow**: index offset for `work`.
91+
92+
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,
93+
94+
<!-- eslint-disable max-len -->
95+
96+
```javascript
97+
var Float64Array = require( '@stdlib/array/float64' );
98+
99+
var A = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
100+
var tau = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] );
101+
var work = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
102+
103+
dorg2r.ndarray( 3, 2, 2, A, 1, 3, 3, tau, 1, 2, work, 1, 0 );
104+
// A => <Float64Array>[ 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ]
105+
```
106+
107+
</section>
108+
109+
<!-- /.usage -->
110+
111+
<section class="notes">
112+
113+
## Notess
114+
115+
- The function overwrites the input matrix `A` with the orthogonal matrix `Q`.
116+
- The matrix Q is generated from the Householder vectors and scalar factors returned by `dgeqrf`.
117+
- `dorg2r()` corresponds to the [LAPACK][LAPACK] function [`dorg2r`][lapack-dorg2r].
118+
119+
</section>
120+
121+
<!-- /.notes -->
122+
123+
<section class="examples">
124+
125+
## Examples
126+
127+
<!-- eslint no-undef: "error" -->
128+
129+
<!-- eslint-disable max-len -->
130+
131+
```javascript
132+
var Float64Array = require( '@stdlib/array/float64' );
133+
var ndarray2array = require( '@stdlib/ndarray/base/to-array' );
134+
var dorg2r = require( '@stdlib/lapack/base/dorg2r' );
135+
136+
// Specify matrix meta data:
137+
var M = 4;
138+
var N = 3;
139+
var K = 2;
140+
141+
// Create a matrix stored in linear memory:
142+
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 ] );
143+
console.log( 'Original matrix A containing Householder vectors:' );
144+
console.log( ndarray2array( A, [ M, N ], [ 1, M ], 0, 'column-major' ) );
145+
146+
// Define scalar factors of the elementary reflectors:
147+
var tau = new Float64Array( [ 1.2, 0.8 ] );
148+
149+
// Create workspace array:
150+
var work = new Float64Array( N );
151+
152+
// Generate the orthogonal matrix Q:
153+
dorg2r( 'column-major', M, N, K, A, M, tau, work );
154+
console.log( 'Resulting orthogonal matrix Q:' );
155+
console.log( ndarray2array( A, [ M, N ], [ 1, M ], 0, 'column-major' ) );
156+
```
157+
158+
</section>
159+
160+
<!-- /.examples -->
161+
162+
<!-- C interface documentation. -->
163+
164+
* * *
165+
166+
<section class="c">
167+
168+
## C APIs
169+
170+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
171+
172+
<section class="intro">
173+
174+
</section>
175+
176+
<!-- /.intro -->
177+
178+
<!-- C usage documentation. -->
179+
180+
<section class="usage">
181+
182+
### Usage
183+
184+
```c
185+
TODO
186+
```
187+
188+
#### TODO
189+
190+
TODO.
191+
192+
```c
193+
TODO
194+
```
195+
196+
TODO
197+
198+
```c
199+
TODO
200+
```
201+
202+
</section>
203+
204+
<!-- /.usage -->
205+
206+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
207+
208+
<section class="notes">
209+
210+
</section>
211+
212+
<!-- /.notes -->
213+
214+
<!-- C API usage examples. -->
215+
216+
<section class="examples">
217+
218+
### Examples
219+
220+
```c
221+
TODO
222+
```
223+
224+
</section>
225+
226+
<!-- /.examples -->
227+
228+
</section>
229+
230+
<!-- /.c -->
231+
232+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
233+
234+
<section class="related">
235+
236+
</section>
237+
238+
<!-- /.related -->
239+
240+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
241+
242+
<section class="links">
243+
244+
[lapack]: https://www.netlib.org/lapack/explore-html/
245+
246+
[lapack-dorg2r]: https://netlib.org/lapack/explore-html/da/da2/group__ung2r_ga8877e79ab6e262ae7497f11d8534635c.html#ga8877e79ab6e262ae7497f11d8534635c
247+
248+
[mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array
249+
250+
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
251+
252+
</section>
253+
254+
<!-- /.links -->
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{{alias}}( order, M, N, K, A, LDA, tau, work )
2+
Generates an M-by-N real matrix Q with orthonormal columns. The matrix Q
3+
is defined as the first N columns of a product of K elementary reflectors
4+
of order M. Q = H(1) H(2) . . . H(K) as returned by dgeqrf.
5+
6+
The function overwrites the input matrix A with the orthogonal matrix Q.
7+
8+
Parameters
9+
----------
10+
order: string
11+
Row-major (C-style) or column-major (Fortran-style) order. Must be
12+
either 'row-major' or 'column-major'.
13+
14+
M: integer
15+
Number of rows in matrix A.
16+
17+
N: integer
18+
Number of columns in matrix A.
19+
20+
K: integer
21+
Number of elementary reflectors whose product defines the matrix Q.
22+
23+
A: Float64Array
24+
Input matrix (overwritten by Householder vectors from dgeqrf).
25+
26+
LDA: integer
27+
Stride of the first dimension of A (a.k.a., leading dimension of the
28+
matrix A).
29+
30+
tau: Float64Array
31+
Vector of K scalar factors of the elementary reflectors.
32+
33+
work: Float64Array
34+
Workspace array.
35+
36+
Returns
37+
-------
38+
A: Float64Array
39+
Mutated input matrix overwritten with the orthogonal matrix Q.
40+
41+
Examples
42+
--------
43+
> var A = new {{alias:@stdlib/array/float64}}([ 1.0,2.0,3.0,4.0,5.0,6.0 ]);
44+
> var tau = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0 ] );
45+
> var work = new {{alias:@stdlib/array/float64}}( 10 );
46+
> {{alias}}( 'column-major', 3, 2, 2, A, 3, tau, work )
47+
<Float64Array>[ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ]
48+
49+
50+
{{alias}}.ndarray( M, N, K, A, sa1, sa2, oa, tau, st, ot, work, sw, ow )
51+
Generates an M-by-N real matrix Q with orthonormal columns using
52+
alternative indexing semantics. The matrix Q is defined as the first N
53+
columns of a product of K elementary reflectors of order M.
54+
`Q = H(1) H(2) . . . H(K)` as returned by `dgeqrf`.
55+
56+
While typed array views mandate a view offset based on the underlying
57+
buffer, the offset parameters support indexing semantics based on starting
58+
indices.
59+
60+
Parameters
61+
----------
62+
M: integer
63+
Number of rows in matrix A.
64+
65+
N: integer
66+
Number of columns in matrix A.
67+
68+
K: integer
69+
Number of elementary reflectors whose product defines the matrix Q.
70+
71+
A: Float64Array
72+
Input matrix.
73+
74+
sa1: integer
75+
Stride of the first dimension of A.
76+
77+
sa2: integer
78+
Stride of the second dimension of A.
79+
80+
oa: integer
81+
Index offset for A.
82+
83+
tau: Float64Array
84+
Vector of K scalar factors of the elementary reflectors.
85+
86+
st: integer
87+
Stride length for tau.
88+
89+
ot: integer
90+
Index offset for tau.
91+
92+
work: Float64Array
93+
Workspace array.
94+
95+
sw: integer
96+
Stride length for work.
97+
98+
ow: integer
99+
Index offset for work.
100+
101+
Returns
102+
-------
103+
A: Float64Array
104+
Mutated input matrix overwritten with the orthogonal matrix Q.
105+
106+
Examples
107+
--------
108+
> var A = new {{alias:@stdlib/array/float64}}([ 1.0,2.0,3.0,4.0,5.0,6.0 ]);
109+
> var tau = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0 ] );
110+
> var work = new {{alias:@stdlib/array/float64}}( 10 );
111+
> {{alias}}.ndarray( 3, 2, 2, A, 1, 3, 0, tau, 1, 0, work, 1, 0 )
112+
<Float64Array>[ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ]
113+
114+
See Also
115+
--------

0 commit comments

Comments
 (0)