cherab.inversion.regularization.TSVDΒΆ

class cherab.inversion.regularization.TSVD(s: ArrayLike, U: ArrayLike, basis: ArrayLike, /, B: NDArray[float64] | _spbase[float64, tuple[int, int]] | None = None, *, data: ArrayLike | None = None)SourceΒΆ
class cherab.inversion.regularization.TSVD(T: NDArray[float64] | _spbase[float64, tuple[int, int]], /, *, H: NDArray[float64] | _spbase[float64, tuple[int, int]] | None = None, Q: NDArray[float64] | _spbase[float64, tuple[int, int]] | None = None, data: ArrayLike | None = None, use_gpu: bool = False, dtype: DTypeLike | None = None, sp: Progress | None = None, task_id: TaskID | None = None)

Bases: SVD

Truncated SVD solver.

Parameters:
*args

Same as SVD.

**kwargs

Same as SVD.

Notes

For TSVD, an L-curve criterion can be applied in a discrete manner by evaluating candidate truncation points \(\beta_k = \sigma_k^2\). If the criterion object provides optimize_discrete (as Lcurve does), solve() dispatches to that method automatically.

Methods

eta(beta)

Squared regularization norm \(\eta\).

eta_diff(beta)

Differential of \(\eta\).

filter(beta)

Calculate the filter factors \(f_{\lambda, i}\).

regularization_norm(beta)

Regularization norm: \(\sqrt{\eta} = \|\mathbf{x}_\lambda\|_\mathbf{H}\).

residual_norm(beta)

Residual norm: \(\sqrt{\rho} = \|\mathbf{T}\mathbf{x}_\lambda - \mathbf{b}\|_{\mathbf{Q}}\).

rho(beta)

Squared residual norm \(\rho\).

solution(beta)

Solution vector \(\mathbf{x}_\lambda\).

solve([criterion,Β bounds,Β stepsize])

Solve with TSVD regularization.

Attributes

B

Matrix \(\mathbf{B}\) from \(\mathbf{Q} = \mathbf{B}^\mathsf{T}\mathbf{B}\).

U

Left singular vectors \(\mathbf{U}\).

basis

Inverted solution basis \(\tilde{\mathbf{V}}\).

bounds

\((\log_{10}\sigma_r^2, \log_{10}\sigma_1^2)\).

data

Given data for inversion calculation \(\mathbf{b}\).

lambda_opt

Optimal regularization parameter, set after solve() is executed.

s

Singular values \(\mathbf{s}\).

filter(beta: float) ndarray[tuple[Any, ...], dtype[float64]]SourceΒΆ

Calculate the filter factors \(f_{\lambda, i}\).

The filter factors are diagonal elements of the filter matrix \(\mathbf{F}_\lambda\), and can be expressed with TSVD components as follows:

\[\begin{split}f_{\lambda, i} = \begin{cases} 1 & \mathrm{if}\; \sigma_i^2 \geq \beta, \\ 0 & \mathrm{if}\; \sigma_i^2 < \beta. \end{cases}\end{split}\]
Parameters:
beta: floatΒΆ

Regularization parameter.

Returns:

(r, ) ndarray – 1-D array containing filter factors, the length of which is the same as the number of singular values.

solve(criterion: Criterion | None = None, bounds=None, stepsize: float = 10, **kwargs: Any) tuple[ndarray, Any]SourceΒΆ

Solve with TSVD regularization.

Parameters:
criterion: Criterion | None = NoneΒΆ

Criterion object. If it has optimize_discrete, that method is used.

bounds=NoneΒΆ

Bounds for continuous criteria.

stepsize: float = 10ΒΆ

Step-size for continuous criteria.

**kwargs: AnyΒΆ

Extra arguments forwarded to criterion optimizer.

Returns:

  • sol ((N,) ndarray) – Optimal solution vector.

  • result (OptimizeResult | dict) – Object returned by basinhopping function for continuous criteria, or a dictionary of relevant information for discrete criteria.

property B : NDArray[float64] | _spbase[float64, tuple[int, int]] | NoneSourceΒΆ

Matrix \(\mathbf{B}\) from \(\mathbf{Q} = \mathbf{B}^\mathsf{T}\mathbf{B}\).

If users do not specify the matrix \(\mathbf{B}\), this property is None.

property U : ndarray[tuple[Any, ...], dtype[float64]]SourceΒΆ

Left singular vectors \(\mathbf{U}\).

Left singular vectors form a matrix containing column vectors like \(\mathbf{U}=\begin{bmatrix}\mathbf{u}_1 & \cdots &\mathbf{u}_r\end{bmatrix}\in\mathbb{R}^{M\times r}\).

property basis : ndarray[tuple[Any, ...], dtype[float64]]SourceΒΆ

Inverted solution basis \(\tilde{\mathbf{V}}\).

The inverted solution basis is a matrix containing column vectors like \(\tilde{\mathbf{V}}=\begin{bmatrix}\tilde{\mathbf{v}}_1&\cdots&\tilde{\mathbf{v}}_r\end{bmatrix}\in\mathbb{R}^{N\times r}\).

property bounds : tuple[float, float]SourceΒΆ

\((\log_{10}\sigma_r^2, \log_{10}\sigma_1^2)\).

Type:

Default bounds of \(\log_{10}\lambda\)

property data : ndarray[tuple[Any, ...], dtype[float64]] | NoneSourceΒΆ

Given data for inversion calculation \(\mathbf{b}\).

The given data is a vector array like \(\mathbf{b} \in \mathbb{R}^M\).

eta(beta: float) floatSourceΒΆ

Squared regularization norm \(\eta\).

\(\eta\) can be expressed with SVD components as follows:

\[\begin{split}\eta &= \|\mathbf{x}_\lambda\|_\mathbf{H}^2\\ &= \| \mathbf{F}_\lambda\mathbf{S}^{-1} \mathbf{U}^\mathsf{T}\mathbf{B}\mathbf{b} \|^2\end{split}\]
Parameters:
beta: floatΒΆ

Regularization parameter.

Returns:

float – Squared regularization norm \(\eta\).

eta_diff(beta: float) floatSourceΒΆ

Differential of \(\eta\).

\(\eta'\equiv\frac{\partial\eta}{\partial\lambda}\) can be calculated with SVD components as follows:

\[\eta' = \frac{2}{\lambda} (\mathbf{U}^\mathsf{T}\mathbf{B}\mathbf{b})^\mathsf{T} (\mathbf{F}_\lambda - \mathbf{I}_r) \mathbf{F}_\lambda^2\mathbf{S}^{-2}\ \mathbf{U}^\mathsf{T}\mathbf{B}\mathbf{b}.\]
Parameters:
beta: floatΒΆ

Regularization parameter \(\lambda\).

Returns:

float – Differential of \(\eta\) with respect to \(\lambda\).

property lambda_opt : float | NoneSourceΒΆ

Optimal regularization parameter, set after solve() is executed.

regularization_norm(beta: float) floatSourceΒΆ

Regularization norm: \(\sqrt{\eta} = \|\mathbf{x}_\lambda\|_\mathbf{H}\).

Parameters:
beta: floatΒΆ

Regularization parameter.

Returns:

float – Regularization norm \(\sqrt{\eta}\).

residual_norm(beta: float) floatSourceΒΆ

Residual norm: \(\sqrt{\rho} = \|\mathbf{T}\mathbf{x}_\lambda - \mathbf{b}\|_{\mathbf{Q}}\).

Parameters:
beta: floatΒΆ

Regularization parameter.

Returns:

float – Residual norm \(\sqrt{\rho}\).

rho(beta: float) floatSourceΒΆ

Squared residual norm \(\rho\).

\(\rho\) can be expressed with SVD components as follows:

\[\begin{split}\rho &= \| \mathbf{T}\mathbf{x}_\lambda - \mathbf{b} \|_\mathbf{Q}^2\\ &= \| (\mathbf{F}_\lambda - \mathbf{I}_r) \mathbf{U}^\mathsf{T}\mathbf{B}\mathbf{b} \|^2.\end{split}\]
Parameters:
beta: floatΒΆ

Regularization parameter.

Returns:

float – Squared residual norm \(\rho\).

property s : ndarray[tuple[Any, ...], dtype[float64]]SourceΒΆ

Singular values \(\mathbf{s}\).

Singular values form a vector array like \(\mathbf{s} = \begin{bmatrix}\sigma_1 & \cdots & \sigma_r\end{bmatrix}^\mathsf{T} \in \mathbb{R}^r\).

solution(beta: float) ndarraySourceΒΆ

Solution vector \(\mathbf{x}_\lambda\).

The solution vector \(\mathbf{x}_\lambda\) can be expressed with SVD components as

\[\mathbf{x}_\lambda = \tilde{\mathbf{V}} \mathbf{F}_\lambda \mathbf{S}^{-1} \mathbf{U}^\mathsf{T}\mathbf{B}\mathbf{b}.\]
Parameters:
beta: floatΒΆ

Regularization parameter.

Returns:

(N, ) array – Solution vector \(\mathbf{x}_\lambda\).