Changeset 100
- Timestamp:
- Jan 12, 2010, 1:54:07 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
proiecte/PPPP/eigenface/new/jacobi_vector.c
r95 r100 19 19 z = (float *) malloc(n * sizeof(float)); 20 20 21 /* Fork a team of threads giving them their own copies of variables */ 22 #pragma omp parallel private(nthreads, tid, i, j, ip, iq) shared(tresh, theta, tau, sm, s, h, g, c, b, z, a, n, d, v, nrot) 23 { 24 25 /* Obtain thread number */ 26 tid = omp_get_thread_num(); 27 printf("Hello World from thread = %d\n", tid); 28 29 /* Only master thread does this */ 30 if (tid == 0) 31 { 32 nthreads = omp_get_num_threads(); 33 printf("Number of threads = %d\n", nthreads); 34 } 35 36 37 #pragma omp parallel for 21 38 for (ip=0;ip<n;ip++) { // Initialize to the identity matrix. 22 39 for (iq=0;iq<n;iq++) v[ip*n + iq]=0.0; 23 40 v[ip*n + ip]=1.0; 24 41 } 42 #pragma omp parallel for 25 43 for (ip=0;ip<n;ip++) { // Initialize b and d to the diagonal of a. 26 44 b[ip]=d[ip]=a[ip*n + ip]; 27 45 z[ip]=0.0; // This vector will accumulate terms of the form t*a[pq] as in equation (11.1.14). 28 46 } 29 47 } 30 48 *nrot=0; 31 49 for (i=1;i<=50;i++) { 32 50 sm=0.0; 51 #pragma omp parallel for reduction(+:sm) 33 52 for (ip=0;ip<n-1;ip++) { // Sum off-diagonal elements. 34 53 for (iq=ip+1;iq<n;iq++) … … 70 89 a[ip*n + iq]=0.0; 71 90 91 #pragma omp parallel for 72 92 for (j=0;j<=ip-1;j++) { // Case of rotations 1 <= j < p. 73 93 ROTATE(a,j,ip,j,iq) 74 94 } 95 #pragma omp parallel for 75 96 for (j=ip+1;j<=iq-1;j++) { // Case of rotations p < j < q. 76 97 ROTATE(a,ip,j,j,iq) 77 98 } 99 #pragma omp parallel for 78 100 for (j=iq+1;j<n;j++) { // Case of rotations q < j <= n. 79 101 ROTATE(a,ip,j,iq,j) 80 102 } 103 #pragma omp parallel for 81 104 for (j=0;j<n;j++) { 82 105 ROTATE(v,j,ip,j,iq)
Note: See TracChangeset
for help on using the changeset viewer.