diff --git a/Projekt1_Knuettel_Daniel.c b/Projekt1_Knuettel_Daniel.c index 10c94ab..3208133 100644 --- a/Projekt1_Knuettel_Daniel.c +++ b/Projekt1_Knuettel_Daniel.c @@ -31,6 +31,14 @@ * Programm erhalten haben. Wenn nicht, siehe . */ +/* + * General Information: + * + * - Matrices are represented using line vectors. This is + * convenient for accessing elements. + * + * */ + #include #include #include @@ -262,6 +270,31 @@ int main(void) } status = solve_QR(A_2, alpha_2, m, b); + double ** R_2; + + status = unwind_R(A_2, alpha_2, m, n, &R_2); + if(status) + { + fprintf(stderr, "failed to unwind R\n"); + free(alpha_2); + for(i = 0; i < m; i++) + { + free(A_2[i]); + } + free(A_2); + free(b); + goto exit; + } + printf("R:\n"); + printm(R_2, m, n); + + for(i = 0; i < m; i++) + { + free(R_2[i]); + } + free(R_2); + + printf("Solution for the System:\n"); printv(b, m); @@ -358,6 +391,9 @@ int fprintm(FILE * stream, double ** matrix, int m, int n) for(j = 0; j < n; j++) { +#ifdef DEBUG + fprintf(stderr, "matrix[%d][%d] = %f\n", i, j, matrix[i][j]); +#endif fprintf(stream, "%6.2f ", matrix[i][j]); } @@ -526,6 +562,9 @@ int unwind_R(double ** A, double * alpha, int m, int n, double *** R) { for(j = 0; j < n; j++) { +#ifdef DEBUG + fprintf(stderr, "set result[%d][%d]\n", i, j); +#endif if(i > j) { result[i][j] = 0;