srush / annotated-s4

Implementation of https://srush.github.io/annotated-s4
https://srush.github.io/annotated-s4
MIT License
460 stars 61 forks source link

conj() is used when the equation doesn't specify it #74

Closed ratishsp closed 1 year ago

ratishsp commented 1 year ago

Hi, why do we use conj() in the code below when the equation doesn't specify it: image

def K_gen_inverse(Ab, Bb, Cb, L):
    I = np.eye(Ab.shape[0])
    Ab_L = matrix_power(Ab, L)
    Ct = Cb @ (I - Ab_L)
    return lambda z: (Ct.conj() @ inv(I - Ab * z) @ Bb).reshape()
albertfgu commented 1 year ago

Notation and code doesn't have to map 1-1. Things can be defined in whatever way is simpler. In other words, just think of $\overline{\boldsymbol{C}}$ in the equation to be represented by Ct.conj() in the code.

You do need to pay close attention to all the conjugates to get the implementation exactly right. See also the original paper (appendix C.3), in particular this comment: image

ratishsp commented 1 year ago

Ah, it now makes sense. Thanks again!