seems to work.

This commit is contained in:
Daniel Knüttel 2018-11-12 19:53:36 +01:00
parent c607424231
commit 9e7b908db7

View File

@ -34,9 +34,21 @@
/* /*
* General Information: * General Information:
* *
* - Matrices are represented using line vectors. This is * - Matrices are represented using row vectors. This is
* convenient for accessing elements. * convenient for accessing elements.
* *
* Compiling:
*
* Use
*
* gcc -lm -o main Projekt1_Knuettel_Daniel.c
*
* To produce the executable. You can use
*
* gcc -DDEBUG -g -lm -o main Projekt1_Knuettel_Daniel.c
*
* To enable a rudimentary debug mode.
*
* */ * */
#include <stdio.h> #include <stdio.h>
@ -243,6 +255,10 @@ int main(void)
A_2[i] = malloc(sizeof(double) * n); A_2[i] = malloc(sizeof(double) * n);
for(j = 0; j < n; j++) for(j = 0; j < n; j++)
{ {
#ifdef DEBUG
fprintf(stderr, "set A_2[%d][%d] = A_stack_2[%d] = %f\n"
, i, j, n*i + j, A_stack_2[n*i + j]);
#endif
A_2[i][j] = A_stack_2[n*i + j]; A_2[i][j] = A_stack_2[n*i + j];
} }
} }
@ -330,7 +346,9 @@ int householder(double ** A, double * alpha, int m, int n)
* This is just the sample implementation from the * This is just the sample implementation from the
* lecture script. * lecture script.
* */ * */
for(k = 0; k < min(n, m - 1); k++) // I figured out that min(n, m - 1) from the scrip is wrong.
// It must be because the last row would be uninitialized.
for(k = 0; k < min(n, m); k++)
{ {
alpha[k] = square(A[k][k]); alpha[k] = square(A[k][k]);