[Bf-blender-cvs] [8717a67] soc-2016-cycles_denoising: Cycles: Improve robustness of the Cholesky decomposition

Lukas Stockner noreply at git.blender.org
Tue Nov 22 04:25:37 CET 2016


Commit: 8717a677fee1c86d654a75f100e8114475335c51
Author: Lukas Stockner
Date:   Tue Nov 22 04:10:56 2016 +0100
Branches: soc-2016-cycles_denoising
https://developer.blender.org/rB8717a677fee1c86d654a75f100e8114475335c51

Cycles: Improve robustness of the Cholesky decomposition

===================================================================

M	intern/cycles/util/util_math_matrix.h

===================================================================

diff --git a/intern/cycles/util/util_math_matrix.h b/intern/cycles/util/util_math_matrix.h
index 6386360..967fda6 100644
--- a/intern/cycles/util/util_math_matrix.h
+++ b/intern/cycles/util/util_math_matrix.h
@@ -61,10 +61,15 @@ ccl_device void math_cholesky(float *A, int n)
 	for(int row = 0; row < n; row++) {
 		for(int col = 0; col <= row; col++) {
 			float sum_col = MAT(A, n, row, col);
-			for(int k = 0; k < col; k++)
+			for(int k = 0; k < col; k++) {
 				sum_col -= MAT(A, n, row, k) * MAT(A, n, col, k);
-			if(row == col) sum_col = sqrtf(sum_col);
-			else           sum_col = sum_col / MAT(A, n, col, col);
+			}
+			if(row == col) {
+				sum_col = sqrtf(max(sum_col, 0.0f));
+			}
+			else {
+				sum_col /= MAT(A, n, col, col);
+			}
 			MAT(A, n, row, col) = sum_col;
 		}
 	}




More information about the Bf-blender-cvs mailing list