-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoisson_opprydning.c
86 lines (66 loc) · 1.75 KB
/
poisson_opprydning.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
C-program to solve the two-dimensional Poisson equation on
a unit square using one-dimensional eigenvalue decompositions
and fast sine transforms
einar m. ronquist
ntnu, october 2000
revised, october 2001
*/
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <math.h>
#include "utils.h"
int main(int argc, char **argv )
{
Real *diag, **b, **bt;
Real pi, h, umax;
int i, j, n, m, nn;
/* the total number of grid points in each spatial direction is (n+1) */
/* the total number of degrees-of-freedom in each spatial direction is (n-1) */
/* this version requires n to be a power of 2 */
if( argc < 2 ) {
printf("need a problem size\n");
return 1;
}
n = atoi(argv[1]);
m = n-1;
nn = 4*n;
diag = createRealArray (m);
b = createReal2DArray (m,m);
bt = createReal2DArray (m,m);
h = 1./(Real)n;
pi = 4.*atan(1.);
printf("fun_populate_diag(diag, m , n);");
printf("\n");
fun_populate_diag(diag, m , n);
printf(" fun_populate_b(b, m, h*h); ");
printf("\n");
fun_populate_b(b, m, h*h);
printf("fun_col_fst(b, m, n, nn); ");
printf("\n");
fun_col_fst(b, m, n, nn);
printf("transpose (bt,b,m); ");
printf("\n");
transpose (bt,b,m);
printf("fun_col_fstinv( bt , m , n , nn ); ");
printf("\n");
fun_col_fstinv( bt , m , n , nn );
printf("fun_strange(diag, bt, m); ");
printf("\n");
fun_strange(diag, bt, m);
printf("fun_col_fst(bt, m, n, nn);");
printf("\n");
fun_col_fst(bt, m, n, nn);
printf(" transpose (b,bt,m); ");
printf("\n");
transpose (b,bt,m);
printf(" fun_col_fstinv( b,m, n, nn); ");
printf("\n");
fun_col_fstinv( b, m, n, nn);
printf(" umax = fun_find_umax(b, m); ");
printf("\n");
umax = fun_find_umax(b, m);
printf (" umax = %e \n",umax);
}