Changeset 896abb3 in sasview for pr_inversion/c_extensions


Ignore:
Timestamp:
May 23, 2008 2:31:50 PM (17 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
ffca8f2
Parents:
a1718df
Message:

Added docs

Location:
pr_inversion/c_extensions
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pr_inversion/c_extensions/Cinvertor.c

    r43c0a8e r896abb3  
    1  
     1/** 
     2 * C implementation of the P(r) inversion 
     3 * Cinvertor is the base class for the Invertor class 
     4 * and provides the underlying computations. 
     5 *  
     6 */ 
    27#include <Python.h> 
    38#include "structmember.h" 
     
    2934 
    3035// Class definition 
     36/** 
     37 * C implementation of the P(r) inversion 
     38 * Cinvertor is the base class for the Invertor class 
     39 * and provides the underlying computations. 
     40 *  
     41 */ 
    3142typedef struct { 
    3243    PyObject_HEAD     
     44    /// Internal data structure 
    3345    Invertor_params params;  
    3446} Cinvertor; 
     
    7082}; 
    7183 
     84const char set_x_doc[] =  
     85        "Function to set the x data\n" 
     86        "Takes an array of doubles as input.\n" 
     87        " @return: number of entries found"; 
    7288 
    7389/** 
     
    102118        return Py_BuildValue("i", self->params.npoints);         
    103119} 
     120 
     121const char get_x_doc[] =  
     122        "Function to get the x data\n" 
     123        "Takes an array of doubles as input.\n" 
     124        " @return: number of entries found"; 
    104125 
    105126static PyObject * get_x(Cinvertor *self, PyObject *args) { 
     
    126147} 
    127148 
     149const char set_y_doc[] =  
     150        "Function to set the y data\n" 
     151        "Takes an array of doubles as input.\n" 
     152        " @return: number of entries found"; 
     153 
    128154/** 
    129155 * Function to set the y data 
     
    157183        return Py_BuildValue("i", self->params.ny);      
    158184} 
     185 
     186const char get_y_doc[] =  
     187        "Function to get the y data\n" 
     188        "Takes an array of doubles as input.\n" 
     189        " @return: number of entries found"; 
    159190 
    160191static PyObject * get_y(Cinvertor *self, PyObject *args) { 
     
    181212} 
    182213 
     214const char set_err_doc[] =  
     215        "Function to set the err data\n" 
     216        "Takes an array of doubles as input.\n" 
     217        " @return: number of entries found"; 
     218 
    183219/** 
    184220 * Function to set the x data 
     
    212248        return Py_BuildValue("i", self->params.nerr);    
    213249} 
     250 
     251const char get_err_doc[] =  
     252        "Function to get the err data\n" 
     253        "Takes an array of doubles as input.\n" 
     254        " @return: number of entries found"; 
    214255 
    215256static PyObject * get_err(Cinvertor *self, PyObject *args) { 
     
    235276        return Py_BuildValue("i", self->params.npoints);         
    236277} 
     278 
     279const char is_valid_doc[] =  
     280        "Check the validity of the stored data\n" 
     281        " @return: Returns the number of points if it's all good, -1 otherwise"; 
    237282 
    238283/** 
     
    249294} 
    250295 
     296const char set_dmax_doc[] =  
     297        "Sets the maximum distance\n"; 
     298 
    251299/** 
    252300 * Sets the maximum distance 
     
    260308} 
    261309 
     310const char get_dmax_doc[] =  
     311        "Gets the maximum distance\n"; 
     312 
    262313/** 
    263314 * Gets the maximum distance 
     
    266317        return Py_BuildValue("d", self->params.d_max);   
    267318} 
     319 
     320const char set_qmin_doc[] =  
     321        "Sets the minimum q\n"; 
    268322 
    269323/** 
     
    278332} 
    279333 
     334const char get_qmin_doc[] =  
     335        "Gets the minimum q\n"; 
     336 
    280337/** 
    281338 * Gets the minimum q 
     
    285342} 
    286343 
     344const char set_qmax_doc[] =  
     345        "Sets the maximum q\n"; 
    287346 
    288347/** 
     
    297356} 
    298357 
     358const char get_qmax_doc[] =  
     359        "Gets the maximum q\n"; 
     360 
    299361/** 
    300362 * Gets the maximum q 
     
    304366} 
    305367 
     368const char set_alpha_doc[] =  
     369        "Sets the alpha parameter\n"; 
    306370 
    307371static PyObject * set_alpha(Cinvertor *self, PyObject *args) { 
     
    313377} 
    314378 
     379const char get_alpha_doc[] =  
     380        "Gets the alpha parameter\n"; 
     381 
    315382/** 
    316383 * Gets the maximum distance 
     
    320387} 
    321388 
     389const char get_nx_doc[] =  
     390        "Gets the number of x points\n"; 
     391 
    322392/** 
    323393 * Gets the number of x points 
     
    327397} 
    328398 
     399const char get_ny_doc[] =  
     400        "Gets the number of y points\n"; 
     401 
    329402/** 
    330403 * Gets the number of y points 
     
    334407} 
    335408 
     409const char get_nerr_doc[] =  
     410        "Gets the number of err points\n"; 
     411 
    336412/** 
    337413 * Gets the number of error points 
     
    341417} 
    342418 
     419 
     420const char residuals_doc[] =  
     421        "Function to call to evaluate the residuals\n" 
     422        "for P(r) inversion\n" 
     423        " @param args: input parameters\n" 
     424        " @return: list of residuals"; 
    343425 
    344426/** 
     
    391473        return residuals; 
    392474} 
     475 
     476const char pr_residuals_doc[] =  
     477        "Function to call to evaluate the residuals\n" 
     478        "for P(r) minimization (for testing purposes)\n" 
     479        " @param args: input parameters\n" 
     480        " @return: list of residuals"; 
     481 
    393482/** 
    394483 * Function to call to evaluate the residuals 
     
    442531} 
    443532 
     533const char get_iq_doc[] =  
     534        "Function to call to evaluate the scattering intensity\n" 
     535        " @param args: c-parameters, and q\n" 
     536        " @return: I(q)"; 
     537 
    444538/** 
    445539 * Function to call to evaluate the scattering intensity 
     
    460554} 
    461555 
     556const char get_pr_doc[] =  
     557        "Function to call to evaluate P(r)\n" 
     558        " @param args: c-parameters and r\n" 
     559        " @return: P(r)"; 
     560 
    462561/** 
    463562 * Function to call to evaluate P(r) 
     
    478577} 
    479578 
     579const char get_pr_err_doc[] =  
     580        "Function to call to evaluate P(r) with errors\n" 
     581        " @param args: c-parameters and r\n" 
     582        " @return: (P(r),dP(r))"; 
     583 
    480584/** 
    481585 * Function to call to evaluate P(r) with errors 
     
    502606} 
    503607 
     608const char basefunc_ft_doc[] =  
     609        "Returns the value of the nth Fourier transofrmed base function\n" 
     610        " @param args: c-parameters, n and q\n" 
     611        " @return: nth Fourier transformed base function, evaluated at q"; 
     612 
    504613static PyObject * basefunc_ft(Cinvertor *self, PyObject *args) { 
    505614        double d_max, q; 
     
    511620} 
    512621 
     622const char oscillations_doc[] =  
     623        "Returns the value of the oscillation figure of merit for\n" 
     624        "the given set of coefficients. For a sphere, the oscillation\n" 
     625        "figure of merit is 1.1.\n" 
     626        " @param args: c-parameters\n" 
     627        " @return: oscillation figure of merit"; 
     628 
    513629static PyObject * oscillations(Cinvertor *self, PyObject *args) { 
    514630        double *pars; 
     
    526642} 
    527643 
     644const char get_peaks_doc[] =  
     645        "Returns the number of peaks in the output P(r) distrubution\n" 
     646        "for the given set of coefficients.\n" 
     647        " @param args: c-parameters\n" 
     648        " @return: number of P(r) peaks"; 
     649 
    528650static PyObject * get_peaks(Cinvertor *self, PyObject *args) { 
    529651        double *pars; 
     
    540662         
    541663} 
     664 
     665const char get_positive_doc[] =  
     666        "Returns the fraction of P(r) that is positive over\n" 
     667        "the full range of r for the given set of coefficients.\n" 
     668        " @param args: c-parameters\n" 
     669        " @return: fraction of P(r) that is positive"; 
    542670 
    543671static PyObject * get_positive(Cinvertor *self, PyObject *args) { 
     
    555683         
    556684} 
     685 
     686const char get_pos_err_doc[] =  
     687        "Returns the fraction of P(r) that is 1 standard deviation\n" 
     688        "above zero over the full range of r for the given set of coefficients.\n" 
     689        " @param args: c-parameters\n" 
     690        " @return: fraction of P(r) that is positive"; 
    557691 
    558692static PyObject * get_pos_err(Cinvertor *self, PyObject *args) { 
     
    575709} 
    576710 
     711 
     712const char eeeget_qmin_doc[] = "\ 
     713This is a multiline doc string.\n\ 
     714\n\ 
     715This is the second line."; 
     716const char eeeset_qmin_doc[] =  
     717        "This is a multiline doc string.\n" 
     718        "\n" 
     719        "This is the second line."; 
     720 
    577721static PyMethodDef Cinvertor_methods[] = { 
    578                    {"residuals", (PyCFunction)residuals, METH_VARARGS, "Get the list of residuals"}, 
    579                    {"pr_residuals", (PyCFunction)pr_residuals, METH_VARARGS, "Get the list of residuals"}, 
    580                    {"set_x", (PyCFunction)set_x, METH_VARARGS, ""}, 
    581                    {"get_x", (PyCFunction)get_x, METH_VARARGS, ""}, 
    582                    {"set_y", (PyCFunction)set_y, METH_VARARGS, ""}, 
    583                    {"get_y", (PyCFunction)get_y, METH_VARARGS, ""}, 
    584                    {"set_err", (PyCFunction)set_err, METH_VARARGS, ""}, 
    585                    {"get_err", (PyCFunction)get_err, METH_VARARGS, ""}, 
    586                    {"set_dmax", (PyCFunction)set_dmax, METH_VARARGS, ""}, 
    587                    {"get_dmax", (PyCFunction)get_dmax, METH_VARARGS, ""}, 
    588                    {"set_qmin", (PyCFunction)set_qmin, METH_VARARGS, ""}, 
    589                    {"get_qmin", (PyCFunction)get_qmin, METH_VARARGS, ""}, 
    590                    {"set_qmax", (PyCFunction)set_qmax, METH_VARARGS, ""}, 
    591                    {"get_qmax", (PyCFunction)get_qmax, METH_VARARGS, ""}, 
    592                    {"set_alpha", (PyCFunction)set_alpha, METH_VARARGS, ""}, 
    593                    {"get_alpha", (PyCFunction)get_alpha, METH_VARARGS, ""}, 
    594                    {"get_nx", (PyCFunction)get_nx, METH_VARARGS, ""}, 
    595                    {"get_ny", (PyCFunction)get_ny, METH_VARARGS, ""}, 
    596                    {"get_nerr", (PyCFunction)get_nerr, METH_VARARGS, ""}, 
    597                    {"iq", (PyCFunction)get_iq, METH_VARARGS, ""}, 
    598                    {"pr", (PyCFunction)get_pr, METH_VARARGS, ""}, 
    599                    {"get_pr_err", (PyCFunction)get_pr_err, METH_VARARGS, ""}, 
    600                    {"is_valid", (PyCFunction)is_valid, METH_VARARGS, ""}, 
    601                    {"basefunc_ft", (PyCFunction)basefunc_ft, METH_VARARGS, ""}, 
    602                    {"oscillations", (PyCFunction)oscillations, METH_VARARGS, ""}, 
    603                    {"get_peaks", (PyCFunction)get_peaks, METH_VARARGS, ""}, 
    604                    {"get_positive", (PyCFunction)get_positive, METH_VARARGS, ""}, 
    605                    {"get_pos_err", (PyCFunction)get_pos_err, METH_VARARGS, ""}, 
     722                   {"residuals", (PyCFunction)residuals, METH_VARARGS, residuals_doc}, 
     723                   {"pr_residuals", (PyCFunction)pr_residuals, METH_VARARGS, pr_residuals_doc}, 
     724                   {"set_x", (PyCFunction)set_x, METH_VARARGS, set_x_doc}, 
     725                   {"get_x", (PyCFunction)get_x, METH_VARARGS, get_x_doc}, 
     726                   {"set_y", (PyCFunction)set_y, METH_VARARGS, set_y_doc}, 
     727                   {"get_y", (PyCFunction)get_y, METH_VARARGS, get_y_doc}, 
     728                   {"set_err", (PyCFunction)set_err, METH_VARARGS, set_err_doc}, 
     729                   {"get_err", (PyCFunction)get_err, METH_VARARGS, get_err_doc}, 
     730                   {"set_dmax", (PyCFunction)set_dmax, METH_VARARGS, set_dmax_doc}, 
     731                   {"get_dmax", (PyCFunction)get_dmax, METH_VARARGS, get_dmax_doc}, 
     732                   {"set_qmin", (PyCFunction)set_qmin, METH_VARARGS, set_qmin_doc}, 
     733                   {"get_qmin", (PyCFunction)get_qmin, METH_VARARGS, get_qmin_doc}, 
     734                   {"set_qmax", (PyCFunction)set_qmax, METH_VARARGS, set_qmax_doc}, 
     735                   {"get_qmax", (PyCFunction)get_qmax, METH_VARARGS, get_qmax_doc}, 
     736                   {"set_alpha", (PyCFunction)set_alpha, METH_VARARGS, set_alpha_doc}, 
     737                   {"get_alpha", (PyCFunction)get_alpha, METH_VARARGS, get_alpha_doc}, 
     738                   {"get_nx", (PyCFunction)get_nx, METH_VARARGS, get_nx_doc}, 
     739                   {"get_ny", (PyCFunction)get_ny, METH_VARARGS, get_ny_doc}, 
     740                   {"get_nerr", (PyCFunction)get_nerr, METH_VARARGS, get_nerr_doc}, 
     741                   {"iq", (PyCFunction)get_iq, METH_VARARGS, get_iq_doc}, 
     742                   {"pr", (PyCFunction)get_pr, METH_VARARGS, get_pr_doc}, 
     743                   {"get_pr_err", (PyCFunction)get_pr_err, METH_VARARGS, get_pr_err_doc}, 
     744                   {"is_valid", (PyCFunction)is_valid, METH_VARARGS, is_valid_doc}, 
     745                   {"basefunc_ft", (PyCFunction)basefunc_ft, METH_VARARGS, basefunc_ft_doc}, 
     746                   {"oscillations", (PyCFunction)oscillations, METH_VARARGS, oscillations_doc}, 
     747                   {"get_peaks", (PyCFunction)get_peaks, METH_VARARGS, get_peaks_doc}, 
     748                   {"get_positive", (PyCFunction)get_positive, METH_VARARGS, get_positive_doc}, 
     749                   {"get_pos_err", (PyCFunction)get_pos_err, METH_VARARGS, get_pos_err_doc}, 
    606750    
    607751   {NULL} 
  • pr_inversion/c_extensions/__init__.py

    r9e8dc22 r896abb3  
     1""" 
     2    C extensions to provide the P(r) inversion computations. 
     3""" 
  • pr_inversion/c_extensions/invertor.h

    r43c0a8e r896abb3  
    22#define invertor_h 
    33 
    4  
     4/** 
     5 * Internal data structure for P(r) inversion 
     6 */ 
    57typedef struct { 
     8        /// Maximum distance between any two points in the system 
    69    double d_max; 
     10    /// q data 
    711    double *x; 
     12    /// I(q) data 
    813    double *y; 
     14    /// dI(q) data 
    915    double *err; 
     16    /// Number of q points 
    1017    int npoints;     
     18    /// Number of I(q) points 
    1119    int ny;     
     20    /// Number of dI(q) points 
    1221    int nerr;   
     22    /// Alpha value 
    1323    double alpha; 
     24    /// Minimum q to include in inversion 
    1425    double q_min; 
     26    /// Maximum q to include in inversion 
    1527    double q_max; 
    1628} Invertor_params;  
Note: See TracChangeset for help on using the changeset viewer.