source: sasview/sansmodels/src/sans/models/c_extensions/lorentzian.c @ 1aaa579

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 1aaa579 was ae3ce4e, checked in by Mathieu Doucet <doucetm@…>, 17 years ago

Moving sansmodels to trunk

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[ae3ce4e]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 */
21double 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 */
40double 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 */
57double lorentzian_analytical_2D(LorentzianParameters *pars, double length, double phi) {
58    return lorentzian_analytical_2DXY(pars, length*cos(phi), length*sin(phi));
59} 
Note: See TracBrowser for help on using the repository browser.