Changeset 7135 for trunk/psLib/src/math/psMinimizePolyFit.c
- Timestamp:
- May 17, 2006, 5:05:47 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psMinimizePolyFit.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psMinimizePolyFit.c
r7133 r7135 10 10 * @author EAM, IfA 11 11 * 12 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-05-18 0 1:21:16$12 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-05-18 03:05:47 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 379 379 for (int i = 0; i < numTerms; i++) { 380 380 if (termMask[i]) { 381 matrix[i][i] = 1.0; 381 382 continue; 382 383 } … … 560 561 for (int i = 0; i < nTerm; i++) { 561 562 if (termMask[i]) { 563 matrix[i][i] = 1.0; 562 564 continue; 563 565 } … … 575 577 } 576 578 psFree(xSums); 577 578 #if 0579 // set masked elements in A,B appropriately580 // PAP: Is this necessary, given we initialise to zero, and we have already masked on the terms?581 for (int i = 0; i < nTerm; i++) {582 if (!termMask[i])583 continue;584 vector[i] = 0;585 matrix[i][i] = 1.0;586 for (int j = i + 1; j < nTerm; j++) {587 matrix[i][j] = 0.0;588 matrix[j][i] = 0.0;589 }590 }591 #endif592 579 593 580 if (psTraceGetLevel(__func__) >= 4) { … … 1027 1014 // Iterating over the matrix 1028 1015 for (int i = 0; i < nTerm; i++) { 1029 int l = i % nXterm; // x index1030 int m = i / nXterm; // y index1016 int l = i / nYterm; // x index 1017 int m = i % nYterm; // y index 1031 1018 if (termMask[l][m]) { 1019 matrix[i][i] = 1.0; 1032 1020 continue; 1033 1021 } … … 1035 1023 matrix[i][i] += sums[2*l][2*m] * wt; // The diagonal entry 1036 1024 for (int j = i + 1; j < nTerm; j++) { // Doing the upper diagonal only: we will use symmetry 1037 int p = j % nXterm; // x index1038 int q = j / nXterm; // y index1025 int p = j / nYterm; // x index 1026 int q = j % nYterm; // y index 1039 1027 if (termMask[p][q]) { 1040 1028 continue; … … 1054 1042 } else { 1055 1043 // select the appropriate solution entries 1056 for (int n = 0; n < nXterm; n++) {1057 for (int m = 0; m < nYterm; m++) {1058 myPoly->coeff[n][m] = B->data.F64[n+m*nXterm];1059 myPoly->coeffErr[n][m] = sqrt(A->data.F64[n+m*nXterm][n+m*nXterm]);1060 }1044 for (int i = 0; i < nTerm; i++) { 1045 int l = i / nYterm; // x index 1046 int m = i % nYterm; // y index 1047 myPoly->coeff[l][m] = B->data.F64[i]; 1048 myPoly->coeffErr[l][m] = sqrt(A->data.F64[i][i]); 1061 1049 } 1062 1050 } … … 1451 1439 } 1452 1440 psU8 ***termMask = myPoly->mask; // Mask for polynomial terms 1453 int n XYterm = nXterm * nYterm; // Multiplication of the numbers, to calculate the index1441 int nYZterm = nYterm * nZterm; // Multiplication of the numbers, to calculate the index 1454 1442 1455 1443 // Build the B and A data structs. … … 1471 1459 1472 1460 for (int i = 0; i < nTerm; i++) { 1473 int i z = i / nXYterm; // zindex1474 int iy = (i % n XYterm) / nXterm; // y index1475 int i x = (i % nXYterm) % nXterm; // xindex1461 int ix = i / nYZterm; // x index 1462 int iy = (i % nYZterm) / nZterm; // y index 1463 int iz = (i % nYZterm) % nZterm; // z index 1476 1464 if (termMask[ix][iy][iz]) { 1465 matrix[i][i] = 1.0; 1477 1466 continue; 1478 1467 } … … 1481 1470 matrix[i][i] += Sums[2*ix][2*iy][2*iz] * wt; 1482 1471 for (int j = i + 1; j < nTerm; j++) { 1483 int j z = j / (nXterm * nYterm); // zindex1484 int jy = (j % (nXterm * nYterm)) / nXterm; // y index1485 int j x = (j % (nXterm * nYterm)) % nXterm; // xindex1472 int jx = j / (nYZterm); // x index 1473 int jy = (j % nYZterm) / nZterm; // y index 1474 int jz = (j % nYZterm) % nZterm; // z index 1486 1475 if (termMask[jx][jy][jz]) { 1487 1476 continue; … … 1515 1504 } 1516 1505 // select the appropriate solution entries 1517 for (psS32 ix = 0; ix < nXterm; ix++) { 1518 for (psS32 iy = 0; iy < nYterm; iy++) { 1519 for (psS32 iz = 0; iz < nZterm; iz++) { 1520 psS32 nx = ix+iy*nXterm+iz*nXterm*nYterm; 1521 myPoly->coeff[ix][iy][iz] = B->data.F64[nx]; 1522 myPoly->coeffErr[ix][iy][iz] = sqrt(A->data.F64[nx][nx]); 1523 } 1524 } 1506 for (int i = 0; i < nTerm; i++) { 1507 int ix = i / nYZterm; // x index 1508 int iy = (i % nYZterm) / nZterm; // y index 1509 int iz = (i % nYZterm) % nZterm; // z index 1510 myPoly->coeff[ix][iy][iz] = B->data.F64[i]; 1511 myPoly->coeffErr[ix][iy][iz] = sqrt(A->data.F64[i][i]); 1525 1512 } 1526 1513 } else { … … 1933 1920 PS_ASSERT_VECTOR_TYPE(t, PS_TYPE_F64, NULL); 1934 1921 PS_ASSERT_VECTORS_SIZE_EQUAL(f, t, NULL); 1935 if (mask != NULL) {1922 if (mask) { 1936 1923 PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, NULL); 1937 1924 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, NULL); … … 1976 1963 } 1977 1964 psU8 ****termMask = myPoly->mask; // Mask for polynomial terms 1978 int n XYZterm = nXterm * nYterm * nZterm; // Multiplication of the numbers, for calculating the index1979 int n XYterm = nXterm * nYterm; // Multiplication of the numbers, for calculating the index1965 int nYZTterm = nYterm * nZterm * nTterm; // Multiplication of the numbers, for calculating the index 1966 int nZTterm = nZterm * nTterm; // Multiplication of the numbers, for calculating the index 1980 1967 1981 1968 // Build the B and A data structs. … … 1997 1984 1998 1985 for (int i = 0; i < nTerm; i++) { 1999 int i t = i / (nXYZterm); // tindex2000 int i z = (i % (nXYZterm)) / (nXYterm); // zindex2001 int i y = ((i % (nXYZterm)) % (nXYterm)) / nXterm; // yindex2002 int i x = ((i % (nXYZterm)) % (nXYterm)) % nXterm; // xindex1986 int ix = i / (nYZTterm); // x index 1987 int iy = (i % (nYZTterm)) / (nZTterm); // y index 1988 int iz = ((i % (nYZTterm)) % (nZTterm)) / nTterm; // z index 1989 int it = ((i % (nYZTterm)) % (nZTterm)) % nTterm; // t index 2003 1990 if (termMask[ix][iy][iz][it]) { 1991 matrix[i][i] = 1.0; 2004 1992 continue; 2005 1993 } … … 2008 1996 matrix[i][i] += Sums[2*ix][2*iy][2*iz][2*it] * wt; 2009 1997 for (int j = i + 1; j < nTerm; j++) { 2010 int j t = j / nXYZterm; // tindex2011 int j z = (j % nXYZterm) / nXYterm; // zindex2012 int j y = ((j % nXYZterm) % nXYterm) / nXterm; // yindex2013 int j x = ((j % nXYZterm) % nXYterm) % nXterm; // xindex1998 int jx = j / nYZTterm; // x index 1999 int jy = (j % nYZTterm) / nZTterm; // y index 2000 int jz = ((j % nYZTterm) % nZTterm) / nTterm; // z index 2001 int jt = ((j % nYZTterm) % nZTterm) % nTterm; // t index 2014 2002 if (termMask[jx][jy][jz][jt]) { 2015 2003 continue; … … 2047 2035 2048 2036 // select the appropriate solution entries 2049 for (psS32 ix = 0; ix < nXterm; ix++) { 2050 for (psS32 iy = 0; iy < nYterm; iy++) { 2051 for (psS32 iz = 0; iz < nZterm; iz++) { 2052 for (psS32 it = 0; it < nTterm; it++) { 2053 psS32 nx = ix+iy*nXterm+iz*nXterm*nYterm+it*nXterm*nYterm*nZterm; 2054 myPoly->coeff[ix][iy][iz][it] = B->data.F64[nx]; 2055 myPoly->coeffErr[ix][iy][iz][it] = sqrt(A->data.F64[nx][nx]); 2056 } 2057 } 2058 } 2037 for (int i = 0; i < nTerm; i++) { 2038 int ix = i / nYZTterm; // x index 2039 int iy = (i % nYZTterm) / nZTterm; // y index 2040 int iz = ((i % nYZTterm) % nZTterm) / nTterm; // z index 2041 int it = ((i % nYZTterm) % nZTterm) % nTterm; // t index 2042 myPoly->coeff[ix][iy][iz][it] = B->data.F64[i]; 2043 myPoly->coeffErr[ix][iy][iz][it] = sqrt(A->data.F64[i][i]); 2059 2044 } 2060 2045 } else { … … 2136 2121 PS_ASSERT_VECTOR_NON_NULL(f, NULL); 2137 2122 PS_ASSERT_VECTOR_TYPE_F32_OR_F64(f, NULL); 2138 if (mask != NULL) {2123 if (mask) { 2139 2124 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, NULL); 2140 2125 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, NULL); … … 2307 2292 PS_ASSERT_VECTOR_NON_NULL(f, NULL); 2308 2293 PS_ASSERT_VECTOR_TYPE_F32_OR_F64(f, NULL); 2309 if (mask != NULL) {2294 if (mask) { 2310 2295 PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, NULL); 2311 2296 PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, NULL);
Note:
See TracChangeset
for help on using the changeset viewer.
