[59b9b675] | 1 | /** |
---|
| 2 | * Lorentzian function |
---|
| 3 | */ |
---|
| 4 | |
---|
| 5 | #include "lorentzian.h" |
---|
| 6 | #include <math.h> |
---|
| 7 | #include <stdio.h> |
---|
| 8 | #include <stdlib.h> |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | /** |
---|
| 12 | * Function to evaluate 1D Lorentzian function. |
---|
| 13 | * The function is normalized to the 'scale' parameter. |
---|
| 14 | * |
---|
| 15 | * f(x)=scale * 1/pi 0.5gamma / [ (x-x_0)^2 + (0.5gamma)^2 ] |
---|
| 16 | * |
---|
| 17 | * @param pars: parameters of the Lorentzian |
---|
| 18 | * @param x: x-value |
---|
| 19 | * @return: function value |
---|
| 20 | */ |
---|
| 21 | double lorentzian_analytical_1D(LorentzianParameters *pars, double x) { |
---|
| 22 | double delta2 = pow( (x-pars->center), 2); |
---|
| 23 | return pars->scale / acos(-1.0) * 0.5*pars->gamma / |
---|
| 24 | (delta2 + 0.25*pars->gamma*pars->gamma); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | * Function to evaluate 2D Lorentzian function |
---|
| 29 | * The function is normalized to the 'scale' parameter. |
---|
| 30 | * |
---|
| 31 | * f(x,y) = Lorentzian(x) * Lorentzian(y) |
---|
| 32 | * |
---|
| 33 | * where both Lorentzians share the same parameters. |
---|
| 34 | * |
---|
| 35 | * @param pars: parameters of the Lorentzian |
---|
| 36 | * @param x: x-value |
---|
| 37 | * @param y: y-value |
---|
| 38 | * @return: function value |
---|
| 39 | */ |
---|
| 40 | double lorentzian_analytical_2DXY(LorentzianParameters *pars, double x, double y) { |
---|
| 41 | return lorentzian_analytical_1D(pars, x) * lorentzian_analytical_1D(pars, y); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | /** |
---|
| 45 | * Function to evaluate 2D Lorentzian function |
---|
| 46 | * The function is normalized to the 'scale' parameter. |
---|
| 47 | * |
---|
| 48 | * f(x,y) = Lorentzian(x) * Lorentzian(y) |
---|
| 49 | * |
---|
| 50 | * where both Lorentzians share the same parameters. |
---|
| 51 | * |
---|
| 52 | * @param pars: parameters of the Lorentzian |
---|
| 53 | * @param length: length of the (x,y) vector |
---|
| 54 | * @param phi: angle relative to x |
---|
| 55 | * @return: function value |
---|
| 56 | */ |
---|
| 57 | double lorentzian_analytical_2D(LorentzianParameters *pars, double length, double phi) { |
---|
| 58 | return lorentzian_analytical_2DXY(pars, length*cos(phi), length*sin(phi)); |
---|
| 59 | } |
---|