Reference

kaczmarz.Base(A, b[, x0, tol, maxiter, callback]) A base class for the Kaczmarz algorithm.
kaczmarz.Cyclic(*base_args, **base_kwargs) Cycle through the equations of the system in order, repeatedly.
kaczmarz.MaxDistance(A, b[, x0, tol, …]) Choose equations which leads to the most progress.
class kaczmarz.Base(A, b, x0=None, tol=1e-05, maxiter=None, callback=None)[source]

A base class for the Kaczmarz algorithm.

This class cannot be instantiated directly. Subclasses should implement kaczmarz.Base._select_row_index(). Subclasses will typically be constructed using kaczmarz.Base.iterates() or kaczmarz.Base.solve().

Parameters:
  • A ((m, n) spmatrix or array_like) – The m-by-n matrix of the linear system.
  • b ((m,) or (m, 1) array_like) – Right hand side of the linear system.
  • x0 ((n,) or (n, 1) array_like, optional) – Starting guess for the solution.
  • tol (float, optional) – Tolerance for convergence, norm(normalized_residual) <= tol.
  • maxiter (int or float, optional) – Maximum number of iterations.
  • callback (function, optional) – User-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector.

Notes

There may be additional parameters not listed above depending on the selection strategy subclass.

_select_row_index(xk)[source]

Select a row to use for the next Kaczmarz update.

Parameters:xk ((n,) array) – The current Kaczmarz iterate.
Returns:ik – The index of the next row to use.
Return type:int
ik

The index of the row used on the most recent iteration.

Takes the value -1 if a projection was not performed at iteration k.

Type:int
xk

The most recent iterate.

The shape will match that of x0 if provided, or b otherwise.

Type:(n,) or (n, 1) array
classmethod iterates(*base_args, **base_kwargs)[source]

Get the Kaczmarz iterates.

Note

This method takes the same parameters as kaczmarz.Base or the subclass from which it is called. For example, kaczmarz.Cyclic.iterates() takes the same arguments as kaczmarz.Cyclic.

Parameters:
  • base_args (tuple) – Positional arguments for kaczmarz.Base constructor or the subclass in use.
  • base_kwargs (dict) – Keyword arguments for kaczmarz.Base constructor or the subclass in use.
Returns:

iterates – An iterable of the Kaczmarz iterates. The shapes will match that of x0 if provided, or b otherwise.

Return type:

iterable((n,) or (n, 1) array)

classmethod solve(*base_args, **base_kwargs)[source]

Solve a linear system of equations using the Kaczmarz algorithm.

Note

This method takes the same parameters as kaczmarz.Base or the subclass from which it is called. For example, kaczmarz.Cyclic.solve() takes the same arguments as kaczmarz.Cyclic.

Parameters:
  • base_args (tuple) – Positional arguments for kaczmarz.Base constructor or the subclass in use.
  • base_kwargs (dict) – Keyword arguments for kaczmarz.Base constructor or the subclass in use.
Returns:

x – The solution to the system A @ x = b. The shape will match that of x0 if provided, or b otherwise.

Return type:

(n,) or (n, 1) array

class kaczmarz.Cyclic(*base_args, **base_kwargs)[source]

Bases: kaczmarz._abc.Base

Cycle through the equations of the system in order, repeatedly.

References

  1. S. Kaczmarz. “Angenäherte Auflösung von Systemen linearer Gleichungen.” Bulletin International de l’Académie Polonaise des Sciences et des Lettres. Classe des Sciences Mathématiques et Naturelles. Série A, Sciences Mathématiques, 35, 335–357, 1937
class kaczmarz.MaxDistance(A, b, x0=None, tol=1e-05, maxiter=None, callback=None)[source]

Bases: kaczmarz._abc.Base

Choose equations which leads to the most progress.

This selection strategy is also known as Motzkin’s method.

References

  1. T. S. Motzkin and I. J. Schoenberg. “The relaxation method for linear inequalities.” Canadian Journal of Mathematics, 6:393–404, 1954.