AdjacencyOperator#
- class graph_tool.spectral.AdjacencyOperator(*args, **kwargs)[source]#
Bases:
LinearOperatorA
scipy.sparse.linalg.LinearOperatorrepresenting the adjacency matrix of a graph. Seeadjacency()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.
Attributes
- 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
HEquivalent 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
selfis anMbyNlinear 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 integerK, 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 @ XwhereAis anMxNlinear operator (or batch of linear operators) and X is a denseNxKmatrix (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
matmatroutine or overridden_matmatmethod to ensure that Y has the correct type.
- matvec(x)#
Matrix-vector multiplication.
Applies
Ato x, whereAis anMxNlinear 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
FutureWarningis 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
matvecroutine or overridden_matvecmethod 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, likeself.H.rdot(x)orx * 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
selfis anMbyNlinear operator):If x has shape
(M,)it is interpreted as a row vector.If x has shape
(..., K, M)for some integerK, it is interpreted as a matrix (or batch of matrices if there are batch dimensions).
See also
dotMulti-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 @ XwhereAis anMxNlinear operator (or batch of linear operators) and X is a denseMxKmatrix (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
rmatmatroutine or overridden_rmatmatmethod to ensure that Y has the correct type.
- rmatvec(x)#
Adjoint matrix-vector multiplication.
Applies
A^Hto x, whereAis anMxNlinear 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
FutureWarningis 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
rmatvecroutine or overridden_rmatvecmethod to ensure that y has the correct shape and type.
- transpose()#
Transpose.
- Returns:
- LinearOperator
Transpose of the linear operator.
See also
TEquivalent attribute.
- H#
Hermitian adjoint.
See also
scipy.sparse.linalg.LinearOperator.adjointEquivalent method.
- T#
Transpose.
See also
scipy.sparse.linalg.LinearOperator.transposeEquivalent method.