[59b9b675] | 1 | /** |
---|
| 2 | * Schulz function |
---|
| 3 | */ |
---|
| 4 | |
---|
| 5 | #include "schulz.h" |
---|
| 6 | #include <math.h> |
---|
| 7 | #include <stdio.h> |
---|
| 8 | #include <stdlib.h> |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | /** |
---|
| 12 | * Function to evaluate 1D Schulz function. |
---|
| 13 | * The function is normalized to the 'scale' parameter. |
---|
| 14 | * |
---|
| 15 | * f(x)=scale * math.pow(z+1, z+1)*math.pow((R), z)* |
---|
| 16 | * math.exp(-R*(z+1))/(center*gamma(z+1) |
---|
| 17 | * z= math.pow[(1/(sigma/center),2]-1 |
---|
| 18 | * R= x/center |
---|
| 19 | * @param pars: parameters of the schulz |
---|
| 20 | * @param x: x-value |
---|
| 21 | * @return: function value |
---|
| 22 | */ |
---|
| 23 | double schulz_analytical_1D(SchulzParameters *pars, double x) { |
---|
| 24 | double z = pow(pars->center/ pars->sigma, 2)-1; |
---|
| 25 | double R= x/pars->center; |
---|
| 26 | double zz= z+1; |
---|
| 27 | double expo; |
---|
| 28 | expo = log(pars->scale)+zz*log(zz)+z*log(R)-R*zz-log(pars->center)-lgamma(zz); |
---|
| 29 | |
---|
| 30 | return exp(expo);//pars->scale * pow(zz,zz) * pow(R,z) * exp(-1*R*zz)/((pars->center) * tgamma(zz)) ; |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | /** |
---|
| 34 | * Function to evaluate 2D schulz function |
---|
| 35 | * The function is normalized to the 'scale' parameter. |
---|
| 36 | * |
---|
| 37 | * f(x,y) = Schulz(x) * Schulz(y) |
---|
| 38 | * |
---|
| 39 | * where both Shulzs share the same parameters. |
---|
| 40 | * |
---|
| 41 | * @param pars: parameters of the schulz |
---|
| 42 | * @param x: x-value |
---|
| 43 | * @param y: y-value |
---|
| 44 | * @return: function value |
---|
| 45 | */ |
---|
| 46 | double schulz_analytical_2DXY(SchulzParameters *pars, double x, double y) { |
---|
| 47 | return schulz_analytical_1D(pars, x) * schulz_analytical_1D(pars, y); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | /** |
---|
| 51 | * Function to evaluate 2D Schulz function |
---|
| 52 | * The function is normalized to the 'scale' parameter. |
---|
| 53 | * |
---|
| 54 | * f(x,y) = Schulz(x) * Schulz(y) |
---|
| 55 | * |
---|
| 56 | * where both Gaussians share the same parameters. |
---|
| 57 | * |
---|
| 58 | * @param pars: parameters of the gaussian |
---|
| 59 | * @param length: length of the (x,y) vector |
---|
| 60 | * @param phi: angle relative to x |
---|
| 61 | * @return: function value |
---|
| 62 | */ |
---|
| 63 | double schulz_analytical_2D(SchulzParameters *pars, double length, double phi) { |
---|
| 64 | return schulz_analytical_2DXY(pars, length*cos(phi), length*sin(phi)); |
---|
| 65 | } |
---|