Skip to content

Commit d41266a

Browse files
committed
docs: add example
--- 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: na - 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 b284d11 commit d41266a

File tree

1 file changed

+70
-18
lines changed
  • lib/node_modules/@stdlib/lapack/base

1 file changed

+70
-18
lines changed

lib/node_modules/@stdlib/lapack/base/README.md

Lines changed: 70 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ Many LAPACK routines work with banded matrices, which are stored compactly in tw
3030

3131
### General Band Matrix Storage
3232

33-
A general band matrix of size `M`-by-`N` with `KL` subdiagonals and `KU` superdiagonals is stored in a two-dimensional array `AB` with `KL+KU+1` rows and `N` columns.
33+
A general band matrix of size `M`-by-`N` with `KL` subdiagonals and `KU` superdiagonals is stored in a two-dimensional array `A` with `KL+KU+1` rows and `N` columns.
3434

3535
**Storage Mapping:**
3636

37-
- Columns of the original matrix are stored in corresponding columns of the array `AB`.
38-
- Diagonals of the matrix are stored in rows of the array `AB`.
39-
- Element `A[i, j]` from the original matrix is stored in `AB[KU+1+i-j, j]`.
37+
- Columns of the original matrix are stored in corresponding columns of the array `A`.
38+
- Diagonals of the matrix are stored in rows of the array `A`.
39+
- Element `A[i, j]` from the original matrix is stored in `A[KU+1+i-j, j]`.
4040
- Valid range for `i`: `max(1, j-KU) <= i <= min(M, j+KL)`.
4141

4242
#### Example
@@ -59,12 +59,12 @@ A = \left[
5959

6060
<!-- </equation> -->
6161

62-
the band storage matrix `AB` is then
62+
the band storage matrix `A` is then
6363

64-
<!-- <equation class="equation" label="eq:band_storage_ab" align="center" raw="AB = \left[\begin{array}{rrrrr} * & a_{12} & a_{23} & a_{34} & a_{45} \\ a_{11} & a_{22} & a_{33} & a_{44} & a_{55} \\ a_{21} & a_{32} & a_{43} & a_{54} & * \\ a_{31} & a_{42} & a_{53} & * & * \end{array}\right]" alt="Band storage representation of matrix A."> -->
64+
<!-- <equation class="equation" label="eq:band_storage_ab" align="center" raw="A = \left[\begin{array}{rrrrr} * & a_{12} & a_{23} & a_{34} & a_{45} \\ a_{11} & a_{22} & a_{33} & a_{44} & a_{55} \\ a_{21} & a_{32} & a_{43} & a_{54} & * \\ a_{31} & a_{42} & a_{53} & * & * \end{array}\right]" alt="Band storage representation of matrix A."> -->
6565

6666
```math
67-
AB = \left[
67+
A = \left[
6868
\begin{array}{rrrrr}
6969
* & a_{12} & a_{23} & a_{34} & a_{45} \\
7070
a_{11} & a_{22} & a_{33} & a_{44} & a_{55} \\
@@ -76,7 +76,7 @@ AB = \left[
7676

7777
<!-- </equation> -->
7878

79-
`AB` is a 4×5 matrix as `KL+KU+1 = 2+1+1 = 4`. Elements marked `*` need not be set and are not referenced by LAPACK routines.
79+
`A` is a 4×5 matrix as `KL+KU+1 = 2+1+1 = 4`. Elements marked `*` need not be set and are not referenced by LAPACK routines.
8080

8181
**Note:** When a band matrix is supplied for LU factorization, space must be allowed to store an additional `KL` superdiagonals, which are generated by fill-in as a result of row interchanges. This means that the matrix is stored according to the above scheme, but with `KL + KU` superdiagonals.
8282

@@ -93,12 +93,12 @@ For symmetric or Hermitian band matrices with `KD` subdiagonals or superdiagonal
9393

9494
**Upper Triangle Storage (UPLO = 'U'):**
9595

96-
- Element `A[i, j]` is stored in `AB[KD+1+i-j, j]`.
96+
- Element `A[i, j]` is stored in `A[KD+1+i-j, j]`.
9797
- Valid range for `i`: `max(1, j-KD) <= i <= j`.
9898

9999
**Lower Triangle Storage (UPLO = 'L'):**
100100

101-
- Element `A[i, j]` is stored in `AB[1+i-j, j]`.
101+
- Element `A[i, j]` is stored in `A[1+i-j, j]`.
102102
- Valid range for `i`: `j <= i <= min(N, j+KD)`.
103103

104104
#### Example
@@ -121,12 +121,12 @@ A = \left[
121121

122122
<!-- </equation> -->
123123

124-
the band storage matrix `AB` when `UPLO = 'U'` (i.e., upper triangle) is
124+
the band storage matrix `A` when `UPLO = 'U'` (i.e., upper triangle) is
125125

126-
<!-- <equation class="equation" label="eq:symmetric_upper_ab" align="center" raw="AB = \left[\begin{array}{rrrrr} * & * & a_{13} & a_{24} & a_{35} \\ * & a_{12} & a_{23} & a_{34} & a_{45} \\ a_{11} & a_{22} & a_{33} & a_{44} & a_{55} \end{array}\right]" alt="Band storage representation of symmetric matrix A (upper triangle)."> -->
126+
<!-- <equation class="equation" label="eq:symmetric_upper_ab" align="center" raw="A = \left[\begin{array}{rrrrr} * & * & a_{13} & a_{24} & a_{35} \\ * & a_{12} & a_{23} & a_{34} & a_{45} \\ a_{11} & a_{22} & a_{33} & a_{44} & a_{55} \end{array}\right]" alt="Band storage representation of symmetric matrix A (upper triangle)."> -->
127127

128128
```math
129-
AB = \left[
129+
A = \left[
130130
\begin{array}{rrrrr}
131131
* & * & a_{13} & a_{24} & a_{35} \\
132132
* & a_{12} & a_{23} & a_{34} & a_{45} \\
@@ -137,7 +137,7 @@ AB = \left[
137137

138138
<!-- </equation> -->
139139

140-
`AB` is a 3×5 matrix as `KD+1 = 2+1 = 3`. Similarly, given the following matrix `A`,
140+
`A` is a 3×5 matrix as `KD+1 = 2+1 = 3`. Similarly, given the following matrix `A`,
141141

142142
<!-- <equation class="equation" label="eq:symmetric_lower_a" align="center" raw="A = \left[\begin{array}{rrrrr} a_{11} & {a_{21}} & {a_{31}} & 0 & 0 \\ a_{21} & a_{22} & {a_{32}} & {a_{42}} & 0 \\ a_{31} & a_{32} & a_{33} & {a_{43}} & {a_{53}} \\ 0 & a_{42} & a_{43} & a_{44} & {a_{54}} \\ 0 & 0 & a_{53} & a_{54} & a_{55} \end{array}\right]" alt="Representation of symmetric band matrix A (lower triangle)."> -->
143143

@@ -155,12 +155,12 @@ A = \left[
155155

156156
<!-- </equation> -->
157157

158-
the band storage matrix `AB` when `UPLO = 'L'` (i.e., lower triangle) is
158+
the band storage matrix `A` when `UPLO = 'L'` (i.e., lower triangle) is
159159

160-
<!-- <equation class="equation" label="eq:symmetric_lower_ab" align="center" raw="AB = \left[\begin{array}{rrrrr} a_{11} & a_{22} & a_{33} & a_{44} & a_{55} \\ a_{21} & a_{32} & a_{43} & a_{54} & * \\ a_{31} & a_{42} & a_{53} & * & * \end{array}\right]" alt="Band storage representation of symmetric matrix A (lower triangle)."> -->
160+
<!-- <equation class="equation" label="eq:symmetric_lower_ab" align="center" raw="A = \left[\begin{array}{rrrrr} a_{11} & a_{22} & a_{33} & a_{44} & a_{55} \\ a_{21} & a_{32} & a_{43} & a_{54} & * \\ a_{31} & a_{42} & a_{53} & * & * \end{array}\right]" alt="Band storage representation of symmetric matrix A (lower triangle)."> -->
161161

162162
```math
163-
AB = \left[
163+
A = \left[
164164
\begin{array}{rrrrr}
165165
a_{11} & a_{22} & a_{33} & a_{44} & a_{55} \\
166166
a_{21} & a_{32} & a_{43} & a_{54} & * \\
@@ -169,10 +169,62 @@ AB = \left[
169169
\right]
170170
```
171171

172-
`AB` is a 3×5 matrix as `KD+1 = 2+1 = 3`.
172+
`A` is a 3×5 matrix as `KD+1 = 2+1 = 3`.
173+
174+
<!-- </equation> -->
175+
176+
### Example
177+
178+
Consider a 4×4 general band matrix with `KL = 2` subdiagonals and `KU = 1` superdiagonal:
179+
180+
<!-- <equation class="equation" label="eq:band_matrix_numeric_a" align="center" raw="A = \left[\begin{array}{rrrr} 1.0 & 2.0 & 0.0 & 0.0 \\ 3.0 & 4.0 & 5.0 & 0.0 \\ 6.0 & 7.0 & 8.0 & 9.0 \\ 0.0 & 10.0 & 11.0 & 12.0 \end{array}\right]" alt="Representation of band matrix A with numeric values."> -->
181+
182+
```math
183+
A = \left[
184+
\begin{array}{rrrr}
185+
1.0 & 2.0 & 0.0 & 0.0 \\
186+
3.0 & 4.0 & 5.0 & 0.0 \\
187+
6.0 & 7.0 & 8.0 & 9.0 \\
188+
0.0 & 10.0 & 11.0 & 12.0
189+
\end{array}
190+
\right]
191+
```
192+
193+
<!-- </equation> -->
194+
195+
#### Band Storage Representation
196+
197+
The band storage matrix `A` has dimensions `(KL+KU+1) × N = (2+1+1) × 4 = 4 × 4`:
198+
199+
<!-- <equation class="equation" label="eq:band_storage_numeric_a" align="center" raw="A = \left[\begin{array}{rrrr} * & 2.0 & 5.0 & 9.0 \\ 1.0 & 4.0 & 8.0 & 12.0 \\ 3.0 & 7.0 & 11.0 & * \\ 6.0 & 10.0 & * & * \end{array}\right]" alt="Band storage representation of matrix A with numeric values."> -->
200+
201+
```math
202+
A = \left[
203+
\begin{array}{rrrr}
204+
* & 2.0 & 5.0 & 9.0 \\
205+
1.0 & 4.0 & 8.0 & 12.0 \\
206+
3.0 & 7.0 & 11.0 & * \\
207+
6.0 & 10.0 & * & *
208+
\end{array}
209+
\right]
210+
```
173211

174212
<!-- </equation> -->
175213

214+
Here's how to represent this band matrix in JavaScript using `Float64Array`:
215+
216+
##### Row-Major Layout
217+
218+
```javascript
219+
var A = new Float64Array( [ 0.0, 2.0, 5.0, 9.0, 1.0, 4.0, 8.0, 12.0, 3.0, 7.0, 11.0, 0.0, 6.0, 10.0, 0.0, 0.0 ] );
220+
```
221+
222+
##### Column-Major Layout
223+
224+
```javascript
225+
var A = new Float64Array( [ 0.0, 1.0, 3.0, 6.0, 2.0, 4.0, 7.0, 10.0, 5.0, 8.0, 11.0, 0.0, 9.0, 12.0, 0.0, 0.0 ] );
226+
```
227+
176228
</section>
177229

178230
<!-- /.intro -->

0 commit comments

Comments
 (0)