source: sasview/sansmodels/src/sans/models/c_extensions/schulz.c @ ecc58e72

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 ecc58e72 was eba9885, checked in by Gervaise Alina <gervyh@…>, 15 years ago

code for evalDistribution

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[eba9885]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 */
23double 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        return pars->scale * pow(zz,zz) * pow(R,z) * exp(-1*R*zz)/((pars->center) * tgamma(zz)) ;
28}
29
30/**
31 * Function to evaluate 2D schulz function
32 * The function is normalized to the 'scale' parameter.
33 *
34 * f(x,y) = Schulz(x) * Schulz(y)
35 *
36 * where both Shulzs share the same parameters.
37 *
38 * @param pars: parameters of the schulz
39 * @param x: x-value
40 * @param y: y-value
41 * @return: function value
42 */
43double schulz_analytical_2DXY(SchulzParameters *pars, double x, double y) {
44    return schulz_analytical_1D(pars, x) * schulz_analytical_1D(pars, y);
45} 
46
47/**
48 * Function to evaluate 2D Schulz  function
49 * The function is normalized to the 'scale' parameter.
50 *
51 * f(x,y) = Schulz(x) * Schulz(y)
52 *
53 * where both Gaussians share the same parameters.
54 *
55 * @param pars: parameters of the gaussian
56 * @param length: length of the (x,y) vector
57 * @param phi: angle relative to x
58 * @return: function value
59 */
60double schulz_analytical_2D(SchulzParameters *pars, double length, double phi) {
61    return schulz_analytical_2DXY(pars, length*cos(phi), length*sin(phi));
62} 
Note: See TracBrowser for help on using the repository browser.