summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/aux.c
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-05-28 12:22:24 +0000
committerAlberto Ruiz <aruiz@um.es>2007-05-28 12:22:24 +0000
commit80673221e704b451e0d9468d6dfe1a38ad676c07 (patch)
tree1cba10d54d457ebfda1ec7810149664818834027 /lib/Data/Packed/aux.c
parentc3a1c3ed7c1be6f255ff3bd4f8ec6d2dd2a29b66 (diff)
common trans
Diffstat (limited to 'lib/Data/Packed/aux.c')
-rw-r--r--lib/Data/Packed/aux.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/lib/Data/Packed/aux.c b/lib/Data/Packed/aux.c
new file mode 100644
index 0000000..d772d90
--- /dev/null
+++ b/lib/Data/Packed/aux.c
@@ -0,0 +1,90 @@
1#include "aux.h"
2#include <gsl/gsl_blas.h>
3#include <gsl/gsl_linalg.h>
4#include <gsl/gsl_matrix.h>
5#include <gsl/gsl_math.h>
6#include <gsl/gsl_errno.h>
7#include <gsl/gsl_fft_complex.h>
8#include <gsl/gsl_eigen.h>
9#include <gsl/gsl_integration.h>
10#include <gsl/gsl_deriv.h>
11#include <gsl/gsl_poly.h>
12#include <gsl/gsl_multimin.h>
13#include <gsl/gsl_complex.h>
14#include <gsl/gsl_complex_math.h>
15#include <string.h>
16#include <stdio.h>
17
18#define MACRO(B) do {B} while (0)
19#define ERROR(CODE) MACRO(return CODE;)
20#define REQUIRES(COND, CODE) MACRO(if(!(COND)) {ERROR(CODE);})
21
22#define MIN(A,B) ((A)<(B)?(A):(B))
23#define MAX(A,B) ((A)>(B)?(A):(B))
24
25#ifdef DBG
26#define DEBUGMSG(M) printf("GSL Wrapper "M": "); size_t t0 = time(NULL);
27#define OK MACRO(printf("%ld s\n",time(0)-t0); return 0;);
28#else
29#define DEBUGMSG(M)
30#define OK return 0;
31#endif
32
33
34#define CHECK(RES,CODE) MACRO(if(RES) return CODE;)
35
36#ifdef DBG
37#define DEBUGMAT(MSG,X) printf(MSG" = \n"); gsl_matrix_fprintf(stdout,X,"%f"); printf("\n");
38#else
39#define DEBUGMAT(MSG,X)
40#endif
41
42#ifdef DBG
43#define DEBUGVEC(MSG,X) printf(MSG" = \n"); gsl_vector_fprintf(stdout,X,"%f"); printf("\n");
44#else
45#define DEBUGVEC(MSG,X)
46#endif
47
48
49#define DVVIEW(A) gsl_vector_view A = gsl_vector_view_array(A##p,A##n)
50#define DMVIEW(A) gsl_matrix_view A = gsl_matrix_view_array(A##p,A##r,A##c)
51#define CVVIEW(A) gsl_vector_complex_view A = gsl_vector_complex_view_array(A##p,A##n)
52#define CMVIEW(A) gsl_matrix_complex_view A = gsl_matrix_complex_view_array(A##p,A##r,A##c)
53#define KDVVIEW(A) gsl_vector_const_view A = gsl_vector_const_view_array(A##p,A##n)
54#define KDMVIEW(A) gsl_matrix_const_view A = gsl_matrix_const_view_array(A##p,A##r,A##c)
55#define KCVVIEW(A) gsl_vector_complex_const_view A = gsl_vector_complex_const_view_array(A##p,A##n)
56#define KCMVIEW(A) gsl_matrix_complex_const_view A = gsl_matrix_complex_const_view_array(A##p,A##r,A##c)
57
58#define V(a) (&a.vector)
59#define M(a) (&a.matrix)
60
61#define GCVEC(A) int A##n, gsl_complex*A##p
62#define KGCVEC(A) int A##n, const gsl_complex*A##p
63
64#define BAD_SIZE 1000
65#define BAD_CODE 1001
66#define MEM 1002
67#define BAD_FILE 1003
68#define BAD_TYPE 1004
69
70
71int trans(int size,KMAT(x),MAT(t)) {
72 REQUIRES(xr==tc && xc==tr,BAD_SIZE);
73 DEBUGMSG("trans");
74 if(size==8) {
75 DEBUGMSG("trans double");
76 KDMVIEW(x);
77 DMVIEW(t);
78 int res = gsl_matrix_transpose_memcpy(M(t),M(x));
79 CHECK(res,res);
80 OK
81 } else if (size==16) {
82 DEBUGMSG("trans complex double");
83 KCMVIEW(x);
84 CMVIEW(t);
85 int res = gsl_matrix_complex_transpose_memcpy(M(t),M(x));
86 CHECK(res,res);
87 OK
88 }
89 return BAD_TYPE;
90}