# ScalarMult¶

class probnum.linops.ScalarMult(shape, scalar)

A linear operator representing scalar multiplication.

Parameters: shape (tuple) – Matrix dimensions (M, N). scalar (float) – Scalar to multiply by.

Attributes Summary

 H Hermitian adjoint. T Transpose this linear operator. ndim

Methods Summary

 __call__(x) Call self as a function. adjoint() Hermitian adjoint. cond([p]) Compute the condition number of the linear operator. det() Determinant of the linear operator. dot(x) Matrix-matrix or matrix-vector multiplication. eigvals() Eigenvalue spectrum of the linear operator. inv() Inverse of the linear operator. logabsdet() Log absolute determinant of the linear operator. matmat(X) Matrix-matrix multiplication. matvec(x) Matrix-vector multiplication. rank() Rank of the linear operator. rmatmat(X) Adjoint matrix-matrix multiplication. rmatvec(x) Adjoint matrix-vector multiplication. todense() Dense matrix representation of the linear operator. trace() Trace of the linear operator. transpose() Transpose this linear operator.

Attributes Documentation

H

Returns the Hermitian adjoint of self, aka the Hermitian conjugate or Hermitian transpose. For a complex matrix, the Hermitian adjoint is equal to the conjugate transpose.

Returns: A_H – Hermitian adjoint of self. LinearOperator
T

Transpose this linear operator.

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

ndim = 2

Methods Documentation

__call__(x)

Call self as a function.

adjoint()

Returns the Hermitian adjoint of self, aka the Hermitian conjugate or Hermitian transpose. For a complex matrix, the Hermitian adjoint is equal to the conjugate transpose.

Returns: A_H – Hermitian adjoint of self. LinearOperator
cond(p=None)[source]

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:cond – The condition number of the linear operator. May be infinite.
Return type:{float, inf}
det()[source]

Determinant of the linear operator.

dot(x)

Matrix-matrix or matrix-vector multiplication.

Parameters: x (array_like) – 1-d or 2-d array, representing a vector or matrix. Ax – 1-d or 2-d array (depending on the shape of x) that represents the result of applying this linear operator on x. array
eigvals()[source]

Eigenvalue spectrum of the linear operator.

inv()[source]

Inverse of the linear operator.

logabsdet()[source]

Log absolute determinant of the linear operator.

matmat(X)

Matrix-matrix multiplication.

Performs the operation y=A*X where A is an MxN linear operator and X dense N*K matrix or ndarray.

Parameters: X ({matrix, ndarray}) – An array with shape (N,K). Y – A matrix or ndarray with shape (M,K) depending on the type of the X argument. {matrix, ndarray}

Notes

This matmat wraps any user-specified matmat routine or overridden _matmat method to ensure that y has the correct type.

matvec(x)

Matrix-vector multiplication. Performs the operation y=A*x where A is an MxN linear operator and x is a 1-d array or random variable.

Parameters: x ({matrix, ndarray, RandomVariable}) – An array or RandomVariable with shape (N,) or (N,1). y – A matrix or ndarray or RandomVariable with shape (M,) or (M,1) depending on the type and shape of the x argument. {matrix, ndarray}

Notes

This matvec wraps the user-specified matvec routine or overridden _matvec method to ensure that y has the correct shape and type.

rank()[source]

Rank of the linear operator.

rmatmat(X)

Performs the operation y = A^H * x where A is an MxN linear operator and x is a column vector or 1-d array, or 2-d array. The default implementation defers to the adjoint.

Parameters: X ({matrix, ndarray}) – A matrix or 2D array. Y – A matrix or 2D array depending on the type of the input. {matrix, ndarray}

Notes

This rmatmat wraps the user-specified rmatmat routine.

rmatvec(x)

Performs the operation y = A^H * x where A is an MxN linear operator and x is a column vector or 1-d array.

Parameters: x ({matrix, ndarray}) – An array with shape (M,) or (M,1). y – A matrix or ndarray with shape (N,) or (N,1) depending on the type and shape of the x argument. {matrix, ndarray}

Notes

This rmatvec wraps the user-specified rmatvec routine or overridden _rmatvec method to ensure that y has the correct shape and type.

todense()[source]

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. np.ndarray
trace()[source]

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. float ValueError : If trace() is called on a non-square matrix.
transpose()

Transpose this linear operator.

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