private static double[][] CholeskyDecompositionParallel(double[][] matrix) { double[][] lower = MatrixHelper.MatrixCreate(matrix.Length, matrix.Length); // Decomposing a matrix // into Lower Triangular for (int i = 0; i < matrix.Length; i++) { for (int j = 0; j <= i; j++) { // Evaluating L(i, j) // using L(j, j) double sum = 0; Parallel.For(0, j, k => { sum += (lower[i][k] * lower[j][k]); }); // summation for diagnols if (j == i) { lower[j][j] = Math.Sqrt(matrix[j][j] - sum); } else { lower[i][j] = (matrix[i][j] - sum) / lower[j][j]; } } } return(lower); }
private static double[][] ConvertToBlockDiagonal(double[][] matrix, double k) { double[][] result = MatrixHelper.MatrixCreate(matrix.Length, matrix[0].Length); for (int i = 0; i < matrix.Length; i++) { int finish = i / BlockSize * BlockSize + BlockSize; for (int j = i / BlockSize * BlockSize; j < finish; j++) { result[i][j] = matrix[i][j]; } } return(result); }
private static double[][] Transpose(double[][] decomposed) { double[][] lower = MatrixHelper.MatrixCreate(decomposed.Length, decomposed.Length); for (int i = 0; i < decomposed.Length; i++) { for (int j = 0; j < decomposed.Length; j++) { lower[j][i] = decomposed[i][j]; } } return(lower); }
private static double[][] GetGreenValuesMatrix(Bitmap bmp, int n) { double[][] result = MatrixHelper.MatrixCreate(n, n); for (int x = 0; x < n; x++) { result[x] = new double[n]; for (int y = 0; y < n; y++) { result[x][y] = bmp.GetPixel(x, y).G; } } return(result); }