#include <math.h>
#include "nrutil.h"
void svdcmp(float **a, int m, int n, float w[], float **v)
Given a matrix a[1..m][1..n], this routine computes its singular value
decomposition, A =U·W·V*. The matrix U replaces an on output. The
diagonal matrix of singular values W is output as a vector w[1..n]. The
matrix V (the transpose V* ) is output as v[1..n][1..n].
{
float pythag(float a, float b);
int flag,i,its,j,jj,k,l,nm;
float anorm,c,f,g,h,s,scale,x,y,z,*rv1;
rv1=vector(1,n);
g=scale=anorm=0.0;
Householder reduction to bidiagonal form.
for (i=1;i<=n;i++) {
l=i+1;
rv1[i]=scale*g;
g=s=scale=0.0;
if (i <= m) {
for (k=i;k<=m;k++) scale += fabs(a[k][i]);
评论0