summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/aux.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed/aux.c')
-rw-r--r--lib/Data/Packed/aux.c98
1 files changed, 76 insertions, 22 deletions
diff --git a/lib/Data/Packed/aux.c b/lib/Data/Packed/aux.c
index d772d90..da36035 100644
--- a/lib/Data/Packed/aux.c
+++ b/lib/Data/Packed/aux.c
@@ -48,12 +48,12 @@
48 48
49#define DVVIEW(A) gsl_vector_view A = gsl_vector_view_array(A##p,A##n) 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) 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) 51#define CVVIEW(A) gsl_vector_complex_view A = gsl_vector_complex_view_array((double*)A##p,A##n)
52#define CMVIEW(A) gsl_matrix_complex_view A = gsl_matrix_complex_view_array(A##p,A##r,A##c) 52#define CMVIEW(A) gsl_matrix_complex_view A = gsl_matrix_complex_view_array((double*)A##p,A##r,A##c)
53#define KDVVIEW(A) gsl_vector_const_view A = gsl_vector_const_view_array(A##p,A##n) 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) 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) 55#define KCVVIEW(A) gsl_vector_complex_const_view A = gsl_vector_complex_const_view_array((double*)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) 56#define KCMVIEW(A) gsl_matrix_complex_const_view A = gsl_matrix_complex_const_view_array((double*)A##p,A##r,A##c)
57 57
58#define V(a) (&a.vector) 58#define V(a) (&a.vector)
59#define M(a) (&a.matrix) 59#define M(a) (&a.matrix)
@@ -65,26 +65,80 @@
65#define BAD_CODE 1001 65#define BAD_CODE 1001
66#define MEM 1002 66#define MEM 1002
67#define BAD_FILE 1003 67#define BAD_FILE 1003
68#define BAD_TYPE 1004
69 68
70 69
71int trans(int size,KMAT(x),MAT(t)) { 70
71int transR(KRMAT(x),RMAT(t)) {
72 REQUIRES(xr==tc && xc==tr,BAD_SIZE);
73 DEBUGMSG("transR");
74 KDMVIEW(x);
75 DMVIEW(t);
76 int res = gsl_matrix_transpose_memcpy(M(t),M(x));
77 CHECK(res,res);
78 OK
79}
80
81int transC(KCMAT(x),CMAT(t)) {
72 REQUIRES(xr==tc && xc==tr,BAD_SIZE); 82 REQUIRES(xr==tc && xc==tr,BAD_SIZE);
73 DEBUGMSG("trans"); 83 DEBUGMSG("transC");
74 if(size==8) { 84 KCMVIEW(x);
75 DEBUGMSG("trans double"); 85 CMVIEW(t);
76 KDMVIEW(x); 86 int res = gsl_matrix_complex_transpose_memcpy(M(t),M(x));
77 DMVIEW(t); 87 CHECK(res,res);
78 int res = gsl_matrix_transpose_memcpy(M(t),M(x)); 88 OK
79 CHECK(res,res); 89}
80 OK 90
81 } else if (size==16) { 91
82 DEBUGMSG("trans complex double"); 92int constantR(double * pval, RVEC(r)) {
83 KCMVIEW(x); 93 DEBUGMSG("constantR")
84 CMVIEW(t); 94 int k;
85 int res = gsl_matrix_complex_transpose_memcpy(M(t),M(x)); 95 double val = *pval;
86 CHECK(res,res); 96 for(k=0;k<rn;k++) {
87 OK 97 rp[k]=val;
88 } 98 }
89 return BAD_TYPE; 99 OK
100}
101
102int constantC(gsl_complex* pval, CVEC(r)) {
103 DEBUGMSG("constantC")
104 int k;
105 gsl_complex val = *pval;
106 for(k=0;k<rn;k++) {
107 rp[k]=val;
108 }
109 OK
110}
111
112int multiplyR(int ta, KRMAT(a), int tb, KRMAT(b),RMAT(r)) {
113 //printf("%d %d %d %d %d %d\n",ar,ac,br,bc,rr,rc);
114 //REQUIRES(ac==br && ar==rr && bc==rc,BAD_SIZE);
115 DEBUGMSG("multiplyR (gsl_blas_dgemm)");
116 KDMVIEW(a);
117 KDMVIEW(b);
118 DMVIEW(r);
119 int res = gsl_blas_dgemm(
120 ta?CblasTrans:CblasNoTrans,
121 tb?CblasTrans:CblasNoTrans,
122 1.0, M(a), M(b),
123 0.0, M(r));
124 CHECK(res,res);
125 OK
126}
127
128int multiplyC(int ta, KCMAT(a), int tb, KCMAT(b),CMAT(r)) {
129 //REQUIRES(ac==br && ar==rr && bc==rc,BAD_SIZE);
130 DEBUGMSG("multiplyC (gsl_blas_zgemm)");
131 KCMVIEW(a);
132 KCMVIEW(b);
133 CMVIEW(r);
134 gsl_complex alpha, beta;
135 GSL_SET_COMPLEX(&alpha,1.,0.);
136 GSL_SET_COMPLEX(&beta,0.,0.);
137 int res = gsl_blas_zgemm(
138 ta?CblasTrans:CblasNoTrans,
139 tb?CblasTrans:CblasNoTrans,
140 alpha, M(a), M(b),
141 beta, M(r));
142 CHECK(res,res);
143 OK
90} 144}