diff options
Diffstat (limited to 'examples/devel/example/functions.c')
-rw-r--r-- | examples/devel/example/functions.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/examples/devel/example/functions.c b/examples/devel/example/functions.c new file mode 100644 index 0000000..67d3270 --- /dev/null +++ b/examples/devel/example/functions.c | |||
@@ -0,0 +1,22 @@ | |||
1 | |||
2 | typedef struct { double r, i; } doublecomplex; | ||
3 | |||
4 | #define VEC(T,A) int A##n, T* A##p | ||
5 | #define MAT(T,A) int A##r, int A##c, int A##Xr, int A##Xc, T* A##p | ||
6 | |||
7 | #define AT(m,i,j) (m##p[(i)*m##Xr + (j)*m##Xc]) | ||
8 | #define TRAV(m,i,j) int i,j; for (i=0;i<m##r;i++) for (j=0;j<m##c;j++) | ||
9 | |||
10 | |||
11 | int c_diag(MAT(double,m), VEC(double,y), MAT(double,z)) { | ||
12 | int k; | ||
13 | for (k=0; k<yn; k++) { | ||
14 | yp[k] = AT(m,k,k); | ||
15 | } | ||
16 | { TRAV(z,i,j) { | ||
17 | AT(z,i,j) = i==j?yp[i]:0; | ||
18 | } | ||
19 | } | ||
20 | return 0; | ||
21 | } | ||
22 | |||