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

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 2c041e9 was 2c63e80e, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Re #5 fixing samsmodels compilation on MSVC

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