Changeset 1781 for trunk/psLib/src/dataManip/psMinimize.c
- Timestamp:
- Sep 10, 2004, 12:26:09 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/dataManip/psMinimize.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psMinimize.c
r1775 r1781 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.3 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09-10 02:52:02$11 * @version $Revision: 1.37 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-10 22:25:59 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 845 845 } 846 846 /****************************************************************************** 847 This routine will take an procedure which calculates an arbitrary function 848 and it's derivative and minimize it. 849 847 850 GUS 851 852 XXX: Do this: 853 After checking that all entries in the paramMask are 1 or 0, when 854 forming the A matrix from alpha, try this: 855 856 A[i][i] = (1 + lambda*paramask[i]) * alpha[i][i]; 857 858 848 859 *****************************************************************************/ 849 860 bool psMinimizeLM(psMinimization *min, … … 857 868 psVector *perm = psVectorAlloc(params->n, PS_TYPE_F32); 858 869 psVector *newParams = psVectorAlloc(params->n, PS_TYPE_F32); 870 psVector *origParams = psVectorAlloc(params->n, PS_TYPE_F32); 859 871 psImage *alpha = psImageAlloc(params->n, params->n, PS_TYPE_F32); 860 872 psImage *A = psImageAlloc(params->n, params->n, PS_TYPE_F32); … … 869 881 float lamda = 1.0; 870 882 883 for (i=0;i<params->n;i++) { 884 origParams->data.F32[i] = params->data.F32[i]; 885 } 886 871 887 min->lastDelta = -HUGE; 872 888 min->iter = 0; 873 889 min->value = func(deriv, params, coords); 890 for (i=0;i<params->n;i++) { 891 if ((paramMask != NULL) && 892 (paramMask->data.U8[i] != 0)) { 893 deriv->data.F32[i] = 0.0; 894 } 895 } 874 896 875 897 while ((min->lastDelta > min->tol) && … … 897 919 newParams = psMatrixLUSolve(newParams, aOut, beta, perm); 898 920 921 for (i=0;i<params->n;i++) { 922 if ((paramMask != NULL) && 923 (paramMask->data.U8[i] != 0)) { 924 newParams->data.F32[i] = origParams->data.F32[i]; 925 } 926 } 927 899 928 oldValue = min->value; 900 929 newValue = func(newDeriv, newParams, coords); 930 for (i=0;i<params->n;i++) { 931 if ((paramMask != NULL) && 932 (paramMask->data.U8[i] != 0)) { 933 deriv->data.F32[i] = 0.0; 934 } 935 } 936 901 937 if (oldValue > newValue) { 902 938 min->lastDelta = oldValue - newValue; 903 939 min->value = newValue; 904 940 941 // No need to check the paramMask here since we already did so 942 // before the last function evaluation. 905 943 for (i=0;i<params->n;i++) { 906 944 params->data.F32[i] = newParams->data.F32[i]; … … 918 956 psFree(perm); 919 957 psFree(newParams); 958 psFree(origParams); 920 959 psFree(alpha); 921 960 psFree(A); … … 1769 1808 1770 1809 The basic idea is calculate chi-squared for a set of params/coords/errors. 1771 This functions uses global evariables to receive the function pointer, the1810 This functions uses global variables to receive the function pointer, the 1772 1811 data values, and the data errors. 1773 1812 *****************************************************************************/
Note:
See TracChangeset
for help on using the changeset viewer.
