Skip to content

Commit 97fc243

Browse files
committed
docs: document new matrix functions and domain handling
1 parent 048c1a4 commit 97fc243

3 files changed

Lines changed: 46 additions & 3 deletions

File tree

docs/src/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ When releasing a new version, move the "Unreleased" changes to a new version sec
2222

2323
### Added
2424

25+
- New matrix functions `squareroot`, `logarithm` and `power` (with both integer and fractional exponents), supporting the `MatrixFunctionViaLA`, `MatrixFunctionViaEig`, `MatrixFunctionViaEigh` and `DiagonalAlgorithm` algorithms.
26+
- The scalar type of the output of these matrix functions matches that of the input, and out-of-domain eigenvalues (e.g. on the negative real axis for a real input) throw a `DomainError`; eigenvalues that violate the domain within a tolerance `domain_atol` (defaulting to `default_domain_atol`) are treated as rounding artifacts and clamped to the domain boundary.
27+
- `MatrixFunctionViaEig` and `MatrixFunctionViaEigh` accept a `domain_atol` keyword argument to control this tolerance.
28+
2529
### Changed
2630

2731
### Deprecated

docs/src/user_interface/algorithms.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ The following algorithms for matrix functions are available.
103103
| Algorithm | Applicable matrix functions | Key keyword arguments |
104104
|:----------|:--------------------------|:----------------------|
105105
| [`MatrixFunctionViaTaylor`](@ref) | exponential | `tol`, `balance` |
106-
| [`MatrixFunctionViaLA`](@ref) | exponential | |
107-
| [`MatrixFunctionViaEig`](@ref) | exponential | `eig_alg` |
108-
| [`MatrixFunctionViaEigh`](@ref) | exponential | `eigh_alg` |
106+
| [`MatrixFunctionViaLA`](@ref) | exponential, squareroot, logarithm, power | |
107+
| [`MatrixFunctionViaEig`](@ref) | exponential, squareroot, logarithm, power | `eig_alg`, `domain_atol` |
108+
| [`MatrixFunctionViaEigh`](@ref) | exponential, squareroot, logarithm, power | `eigh_alg`, `domain_atol` |
109109

110110
For full docstring details on each algorithm type, see the corresponding section in [Decompositions](@ref).
111111

docs/src/user_interface/matrix_functions.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,42 @@ MatrixAlgebraKit.MatrixFunctionViaLA
3737
MatrixAlgebraKit.MatrixFunctionViaEig
3838
MatrixAlgebraKit.MatrixFunctionViaEigh
3939
```
40+
41+
## Domain considerations
42+
43+
The functions below ([`squareroot`](@ref), [`logarithm`](@ref) and [`power`](@ref) with fractional powers) are only defined for matrices whose eigenvalues avoid (part of) the negative real axis, and their principal values are complex whenever eigenvalues on that axis are present.
44+
In MatrixAlgebraKit, we aim to keep type stability, and thus the scalar type of the output always matches that of the input.
45+
As such, a real matrix with eigenvalues on the negative real axis leads to a `DomainError`, you should pass a complex matrix instead to obtain the complex principal value.
46+
To avoid spurious errors for eigenvalues that lie on the negative real axis only because of rounding errors (e.g. a positive semidefinite matrix with a tiny negative eigenvalue), eigenvalues within an absolute tolerance `domain_atol` of the domain boundary are clamped onto it.
47+
This tolerance defaults to [`default_domain_atol`](@ref) and can be specified explicitly for the algorithms that support it, e.g. `MatrixFunctionViaEigh(eigh_alg; domain_atol=...)`.
48+
49+
```@docs; canonical=false
50+
MatrixAlgebraKit.default_domain_atol
51+
```
52+
53+
## Square root
54+
55+
The principal [square root](https://en.wikipedia.org/wiki/Square_root_of_a_matrix) of a square matrix `A` is the unique square root whose eigenvalues have nonnegative real part.
56+
It is computed by the function [`squareroot`](@ref), where the default algorithm [`MatrixFunctionViaLA`](@ref) wraps the Schur-based implementation of `LinearAlgebra`, and the eigenvalue-decomposition-based algorithms [`MatrixFunctionViaEig`](@ref) and [`MatrixFunctionViaEigh`](@ref) are available as well.
57+
58+
```@docs; canonical=false
59+
squareroot
60+
```
61+
62+
## Logarithm
63+
64+
The principal [logarithm](https://en.wikipedia.org/wiki/Logarithm_of_a_matrix) of a square matrix `A` is the unique logarithm whose eigenvalues have imaginary part in `(-π, π]`, and exists for matrices without (numerically) zero eigenvalues that satisfy the domain considerations above.
65+
It is computed by the function [`logarithm`](@ref), with the same algorithm choices as [`squareroot`](@ref).
66+
67+
```@docs; canonical=false
68+
logarithm
69+
```
70+
71+
## Power
72+
73+
Matrix powers `A^p` for real `p` are computed by the function [`power`](@ref), which takes the exponent as a second positional argument.
74+
Integer powers are defined for any square matrix (invertible for negative powers) and reduce to repeated multiplication, while fractional powers are principal powers subject to the domain considerations above.
75+
76+
```@docs; canonical=false
77+
power
78+
```

0 commit comments

Comments
 (0)