diff options
author | Alberto Ruiz <aruiz@um.es> | 2014-05-21 10:30:55 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2014-05-21 10:30:55 +0200 |
commit | 197e88c3b56d28840217010a2871c6ea3a4dd1a4 (patch) | |
tree | 825be9d6c9d87d23f7e5497c0133d11d52c63535 /examples/devel/ej1/functions.c | |
parent | e07c3dee7235496b71a89233106d93f6cc94ada1 (diff) |
update dependencies, move examples etc
Diffstat (limited to 'examples/devel/ej1/functions.c')
-rw-r--r-- | examples/devel/ej1/functions.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/examples/devel/ej1/functions.c b/examples/devel/ej1/functions.c new file mode 100644 index 0000000..02a4cdd --- /dev/null +++ b/examples/devel/ej1/functions.c | |||
@@ -0,0 +1,35 @@ | |||
1 | /* assuming row order */ | ||
2 | |||
3 | typedef struct { double r, i; } doublecomplex; | ||
4 | |||
5 | #define DVEC(A) int A##n, double*A##p | ||
6 | #define CVEC(A) int A##n, doublecomplex*A##p | ||
7 | #define DMAT(A) int A##r, int A##c, double*A##p | ||
8 | #define CMAT(A) int A##r, int A##c, doublecomplex*A##p | ||
9 | |||
10 | #define AT(M,row,col) (M##p[(row)*M##c + (col)]) | ||
11 | |||
12 | /*-----------------------------------------------------*/ | ||
13 | |||
14 | int c_scale_vector(double s, DVEC(x), DVEC(y)) { | ||
15 | int k; | ||
16 | for (k=0; k<=yn; k++) { | ||
17 | yp[k] = s*xp[k]; | ||
18 | } | ||
19 | return 0; | ||
20 | } | ||
21 | |||
22 | /*-----------------------------------------------------*/ | ||
23 | |||
24 | int c_diag(DMAT(m),DVEC(y),DMAT(z)) { | ||
25 | int i,j; | ||
26 | for (j=0; j<yn; j++) { | ||
27 | yp[j] = AT(m,j,j); | ||
28 | } | ||
29 | for (i=0; i<mr; i++) { | ||
30 | for (j=0; j<mc; j++) { | ||
31 | AT(z,i,j) = i==j?yp[i]:0; | ||
32 | } | ||
33 | } | ||
34 | return 0; | ||
35 | } | ||