summaryrefslogtreecommitdiff
path: root/lib/Numeric
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric')
-rw-r--r--lib/Numeric/GSL/gsl-aux.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/Numeric/GSL/gsl-aux.c b/lib/Numeric/GSL/gsl-aux.c
index 052cafd..77e793e 100644
--- a/lib/Numeric/GSL/gsl-aux.c
+++ b/lib/Numeric/GSL/gsl-aux.c
@@ -95,6 +95,26 @@ inline double sign(double x) {
95 } 95 }
96} 96}
97 97
98inline gsl_complex complex_abs(gsl_complex z) {
99 gsl_complex r;
100 r.dat[0] = gsl_complex_abs(z);
101 r.dat[1] = 0;
102 return r;
103}
104
105inline gsl_complex complex_signum(gsl_complex z) {
106 gsl_complex r;
107 double mag;
108 if (z.dat[0] == 0 && z.dat[1] == 0) {
109 r.dat[0] = 0;
110 r.dat[1] = 0;
111 } else {
112 mag = gsl_complex_abs(z);
113 r.dat[0] = z.dat[0]/mag;
114 r.dat[1] = z.dat[1]/mag;
115 }
116 return r;
117}
98 118
99#define OP(C,F) case C: { for(k=0;k<xn;k++) rp[k] = F(xp[k]); OK } 119#define OP(C,F) case C: { for(k=0;k<xn;k++) rp[k] = F(xp[k]); OK }
100#define OPV(C,E) case C: { for(k=0;k<xn;k++) rp[k] = E; OK } 120#define OPV(C,E) case C: { for(k=0;k<xn;k++) rp[k] = E; OK }
@@ -124,6 +144,7 @@ int mapR(int code, KRVEC(x), RVEC(r)) {
124 } 144 }
125} 145}
126 146
147
127int mapCAux(int code, KGCVEC(x), GCVEC(r)) { 148int mapCAux(int code, KGCVEC(x), GCVEC(r)) {
128 int k; 149 int k;
129 REQUIRES(xn == rn,BAD_SIZE); 150 REQUIRES(xn == rn,BAD_SIZE);
@@ -132,7 +153,7 @@ int mapCAux(int code, KGCVEC(x), GCVEC(r)) {
132 OP(0,gsl_complex_sin) 153 OP(0,gsl_complex_sin)
133 OP(1,gsl_complex_cos) 154 OP(1,gsl_complex_cos)
134 OP(2,gsl_complex_tan) 155 OP(2,gsl_complex_tan)
135 156 OP(3,complex_abs)
136 OP(4,gsl_complex_arcsin) 157 OP(4,gsl_complex_arcsin)
137 OP(5,gsl_complex_arccos) 158 OP(5,gsl_complex_arccos)
138 OP(6,gsl_complex_arctan) 159 OP(6,gsl_complex_arctan)
@@ -144,7 +165,7 @@ int mapCAux(int code, KGCVEC(x), GCVEC(r)) {
144 OP(12,gsl_complex_arctanh) 165 OP(12,gsl_complex_arctanh)
145 OP(13,gsl_complex_exp) 166 OP(13,gsl_complex_exp)
146 OP(14,gsl_complex_log) 167 OP(14,gsl_complex_log)
147 168 OP(15,complex_signum)
148 OP(16,gsl_complex_sqrt) 169 OP(16,gsl_complex_sqrt)
149 170
150 // gsl_complex_arg 171 // gsl_complex_arg