Le dim. 7 févr. 2021 à 16:57, Henry Baker <hbaker1@pipeline.com> a écrit :
Re: The 'textbook' solution using SVD's is looking better all the time,
Better than what? Do you have a "test suite", and if so (or otherwise), what do you get comparing that method and the "find the largest element..." solution or "add all rows / cols modulo sign flip" proposal ? I would like to see such data/results. I would be glad to provide my algorithm(s) in any current programming language. here it is in PARI/GP: /* simple variant: find the index (r,c) of the maximal element m = max{abs(M[i,j])}, return U = col. c and V' = row r of M with suitable normalization: Both (col. c and row r) have M[r,c] as a component, so we divide one of them by M[r,c] to get indeed U V' = M. One might also divide both by sqrt(m), one with the sign of M[r,c] if negative. */ getUVsimple(M)={ my(i); vecmax(abs(M),&i); [ M[,i[2]]/M[i[1],i[2]] , M[i[1],] ] } /* "average" variant: sum over rows & cols with possible sign flip to avoid cancellations. Linear combination of the rows is equivalent to left multiplication by a row matrix, similar for columns with right multiplication by a column vector / matrix. */ getUVsum(M)={ my(i,U,V); vecmax(abs(M),&i)/*use largest element as reference for sign*/; U = M*apply(sign,M[i[1],])~ ; V = apply(sign,M[,i[2]])~ *M; U *= M[i[1],i[2]] /(U[i[1]] * V[i[2]])/* normalize: want / have */ ; [U,V]} Both of these seem to work well for ill conditioned matrices. I tried for M = U V' with U and V having large and small elements of different sign, but I did not test with ("explicitly") perturbed M and also don't have the "textbook/SVD solution(s)" ready for use. - Maximilian