Changeset 26891 for trunk/Ohana/src/opihi/cmd.data/svd.c
- Timestamp:
- Feb 10, 2010, 7:24:46 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/svd.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/svd.c
r20936 r26891 57 57 /* use a bcopy instead? */ 58 58 59 // try C.R. Bond's version -- requires matrices in the form A[row][col] not A[row*Ncol + col] 60 if (1) { 61 int j; 62 double **a, **u, **v, *q; 63 ALLOCATE (a, double *, Ny); 64 ALLOCATE (u, double *, Ny); 65 ALLOCATE (v, double *, Ny); 66 for (i = 0; i < Ny; i++) { 67 ALLOCATE (a[i], double, Nx); 68 ALLOCATE (u[i], double, Nx); 69 ALLOCATE (v[i], double, Nx); 70 } 71 ALLOCATE (q, double, Nx); 72 73 for (j = 0; j < Ny; j++) { 74 for (i = 0; i < Nx; i++) { 75 a[j][i] = A[j*Nx + i]; 76 u[j][i] = 0; 77 v[j][i] = 0; 78 } 79 } 80 for (i = 0; i < Nx; i++) { 81 q[i] = 0; 82 } 83 84 status = svdcmp_bond_raw (Ny, Nx, 1, 1, FLT_EPSILON, 1e-6, a, q, u, v); 85 fprintf (stderr, "status: %d\n", status); 86 87 // copy u q v back to U W V: 88 for (j = 0; j < Ny; j++) { 89 for (i = 0; i < Nx; i++) { 90 U[j*Nx + i] = u[j][i]; 91 V[j*Nx + i] = v[j][i]; 92 } 93 } 94 for (i = 0; i < Nx; i++) { 95 W[i] = q[i]; 96 } 97 98 for (j = 0; j < Ny; j++) { 99 free(a[j]); 100 free(u[j]); 101 free(v[j]); 102 } 103 free (a); 104 free (u); 105 free (v); 106 free (q); 107 108 return TRUE; 109 } 110 59 111 status = svdcmp (U, W, V, Nx, Ny); 60 112 if (!status) {
Note:
See TracChangeset
for help on using the changeset viewer.
