MATLAB has a gsvd function to perform the generalised SVD. Since 2013 I think there has been a lot of discussion on the github pages regarding putting it in scipy and some pages have code that I can use such as here which is super complicated for a novice like me(to get it running).
I also found LJWilliams github page with an implementation. This is of no good as has lot of bugs when transferred to python 3. Attempted correcting the simple ones such as assert and print. It quickly gets complicated.
Can someone help me with a gsvd code for python or show me how to use the ones that are online?
Also, This is what I get with the LJWilliams implementation, once the print and assert statements are corrected. The code looks complicated and I am not sure spending time on it is the best thing to do! Also some people have reported issues on the same github page which I am not sure are fixed or connected.
n = 10
m = 6
p = 6
A = np.random.rand(m,n)
B = np.random.rand(p,n)
gsvd(A,B)
File "/home/eghx/agent18/master_thesis/AMfe/amfe/gsvd.py", line 260, in gsvd U, V, Z, C, S = csd(Q[0:m,:],Q[m:m+n,:])
File "/home/eghx/agent18/master_thesis/AMfe/amfe/gsvd.py", line 107, in csd Q,R = scipy.linalg.qr(S[q:n,m:p])
File "/home/eghx/anaconda3/lib/python3.5/site-packages/scipy/linalg/decomp_qr.py", line 141, in qr overwrite_a=overwrite_a)
File "/home/eghx/anaconda3/lib/python3.5/site-packages/scipy/linalg/decomp_qr.py", line 19, in safecall ret = f(*args, **kwargs)
ValueError: failed to create intent(cache|hide)|optional array-- must have defined dimensions but got (0,)