Skip to content

Commit 345f6f9

Browse files
committed
Added documentation for symmetric and hermitian matrices.
1 parent 7ea8d29 commit 345f6f9

File tree

1 file changed

+109
-7
lines changed

1 file changed

+109
-7
lines changed

doc/specs/stdlib_specialmatrices.md

Lines changed: 109 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ The `stdlib_specialmatrices` module provides derived types and specialized drive
1212
These include:
1313

1414
- Tridiagonal matrices
15-
- Symmetric Tridiagonal matrices (not yet supported)
15+
- Symmetric Tridiagonal matrices
16+
- Hermitian Tridiagonal matrices
1617
- Circulant matrices (not yet supported)
1718
- Toeplitz matrices (not yet supported)
1819
- Hankel matrices (not yet supported)
@@ -76,6 +77,107 @@ Tridiagonal matrices are available with all supported data types as `tridiagonal
7677
{!example/specialmatrices/example_tridiagonal_dp_type.f90!}
7778
```
7879

80+
### Symmetric tridiagonal matrices {#SymTridiagonal}
81+
82+
#### Status
83+
84+
Experimental
85+
86+
#### Description
87+
88+
Symmetric tridiagonal matrices are ubiquituous in scientific computing and often appear when discretizing 1D differential operators.
89+
A generic symmetric tridiagonal matrix has the following structure:
90+
$$
91+
A
92+
=
93+
\begin{bmatrix}
94+
a_1 & b_1 \\
95+
b_1 & a_2 & b_2 \\
96+
& \ddots & \ddots & \ddots \\
97+
& & b_{n-2} & a_{n-1} & b_{n-1} \\
98+
& & & b_{n-1} & a_n
99+
\end{bmatrix}.
100+
$$
101+
Hence, only one vector of size `n` and two of size `n-1` need to be stored to fully represent the matrix.
102+
This particular structure also lends itself to specialized implementations for many linear algebra tasks.
103+
Interfaces to the most common ones will soon be provided by `stdlib_specialmatrices`.
104+
Symmetric tridiagonal matrices are available with all supported data types as `symtridiagonal_<kind>_type`, for example:
105+
106+
- `symtridiagonal_sp_type` : Symmetric tridiagonal matrix of size `n` with `real`/`single precision` data.
107+
- `symtridiagonal_dp_type` : Symmetric tridiagonal matrix of size `n` with `real`/`double precision` data.
108+
- `symtridiagonal_xdp_type` : Symmetric tridiagonal matrix of size `n` with `real`/`extended precision` data.
109+
- `symtridiagonal_qp_type` : Symmetric tridiagonal matrix of size `n` with `real`/`quadruple precision` data.
110+
- `symtridiagonal_csp_type` : Symmetric tridiagonal matrix of size `n` with `complex`/`single precision` data.
111+
- `symtridiagonal_cdp_type` : Symmetric tridiagonal matrix of size `n` with `complex`/`double precision` data.
112+
- `symtridiagonal_cxdp_type` : Symmetric tridiagonal matrix of size `n` with `complex`/`extended precision` data.
113+
- `symtridiagonal_cqp_type` : Symmetric tridiagonal matrix of size `n` with `complex`/`quadruple precision` data.
114+
115+
#### Syntax
116+
117+
- To construct a symmetric tridiagonal matrix from already allocated arrays `dv` (main diagonal, size `n`) and `ev` (upper diagonal, size `n-1`):
118+
119+
`A = ` [[stdlib_specialmatrices(module):symtridiagonal(interface)]] `(dv, ev)`
120+
121+
- To construct a symmetric tridiagonal matrix of size `n x n` with constant diagonal elements `dv`, and `ev`:
122+
123+
`A = ` [[stdlib_specialmatrices(module):symtridiagonal(interface)]] `(dv, ev, n)`
124+
125+
#### Example
126+
127+
```fortran
128+
{!example/specialmatrices/example_symtridiagonal_dp_type.f90!}
129+
```
130+
131+
### Hermitian tridiagonal matrices {#HermTridiagonal}
132+
133+
#### Status
134+
135+
Experimental
136+
137+
#### Description
138+
139+
Hermitian tridiagonal matrices are ubiquituous in scientific computing.
140+
A generic hermitian tridiagonal matrix has the following structure:
141+
$$
142+
A
143+
=
144+
\begin{bmatrix}
145+
a_1 & b_1 \\
146+
\bar{b}_1 & a_2 & b_2 \\
147+
& \ddots & \ddots & \ddots \\
148+
& & \bar{b}_{n-2} & a_{n-1} & b_{n-1} \\
149+
& & & \bar{b}_{n-1} & a_n
150+
\end{bmatrix},
151+
$$
152+
where \( a_i \in \mathbb{R} \), \( b_i \in \mathbb{C} \) and the overbar denotes the complex conjugate operation.
153+
Hence, only one vector of size `n` and two of size `n-1` need to be stored to fully represent the matrix.
154+
This particular structure also lends itself to specialized implementations for many linear algebra tasks.
155+
Interfaces to the most common ones will soon be provided by `stdlib_specialmatrices`.
156+
Hermitian tridiagonal matrices are available with all supported data types as `hermtridiagonal_<kind>_type`, for example:
157+
158+
- `hermtridiagonal_csp_type` : Hermitian tridiagonal matrix of size `n` with `complex`/`single precision` data.
159+
- `hermtridiagonal_cdp_type` : Hermitian tridiagonal matrix of size `n` with `complex`/`double precision` data.
160+
- `hermtridiagonal_cxdp_type` : Hermitian tridiagonal matrix of size `n` with `complex`/`extended precision` data.
161+
- `hermtridiagonal_cqp_type` : Hermitian tridiagonal matrix of size `n` with `complex`/`quadruple precision` data.
162+
163+
#### Syntax
164+
165+
- To construct a hermitian tridiagonal matrix from already allocated arrays `dv` (main diagonal, size `n`) and `ev` (upper diagonal, size `n-1`):
166+
167+
`A = ` [[stdlib_specialmatrices(module):hermtridiagonal(interface)]] `(dv, ev)`
168+
169+
- To construct a hermitian tridiagonal matrix of size `n x n` with constant diagonal elements `dv`, and `ev`:
170+
171+
`A = ` [[stdlib_specialmatrices(module):hermtridiagonal(interface)]] `(dv, ev, n)`
172+
173+
Note that only the real parts of the diagonal elements `dv` are being used to construct the corresponding Hermitian matrix.
174+
175+
#### Example
176+
177+
```fortran
178+
{!example/specialmatrices/example_hermtridiagonal_dp_type.f90!}
179+
```
180+
79181
## Specialized drivers for linear algebra tasks
80182

81183
Below is a list of all the specialized drivers for linear algebra tasks currently provided by the `stdlib_specialmatrices` module.
@@ -111,7 +213,7 @@ With the exception of `extended precision` and `quadruple precision`, all the ty
111213
- `op` (optional) : In-place operator identifier. Shall be a character(1) argument. It can have any of the following values: `N`: no transpose, `T`: transpose, `H`: hermitian or complex transpose.
112214

113215
@warning
114-
Due to limitations of the underlying `lapack` driver, currently `alpha` and `beta` can only take one of the values `[-1, 0, 1]` for `tridiagonal` and `symtridiagonal` matrices. See `lagtm` for more details.
216+
Due to limitations of the underlying `lapack` driver, currently `alpha` and `beta` can only take one of the values `[-1, 0, 1]` for `tridiagonal`, `symtridiagonal` and `hermtridiagonal` matrices. See `lagtm` for more details.
115217
@endwarning
116218

117219
#### Examples
@@ -192,17 +294,17 @@ Experimental
192294

193295
The definition of all standard artihmetic operators have been overloaded to be applicable for the matrix types defined by `stdlib_specialmatrices`:
194296

195-
- Overloading the `+` operator for adding two matrices of the same type and kind.
196-
- Overloading the `-` operator for subtracting two matrices of the same type and kind.
297+
- Overloading the `+` operator for adding two matrices of the same class and kind.
298+
- Overloading the `-` operator for subtracting two matrices of the same class and kind.
197299
- Overloading the `*` for scalar-matrix multiplication.
198300

199301
#### Syntax
200302

201-
- Adding two matrices of the same type:
303+
- Adding two matrices of the same class:
202304

203305
`C = A` [[stdlib_specialmatrices(module):operator(+)(interface)]] `B`
204306

205-
- Subtracting two matrices of the same type:
307+
- Subtracting two matrices of the same class:
206308

207309
`C = A` [[stdlib_specialmatrices(module):operator(-)(interface)]] `B`
208310

@@ -211,5 +313,5 @@ The definition of all standard artihmetic operators have been overloaded to be a
211313
`B = alpha` [[stdlib_specialmatrices(module):operator(*)(interface)]] `A`
212314

213315
@note
214-
For addition (`+`) and subtraction (`-`), matrices `A`, `B` and `C` all need to be of the same type and kind. For scalar multiplication (`*`), `A` and `B` need to be of the same type and kind, while `alpha` is either `real` or `complex` (with the same kind again) depending on the type being used.
316+
For addition (`+`) and subtraction (`-`), matrices `A`, and `B` need to be of the same class and kind. For scalar multiplication (`*`), `A` and `B` need to be of the same class and kind, while `alpha` is either `real` or `complex` (with the same kind again) depending on the type being used.
215317
@endnote

0 commit comments

Comments
 (0)