42 #include <tpia_target.h>
43 #include <tpia_misc.h>
45 #if defined __cplusplus
50 static int _tpia_Legendre_getOrder( statusMessageReporting *smr, xData_element *LegendreOrder, tpia_Legendre *Legendre, tpia_EqualProbableBinSpectra *l );
56 memset( Legendre, 0,
sizeof( tpia_Legendre ) );
58 Legendre->binned.numberOfLs = 0;
59 Legendre->binned.ls = NULL;
69 for( i = 0; i < Legendre->binned.numberOfLs; i++ )
xData_free( smr, Legendre->binned.ls[i].energies );
71 Legendre->binned.ls = (tpia_EqualProbableBinSpectra*)
xData_free( smr, Legendre->binned.ls );
81 xData_elementList *list;
91 if( ( Legendre->binned.ls = (tpia_EqualProbableBinSpectra*) xData_malloc2( smr, list->n *
sizeof( tpia_EqualProbableBinSpectra ), 1,
"ls" ) ) != NULL ) {
92 Legendre->binned.numberOfLs = 0;
93 for( i = 0; i < list->n; i++ ) {
94 if( ( status =
_tpia_Legendre_getOrder( smr, list->items[i].element, Legendre, &(Legendre->binned.ls[i]) ) ) != 0 )
break;
95 Legendre->binned.numberOfLs++;
106 static int _tpia_Legendre_getOrder( statusMessageReporting *smr, xData_element *LegendreOrder, tpia_Legendre *, tpia_EqualProbableBinSpectra *l ) {
109 xData_Int
n, nBins, lOrder;
118 l->nBins = (int) nBins;
119 l->numberOfEs = (int) n;
127 int tpia_Legendre_SampleEp( statusMessageReporting *smr, tpia_Legendre *Legendre,
int sampleMu, tpia_decaySamplingInfo *decaySamplingInfo ) {
129 tpia_EqualProbableBinSpectra *binned_l0 = Legendre->binned.ls;
136 if( Legendre->binned.numberOfLs > 0 ) {
137 if( sampleMu ) decaySamplingInfo->mu = 2. *
tpia_misc_drng( decaySamplingInfo->rng, decaySamplingInfo->rngState ) - 1.;
139 if( decaySamplingInfo->mu <= -1 ) decaySamplingInfo->mu = nextafter( -1., 0. );
142 if( decaySamplingInfo->mu <= -1 ) decaySamplingInfo->mu = _nextafter( -1., 0. );
147 decaySamplingInfo->Ep = Ep; }
155 #if defined __cplusplus
xData_Int xData_convertAttributeTo_xData_Int(statusMessageReporting *smr, xData_element *element, const char *name, xData_Int *n)
int xData_addToAccessed(statusMessageReporting *, xData_element *element, int increment)
int tpia_Legendre_getFromElement(statusMessageReporting *smr, xData_element *LegendreElement, tpia_Legendre *Legendre)
int tpia_Legendre_SampleEp(statusMessageReporting *smr, tpia_Legendre *Legendre, int sampleMu, tpia_decaySamplingInfo *decaySamplingInfo)
tpia_EqualProbableBinSpectrum * tpia_misc_getEqualProbableBin(statusMessageReporting *smr, xData_element *parent, xData_Int *n, xData_Int *nBins)
int tpia_misc_setMessageError_Element(statusMessageReporting *smr, void *userInterface, xData_element *element, const char *file, int line, int code, const char *fmt,...)
int tpia_Legendre_initialize(statusMessageReporting *smr, tpia_Legendre *Legendre)
double tpia_misc_drng(double(*rng)(void *), void *rngState)
int tpia_frame_setFromString(statusMessageReporting *smr, const char *forItem, const char *value, int dimension, tpia_data_frame *frame)
xData_elementList * xData_getElementsByTagNameAndSort(statusMessageReporting *smr, xData_element *element, const char *tagName, const char *sortAttributeName, xData_sortElementFunc sortFunction)
int tpia_frame_setFromElement(statusMessageReporting *smr, xData_element *element, int dimension, tpia_data_frame *frame)
void * xData_free(statusMessageReporting *, void *p)
int tpia_misc_sampleEqualProbableBin(statusMessageReporting *, tpia_decaySamplingInfo *decaySamplingInfo, double e_in, int nBins, tpia_EqualProbableBinSpectra *binned, double *value_)
static int _tpia_Legendre_getOrder(statusMessageReporting *smr, xData_element *LegendreOrder, tpia_Legendre *Legendre, tpia_EqualProbableBinSpectra *l)
int tpia_Legendre_release(statusMessageReporting *smr, tpia_Legendre *Legendre)
void xData_freeElementList(statusMessageReporting *smr, xData_elementList *list)