source: sasview/sansmodels/src/c_models/schulz.cpp @ 046af80

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 046af80 was cd127d2, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

add lgamma on windows

  • Property mode set to 100644
File size: 2.5 KB
RevLine 
[20d91bd]1/**
2        This software was developed by the University of Tennessee as part of the
3        Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
4        project funded by the US National Science Foundation.
5
6        If you use DANSE applications to do scientific research that leads to
7        publication, we ask that you acknowledge the use of the software with the
8        following sentence:
9
10        "This work benefited from DANSE software developed under NSF award DMR-0520547."
11
12        copyright 2008, University of Tennessee
13 */
14
15#include <math.h>
16#include "parameters.hh"
17#include <stdio.h>
18using namespace std;
19#include "schulz.h"
20
[cd127d2]21#if defined(_MSC_VER)
22#include "gamma_win.h"
23#endif
24
[20d91bd]25Schulz :: Schulz() {
26  scale  = Parameter(1.0, true);
27  sigma  = Parameter(1.0, true);
28  center = Parameter(0.0, true);
29}
30
31/**
32 * Function to evaluate 1D scattering function
33/**
34 * Function to evaluate 1D Schulz function.
35 * The function is normalized to the 'scale' parameter.
36 *
37 * f(x)=scale * math.pow(z+1, z+1)*math.pow((R), z)*
38 *          math.exp(-R*(z+1))/(center*gamma(z+1)
39 *    z= math.pow[(1/(sigma/center),2]-1
40 *    R= x/center
41 *
42 * @param q: q-value
43 * @return: function value
44 */
45double Schulz :: operator()(double q) {
46  double z = pow(center()/ sigma(), 2)-1;
47  double R= q/center();
48  double zz= z+1;
49  double expo;
50  expo = log(scale())+zz*log(zz)+z*log(R)-R*zz-log(center())-lgamma(zz);
51
52  return exp(expo);//scale * pow(zz,zz) * pow(R,z) * exp(-1*R*zz)/((center) * tgamma(zz)) ;
53}
54
55/**
56 * Function to evaluate 2D schulz function
57 * The function is normalized to the 'scale' parameter.
58 *
59 * f(x,y) = Schulz(x) * Schulz(y)
60 *
61 * where both Shulzs share the same parameters.
62 * @param q_x: value of Q along x
63 * @param q_y: value of Q along y
64 * @return: function value
65 */
66double Schulz :: operator()(double qx, double qy) {
67  return (*this).operator()(qx) * (*this).operator()(qy);
68}
69
70/**
71 * Function to evaluate 2D schulz function
72 * The function is normalized to the 'scale' parameter.
73 *
74 * f(x,y) = Schulz(x) * Schulz(y)
75 *
76 * where both Shulzs share the same parameters.
77 * @param pars: parameters of the cylinder
78 * @param q: q-value
79 * @param phi: angle phi
80 * @return: function value
81 */
82double Schulz :: evaluate_rphi(double q, double phi) {
83  double qx = q*cos(phi);
84  double qy = q*sin(phi);
85  return (*this).operator()(qx, qy);
86}
87/**
88 * Function to calculate effective radius
89 * @return: effective radius value
90 */
91double Schulz :: calculate_ER() {
92  //NOT implemented yet!!!
93  return 0.0;
94}
Note: See TracBrowser for help on using the repository browser.