The Tensorflow documentation here says that:

tf.linalg.pinv is ''analogous to numpy.linalg.pinv. It differs only in default value of rcond''.

However, tf.linalg.pinv requires the matrix to be float type while np.linalg.pinv could be used with complex matrices.

I was wondering why they would only create it for float types and if there is a straightforward way to modify tf.linalg.pinv to be used with complex matrices.


1 Answer 1


I just faced the same situation. If you need to explicitly build the inverse, check this paper:


In particular, given a Matrix M that you need to invert, you can just do:

    A = tf.math.real(M)
    C = tf.math.imag(M)

    r0  = tf.linalg.pinv(A) @ C
    y11 = tf.linalg.pinv(C @ r0 + A)
    y10 = -r0 @ y11

    M_inverse = tf.cast(tf.complex(y11,y10), dtype = M.dtype)

The complexity is a bit higher than the pure-complex implementation, but so far it has proven to be pretty stable for me.

(just copying my answer from your other post: https://stackoverflow.com/questions/60025950/tensorflow-pseudo-inverse-doesnt-work-for-complex-matrices/60128892#60128892)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.