Changeset 6432
- Timestamp:
- Feb 15, 2006, 10:10:27 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/rel10_ifa/psLib/src/math/psMinimizePolyFit.c
r6305 r6432 10 10 * @author EAM, IfA 11 11 * 12 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $13 * @date $Date: 2006-02- 02 21:09:07 $12 * @version $Revision: 1.7.6.1 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-02-16 08:10:27 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 810 810 } 811 811 for (psS32 i = 0; i < nTerm; i++) { 812 if (myPoly->mask[i]) 813 continue; 812 814 B->data.F64[i] += f->data.F64[k] * xSums->data.F64[i] * wt; 813 815 } … … 816 818 // we must handle masked orders 817 819 for (psS32 i = 0; i < nTerm; i++) { 820 if (myPoly->mask[i]) 821 continue; 818 822 for (psS32 j = 0; j < nTerm; j++) { 823 if (myPoly->mask[j]) 824 continue; 819 825 A->data.F64[i][j] += xSums->data.F64[i + j] * wt; 820 826 } … … 822 828 } 823 829 824 if (0) { 830 // set masked elements in A,B appropriately 831 for (int i = 0; i < nTerm; i++) { 832 if (!myPoly->mask[i]) 833 continue; 834 B->data.F64[i] = 0; 835 for (int j = 0; j < nTerm; j++) { 836 A->data.F64[i][j] = (i == j) ? 1 : 0; 837 } 838 } 839 840 841 if (1) { 825 842 // GaussJordan version 826 843 if (false == psGaussJordan(A, B)) { … … 833 850 for (psS32 k = 0; k < nTerm; k++) { 834 851 myPoly->coeff[k] = B->data.F64[k]; 852 myPoly->coeffErr[k] = sqrt(A->data.F64[k][k]); 835 853 } 836 854 } … … 857 875 for (psS32 k = 0; k < nTerm; k++) { 858 876 myPoly->coeff[k] = coeffs->data.F64[k]; 877 // XXX LUD does not give inverse of A 859 878 } 860 879 } … … 1236 1255 for (psS32 n = 0; n < nXterm; n++) { 1237 1256 for (psS32 m = 0; m < nYterm; m++) { 1257 if (myPoly->mask[n][m]) 1258 continue; 1238 1259 B->data.F64[n+m*nXterm] += f->data.F64[k] * Sums->data.F64[n][m] * wt; 1239 1260 } … … 1242 1263 for (psS32 i = 0; i < nXterm; i++) { 1243 1264 for (psS32 j = 0; j < nYterm; j++) { 1265 if (myPoly->mask[i][j]) 1266 continue; 1244 1267 for (psS32 n = 0; n < nXterm; n++) { 1245 1268 for (psS32 m = 0; m < nYterm; m++) { 1269 if (myPoly->mask[n][m]) 1270 continue; 1246 1271 A->data.F64[i+j*nXterm][n+m*nXterm] += Sums->data.F64[i+n][j+m] * wt; 1247 1272 } 1273 } 1274 } 1275 } 1276 } 1277 1278 // set masked elements appropriately 1279 for (int i = 0; i < nXterm; i++) { 1280 for (int j = 0; j < nYterm; j++) { 1281 if (!myPoly->mask[i][j]) 1282 continue; 1283 int nx = i+j*nXterm; 1284 B->data.F64[nx] = 0; 1285 for (int n = 0; n < nXterm; n++) { 1286 for (int m = 0; m < nYterm; m++) { 1287 int ny = n+m*nXterm; 1288 A->data.F64[nx][ny] = (nx == ny) ? 1 : 0; 1248 1289 } 1249 1290 } … … 1260 1301 for (psS32 m = 0; m < nYterm; m++) { 1261 1302 myPoly->coeff[n][m] = B->data.F64[n+m*nXterm]; 1303 myPoly->coeffErr[n][m] = sqrt(A->data.F64[n+m*nXterm][n+m*nXterm]); 1262 1304 } 1263 1305 } … … 1712 1754 } 1713 1755 1714 if ( 0) {1756 if (1) { 1715 1757 // does the solution in place 1716 1758 // The matrices were overflowing, so I switched to LUD. … … 1764 1806 psS32 nx = ix+iy*nXterm+iz*nXterm*nYterm; 1765 1807 myPoly->coeff[ix][iy][iz] = coeffs->data.F64[nx]; 1766 myPoly->coeffErr[ix][iy][iz] = sqrt(A->data.F64[nx][nx]); 1808 // XXX myPoly->coeffErr[ix][iy][iz] = sqrt(A->data.F64[nx][nx]); 1809 // XXX this is wrong: A is not replaced with inverse(A), as for GaussJordan 1767 1810 } 1768 1811 } … … 2265 2308 2266 2309 2267 if ( 0) {2310 if (1) { 2268 2311 // does the solution in place 2269 2312 // The GaussJordan version was overflowing, so I'm using LUD. … … 2323 2366 psS32 nx = ix+iy*nXterm+iz*nXterm*nYterm+it*nXterm*nYterm*nZterm; 2324 2367 myPoly->coeff[ix][iy][iz][it] = coeffs->data.F64[nx]; 2325 myPoly->coeffErr[ix][iy][iz][it] = sqrt(A->data.F64[nx][nx]); 2368 // myPoly->coeffErr[ix][iy][iz][it] = sqrt(A->data.F64[nx][nx]); 2369 // XXX this is wrong: LUD does not supply inverse(A) 2326 2370 } 2327 2371 }
Note:
See TracChangeset
for help on using the changeset viewer.
