File indexing completed on 2025-02-21 10:03:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 struct f
0022 {
0023 char *name;
0024 double (*f) (gsl_complex z);
0025 double x;
0026 double y;
0027 double fx;
0028 double fy;
0029 };
0030
0031 struct fz
0032 {
0033 char *name;
0034 gsl_complex (*f) (gsl_complex z);
0035 double x;
0036 double y;
0037 double fx;
0038 double fy;
0039 };
0040
0041 struct fzz
0042 {
0043 char *name;
0044 gsl_complex (*f) (gsl_complex z1, gsl_complex z2);
0045 double x1;
0046 double y1;
0047 double x2;
0048 double y2;
0049 double fx;
0050 double fy;
0051 };
0052
0053
0054 struct freal
0055 {
0056 char *name;
0057 gsl_complex (*f) (double x);
0058 double x;
0059 double fx;
0060 double fy;
0061 };
0062
0063 struct fzreal
0064 {
0065 char *name;
0066 gsl_complex (*f) (gsl_complex z, double a);
0067 double x;
0068 double y;
0069 double a;
0070 double fx;
0071 double fy;
0072 };
0073
0074 #define FN(x) "gsl_complex_" #x, gsl_complex_ ## x
0075 #define ARG(x,y) x, y
0076 #define RES(x,y) x, y
0077
0078 struct f list[] =
0079 {
0080 #include "results1.h"
0081 {"", 0, 0, 0, 0, 0}
0082 };
0083
0084
0085 struct fz listz[] =
0086 {
0087 #include "results.h"
0088 {"", 0, 0, 0, 0, 0}
0089 };
0090
0091 struct fzz listzz[] =
0092 {
0093 {FN (pow), ARG(0.0,0.0), ARG(0.0,0.0), RES(1.0, 0.0)},
0094 #include "results2.h"
0095 {"", 0, 0, 0, 0, 0, 0, 0}
0096 };
0097
0098 struct freal listreal[] =
0099 {
0100 #include "results_real.h"
0101 {"", 0, 0, 0, 0}
0102 };
0103
0104
0105 struct fzreal listzreal[] =
0106 {
0107 #include "results_zreal.h"
0108 {"", 0, 0, 0, 0, 0, 0}
0109 };
0110
0111
0112 #ifndef TEST_FACTOR
0113 #ifdef RELEASED
0114 #define TEST_FACTOR 100.0
0115 #else
0116 #define TEST_FACTOR 1.0
0117 #endif
0118 #endif
0119
0120 static int
0121 FUNCTION (test, all) ()
0122 {
0123 size_t i = 0;
0124 #if defined(BASE_DOUBLE)
0125 const double tol = GSL_DBL_EPSILON;
0126 #endif
0127
0128 gsl_ieee_env_setup();
0129
0130 for (i = 0 ; i < 10; i++)
0131 {
0132 ATOMIC x = (i - 5.0) * 0.3;
0133 ATOMIC y = (i + 2.1) * 0.5;
0134 TYPE(gsl_complex) z = gsl_complex_rect(x, y);
0135
0136 gsl_test_rel (GSL_REAL(z), x, tol, "gsl_complex_rect real part at (x=%g,y=%g)", x, y);
0137 gsl_test_rel (GSL_IMAG(z), y, tol, "gsl_complex_rect imag part at (x=%g,y=%g)", x, y);
0138
0139 GSL_REAL(z) = y;
0140 gsl_test_rel (GSL_REAL(z), y, tol, "assignment real part (%g)", y);
0141
0142 GSL_IMAG(z) = x;
0143 gsl_test_rel (GSL_IMAG(z), x, tol, "assignment imag part (%g)", x);
0144 }
0145
0146 for (i = 0 ; i < 10; i++)
0147 {
0148 ATOMIC r = (i - 5.0) * 0.3 ;
0149 ATOMIC t = 2.0 * M_PI * i / 5 ;
0150 ATOMIC x = r * cos(t), y = r * sin(t) ;
0151 TYPE(gsl_complex) z = gsl_complex_polar (r, t) ;
0152 gsl_test_rel (GSL_REAL(z), x, tol, "gsl_complex_polar real part at (r=%g,t=%g)", r, t);
0153 gsl_test_rel (GSL_IMAG(z), y, tol, "gsl_complex_polar imag part at (r=%g,t=%g)", r, t);
0154 }
0155
0156 i = 0;
0157
0158 while (list[i].f)
0159 {
0160 struct f t = list[i];
0161 TYPE(gsl_complex) z = gsl_complex_rect (t.x, t.y);
0162 ATOMIC f = (t.f) (z);
0163 gsl_test_rel (f, t.fx, tol, "%s at (%g,%g)", t.name, t.x, t.y);
0164 i++;
0165 }
0166
0167 i = 0;
0168
0169 while (listz[i].f)
0170 {
0171 struct fz t = listz[i];
0172 TYPE(gsl_complex) z = gsl_complex_rect (t.x, t.y);
0173 TYPE(gsl_complex) fz = (t.f) (z);
0174 ATOMIC fx = GSL_REAL (fz), fy = GSL_IMAG (fz);
0175
0176 #ifdef DEBUG
0177 printf("x = "); gsl_ieee_fprintf_double (stdout, &t.x); printf("\n");
0178 printf("y = "); gsl_ieee_fprintf_double (stdout, &t.y); printf("\n");
0179 printf("fx = "); gsl_ieee_fprintf_double (stdout, &fx); printf("\n");
0180 printf("ex = "); gsl_ieee_fprintf_double (stdout, &t.fx); printf("\n");
0181 printf("fy = "); gsl_ieee_fprintf_double (stdout, &fy); printf("\n");
0182 printf("ey = "); gsl_ieee_fprintf_double (stdout, &t.fy); printf("\n");
0183 #endif
0184
0185 gsl_test_rel (fx, t.fx, 10.0 * tol, "%s real part at (%g,%g)", t.name, t.x, t.y);
0186 gsl_test_rel (fy, t.fy, 10.0 * tol, "%s imag part at (%g,%g)", t.name, t.x, t.y);
0187 i++;
0188 }
0189
0190 i = 0;
0191
0192 while (listzz[i].f)
0193 {
0194 struct fzz t = listzz[i];
0195 TYPE(gsl_complex) z1 = gsl_complex_rect (t.x1, t.y1);
0196 TYPE(gsl_complex) z2 = gsl_complex_rect (t.x2, t.y2);
0197 TYPE(gsl_complex) fz = (t.f) (z1, z2);
0198 ATOMIC fx = GSL_REAL (fz), fy = GSL_IMAG (fz);
0199
0200 #ifdef DEBUG
0201 printf("x1 = "); gsl_ieee_fprintf_double (stdout, &t.x1); printf("\n");
0202 printf("y1 = "); gsl_ieee_fprintf_double (stdout, &t.y1); printf("\n");
0203 printf("x2 = "); gsl_ieee_fprintf_double (stdout, &t.x2); printf("\n");
0204 printf("y2 = "); gsl_ieee_fprintf_double (stdout, &t.y2); printf("\n");
0205 printf("fx = "); gsl_ieee_fprintf_double (stdout, &fx); printf("\n");
0206 printf("ex = "); gsl_ieee_fprintf_double (stdout, &t.fx); printf("\n");
0207 printf("fy = "); gsl_ieee_fprintf_double (stdout, &fy); printf("\n");
0208 printf("ey = "); gsl_ieee_fprintf_double (stdout, &t.fy); printf("\n");
0209 #endif
0210
0211 gsl_test_rel (fx, t.fx, 1.0e3 * tol, "%s real part at (%g,%g;%g,%g)", t.name, t.x1, t.y1, t.x2, t.y2);
0212 gsl_test_rel (fy, t.fy, 1.0e3 * tol, "%s imag part at (%g,%g;%g,%g)", t.name, t.x1, t.y1, t.x2, t.y2);
0213 i++;
0214 }
0215
0216 i = 0;
0217
0218 while (listreal[i].f)
0219 {
0220 struct freal t = listreal[i];
0221 TYPE(gsl_complex) fz = (t.f) (t.x);
0222 ATOMIC fx = GSL_REAL (fz), fy = GSL_IMAG (fz);
0223
0224 #ifdef DEBUG
0225 printf("x = "); gsl_ieee_fprintf_double (stdout, &t.x); printf("\n");
0226 printf("fx = "); gsl_ieee_fprintf_double (stdout, &fx); printf("\n");
0227 printf("ex = "); gsl_ieee_fprintf_double (stdout, &t.fx); printf("\n");
0228 printf("fy = "); gsl_ieee_fprintf_double (stdout, &fy); printf("\n");
0229 printf("ey = "); gsl_ieee_fprintf_double (stdout, &t.fy); printf("\n");
0230 #endif
0231
0232 gsl_test_rel (fx, t.fx, tol, "%s real part at (%g,0)", t.name, t.x);
0233 gsl_test_rel (fy, t.fy, tol, "%s imag part at (%g,0)", t.name, t.x);
0234 i++;
0235 }
0236
0237 i = 0;
0238
0239 while (listzreal[i].f)
0240 {
0241 struct fzreal t = listzreal[i];
0242 TYPE(gsl_complex) z = gsl_complex_rect (t.x, t.y);
0243 TYPE(gsl_complex) fz = (t.f) (z, t.a);
0244 ATOMIC fx = GSL_REAL (fz), fy = GSL_IMAG (fz);
0245
0246 #ifdef DEBUG
0247 printf("x = "); gsl_ieee_fprintf_double (stdout, &t.x); printf("\n");
0248 printf("y = "); gsl_ieee_fprintf_double (stdout, &t.y); printf("\n");
0249 printf("a = "); gsl_ieee_fprintf_double (stdout, &t.a); printf("\n");
0250 printf("fx = "); gsl_ieee_fprintf_double (stdout, &fx); printf("\n");
0251 printf("ex = "); gsl_ieee_fprintf_double (stdout, &t.fx); printf("\n");
0252 printf("fy = "); gsl_ieee_fprintf_double (stdout, &fy); printf("\n");
0253 printf("ey = "); gsl_ieee_fprintf_double (stdout, &t.fy); printf("\n");
0254 #endif
0255
0256 gsl_test_rel (fx, t.fx, 10.0 * tol, "%s real part at (%g,0)", t.name, t.x);
0257 gsl_test_rel (fy, t.fy, 10.0 * tol, "%s imag part at (%g,0)", t.name, t.x);
0258 i++;
0259 }
0260
0261 return 0;
0262 }