Browse code

changed all densities=0 behaviour

chakalakka authored on 06/10/2015 14:19:40
Showing 2 changed files

... ...
@@ -20,10 +20,10 @@ void R_univariate_hmm(int* O, int* T, int* N, double* size, double* prob, int* m
20 20
 {
21 21
 
22 22
 	// Define logging level
23
-// 	//FILE* pFile = fopen("chromStar.log", "w");
24
-// 	Output2//FILE::Stream() = pFile;
25
- 	//FILELog::ReportingLevel() = //FILELog::FromString("ERROR");
26
-//  	//FILELog::ReportingLevel() = //FILELog::FromString("DEBUG2");
23
+	//FILE* pFile = fopen("chromStar.log", "w");
24
+ 	//Output2FILE::Stream() = pFile;
25
+ 	//FILELog::ReportingLevel() = FILELog::FromString("ERROR");
26
+ 	//FILELog::ReportingLevel() = FILELog::FromString("DEBUG2");
27 27
 
28 28
 	//FILE_LOG(logDEBUG2) << __PRETTY_FUNCTION__;
29 29
 	// Parallelization settings
... ...
@@ -272,10 +272,10 @@ void R_multivariate_hmm(int* O, int* T, int* N, int *Nmod, int* comb_states, dou
272 272
 {
273 273
 
274 274
 	// Define logging level {"ERROR", "WARNING", "INFO", "ITERATION", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4"}
275
-// 	//FILE* pFile = fopen("chromStar.log", "w");
276
-// 	Output2//FILE::Stream() = pFile;
277
- 	//FILELog::ReportingLevel() = //FILELog::FromString("ERROR");
278
-//  	//FILELog::ReportingLevel() = //FILELog::FromString("DEBUG3");
275
+ 	//FILE* pFile = fopen("chromStar.log", "w");
276
+	//Output2FILE::Stream() = pFile;
277
+ 	//FILELog::ReportingLevel() = FILELog::FromString("ERROR");
278
+ 	FILELog::ReportingLevel() = FILELog::FromString("DEBUG3");
279 279
 
280 280
 	//FILE_LOG(logDEBUG2) << __PRETTY_FUNCTION__;
281 281
 	// Parallelization settings
... ...
@@ -983,18 +983,19 @@ void ScaleHMM::calc_densities()
983 983
 		}
984 984
 	}
985 985
 
986
-	// Check if the density for all states is numerically zero and correct to prevent NaNs
986
+	// Check if the density for all states is close to zero and correct to prevent NaNs
987
+	double zero_cutoff = 1e-100;
987 988
 	std::vector<double> temp(this->N);
988 989
 	// t=0
989 990
 	for (int iN=0; iN<this->N; iN++)
990 991
 	{
991 992
 		temp[iN] = this->densities[iN][0];
992 993
 	}
993
-	if (*std::max_element(temp.begin(), temp.end()) == 0.0)
994
+	if (*std::max_element(temp.begin(), temp.end()) < zero_cutoff)
994 995
 	{
995 996
 		for (int iN=0; iN<this->N; iN++)
996 997
 		{
997
-			this->densities[iN][0] = 0.00000000001;
998
+			this->densities[iN][0] = zero_cutoff;
998 999
 		}
999 1000
 	}
1000 1001
 	// t>0
... ...
@@ -1004,7 +1005,7 @@ void ScaleHMM::calc_densities()
1004 1005
 		{
1005 1006
 			temp[iN] = this->densities[iN][t];
1006 1007
 		}
1007
-		if (*std::max_element(temp.begin(), temp.end()) == 0.0)
1008
+		if (*std::max_element(temp.begin(), temp.end()) < zero_cutoff)
1008 1009
 		{
1009 1010
 			for (int iN=0; iN<this->N; iN++)
1010 1011
 			{