AdjacencyOperator#

class graph_tool.spectral.AdjacencyOperator(*args, **kwargs)[source]#

Bases: LinearOperator

A scipy.sparse.linalg.LinearOperator representing the adjacency matrix of a graph. See adjacency() for details.

Methods

adjoint()

Hermitian adjoint.

dot(x)

Multi-purpose multiplication method.

matmat(X)

Matrix-matrix multiplication.

matvec(x)

Matrix-vector multiplication.

rdot(x)

Multi-purpose multiplication method from the right.

rmatmat(X)

Adjoint matrix-matrix multiplication.

rmatvec(x)

Adjoint matrix-vector multiplication.

transpose()

Transpose.

Attributes

H

Hermitian adjoint.

T

Transpose.

ndim

adjoint()#

Hermitian adjoint.

Returns the Hermitian adjoint of this linear operator, also known as the Hermitian conjugate or Hermitian transpose. For a complex matrix, the Hermitian adjoint is equal to the conjugate transpose.

Returns:
LinearOperator

Hermitian adjoint of self.

See also

H

Equivalent attribute.

dot(x)#

Multi-purpose multiplication method.

Parameters:
xarray_like or LinearOperator or scalar

Array-like input will be interpreted as a 1-D row vector or 2-D matrix (or batch of matrices) depending on its shape. See the Returns section for details.

Returns:
Axarray or LinearOperator
  • For LinearOperator input, operator composition is performed.

  • For scalar input, a lazily scaled operator is returned.

  • Otherwise, the input is expected to take the form of a dense 1-D vector or 2-D matrix (or batch of matrices), interpreted as follows (where self is an M by N linear operator):

    • If x has shape (N,) it is interpreted as a row vector and matvec is called.

    • If x has shape (..., N, K) for some integer K, it is interpreted as a matrix (or batch of matrices if there are batch dimensions) and matmat is called.

See also

__mul__

Equivalent method used by the * operator.

__matmul__

Method used by the @ operator which rejects scalar input before calling this method.

Notes

To perform matrix-vector multiplication on batches of vectors, use matvec.

For clarity, it is recommended to use the matvec or matmat methods directly instead of this method when interacting with dense vectors and matrices.

matmat(X)#

Matrix-matrix multiplication.

Performs the operation A @ X where A is an M x N linear operator (or batch of linear operators) and X is a dense N x K matrix (or batch of dense matrices).

Parameters:
X{matrix, ndarray}

An array with shape (..., N, K) representing the dense matrix (or batch of dense matrices).

Returns:
Y{matrix, ndarray}

An array with shape (..., M, K).

Notes

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

matvec(x)#

Matrix-vector multiplication.

Applies A to x, where A is an M x N linear operator (or batch of linear operators) and x is a row vector (or batch of such vectors).

Parameters:
x{matrix, ndarray}

An array with shape (..., N) representing a row vector (or batch of row vectors).

Added in version 1.18.0: A FutureWarning is emitted for column vector input of shape (N, 1), for which an array with shape (M, 1) is returned. matmat can be called instead for identical behaviour on such input.

Returns:
y{matrix, ndarray}

An array with shape (..., M).

Notes

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

rdot(x)#

Multi-purpose multiplication method from the right.

Note

This method returns x A. To perform adjoint multiplication instead, use one of rmatvec or rmatmat, or take the adjoint first, like self.H.rdot(x) or x * self.H.

Parameters:
xarray_like or LinearOperator or scalar

Array-like input will be interpreted as a 1-D row vector or 2-D matrix (or batch of matrices) depending on its shape. See the Returns section for details.

Returns:
xAarray or LinearOperator
  • For LinearOperator input, operator composition is performed.

  • For scalar input, a lazily scaled operator is returned.

  • Otherwise, the input is expected to take the form of a dense 1-D vector or 2-D matrix (or batch of matrices), interpreted as follows (where self is an M by N linear operator):

    • If x has shape (M,) it is interpreted as a row vector.

    • If x has shape (..., K, M) for some integer K, it is interpreted as a matrix (or batch of matrices if there are batch dimensions).

See also

dot

Multi-purpose multiplication method from the left.

__rmul__

Equivalent method, used by the * operator from the right.

__rmatmul__

Method used by the @ operator from the right which rejects scalar input before calling this method.

rmatmat(X)#

Adjoint matrix-matrix multiplication.

Performs the operation A^H @ X where A is an M x N linear operator (or batch of linear operators) and X is a dense M x K matrix (or batch of dense matrices). The default implementation defers to the adjoint.

Parameters:
X{matrix, ndarray}

An array with shape (..., M, K) representing the dense matrix (or batch of dense matrices).

Returns:
Y{matrix, ndarray}

An array with shape (..., N, K).

Notes

This method wraps any user-specified rmatmat routine or overridden _rmatmat method to ensure that Y has the correct type.

rmatvec(x)#

Adjoint matrix-vector multiplication.

Applies A^H to x, where A is an M x N linear operator (or batch of linear operators) and x is a row vector (or batch of such vectors).

Parameters:
x{matrix, ndarray}

An array with shape (..., M) representing a row vector (or batch of row vectors), or an array with shape (M, 1) representing a column vector.

Added in version 1.18.0: A FutureWarning is now emitted for column vector input of shape (M, 1), for which an array with shape (N, 1) is returned. rmatmat can be called instead for identical behaviour on such input.

Returns:
y{matrix, ndarray}

An array with shape (..., N).

Notes

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

transpose()#

Transpose.

Returns:
LinearOperator

Transpose of the linear operator.

See also

T

Equivalent attribute.

H#

Hermitian adjoint.

See also

scipy.sparse.linalg.LinearOperator.adjoint

Equivalent method.

T#

Transpose.

ndim: int#