From a0cf08ef61d59b1bfb297d38081b22e6c5e1cc0b Mon Sep 17 00:00:00 2001 From: ShilohSanity <51039238+ShilohSanity@users.noreply.github.com> Date: Tue, 5 May 2020 15:09:36 +0800 Subject: [PATCH] Group-inverse & sympy code This is the sympy code to calculate the Group inverse of every matrix A. The matrix can be included real, complex and even symbolic. The calculate speed may faster. --- Group-inverse-sympy | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Group-inverse-sympy diff --git a/Group-inverse-sympy b/Group-inverse-sympy new file mode 100644 index 0000000..8fc930e --- /dev/null +++ b/Group-inverse-sympy @@ -0,0 +1,24 @@ +import sympy as sp +def Shiloh_GI1(A): + n=A.shape[1] + p=1 + F=sp.eye(n) + Y=A + YA=Y*A + j=1 + while p!=0: + YAF=YA*F + p=sp.trace(YAF)/j + A_pinv=F*Y/p + F=YAF-p*sp.eye(n) + j+=1 + p=sp.trace(YA*F)/j + return A_pinv +def Shiloh_GI(A,v): + (m,n)=A.shape + if m>=n: + A_pinv,DIM= Shiloh_GI1(A) + else: + AH_pinv,DIM= Shiloh_GI1(A.H) + A_pinv=AH_pinv.H + return A_pinv,DIM