正在加载图片...
2.6 Singular Value Decomposition 65 #define N.· f10 at wmax,m1n,**a,**u,*智,**v,米b,*x; int i,ji 。。4 for(i=1;i<=N:1++) Copy a into u if you don't want it to be de- for j=1;j<=N;j++) stroyed. u[i][j]=a[i][]: svdcmp(u,N,N,w,v); SVD the square matrix a. wmax=0.0; Will be the maximum singular value obtained. for(j=1;j<=N;j++)if (w[j]wmax)wmax=w[j]; This is where we set the threshold for singular values allowed to be nonzero.The constant is typical,but not universal.You have to experiment with your own application. wmin=wmax*1.0e-6; for(j=1;j<-N;j++)if (w[j]wmin)w[j]=0.0; svbksb(u,w,v,N,N,b,x); Now we can backsubstitute. -200 SVD for Fewer Equations than Unknowns ⊙ If you have fewer linear equations M than unknowns N,then you are not expecting a unique solution.Usually there will be an N-M dimensional family 需 of solutions.If you want to find this whole solution space,then SVD can readily 2aessadNS Press. do the job. The SVD decomposition will yield N-M zero or negligible wi's,since M<N.There may be additional zero wi's from any degeneracies in your M equations.Be sure that you find this many small wi's,and zero them before calling OF SCIENTIFIC( svbksb,which will give you the particular solution vector x.As before,the columns of V corresponding to zeroed wj's are the basis vectors whose linear combinations, 61 added to the particular solution,span the solution space. SVD for More Equations than Unknowns COMPUTING (ISBN 188810920 10-6211 This situation will occur in Chapter 15.when we wish to find the least-squares solution to an overdetermined set of linear equations.In tableau,the equations uurggoglrion Numerical Recipes 43106 to be solved are (outside Software. ying of (2.6.11) The proofs that we gave above for the square case apply without modification to the case of more equations than unknowns.The least-squares solution vector x is2.6 Singular Value Decomposition 65 Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machine￾readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). #define N ... float wmax,wmin,**a,**u,*w,**v,*b,*x; int i,j; ... for(i=1;i<=N;i++) Copy a into u if you don’t want it to be de￾for j=1;j<=N;j++) stroyed. u[i][j]=a[i][j]; svdcmp(u,N,N,w,v); SVD the square matrix a. wmax=0.0; Will be the maximum singular value obtained. for(j=1;j<=N;j++) if (w[j] > wmax) wmax=w[j]; This is where we set the threshold for singular values allowed to be nonzero. The constant is typical, but not universal. You have to experiment with your own application. wmin=wmax*1.0e-6; for(j=1;j<=N;j++) if (w[j] < wmin) w[j]=0.0; svbksb(u,w,v,N,N,b,x); Now we can backsubstitute. SVD for Fewer Equations than Unknowns If you have fewer linear equations M than unknowns N, then you are not expecting a unique solution. Usually there will be an N − M dimensional family of solutions. If you want to find this whole solution space, then SVD can readily do the job. The SVD decomposition will yield N − M zero or negligible wj ’s, since M<N. There may be additional zero wj ’s from any degeneracies in your M equations. Be sure that you find this many small wj ’s, and zero them before calling svbksb, which will give you the particular solution vector x. As before, the columns of V corresponding to zeroed wj ’s are the basis vectors whose linear combinations, added to the particular solution, span the solution space. SVD for More Equations than Unknowns This situation will occur in Chapter 15, when we wish to find the least-squares solution to an overdetermined set of linear equations. In tableau, the equations to be solved are   A   ·   x   =   b   (2.6.11) The proofs that we gave above for the square case apply without modification to the case of more equations than unknowns. The least-squares solution vector x is
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有