lime/optics.py
def schmidt_decompose(f, dp, dq, nmodes=5, method='rdm'):
    """
    kernel method
    f: 2D array,
        input function to be decomposed
    nmodes: int
        number of modes to be kept
    method: str
        rdm or svd
    """
    if method == 'rdm':
        kernel1 = f.dot(dag(f)) * dq * dp
        kernel2 = f.T.dot(f.conj()) * dp * dq


        print('c: Schmidt coefficients')
        s, phi = np.linalg.eig(kernel1)
        s1, psi = np.linalg.eig(kernel2)

        phi /= np.sqrt(dp)
        psi /= np.sqrt(dq)
    elif method == 'svd':
        raise NotImplementedError

    return np.sqrt(s[:nmodes]), phi[:, :nmodes], psi[:, :nmodes]

    kernel method
    f: 2D array,
        input function to be decomposed
    nmodes: int
        number of modes to be kept
    method: str
        rdm or svd
    
kernel method
f: 2D array,
input function to be decomposed
nmodes: int
number of modes to be kept
method: str
rdm or svd
kernel method f : 2D array input function to be decomposed nmodes : int number of modes to be kept method : str rdm or svd
def schmidt_decompose(f, dp, dq, nmodes=5, method='rdm'):
    if method == 'rdm':
        kernel1 = f.dot(dag(f)) * dq * dp
        kernel2 = f.T.dot(f.conj()) * dp * dq
        print('c: Schmidt coefficients')
        s, phi = np.linalg.eig(kernel1)
        s1, psi = np.linalg.eig(kernel2)
        phi /= np.sqrt(dp)
        psi /= np.sqrt(dq)
    elif method == 'svd':
        raise NotImplementedError
    return np.sqrt(s[:nmodes]), phi[:, :nmodes], psi[:, :nmodes]
def schmidt_decompose ( f , dp , dq , nmodes = 5 , method = 'rdm' ) : if method == 'rdm' : kernel1 = f . dot ( dag ( f ) ) * dq * dp kernel2 = f . T . dot ( f . conj ( ) ) * dp * dq print ( 'c: Schmidt coefficients' ) s , phi = np . linalg . eig ( kernel1 ) s1 , psi = np . linalg . eig ( kernel2 ) phi /= np . sqrt ( dp ) psi /= np . sqrt ( dq ) elif method == 'svd' : raise NotImplementedError return np . sqrt ( s [ : nmodes ] ) , phi [ : , : nmodes ] , psi [ : , : nmodes ]
kernel method
f: 2D array,
input function to be decomposed
nmodes: int
number of modes to be kept
method: str
rdm or svd
kernel method f : 2D array input function to be decomposed nmodes : int number of modes to be kept method : str rdm or svd
"""
    kernel method
    f: 2D array,
        input function to be decomposed
    nmodes: int
        number of modes to be kept
    method: str
        rdm or svd
    """
f
dp
dq
nmodes
method