2.1.1. tomotok.inversions.solvers package#
- class tomotok.inversions.solvers.CholeskySolver(check_finite: bool = False)#
Bases:
SolverScipy based engine using Cholesky decomposition to solve linear systems.
Implementation based on dense matrices, sparse ones are converted to dense.
Methods
solve(a, b)Sparse matrices are converted to dense arrays before decomposition.
- class tomotok.inversions.solvers.NNLSSolver#
Bases:
SolverScipy based engine using non-negative least squares to solve linear systems.
Methods
solve(a, b)Sparse matrices are converted to dense arrays before decomposition.
- class tomotok.inversions.solvers.Solver(sparse: bool = False)#
Bases:
objectBase class for solving a system of linear equations.
Methods
__call__(a, b)Call self as a function.
solve(a, b)Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- solve(a: ArrayLike | sparray, b: ArrayLike | sparray) ndarray#
Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- Parameters:
- aarray_like or sparse array
System of equations matrix to be solved
- barray_like
right hand side vector or matrix (in case of multiple time slices)
- Returns:
- numpy.ndarray
The solution of the linear system.
2.1.1.1. Submodules#
2.1.1.2. tomotok.inversions.solvers.base module#
- class tomotok.inversions.solvers.base.Solver(sparse: bool = False)#
Bases:
objectBase class for solving a system of linear equations.
Methods
__call__(a, b)Call self as a function.
solve(a, b)Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- solve(a: ArrayLike | sparray, b: ArrayLike | sparray) ndarray#
Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- Parameters:
- aarray_like or sparse array
System of equations matrix to be solved
- barray_like
right hand side vector or matrix (in case of multiple time slices)
- Returns:
- numpy.ndarray
The solution of the linear system.
2.1.1.3. tomotok.inversions.solvers.cvxpy module#
- class tomotok.inversions.solvers.cvxpy.CvxpyNNLS(verbose: bool = False, cvxpy_solver=cvxpy.CLARABEL)#
Bases:
SolverImplements non-negative least squares solver using cvxpy.
The cvxpy solver accepts sparse matrices. The solver can be configured to use different cvxpy solvers and verbosity levels.
- Attributes:
- verbose
Methods
solve(a, b)Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- property verbose#
- solve(a: ndarray | csc_array, b: ndarray)#
Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- Parameters:
- aarray_like or sparse array
System of equations matrix to be solved
- barray_like
right hand side vector or matrix (in case of multiple time slices)
- Returns:
- numpy.ndarray
The solution of the linear system.
2.1.1.4. tomotok.inversions.solvers.jax module#
- class tomotok.inversions.solvers.jax.JaxCholesky(enable_x64: bool = True)#
Bases:
SolverUses JAX’s Cholesky decomposition for solving linear systems.
Methods
solve(a, b)Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- solve(a: ndarray | spmatrix | sparray, b: ndarray | spmatrix | sparray) ndarray#
Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- Parameters:
- aarray_like or sparse array
System of equations matrix to be solved
- barray_like
right hand side vector or matrix (in case of multiple time slices)
- Returns:
- numpy.ndarray
The solution of the linear system.
- class tomotok.inversions.solvers.jax.JaxSolver(sparse: bool = False)#
Bases:
SolverUses JAX’s linear solver for solving linear systems.
Methods
solve(a, b)Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- solve(a: ndarray | spmatrix | sparray, b: ndarray | spmatrix | sparray) ndarray#
Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- Parameters:
- aarray_like or sparse array
System of equations matrix to be solved
- barray_like
right hand side vector or matrix (in case of multiple time slices)
- Returns:
- numpy.ndarray
The solution of the linear system.
- class tomotok.inversions.solvers.jax.JaxNNLS(parametrization: str = 'quadratic', init_values: float = 1.0)#
Bases:
SolverNon-negative least squares solver using JAX.
The solver supports different parametrizations for enforcing non-negativity, including quadratic, exponential and softplus functions.
Methods
solve(a, b)Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- solve(a: ndarray | sparray, b: ndarray | sparray)#
Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- Parameters:
- aarray_like or sparse array
System of equations matrix to be solved
- barray_like
right hand side vector or matrix (in case of multiple time slices)
- Returns:
- numpy.ndarray
The solution of the linear system.
2.1.1.5. tomotok.inversions.solvers.optax module#
- class tomotok.inversions.solvers.optax.OptaxNNLS(iterations: int = 5000)#
Bases:
SolverMethods
solve(a, b)Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- solve(a: ndarray | sparray, b: ndarray | sparray)#
Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- Parameters:
- aarray_like or sparse array
System of equations matrix to be solved
- barray_like
right hand side vector or matrix (in case of multiple time slices)
- Returns:
- numpy.ndarray
The solution of the linear system.
- class tomotok.inversions.solvers.optax.OptaxNN(max_iter_num: int = 10000, learning_rate: float = 0.1, tolerance: float = 1e-08)#
Bases:
SolverDense matrices only, requires reasonable estimate on learning rate and parameters.
Methods
solve(a, b)Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
step
- step(x, opt_state)#
- solve(a: ndarray | sparray, b: ndarray | sparray)#
Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- Parameters:
- aarray_like or sparse array
System of equations matrix to be solved
- barray_like
right hand side vector or matrix (in case of multiple time slices)
- Returns:
- numpy.ndarray
The solution of the linear system.
2.1.1.6. tomotok.inversions.solvers.scipy module#
- class tomotok.inversions.solvers.scipy.CholeskySolver(check_finite: bool = False)#
Bases:
SolverScipy based engine using Cholesky decomposition to solve linear systems.
Implementation based on dense matrices, sparse ones are converted to dense.
Methods
solve(a, b)Sparse matrices are converted to dense arrays before decomposition.
- class tomotok.inversions.solvers.scipy.NNLSSolver#
Bases:
SolverScipy based engine using non-negative least squares to solve linear systems.
Methods
solve(a, b)Sparse matrices are converted to dense arrays before decomposition.
- class tomotok.inversions.solvers.scipy.LSQSolver(bounds: tuple[float, float] | None = (0, inf))#
Bases:
SolverScipy based engine using bounded least squares to solve linear systems.
This engine works with sparse matrices, converting dense matrices to sparse format.
It uses lsa_linear from scipy.optimize to solve the problem with bounds. The default bounds are set to (0, inf) to ensure non-negativity of the solution.
Methods
solve(a, b)Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- solve(a: ndarray | sparray, b: ndarray | sparray) ndarray | sparray#
Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- Parameters:
- aarray_like or sparse array
System of equations matrix to be solved
- barray_like
right hand side vector or matrix (in case of multiple time slices)
- Returns:
- numpy.ndarray
The solution of the linear system.
2.1.1.7. tomotok.inversions.solvers.sksparse module#
- class tomotok.inversions.solvers.sksparse.SksparseCholesky(sparse: bool = False)#
Bases:
SolverMethods
solve(a, b)Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- solve(a: ndarray | sparray, b: ndarray | sparray) ndarray#
Solves the linear system \(\mathbf{Ax}=\mathbf{b}\).
- Parameters:
- aarray_like or sparse array
System of equations matrix to be solved
- barray_like
right hand side vector or matrix (in case of multiple time slices)
- Returns:
- numpy.ndarray
The solution of the linear system.