Scaling

class probnum.linops.Scaling(factors, shape=None, dtype=None)

Bases: probnum.linops.LinearOperator

Scaling linear operator.

Creates a diagonal linear operator which (non-uniformly) scales elements of vectors, defined by

\[\begin{split}v \mapsto \begin{bmatrix} \alpha_1 & 0 & \dots & 0 \\ 0 & \alpha_2 & & \vdots \\ \vdots & & \ddots & 0 \\ 0 & \dots & 0 & \alpha_n \end{bmatrix} v.\end{split}\]
Parameters

Attributes Summary

H

Hermitian adjoint.

T

Transposed linear operator.

dtype

Data type of the linear operator.

factors

Scaling factors.

is_isotropic

Whether scaling is uniform / isotropic.

is_square

Whether input dimension matches output dimension.

ndim

Number of linear operator dimensions.

scalar

Scaling factor.

shape

Shape of the linear operator.

Methods Summary

__call__(x[, axis])

Call self as a function.

adjoint()

Hermitian adjoint.

astype(dtype[, order, casting, subok, copy])

Cast a linear operator to a different dtype.

broadcast_matmat(matmat)

Broadcasting for a (implicitly defined) matrix-matrix product.

broadcast_matvec(matvec)

Broadcasting for a (implicitly defined) matrix-vector product.

broadcast_rmatmat(rmatmat)

rtype

Callable[[ndarray], ndarray]

broadcast_rmatvec(rmatvec)

rtype

Callable[[ndarray], ndarray]

cond([p])

Compute the condition number of the linear operator.

conj()

Complex conjugate linear operator.

conjugate()

Complex conjugate linear operator.

det()

Determinant of the linear operator.

eigvals()

Eigenvalue spectrum of the linear operator.

inv()

Inverse of the linear operator.

logabsdet()

Log absolute determinant of the linear operator.

rank()

Rank of the linear operator.

todense([cache])

Dense matrix representation of the linear operator.

trace()

Trace of the linear operator.

transpose()

Transpose this linear operator.

Attributes Documentation

H

Hermitian adjoint.

Return type

LinearOperator

T

Transposed linear operator.

Return type

LinearOperator

dtype

Data type of the linear operator.

Return type

dtype

factors

Scaling factors.

Scaling factors on the diagonal of the matrix representation.

Return type

ndarray

is_isotropic

Whether scaling is uniform / isotropic.

Return type

bool

is_square

Whether input dimension matches output dimension.

Return type

bool

ndim

Number of linear operator dimensions.

Defined analogously to numpy.ndarray.ndim.

Return type

int

scalar

Scaling factor.

Return type

Optional[number]

shape

Shape of the linear operator.

Defined as a tuple of the output and input dimension of operator.

Return type

Tuple[int, int]

Methods Documentation

__call__(x, axis=None)

Call self as a function.

Return type

ndarray

adjoint()

Hermitian adjoint.

Return type

LinearOperator

astype(dtype, order='K', casting='unsafe', subok=True, copy=True)

Cast a linear operator to a different dtype.

Parameters
  • dtype (Union[dtype, str]) – Data type to which the linear operator is cast.

  • order (str) – Memory layout order of the result.

  • casting (str) – Controls what kind of data casting may occur.

  • subok (bool) – If True, then sub-classes will be passed-through (default). False is currently not supported for linear operators.

  • copy (bool) – Whether to return a new linear operator, even if dtype is the same.

Return type

LinearOperator

classmethod broadcast_matmat(matmat)

Broadcasting for a (implicitly defined) matrix-matrix product.

Convenience function / decorator to broadcast the definition of a matrix-matrix product to vectors. This can be used to easily construct a new linear operator only from a matrix-matrix product.

Return type

Callable[[ndarray], ndarray]

classmethod broadcast_matvec(matvec)

Broadcasting for a (implicitly defined) matrix-vector product.

Convenience function / decorator to broadcast the definition of a matrix-vector product. This can be used to easily construct a new linear operator only from a matrix-vector product.

Return type

Callable[[ndarray], ndarray]

classmethod broadcast_rmatmat(rmatmat)
Return type

Callable[[ndarray], ndarray]

classmethod broadcast_rmatvec(rmatvec)
Return type

Callable[[ndarray], ndarray]

cond(p=None)

Compute the condition number of the linear operator.

The condition number of the linear operator with respect to the p norm. It measures how much the solution \(x\) of the linear system \(Ax=b\) changes with respect to small changes in \(b\).

Parameters

p ({None, 1, , 2, , inf, 'fro'}, optional) –

Order of the norm:

p

norm for matrices

None

2-norm, computed directly via singular value decomposition

’fro’

Frobenius norm

np.inf

max(sum(abs(x), axis=1))

1

max(sum(abs(x), axis=0))

2

2-norm (largest sing. value)

Returns

The condition number of the linear operator. May be infinite.

Return type

cond

conj()

Complex conjugate linear operator.

Return type

LinearOperator

conjugate()

Complex conjugate linear operator.

Return type

LinearOperator

det()

Determinant of the linear operator.

Return type

inexact

eigvals()

Eigenvalue spectrum of the linear operator.

Return type

ndarray

inv()

Inverse of the linear operator.

Return type

LinearOperator

logabsdet()

Log absolute determinant of the linear operator.

Return type

inexact

rank()

Rank of the linear operator.

Return type

int64

todense(cache=True)

Dense matrix representation of the linear operator.

This method can be computationally very costly depending on the shape of the linear operator. Use with caution.

Returns

matrix – Matrix representation of the linear operator.

Return type

np.ndarray

trace()

Trace of the linear operator.

Computes the trace of a square linear operator \(\text{tr}(A) = \sum_{i-1}^n A_{ii}\).

Returns

trace – Trace of the linear operator.

Return type

float

Raises

LinAlgError : – If trace() is called on a non-square matrix.

transpose()

Transpose this linear operator.

Can be abbreviated self.T instead of self.transpose().

Return type

LinearOperator