确定 CustomLinearOperator 的转置

Determining the transpose of a CustomLinearOperator

使用 from scipy.sparse.linalg import LinearOperator 我想确定 <3x3 _CustomLinearOperator with dtype=float64>> 的转置。考虑以下坐标轴的随机排列:

import numpy as np
from scipy.sparse.linalg import LinearOperator

n=3
x = np.arange(n)
np.random.shuffle(x)

def w(v): 
    n = len(v)
    w = np.zeros((n,1))
    for j in range(n):
        w[j] = v[x[j]]
    return np.array(w)

W = LinearOperator((n,n), matvec=w)

注意W是一个正交矩阵。 W.tranpose 导致 <bound method LinearOperator.transpose of <3x3 _CustomLinearOperator with dtype=float64>> 但我不知道如何处理这个 method。我想计算的是 W.tranpose*W 作为 <3x3 _CustomLinearOperator with dtype=float64>> 但这当然是 unsupported operand type.

运算符的转置需要自己定义,否则不知道应用什么运算;你不能假设 scipy 会知道它的运算符的转置是什么甚至存在。

您可以阅读以下内容link: https://www.google.com/amp/s/samrelton.wordpress.com/2013/12/04/implicit-matrices-in-python/amp/

旁注:您正在尝试计算范数,因此一旦您定义了转置,您就可以像函数一样应用范数