diff options
| -rw-r--r-- | dis/Field/field.c | 27 | ||||
| -rwxr-xr-x | dis/Matrix/ver2/matrix.c | 79 | ||||
| -rw-r--r-- | dis/Neighborhood/initializeImage.c | 371 | ||||
| -rw-r--r-- | dis/Neighborhood/neighborhood.c | 14 | ||||
| -rw-r--r-- | dis/Neighborhood/utili.h | 161 | ||||
| -rw-r--r-- | dis/Pointer/pointer.c | 32 | ||||
| -rw-r--r-- | dis/Transitive/transitive.c | 92 | ||||
| -rw-r--r-- | dis/Update/update.c | 14 |
8 files changed, 560 insertions, 230 deletions
diff --git a/dis/Field/field.c b/dis/Field/field.c index 8565e8c..f83a403 100644 --- a/dis/Field/field.c +++ b/dis/Field/field.c | |||
| @@ -47,7 +47,7 @@ int main(int argc, char** argv){ | |||
| 47 | int mod_offset; | 47 | int mod_offset; |
| 48 | unsigned int n; | 48 | unsigned int n; |
| 49 | 49 | ||
| 50 | time_t startTime; | 50 | time_t startTime, endTime; |
| 51 | 51 | ||
| 52 | struct tokenS{ | 52 | struct tokenS{ |
| 53 | unsigned char delimiter[MAX_TOKEN_LENGTH]; | 53 | unsigned char delimiter[MAX_TOKEN_LENGTH]; |
| @@ -92,9 +92,9 @@ int main(int argc, char** argv){ | |||
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | startTime = time(NULL); | 94 | startTime = time(NULL); |
| 95 | 95 | START_LOOP | |
| 96 | |||
| 96 | for (l =0; l<n; l++){ | 97 | for (l =0; l<n; l++){ |
| 97 | START_LOOP | ||
| 98 | unsigned int index; | 98 | unsigned int index; |
| 99 | 99 | ||
| 100 | token[l].subfields = 0; | 100 | token[l].subfields = 0; |
| @@ -133,20 +133,25 @@ int main(int argc, char** argv){ | |||
| 133 | index++; | 133 | index++; |
| 134 | } | 134 | } |
| 135 | token[l].subfields++; | 135 | token[l].subfields++; |
| 136 | STOP_LOOP | ||
| 137 | } | 136 | } |
| 138 | 137 | ||
| 139 | startTime = time(NULL) - startTime; | 138 | STOP_LOOP |
| 139 | endTime = time(NULL); | ||
| 140 | 140 | ||
| 141 | volatile int sumAll = 0; | ||
| 141 | for (l = 0; l< n; l++){ | 142 | for (l = 0; l< n; l++){ |
| 142 | unsigned int ll; | 143 | unsigned int ll; |
| 143 | fprintf(stdout, "%d subfields for token %d \n", token[l].subfields, l); | 144 | //fprintf(stdout, "%d subfields for token %d \n", token[l].subfields, l); |
| 144 | for ( ll =0; ll<token[l].subfields; ll++) | 145 | sumAll += token[l].subfields + l; |
| 145 | fprintf(stdout, "subfields %d:\tcount = %d\tmin= %x\tsum= %x\n", | 146 | for ( ll =0; ll<token[l].subfields; ll++) { |
| 146 | ll, token[l].stat[ll].count, | 147 | sumAll += ll + token[l].stat[ll].count + token[l].stat[ll].min + token[l].stat[ll].sum; |
| 147 | token[l].stat[ll].min, token[l].stat[ll].sum); | 148 | /*fprintf(stdout, "subfields %d:\tcount = %d\tmin= %x\tsum= %x\n", |
| 149 | ll, token[l].stat[ll].count, | ||
| 150 | token[l].stat[ll].min, token[l].stat[ll].sum);*/ | ||
| 151 | } | ||
| 148 | } | 152 | } |
| 149 | fprintf(stdout, "total time = %d seconds.\n", (int)startTime); | 153 | fprintf(stderr, "time for field stressmark = %f seconds.\n", |
| 154 | difftime(endTime, startTime)); | ||
| 150 | free(field); | 155 | free(field); |
| 151 | WRITE_TO_FILE | 156 | WRITE_TO_FILE |
| 152 | return(0); | 157 | return(0); |
diff --git a/dis/Matrix/ver2/matrix.c b/dis/Matrix/ver2/matrix.c index 957d7c5..ffa7cb7 100755 --- a/dis/Matrix/ver2/matrix.c +++ b/dis/Matrix/ver2/matrix.c | |||
| @@ -48,7 +48,7 @@ | |||
| 48 | #define MIN_DIM 1 | 48 | #define MIN_DIM 1 |
| 49 | #define MAX_DIM 32768 | 49 | #define MAX_DIM 32768 |
| 50 | #define MAX_ITERATIONS 65536 | 50 | #define MAX_ITERATIONS 65536 |
| 51 | #define MIN_TOLERANCE 0.000007 | 51 | #define MIN_TOLERANCE 1e-7//0.000007 |
| 52 | #define MAX_TOLERANCE 0.5 | 52 | #define MAX_TOLERANCE 0.5 |
| 53 | #define MIN_NUMBER -3.4e10/dim | 53 | #define MIN_NUMBER -3.4e10/dim |
| 54 | #define MAX_NUMBER 3.4e10/dim | 54 | #define MAX_NUMBER 3.4e10/dim |
| @@ -61,8 +61,6 @@ | |||
| 61 | */ | 61 | */ |
| 62 | 62 | ||
| 63 | static int dim; | 63 | static int dim; |
| 64 | int argc; | ||
| 65 | char** argv; | ||
| 66 | 64 | ||
| 67 | /* | 65 | /* |
| 68 | * matrix * vector | 66 | * matrix * vector |
| @@ -312,7 +310,14 @@ void biConjugateGradient(double *value, | |||
| 312 | int maxIterations, | 310 | int maxIterations, |
| 313 | double *actualError, | 311 | double *actualError, |
| 314 | int *actualIteration, | 312 | int *actualIteration, |
| 315 | int dim) | 313 | int dim, |
| 314 | // Start internal matrixes | ||
| 315 | double *vectorP, | ||
| 316 | double *vectorR, | ||
| 317 | double *nextVectorR, | ||
| 318 | double *tmpVector1, | ||
| 319 | double *tmpVector2, | ||
| 320 | double *tmpVector3) | ||
| 316 | /* | 321 | /* |
| 317 | * in the code, we use a lot of temparary vectors and variables | 322 | * in the code, we use a lot of temparary vectors and variables |
| 318 | * this is just for simple and clear | 323 | * this is just for simple and clear |
| @@ -321,31 +326,18 @@ void biConjugateGradient(double *value, | |||
| 321 | * | 326 | * |
| 322 | */ | 327 | */ |
| 323 | { | 328 | { |
| 324 | double *vectorR; | ||
| 325 | double *vectorP, *matrixAvectorP, *nextVectorR; | ||
| 326 | double error; | 329 | double error; |
| 327 | int iteration; | 330 | int iteration; |
| 328 | double alpha, beta; | 331 | double alpha, beta; |
| 329 | 332 | ||
| 330 | double *tmpVector1, *tmpVector2, *tmpVector3; | ||
| 331 | double tmpValue1, tmpValue2; | 333 | double tmpValue1, tmpValue2; |
| 332 | int i; | 334 | int i; |
| 333 | int l; | 335 | int l; |
| 334 | int ll; | 336 | int ll; |
| 335 | SET_UP | ||
| 336 | 337 | ||
| 337 | alpha = 0; | 338 | alpha = 0; |
| 338 | beta = 0; | 339 | beta = 0; |
| 339 | 340 | ||
| 340 | vectorP = (double *)malloc(dim*sizeof(double)); | ||
| 341 | vectorR = (double *)malloc(dim*sizeof(double)); | ||
| 342 | nextVectorR = (double *)malloc(dim*sizeof(double)); | ||
| 343 | vectorX = (double *)malloc(dim*sizeof(double)); | ||
| 344 | |||
| 345 | tmpVector1 = (double *)malloc(dim*sizeof(double)); | ||
| 346 | tmpVector2 = (double *)malloc(dim*sizeof(double)); | ||
| 347 | tmpVector3 = (double *)malloc(dim*sizeof(double)); | ||
| 348 | |||
| 349 | /* | 341 | /* |
| 350 | * vectorR = vectorB - matrixA*vectorX | 342 | * vectorR = vectorB - matrixA*vectorX |
| 351 | */ | 343 | */ |
| @@ -369,7 +361,6 @@ void biConjugateGradient(double *value, | |||
| 369 | iteration = 0; | 361 | iteration = 0; |
| 370 | 362 | ||
| 371 | while ((iteration < maxIterations) && (error > errorTolerance)){ | 363 | while ((iteration < maxIterations) && (error > errorTolerance)){ |
| 372 | START_LOOP | ||
| 373 | 364 | ||
| 374 | /* | 365 | /* |
| 375 | * alpha = (transpose(vectorR) * vectorR) / | 366 | * alpha = (transpose(vectorR) * vectorR) / |
| @@ -434,7 +425,6 @@ void biConjugateGradient(double *value, | |||
| 434 | error = vectorValue(tmpVector1)/vectorValue(vectorB); | 425 | error = vectorValue(tmpVector1)/vectorValue(vectorB); |
| 435 | 426 | ||
| 436 | iteration++; | 427 | iteration++; |
| 437 | STOP_LOOP | ||
| 438 | } | 428 | } |
| 439 | 429 | ||
| 440 | *actualError = error; | 430 | *actualError = error; |
| @@ -446,7 +436,6 @@ void biConjugateGradient(double *value, | |||
| 446 | 436 | ||
| 447 | free(vectorR); | 437 | free(vectorR); |
| 448 | free(vectorP); | 438 | free(vectorP); |
| 449 | WRITE_TO_FILE | ||
| 450 | 439 | ||
| 451 | return; | 440 | return; |
| 452 | } | 441 | } |
| @@ -515,10 +504,8 @@ void create_CRS(double *matrixA, | |||
| 515 | } | 504 | } |
| 516 | 505 | ||
| 517 | 506 | ||
| 518 | int main(int _argc, char** _argv) | 507 | int main(int argc, char** argv) |
| 519 | { | 508 | { |
| 520 | argc = _argc; | ||
| 521 | argv = _argv; | ||
| 522 | int seed; | 509 | int seed; |
| 523 | int numberNonzero; | 510 | int numberNonzero; |
| 524 | int maxIterations; | 511 | int maxIterations; |
| @@ -536,18 +523,22 @@ int main(int _argc, char** _argv) | |||
| 536 | double *value; | 523 | double *value; |
| 537 | int *col_ind; | 524 | int *col_ind; |
| 538 | int *row_start; | 525 | int *row_start; |
| 539 | int sum; | 526 | double sum; |
| 540 | int k; | 527 | int k; |
| 528 | // Internal vects for biConj | ||
| 529 | double *vectorR, *vectorP, *nextVectorR; | ||
| 530 | double *tmpVector1, *tmpVector2, *tmpVector3; | ||
| 531 | SET_UP | ||
