Changeset 7737 for trunk/projects
 Timestamp:
 08/25/11 15:55:18 (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/projects/slimcurve/src/main/c/EcfUtil.c
r7710 r7737 1 1 //#include <ansi_c.h> 2 2 /* The 2010 version of the ECF library. This has basically been 3 completely rewritten to avoid license issues. 3 completely rewritten to avoid license issues. 4 4 Also, this takes account of the fact that we may be 5 5 handling Poisson noise. … … 44 44 float max; 45 45 float temp; 46 float pivotInverse[n];46 float *pivotInverse = (float *)malloc(n * sizeof(float)); 47 47 int i, j, k, m; 48 49 48 /*int q, w; 50 49 printf("\n"); … … 83 82 if (0.0 == a[k][k]) 84 83 { 84 free(pivotInverse); 85 85 return 2; // singular matrix 86 86 } … … 119 119 }*/ 120 120 121 free(pivotInverse); 121 122 return 0; 122 123 } … … 130 131 { 131 132 int returnValue = 0; 132 float identity[n][n];133 float **identity = GCI_ecf_matrix(n, n); 133 134 float **work = GCI_ecf_matrix(n, n); 134 135 int i, j, k; … … 149 150 } 150 151 } 151 GCI_ecf_free_matrix(work);152 152 153 153 // copy over results … … 157 157 } 158 158 } 159 160 GCI_ecf_free_matrix(identity); 161 GCI_ecf_free_matrix(work); 159 162 return returnValue; 160 163 } … … 223 226 Performs an inplace Crout lower/upper decomposition of n x n matrix A. 224 227 Values on or below diagonals are lowers, values about the 225 diagonal are uppers, with an implicit 1.0 value for the 228 diagonal are uppers, with an implicit 1.0 value for the 226 229 diagonals. 227 230 Returns 0 upon success, 2 if matrix is singular. … … 332 335 int nvbl; 333 336 float sum; 334 337 335 338 // rearrange the elements of the b vector in place. 336 339 startIndex = order[0]; … … 351 354 for (iRow = 1; iRow < n; ++iRow) { 352 355 sum = 0.0; 353 int jCol;354 356 for (jCol = 0; jCol < iRow; ++jCol) { 355 357 sum += lu[iRow][jCol] * b[jCol]; … … 378 380 int GCI_solve_lu_decomp(float **a, int n, float *b) 379 381 { 380 int order[n];382 int *order = (int *) malloc(n * sizeof(int)); 381 383 int return_value = lu_decomp(a, n, order); 382 384 if (return_value >= 0) { 383 385 return_value = solve_lu(a, n, b, order); 384 386 } 387 free(order); 385 388 return return_value; 386 389 } … … 393 396 { 394 397 int returnValue; 395 int order[n];396 float identity[n][n];398 int *order = (int *) malloc(n * sizeof(int)); 399 float **identity = GCI_ecf_matrix(n, n); 397 400 int i, j; 398 401 … … 413 416 } 414 417 } 418 419 free(order); 420 GCI_ecf_free_matrix(identity); 415 421 return returnValue; 416 422 } … … 448 454 449 455 k = mfit1; 450 for (j=nparam1; j>=0; j) 456 for (j=nparam1; j>=0; j) 451 457 { 452 if (paramfree[j]) 458 if (paramfree[j]) 453 459 { 454 460 for (i=0; i<nparam; i++) SWAP(covar[i][k], covar[i][j]); … … 781 787 a2inv = 1/param[2]; 782 788 a3inv = 1/param[3]; 783 789 784 790 /* When x=0 */ 785 791 y[0] = param[1]; … … 1088 1094 void ecf_ExportParams_OpenFile (void) 1089 1095 { 1090 ecf_exportFileStream = fopen(ecf_exportParams_path, "a"); 1096 ecf_exportFileStream = fopen(ecf_exportParams_path, "a"); 1091 1097 } 1092 1098 … … 1100 1106 { 1101 1107 int i; 1102 1108 1103 1109 for (i=0; i<nparam; i++) fprintf(ecf_exportFileStream, "%g, ", param[i]); 1104 1110 fprintf(ecf_exportFileStream, "%g\n", chisq);
Note: See TracChangeset
for help on using the changeset viewer.