Index: proiecte/PPPP/eigenface2/eigenface_p.c
===================================================================
--- proiecte/PPPP/eigenface2/eigenface_p.c	(revision 132)
+++ proiecte/PPPP/eigenface2/eigenface_p.c	(revision 133)
@@ -25,35 +25,33 @@
 	z = (float *) malloc(n * sizeof(float));
 	
-	/* Fork a team of threads giving them their own copies of variables */
-	#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)
-  	{
-
-  	/* Obtain thread number */
-  	tid = omp_get_thread_num();
-  	printf("Hello World from thread = %d\n", tid);
-
-  	/* Only master thread does this */
-  	if (tid == 0) 
-    {
-    	nthreads = omp_get_num_threads();
-    	printf("Number of threads = %d\n", nthreads);
-    }
-
-	
-	#pragma omp parallel for
+	//~ #pragma omp parallel private(nthreads, tid)
+  	//~ {
+
+  	//~ /* Obtain thread number */
+  	//~ tid = omp_get_thread_num();
+  	//~ printf("Hello World from thread = %d\n", tid);
+
+  	//~ /* Only master thread does this */
+  	//~ if (tid == 0) 
+    //~ {
+    	//~ nthreads = omp_get_num_threads();
+    	//~ printf("Number of threads = %d\n", nthreads);
+    //~ }}
+	
+	//#pragma omp parallel for
 	for (ip=0;ip<n;ip++) { 									// Initialize to the identity matrix.
 		for (iq=0;iq<n;iq++) v[ip*n + iq]=0.0;
 			v[ip*n + ip]=1.0;
 	}
-	#pragma omp parallel for
+	//#pragma omp parallel for
 	for (ip=0;ip<n;ip++) { 								// Initialize b and d to the diagonal of a.
 		b[ip]=d[ip]=a[ip*n + ip]; 														
 		z[ip]=0.0; 										// This vector will accumulate terms of the form t*a[pq] as in equation (11.1.14).
 	}
-	}	
+		
 	*nrot=0;
 	for (i=1;i<=50;i++) {
 		sm=0.0;
-        #pragma omp parallel for reduction(+:sm)
+        //#pragma omp parallel for reduction(+:sm)
 		for (ip=0;ip<n-1;ip++) {							// Sum off-diagonal elements.
 			for (iq=ip+1;iq<n;iq++)
@@ -95,21 +93,29 @@
 					a[ip*n + iq]=0.0;
 					
-					#pragma omp parallel for
-					for (j=0;j<=ip-1;j++) { 											// Case of rotations 1 <= j < p.
-						ROTATE(a,j,ip,j,iq)
+					#pragma omp parallel shared(a,ip,iq, s, tau) private(j)
+					{
+						  #pragma omp sections nowait
+						{
+							
+							#pragma omp section
+							//#pragma omp parallel for
+							for (j=0;j<=ip-1;j++) { 											// Case of rotations 1 <= j < p.
+								ROTATE(a,j,ip,j,iq)
+							}
+							
+							#pragma omp section
+							for (j=ip+1;j<=iq-1;j++) { 										// Case of rotations p < j < q.
+								ROTATE(a,ip,j,j,iq)
+							}
+							#pragma omp section
+							for (j=iq+1;j<n;j++) { 											// Case of rotations q < j <= n.
+								ROTATE(a,ip,j,iq,j)
+							}
+						}
 					}
-					#pragma omp parallel for
-					for (j=ip+1;j<=iq-1;j++) { 										// Case of rotations p < j < q.
-						ROTATE(a,ip,j,j,iq)
-					}
-					#pragma omp parallel for
-					for (j=iq+1;j<n;j++) { 											// Case of rotations q < j <= n.
-						ROTATE(a,ip,j,iq,j)
-					}
-					#pragma omp parallel for
+					
 					for (j=0;j<n;j++) {
 						ROTATE(v,j,ip,j,iq)
 					}
-					
 					++(*nrot);
 				}
@@ -117,5 +123,5 @@
 		}
 		
-		#pragma omp parallel for
+		//#pragma omp parallel for
 		for (ip=0;ip<n;ip++) {
 			b[ip] += z[ip];
@@ -157,10 +163,10 @@
 	float* bf = avg;
 	
-	#pragma omp parallel for
 	for( i = 0; i < size.height; i++, bf += avgStep)
+		//#pragma omp parallel for
 		for( j = 0; j < size.width; j++ )
 			bf[j] = 0.f;
 	
-	#pragma omp parallel for
+	//#pragma omp parallel for
 	for( i = 0; i < nFaces; i++ )
 	{
@@ -174,5 +180,5 @@
 	bf = avg;
 	for( i = 0; i < size.height; i++, bf += avgStep)
-		#pragma omp parallel for
+		//#pragma omp parallel for
 		for( j = 0; j < size.width; j++ ) {
 			bf[j] *= m;
@@ -197,8 +203,8 @@
 			uchar *bu2 = faceArr[j];
 
-			#pragma omp parallel for
 			for( k = 0; k < size.height;
 			     k++, bu1 += faceStep, bu2 += faceStep, a += avgStep )
 			{
+				//#pragma omp parallel for
 				for( l = 0; l < size.width - 3; l += 4 )
 				{
@@ -221,4 +227,5 @@
 					w += (u1 - f) * (u2 - f);
 				}
+				
 				for( ; l < size.width; l++ )
 				{
@@ -300,14 +307,14 @@
 	cvCalcCovarMatrixEx( nFaces,  facesArr, 0, 0, NULL, NULL, avg, covarMat );
 	
-	printf("\n");
-	for ( i = 0; i < nFaces; i++ ) 
-	{
-		for ( j = 0; j < nFaces; j++ ) 
-		{
-			printf("%f ", covarMat[i*nFaces+j]);
-		}
-		printf("\n");
-	}
-	printf("\n");
+	//~ printf("\n");
+	//~ for ( i = 0; i < nFaces; i++ ) 
+	//~ {
+		//~ for ( j = 0; j < nFaces; j++ ) 
+		//~ {
+			//~ printf("%f ", covarMat[i*nFaces+j]);
+		//~ }
+		//~ printf("\n");
+	//~ }
+	//~ printf("\n");
 	
 	ev = (float *) cvAlloc( sizeof( float ) * nFaces * nFaces );
@@ -318,32 +325,33 @@
 	//JacobiEigens_32f(covarMat, ev, eigVals, nFaces, 0);
 		
-	for ( j = 0; j < nFaces; j++ ) 
-	{
-		printf("%f ", eigVals[j]);
-	}
-	printf("\n\n");
-	
-	for ( i = 0; i < nFaces; i++ ) 
-	{
-		for ( j = 0; j < nFaces; j++ ) 
-		{
-			printf("%f ", ev[i*nFaces+j]);
-		}
-		printf("\n");
-	}
-	
-	#pragma omp parallel for
+	//~ for ( j = 0; j < nFaces; j++ ) 
+	//~ {
+		//~ printf("%f ", eigVals[j]);
+	//~ }
+	//~ printf("\n\n");
+	
+	//~ for ( i = 0; i < nFaces; i++ ) 
+	//~ {
+		//~ for ( j = 0; j < nFaces; j++ ) 
+		//~ {
+			//~ printf("%f ", ev[i*nFaces+j]);
+		//~ }
+		//~ printf("\n");
+	//~ }
+	
+	//#pragma omp parallel for
 	for( i = 0; i < iter; i++ )
 		eigVals[i] = (float) (1.0 / sqrt( (double)eigVals[i] ));
 	
 	for( i = 0; i < iter; i++ ) 
-    {
+	{
 		float *be = eigs[i];
 
-		#pragma omp parallel for
-		for( k = 0; k < size.height; k++, be += avg_step )
+		//#pragma omp parallel for
+		for( k = 0; k < size.height; k++, be += avg_step ) {
 			for( l = 0; l < size.width; l++ )
 				be[l] = 0.0f;
-    }
+		}
+	}
 
     for( k = 0; k < nFaces; k++ )
@@ -360,8 +368,8 @@
 			float *bf = avg_data;
 
-			#pragma omp parallel for
 			for( p = 0; p < size.height; p++, bu += face_step,
 				bf += avg_step, be += avg_step )
 			{
+				//#pragma omp parallel for
 				for( l = 0; l < size.width - 3; l += 4 )
 				{
@@ -386,5 +394,5 @@
 	}
 	
-	#pragma omp parallel for
+	//#pragma omp parallel for
 	for( i = 0; i < iter; i++ )
 		eigVals[i] = 1.f / (eigVals[i] * eigVals[i]);
