Index: proiecte/Parallel-DT/R8/Src/info.c
===================================================================
--- proiecte/Parallel-DT/R8/Src/info.c	(revision 26)
+++ proiecte/Parallel-DT/R8/Src/info.c	(revision 69)
@@ -5,5 +5,4 @@
 /*									 */
 /*************************************************************************/
-
 
 #include "buildex.i"
@@ -28,27 +27,17 @@
 /*************************************************************************/
 
-
 float Worth(ThisInfo, ThisGain, MinGain)
-/*    -----  */
-    float ThisInfo, ThisGain, MinGain;
-{
-    if ( GAINRATIO )
-    {
-	if ( ThisGain >= MinGain - Epsilon && ThisInfo > Epsilon )
-	{
-	    return ThisGain / ThisInfo;
-	}
-	else
-	{
-	    return -Epsilon;
-	}
-    }
-    else
-    {
-	return ( ThisInfo > 0 && ThisGain > -Epsilon ? ThisGain : -Epsilon );
-    }
-}
-
-
+	/*    -----  */
+	float ThisInfo, ThisGain, MinGain; {
+	if (GAINRATIO) {
+		if (ThisGain >= MinGain - Epsilon && ThisInfo > Epsilon) {
+			return ThisGain / ThisInfo;
+		} else {
+			return -Epsilon;
+		}
+	} else {
+		return (ThisInfo > 0 && ThisGain > -Epsilon ? ThisGain : -Epsilon);
+	}
+}
 
 /*************************************************************************/
@@ -58,23 +47,18 @@
 /*************************************************************************/
 
-
-    ResetFreq(MaxVal)
-/*  ---------  */
-    DiscrValue MaxVal;
-{
-    DiscrValue v;
-    ClassNo c;
-
-    ForEach(v, 0, MaxVal)
-    { 
-	ForEach(c, 0, MaxClass)
-	{
-	    Freq[v][c] = 0;
-	}
-	ValFreq[v] = 0;
-    } 
-}
-
-
+ResetFreq(MaxVal, Freq, ValFreq)
+	/*  ---------  */
+	DiscrValue MaxVal; ItemCount** Freq; ItemCount* ValFreq; {
+	DiscrValue v;
+	ClassNo c;
+
+	#pragma omp parallel for private(v)
+	ForEach(v, 0, MaxVal) {
+		ForEach(c, 0, MaxClass) {
+			Freq[v][c] = 0;
+		}
+		ValFreq[v] = 0;
+	}
+}
 
 /*************************************************************************/
@@ -97,47 +81,84 @@
 /*************************************************************************/
 
-
 float ComputeGain(BaseInfo, UnknFrac, MaxVal, TotalItems)
-/*    -----------  */
-    float BaseInfo, UnknFrac;
-    DiscrValue MaxVal;
-    ItemCount TotalItems;
-{
-    DiscrValue v;
-    float ThisInfo=0.0, ThisGain, TotalInfo();
-    short ReasonableSubsets=0;
-
-    /*  Check whether all values are unknown or the same  */
-
-    if ( ! TotalItems ) return -Epsilon;
-
-    /*  There must be at least two subsets with MINOBJS items  */
-
-    ForEach(v, 1, MaxVal)
-    {
-	if ( ValFreq[v] >= MINOBJS ) ReasonableSubsets++;
-    }
-    if ( ReasonableSubsets < 2 ) return -Epsilon;
-
-    /*  Compute total info after split, by summing the
-	info of each of the subsets formed by the test  */
-
-    ForEach(v, 1, MaxVal)
-    {
-	ThisInfo += TotalInfo(Freq[v], 0, MaxClass);
-    }
-
-    /*  Set the gain in information for all items, adjusted for unknowns  */
-
-    ThisGain = (1 - UnknFrac) * (BaseInfo - ThisInfo / TotalItems);
-
-    Verbosity(5)
-        printf("ComputeThisGain: items %.1f info %.3f base %.3f unkn %.3f result %.3f\n",
-    		TotalItems + ValFreq[0], ThisInfo, BaseInfo, UnknFrac, ThisGain);
-
-    return ThisGain;
-}
-
-
+	/*    -----------  */
+	float BaseInfo, UnknFrac;DiscrValue MaxVal;ItemCount TotalItems; {
+	DiscrValue v;
+	float ThisInfo = 0.0, ThisGain, TotalInfo();
+	short ReasonableSubsets = 0;
+
+	/*  Check whether all values are unknown or the same  */
+
+	if (!TotalItems)
+		return -Epsilon;
+
+	/*  There must be at least two subsets with MINOBJS items  */
+
+	ForEach(v, 1, MaxVal) {
+		if (ValFreq[v] >= MINOBJS)
+			ReasonableSubsets++;
+	}
+	if (ReasonableSubsets < 2)
+		return -Epsilon;
+
+	/*  Compute total info after split, by summing the
+	 info of each of the subsets formed by the test  */
+
+	//#pragma omp parallel for reduction(+:ThisInfo)
+	ForEach(v, 1, MaxVal) {
+		ThisInfo += TotalInfo(Freq[v], 0, MaxClass);
+	}
+
+	/*  Set the gain in information for all items, adjusted for unknowns  */
+
+	ThisGain = (1 - UnknFrac) * (BaseInfo - ThisInfo / TotalItems);
+
+	Verbosity(5)
+		printf(
+				"ComputeThisGain: items %.1f info %.3f base %.3f unkn %.3f result %.3f\n",
+				TotalItems + ValFreq[0], ThisInfo, BaseInfo, UnknFrac, ThisGain);
+
+	return ThisGain;
+}
+
+float ComputeGain_Discr(BaseInfo, UnknFrac, MaxVal, TotalItems, Freq, ValFreq)
+	/*    -----------  */
+	float BaseInfo, UnknFrac;DiscrValue MaxVal;ItemCount TotalItems; ItemCount** Freq; ItemCount* ValFreq; {
+	DiscrValue v;
+	float ThisInfo = 0.0, ThisGain, TotalInfo();
+	short ReasonableSubsets = 0;
+
+	/*  Check whether all values are unknown or the same  */
+
+	if (!TotalItems)
+		return -Epsilon;
+
+	/*  There must be at least two subsets with MINOBJS items  */
+
+	ForEach(v, 1, MaxVal) {
+		if (ValFreq[v] >= MINOBJS)
+			ReasonableSubsets++;
+	}
+	if (ReasonableSubsets < 2)
+		return -Epsilon;
+
+	/*  Compute total info after split, by summing the
+	 info of each of the subsets formed by the test  */
+
+	ForEach(v, 1, MaxVal) {
+		ThisInfo += TotalInfo(Freq[v], 0, MaxClass);
+	}
+
+	/*  Set the gain in information for all items, adjusted for unknowns  */
+
+	ThisGain = (1 - UnknFrac) * (BaseInfo - ThisInfo / TotalItems);
+
+	Verbosity(5)
+		printf(
+				"ComputeThisGain: items %.1f info %.3f base %.3f unkn %.3f result %.3f\n",
+				TotalItems + ValFreq[0], ThisInfo, BaseInfo, UnknFrac, ThisGain);
+
+	return ThisGain;
+}
 
 /*************************************************************************/
@@ -147,26 +168,20 @@
 /*************************************************************************/
 
-
 float TotalInfo(V, MinVal, MaxVal)
-/*    ---------  */
-    ItemCount V[];
-    DiscrValue MinVal, MaxVal;
-{
-    DiscrValue v;
-    float Sum=0.0;
-    ItemCount N, TotalItems=0;
-
-    ForEach(v, MinVal, MaxVal)
-    {
-	N = V[v];
-
-	Sum += N * Log(N);
-	TotalItems += N;
-    }
-
-    return TotalItems * Log(TotalItems) - Sum;
-}
-
-
+	/*    ---------  */
+	ItemCount V[];DiscrValue MinVal, MaxVal; {
+	DiscrValue v;
+	float Sum = 0.0;
+	ItemCount N, TotalItems = 0;
+
+	ForEach(v, MinVal, MaxVal) {
+		N = V[v];
+
+		Sum += N * Log(N);
+		TotalItems += N;
+	}
+
+	return TotalItems * Log(TotalItems) - Sum;
+}
 
 /*************************************************************************/
@@ -176,42 +191,61 @@
 /*************************************************************************/
 
-
-    PrintDistribution(Att, MaxVal, ShowNames)
-/*  -----------------  */
-    Attribute Att;
-    DiscrValue MaxVal;
-    Boolean ShowNames;
-{
-    DiscrValue v;
-    ClassNo c;
-    String Val;
-
-    printf("\n\t\t\t ");
-    ForEach(c, 0, MaxClass)
-    {
-	printf("%7.6s", ClassName[c]);
-    }
-    printf("\n");
-
-    ForEach(v, 0, MaxVal)
-    {
-	if ( ShowNames )
-	{
-	    Val = ( !v ? "unknown" :
-		    MaxAttVal[Att] ? AttValName[Att][v] :
-		    v == 1 ? "below" : "above" );
-	    printf("\t\t[%-7.7s:", Val);
-	}
-	else
-	{
-	    printf("\t\t[%-7d:", v);
-	}
-
-	ForEach(c, 0, MaxClass)
-	{
-	    printf(" %6.1f", Freq[v][c]);
-	}
-
-	printf("]\n");
-    }
-}
+PrintDistribution(Att, MaxVal, ShowNames)
+	/*  -----------------  */
+	Attribute Att;DiscrValue MaxVal;Boolean ShowNames; {
+	DiscrValue v;
+	ClassNo c;
+	String Val;
+
+	printf("\n\t\t\t ");
+	ForEach(c, 0, MaxClass) {
+		printf("%7.6s", ClassName[c]);
+	}
+	printf("\n");
+
+	ForEach(v, 0, MaxVal) {
+		if (ShowNames) {
+			Val = (!v ? "unknown" : MaxAttVal[Att] ? AttValName[Att][v] : v
+					== 1 ? "below" : "above");
+			printf("\t\t[%-7.7s:", Val);
+		} else {
+			printf("\t\t[%-7d:", v);
+		}
+
+		ForEach(c, 0, MaxClass) {
+			printf(" %6.1f", Freq[v][c]);
+		}
+
+		printf("]\n");
+	}
+}
+
+PrintDistribution_Discr(Att, MaxVal, ShowNames, Freq)
+	/*  -----------------  */
+	Attribute Att;DiscrValue MaxVal;Boolean ShowNames; ItemCount** Freq;{
+	DiscrValue v;
+	ClassNo c;
+	String Val;
+
+	printf("\n\t\t\t ");
+	ForEach(c, 0, MaxClass) {
+		printf("%7.6s", ClassName[c]);
+	}
+	printf("\n");
+
+	ForEach(v, 0, MaxVal) {
+		if (ShowNames) {
+			Val = (!v ? "unknown" : MaxAttVal[Att] ? AttValName[Att][v] : v
+					== 1 ? "below" : "above");
+			printf("\t\t[%-7.7s:", Val);
+		} else {
+			printf("\t\t[%-7d:", v);
+		}
+
+		ForEach(c, 0, MaxClass) {
+			printf(" %6.1f", Freq[v][c]);
+		}
+
+		printf("]\n");
+	}
+}
