Reputation: 305
I'm trying to compute the adjoint of a 10 000 x 10 000 sparse matrix in a non-standard inner product space.
(For physicist out there: the matrix is a representation of the Fokker-Planck operator and is in this case not self-adjoint.)
The inner product space in which I'd like to compute the adjoint is the weighted by the eigenvector corresponding to the first eigenvalue of the matrix (which corresponds to the equilibrium probability density.)
The scipy function scipy.sparse.linalg.LinearOperator
or the numpy.matrix.H
do not seem to have options for a different inner product space.
Upvotes: 0
Views: 1350
Reputation: 305
Computing the adjoint of a matrix A turns out to be quite simple.
If your inner product space is weighted with a matrix M, you simply have to compute M^-1 A^T M where T is the (conjugate) transpose and the first term is the inverse of matrix M.
In code for a sparse matrix A this would be:
import scipy.sparse as sparse
def computeAdjoint(A,measure):
"""Compute the adjoint matrix our inner product space by multiplying
with the kernel of integration/weighting function inverse on the left
and weighting function itself on the right"""
Minv=sparse.diags(1./measure)
M=sparse.diags(measure)
return Minv*A.transpose()*M
(Also note that the * stands for matrix multiplication and A.multiply(M) for component wise multiplication)
Upvotes: 0