Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
GIDI::Functions::XYs1d Class Reference

#include <GIDI.hpp>

Inheritance diagram for GIDI::Functions::XYs1d:

Public Member Functions

 XYs1d ()
 XYs1d (Axes const &a_axes, ptwXY_interpolation m_interpolation, int a_index=0, double a_outerDomainValue=0.0)
 XYs1d (Axes const &a_axes, ptwXY_interpolation m_interpolation, std::vector< double > const &a_values, int a_index=0, double a_outerDomainValue=0.0)
 XYs1d (Axes const &a_axes, ptwXY_interpolation m_interpolation, std::vector< double > const &a_xs, std::vector< double > const &a_ys, int a_index=0, double a_outerDomainValue=0.0)
 XYs1d (Axes const &a_axes, ptwXYPoints *a_ptwXY, int a_index=0, double a_outerDomainValue=0.0)
 XYs1d (Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, Suite *a_parent)
 XYs1d (XYs1d const &a_XYs1d)
 ~XYs1d ()
XYs1doperator= (XYs1d const &a_rhs)
std::size_t size () const
ptwXYPoints const * ptwXY () const
ptwXYPointsptwXY ()
std::pair< double, double > operator[] (std::size_t a_index) const
XYs1d operator+ (XYs1d const &a_XYs1d) const
XYs1doperator+= (XYs1d const &a_XYs1d)
XYs1d operator- (XYs1d const &a_XYs1d) const
XYs1doperator-= (XYs1d const &a_XYs1d)
XYs1d operator* (double a_value) const
XYs1d operator* (XYs1d const &a_XYs1d) const
XYs1doperator*= (double a_value)
XYs1doperator*= (XYs1d const &a_XYs1d)
double domainMin () const
double domainMax () const
std::vector< double > xs () const
std::vector< double > ys () const
std::vector< double > ysMappedToXs (std::vector< double > const &a_xs, std::size_t *a_offset) const
XYs1d domainSlice (double a_domainMin, double a_domainMax, bool a_fill) const
XYs1d domainSliceMax (double a_domainMax) const
double evaluate (double a_x1) const
void mapToXsAndAdd (std::size_t a_offset, std::vector< double > const &a_Xs, std::vector< double > &a_results, double a_scaleFactor) const
XYs1dasXYs1d (bool a_asLinlin, double a_accuray, double a_lowerEps, double a_upperEps) const
double integrate (double a_dommainMin, double a_dommainMax)
double normalize ()
Xs_pdf_cdf1d toXs_pdf_cdf1d ()
void toXMLList_func (GUPI::WriteInfo &a_writeInfo, std::string const &a_indent, bool a_embedded, bool a_inRegions) const
void write (FILE *a_file, std::string const &a_format) const
Public Member Functions inherited from GIDI::Functions::Function1dForm
 Function1dForm (std::string const &a_moniker, FormType a_type, ptwXY_interpolation a_interpolation, int a_index, double a_outerDomainValue)
 Function1dForm (std::string const &a_moniker, FormType a_type, Axes const &a_axes, ptwXY_interpolation a_interpolation, int a_index, double a_outerDomainValue)
 Function1dForm (Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, FormType a_type, Suite *a_suite=nullptr)
 Function1dForm (Function1dForm const &a_form)
 ~Function1dForm ()
Function1dFormoperator= (Function1dForm const &a_rhs)
void print (std::string const &a_format) const
Public Member Functions inherited from GIDI::Functions::FunctionForm
 FunctionForm (std::string const &a_moniker, FormType a_type, int a_dimension, ptwXY_interpolation a_interpolation, int a_index, double a_outerDomainValue)
 FunctionForm (std::string const &a_moniker, FormType a_type, int a_dimension, Axes const &a_axes, ptwXY_interpolation a_interpolation, int a_index, double a_outerDomainValue)
 FunctionForm (Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, FormType a_type, int a_dimension, Suite *a_suite=nullptr)
 FunctionForm (FunctionForm const &a_form)
 ~FunctionForm ()
FunctionFormoperator= (FunctionForm const &a_rhs)
int dimension () const
int index () const
double outerDomainValue () const
void setOuterDomainValue (double a_outerDomainValue)
Axes const & axes () const
Axesaxes ()
ptwXY_interpolation interpolation () const
void setInterpolation (ptwXY_interpolation a_interpolation)
std::string interpolationString () const
void toXMLList (GUPI::WriteInfo &a_writeInfo, std::string const &a_indent) const
Public Member Functions inherited from GIDI::Form
 Form (FormType a_type)
 Form (std::string const &a_moniker, FormType a_type, std::string const &a_label)
 Form (HAPI::Node const &a_node, SetupInfo &a_setupInfo, FormType a_type, Suite *a_suite=nullptr)
 Form (Form const &a_form)
virtual ~Form ()
Formoperator= (Form const &a_rhs)
Suiteparent () const
std::string const & label () const
void setLabel (std::string const &a_label)
virtual std::string actualMoniker () const
std::string const & keyName () const
void setKeyName (std::string const &a_keyName)
std::string const & keyValue () const
virtual void setKeyValue (std::string const &a_keyName) const
FormType type () const
Form const * sibling (std::string a_label) const
GUPI::AncestryfindInAncestry3 (LUPI_maybeUnused std::string const &a_item)
GUPI::Ancestry const * findInAncestry3 (LUPI_maybeUnused std::string const &a_item) const
std::string xlinkItemKey () const
Public Member Functions inherited from GUPI::Ancestry
 Ancestry (std::string const &a_moniker, std::string const &a_attribute="")
virtual ~Ancestry ()
Ancestryoperator= (Ancestry const &a_ancestry)
std::string const & moniker () const
void setMoniker (std::string const &a_moniker)
Ancestryancestor ()
Ancestry const * ancestor () const
void setAncestor (Ancestry *a_ancestor)
std::string attribute () const
Ancestryroot ()
Ancestry const * root () const
bool isChild (Ancestry *a_instance)
bool isParent (Ancestry *a_parent)
bool isRoot () const
AncestryfindInAncestry (std::string const &a_href)
Ancestry const * findInAncestry (std::string const &a_href) const
virtual AncestryfindInAncestry3 (std::string const &a_item)=0
virtual Ancestry const * findInAncestry3 (std::string const &a_item) const =0
virtual LUPI_HOST void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
std::string toXLink () const
void printXML () const

Static Public Member Functions

static XYs1dmakeConstantXYs1d (Axes const &a_axes, double a_domainMin, double a_domainMax, double a_value)
Static Public Member Functions inherited from GUPI::Ancestry
static std::string buildXLinkItemKey (std::string const &a_name, std::string const &a_key)

Detailed Description

Class to store GNDS <XYs1d> node.

Definition at line 1082 of file GIDI.hpp.

Constructor & Destructor Documentation

◆ XYs1d() [1/7]

GIDI::Functions::XYs1d::XYs1d ( )

Constructor an empty XYs1d instance.

Definition at line 30 of file GIDI_XYs1d.cc.

30 :
32
33 double dummy[2];
34
35 m_ptwXY = ptwXY_create2( nullptr, interpolation( ), 0, 0, 0, dummy, 0 );
36}
#define GIDI_XYs1dChars
Definition GIDI.hpp:288
Function1dForm(std::string const &a_moniker, FormType a_type, ptwXY_interpolation a_interpolation, int a_index, double a_outerDomainValue)
Definition GIDI_form.cc:348
ptwXY_interpolation interpolation() const
Definition GIDI.hpp:1015
@ ptwXY_interpolationLinLin
Definition ptwXY.h:37
ptwXYPoints * ptwXY_create2(statusMessageReporting *smr, ptwXY_interpolation interpolation, int64_t primarySize, int64_t secondarySize, int64_t length, double const *xy, int userFlag)
Definition ptwXY_core.c:128

Referenced by asXYs1d(), domainSlice(), domainSliceMax(), makeConstantXYs1d(), operator*(), operator*(), operator*=(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator=(), XYs1d(), XYs1d(), XYs1d(), XYs1d(), XYs1d(), XYs1d(), and XYs1d().

◆ XYs1d() [2/7]

GIDI::Functions::XYs1d::XYs1d ( Axes const & a_axes,
ptwXY_interpolation a_interpolation,
int a_index = 0,
double a_outerDomainValue = 0.0 )

Constructor that creates an empty instance.

Parameters
a_axes[in] The axes to copy for this.
a_interpolation[in] The interpolation along the outer most independent axis and the dependent axis.
a_index[in] Currently not used.
a_outerDomainValue[in] If embedded in a higher dimensional function, the value of the domain of the next higher dimension.
Returns

Definition at line 48 of file GIDI_XYs1d.cc.

48 :
49 Function1dForm( GIDI_XYs1dChars, FormType::XYs1d, a_axes, a_interpolation, a_index, a_outerDomainValue ) {
50
51 double dummy[2];
52
53 m_ptwXY = ptwXY_create2( nullptr, a_interpolation, 0, 0, 0, dummy, 0 );
54}

◆ XYs1d() [3/7]

GIDI::Functions::XYs1d::XYs1d ( Axes const & a_axes,
ptwXY_interpolation a_interpolation,
std::vector< double > const & a_values,
int a_index = 0,
double a_outerDomainValue = 0.0 )

Constructor that create an instance from a list of doubles via a_values which must have an even number of values.

Parameters
a_axes[in] The axes to copy for this.
a_interpolation[in] The interpolation along the outer most independent axis and the dependent axis.
a_values[in] The data values as ( x_1, y_1, x_2, y_2, ..., x_n, y_n ). Must be an even number since they are n-pairs of xy values.
a_index[in] Currently not used.
a_outerDomainValue[in] If embedded in a higher dimensional function, the value of the domain of the next higher dimension.
Returns

Definition at line 67 of file GIDI_XYs1d.cc.

67 :
68 Function1dForm( GIDI_XYs1dChars, FormType::XYs1d, a_axes, a_interpolation, a_index, a_outerDomainValue ) {
69
70 int64_t length = static_cast<int64_t>( a_values.size( ) ) / 2;
71
72 m_ptwXY = ptwXY_create2( nullptr, a_interpolation, length, 0, length, a_values.data( ), 0 );
73}

◆ XYs1d() [4/7]

GIDI::Functions::XYs1d::XYs1d ( Axes const & a_axes,
ptwXY_interpolation a_interpolation,
std::vector< double > const & a_xs,
std::vector< double > const & a_ys,
int a_index = 0,
double a_outerDomainValue = 0.0 )

Constructor that creates an instance from a list of x values and a list of y values. The size of a_xs and a_ys must be the same.

Parameters
a_axes[in] The axes to copy for this.
a_interpolation[in] The interpolation along the outer most independent axis and the dependent axis.
a_xs[in] The data values as ( x_1, x_2, ..., x_n ).
a_ys[in] The data values as ( y_1, y_2, ..., y_n ).
a_index[in] Currently not used.
a_outerDomainValue[in] If embedded in a higher dimensional function, the value of the domain of the next higher dimension.
Returns

Definition at line 88 of file GIDI_XYs1d.cc.

89 :
90 Function1dForm( GIDI_XYs1dChars, FormType::XYs1d, a_axes, a_interpolation, a_index, a_outerDomainValue ) {
91
92 if( a_xs.size( ) != a_ys.size( ) ) throw Exception( "XYs1d::XYs1d: xs and ys not the same size" );
93 int64_t length = static_cast<int64_t>( a_xs.size( ) );
94
95 m_ptwXY = ptwXY_createFrom_Xs_Ys2( nullptr, a_interpolation, length, 0, length, a_xs.data( ), a_ys.data( ), 0 );
96}
ptwXYPoints * ptwXY_createFrom_Xs_Ys2(statusMessageReporting *smr, ptwXY_interpolation interpolation, int64_t primarySize, int64_t secondarySize, int64_t length, double const *Xs, double const *Ys, int userFlag)
Definition ptwXY_core.c:161

◆ XYs1d() [5/7]

GIDI::Functions::XYs1d::XYs1d ( Axes const & a_axes,
ptwXYPoints * a_ptwXY,
int a_index = 0,
double a_outerDomainValue = 0.0 )

Constructor that uses an existing ptwXYPoints instance. The m_ptwXY member is set to ptwXYPoints (i.e., this XYs1d instance now owns the inputted ptwXYPoints instance).

Parameters
a_axes[in] The axes to copy for this.
a_ptwXY[in] The ptwXYPoints instance that this takes ownership of.*
a_index[in] Currently not used.
a_outerDomainValue[in] If embedded in a higher dimensional function, the value of the domain of the next higher dimension.
Returns

Definition at line 109 of file GIDI_XYs1d.cc.

109 :
110 Function1dForm( GIDI_XYs1dChars, FormType::XYs1d, a_axes, ptwXY_getInterpolation( a_ptwXY ), a_index, a_outerDomainValue ),
111 m_ptwXY( a_ptwXY ) {
112
113}
ptwXY_interpolation ptwXY_getInterpolation(ptwXYPoints *ptwXY)
Definition ptwXY_core.c:518

◆ XYs1d() [6/7]

GIDI::Functions::XYs1d::XYs1d ( Construction::Settings const & a_construction,
HAPI::Node const & a_node,
SetupInfo & a_setupInfo,
Suite * a_parent )

Constructs the instance from a HAPI::Node instance.

Parameters
a_construction[in] Used to pass user options for parsing.
a_node[in] The XYs1d HAPI::Node to be parsed and to construct the instance.
a_setupInfo[in] Information create my the Protare constructor to help in parsing.
a_parent[in] If imbedded in a two dimensional function, its pointers.

Definition at line 124 of file GIDI_XYs1d.cc.

124 :
125 Function1dForm( a_construction, a_node, a_setupInfo, FormType::XYs1d, a_parent ) {
126
127 HAPI::Node values = a_node.child( GIDI_valuesChars );
128 nf_Buffer<double> vals;
129 parseValuesOfDoubles( a_construction, values, a_setupInfo, vals );
130
131 int primarySize = static_cast<int>( vals.size() / 2 ), secondarySize = 0;
132 double *dvals = new double[vals.size()]; // Not sure we really need a copy here.
133 for( size_t idx = 0; idx < vals.size(); idx++ ) dvals[idx] = vals[idx];
134 m_ptwXY = ptwXY_create( NULL, interpolation( ), interpolationString( ).c_str( ), 12, 1e-3, primarySize, secondarySize, primarySize, dvals, 0 );
135 delete[] dvals;
136 if( m_ptwXY == nullptr ) throw Exception( "XYs1d::XYs1d: ptwXY_fromString failed" );
137}
#define GIDI_valuesChars
Definition GIDI.hpp:260
std::string interpolationString() const
Definition GIDI.hpp:1017
void parseValuesOfDoubles(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, nf_Buffer< double > &a_vector)
Definition GIDI_misc.cc:88
ptwXYPoints * ptwXY_create(statusMessageReporting *smr, ptwXY_interpolation interpolation, char const *interpolationString, double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize, int64_t length, double const *xy, int userFlag)
Definition ptwXY_core.c:110

◆ XYs1d() [7/7]

GIDI::Functions::XYs1d::XYs1d ( XYs1d const & a_XYs1d)

The XYs1d copy constructor.

Parameters
a_XYs1d[in] The XYs1d instance to copy.

Definition at line 145 of file GIDI_XYs1d.cc.

145 :
146 Function1dForm( a_XYs1d ),
147 m_ptwXY( nullptr ) {
148
149 m_ptwXY = ptwXY_clone2( nullptr, a_XYs1d.ptwXY( ) );
150 if( m_ptwXY == nullptr ) throw Exception( "XYs1d::XYs1d:2: ptwXY_clone2 failed" );
151}
ptwXYPoints * ptwXY_clone2(statusMessageReporting *smr, ptwXYPoints const *ptwXY)
Definition ptwXY_core.c:312

◆ ~XYs1d()

GIDI::Functions::XYs1d::~XYs1d ( )

Definition at line 156 of file GIDI_XYs1d.cc.

156 {
157
158 ptwXY_free( m_ptwXY );
159}
ptwXYPoints * ptwXY_free(ptwXYPoints *ptwXY)
Definition ptwXY_core.c:782

Member Function Documentation

◆ asXYs1d()

XYs1d * GIDI::Functions::XYs1d::asXYs1d ( bool a_asLinlin,
double a_accuray,
double a_lowerEps,
double a_upperEps ) const
virtual

This methods returns an XYs1d representation of this. The calling function owns the created instance and is responible for freeing it.

Parameters
a_asLinlin[in] If true, the inpolatation of the returned XYs1d instance will always be lin-lin. Otherwise, the interpolation depends on the child 1d functions. This argument is not needed or used for this class.
a_accuracy[in] The accuracy use to convert the data to lin=lin interpolation if needed. This argument is not needed or used for this cl
a_lowerEps[in] The dulling of the point at the domain minimum.
a_upperEps[in] The dulling of the point at the domain maximum.
Returns
A pointer to an XYs1d instance that must be freed by the calling function.

Reimplemented from GIDI::Functions::Function1dForm.

Definition at line 537 of file GIDI_XYs1d.cc.

537 {
538
539 ptwXYPoints *ptwXY2 = nullptr;
540
541 if( m_ptwXY->interpolation == ptwXY_interpolationFlat ) {
542 ptwXY2 = ptwXY_flatInterpolationToLinear( nullptr, m_ptwXY, a_lowerEps, a_upperEps ); }
543 else {
544 ptwXY2 = ptwXY_toOtherInterpolation( nullptr, const_cast<ptwXYPoints *>( m_ptwXY ), ptwXY_interpolationLinLin, a_accuracy );
545 }
546
547
548 if( ptwXY2 == nullptr ) return( nullptr );
549
550 return( new XYs1d( axes( ), ptwXY2 ) );
551}
Axes const & axes() const
Definition GIDI.hpp:1012
@ ptwXY_interpolationFlat
Definition ptwXY.h:38
struct ptwXYPoints_s ptwXYPoints
ptwXYPoints * ptwXY_toOtherInterpolation(statusMessageReporting *smr, ptwXYPoints *ptwXY, ptwXY_interpolation interpolation, double accuracy)
ptwXYPoints * ptwXY_flatInterpolationToLinear(statusMessageReporting *smr, ptwXYPoints *ptwXY, double lowerEps, double upperEps)

Referenced by GIDI::calculate1dMultiGroupDataInComponent(), GIDI::calculate1dMultiGroupFissionEnergyRelease(), and GIDI::Reaction::modifyCrossSection().

◆ domainMax()

double GIDI::Functions::XYs1d::domainMax ( ) const
inlinevirtual

Returns last x1 value of this.

Implements GIDI::Functions::FunctionForm.

Definition at line 1115 of file GIDI.hpp.

Referenced by GIDI::calculate1dMultiGroupDataInComponent(), and GIDI::Reaction::modifyCrossSection().

◆ domainMin()

double GIDI::Functions::XYs1d::domainMin ( ) const
inlinevirtual

Returns first x1 value of this.

Implements GIDI::Functions::FunctionForm.

Definition at line 1114 of file GIDI.hpp.

Referenced by GIDI::calculate1dMultiGroupDataInComponent(), and GIDI::Reaction::modifyCrossSection().

◆ domainSlice()

XYs1d GIDI::Functions::XYs1d::domainSlice ( double a_domainMin,
double a_domainMax,
bool a_fill ) const

Returns an XYs1d instance that is a domain slice of this from domainMin to domainMax. If the minimum (maximum) of this is greater (less) than domainMin (domainMax) that domain is unchanged. If this's minimum is less than domainMin, a_fill is true and there is no point at domainMin then an interpolated point is added at domainMin. Similarly for domainMax.

Parameters
a_domainMin[in] The minimum domain for the returned instance if this' minimum is less than **domainMin*.
a_domainMax[in] The maximum domain for the returned instance if this' maximum is less than **domainMax*.
a_fill[in] If true, values at domainMin and domainMax are added if needed.
Returns
An XYs1d instance.

Definition at line 445 of file GIDI_XYs1d.cc.

445 {
446
447 LUPI::StatusMessageReporting smr;
448 ptwXYPoints *ptwXY1 = ptwXY_clone2( smr.smr( ), m_ptwXY );
449 if( ptwXY1 == nullptr ) throw Exception( smr.constructMessage( "XYs1d::domainSlice", -1, true ) );
450
451 ptwXYPoints *ptwXYSliced = ptwXY_domainSlice( nullptr, ptwXY1, a_domainMin, a_domainMax, 10, a_fill ? 1 : 0 );
452 ptwXY_free( ptwXY1 );
453 if( ptwXYSliced == nullptr ) throw Exception( smr.constructMessage( "XYs1d::domainSlice", -1, true ) );
454
455 return( XYs1d( axes( ), ptwXYSliced, index( ), outerDomainValue( ) ) );
456}
double outerDomainValue() const
Definition GIDI.hpp:1010
statusMessageReporting * smr()
Definition LUPI.hpp:112
std::string constructMessage(std::string a_prefix, int a_reports=1, bool a_clear=false)
ptwXYPoints * ptwXY_domainSlice(statusMessageReporting *smr, ptwXYPoints *ptwXY, double domainMin, double domainMax, int64_t secondarySize, int fill)
Definition ptwXY_core.c:422

Referenced by GIDI::Reaction::modifyCrossSection().

◆ domainSliceMax()

XYs1d GIDI::Functions::XYs1d::domainSliceMax ( double a_domainMax) const

Returns an XYs1d instance that is this from its domain minimum to domainMax.

Parameters
a_domainMax[in] The maximum domain
Returns
An XYs1d instance.

Definition at line 465 of file GIDI_XYs1d.cc.

465 {
466
467 ptwXYPoints *_ptwXY = ptwXY_clone2( nullptr, m_ptwXY );
468 if( _ptwXY == nullptr ) throw Exception( "domainSliceMax: ptwXY_clone2 failed" );
469
470 ptwXYPoints *ptwXYSliced = ptwXY_domainMaxSlice( nullptr, _ptwXY, a_domainMax, 10, 1 );
471 ptwXY_free( _ptwXY );
472 if( ptwXYSliced == nullptr ) throw Exception( "domainSliceMax: ptwXY_domainMaxSlice failed" );
473
474 return( XYs1d( axes( ), ptwXYSliced ) );
475}
ptwXYPoints * ptwXY_domainMaxSlice(statusMessageReporting *smr, ptwXYPoints *ptwXY, double domainMax, int64_t secondarySize, int fill)
Definition ptwXY_core.c:499

◆ evaluate()

double GIDI::Functions::XYs1d::evaluate ( double a_x1) const
virtual

The y value of this at the domain value a_x1.

Parameters
a_x1[in] Domain value to evaluate this at.
Returns
The value of this at the domain value a_x1.

Implements GIDI::Functions::Function1dForm.

Definition at line 484 of file GIDI_XYs1d.cc.

484 {
485
486 std::size_t length = static_cast<std::size_t>( ptwXY_length( nullptr, m_ptwXY ) );
487 if( length == 0 ) throw Exception( "XYs1d::evaluate: XYs1d has no datum." );
488
489 ptwXYPoint *point = ptwXY_getPointAtIndex_Unsafely( m_ptwXY, 0 );
490 if( point->x >= a_x1 ) return( point->y );
491
492 point = ptwXY_getPointAtIndex_Unsafely( m_ptwXY, static_cast<int64_t>( length - 1 ) );
493 if( point->x <= a_x1 ) return( point->y );
494
495 double y;
496 nfu_status status = ptwXY_getValueAtX( nullptr, m_ptwXY, a_x1, &y );
497 if( status != nfu_Okay ) throw Exception( "XYs1d::evaluate: status != nfu_Okay" );
498 return( y );
499}
@ nfu_Okay
enum nfu_status_e nfu_status
int64_t ptwXY_length(statusMessageReporting *smr, ptwXYPoints *ptwXY)
Definition ptwXY_core.c:793
struct ptwXYPoint_s ptwXYPoint
ptwXYPoint * ptwXY_getPointAtIndex_Unsafely(ptwXYPoints const *ptwXY, int64_t index)
nfu_status ptwXY_getValueAtX(statusMessageReporting *smr, ptwXYPoints *ptwXY, double x, double *y)
double y
Definition ptwXY.h:64
double x
Definition ptwXY.h:64

Referenced by GIDI::Functions::Regions1d::asXYs1d(), GIDI::Reaction::modifyCrossSection(), and GIDI::Reaction::Reaction().

◆ integrate()

double GIDI::Functions::XYs1d::integrate ( double a_dommainMin,
double a_dommainMax )

This method returns this that is norimalized (i.e., its integral if 1.). The returned value is the integral of this before being normalized.

Returns
A double.

Definition at line 560 of file GIDI_XYs1d.cc.

560 {
561
562 double value = 0.0;
563 LUPI::StatusMessageReporting smr;
564
565 nfu_status status = ptwXY_integrate( smr.smr( ), m_ptwXY, a_dommainMin, a_dommainMax, &value );
566 if( status != nfu_Okay ) throw Exception( smr.constructMessage( "XYs1d::normalize", -1, true ) );
567
568 return( value );
569}
nfu_status ptwXY_integrate(statusMessageReporting *smr, ptwXYPoints *ptwXY, double domainMin, double domainMax, double *value)

◆ makeConstantXYs1d()

XYs1d * GIDI::Functions::XYs1d::makeConstantXYs1d ( Axes const & a_axes,
double a_domainMin,
double a_domainMax,
double a_value )
static

This is a factory function for the XYs1d class that creates a XYs1d instance with the constant value of a_value for the domain from a_domainMin to a_domainMax.

Parameters
a_axes[in] The axes for the function.
a_domainMin[in] The minimum of the domain for which the function is defined.
a_domainMax[in] The maximum of the domain for which the function is defined.
a_value[in] The y-value of the function over its domain.

Definition at line 678 of file GIDI_XYs1d.cc.

678 {
679
680 std::vector<double> points( 4 );
681
682 points[0] = a_domainMin;
683 points[1] = a_value;
684 points[2] = a_domainMax;
685 points[3] = a_value;
686
687 return( new XYs1d( a_axes, ptwXY_interpolationLinLin, points ) );
688}

Referenced by GIDI::calculate1dMultiGroupDataInComponent(), and GIDI::Reaction::modifyCrossSection().

◆ mapToXsAndAdd()

void GIDI::Functions::XYs1d::mapToXsAndAdd ( std::size_t a_offset,
std::vector< double > const & a_Xs,
std::vector< double > & a_results,
double a_scaleFactor ) const
virtual

Evaluates this at the X-values in a_Xs[a_offset:] and adds the results to a_results[a_offset:]. a_Xs and a_results must be the same size otherwise a throw is executed.

Parameters
a_offset[in] The offset in a_Xs to start.
a_Xs[in] The list of domain values to evaluate this at.
a_results[in] The list whose values are added to by the Y-values of this.
a_scaleFactor[in] A factor applied to each evaluation before it is added to a_results.

Reimplemented from GIDI::Functions::Function1dForm.

Definition at line 511 of file GIDI_XYs1d.cc.

511 {
512
513 if( a_Xs.size( ) != a_results.size( ) ) throw Exception( "XYs1d::mapToXsAndAdd: a_Xs.size( ) != a_results.size( )" );
514
515 LUPI::StatusMessageReporting smr;
516 int64_t length = static_cast<int64_t>( a_Xs.size( ) );
517
518 nfu_status status = ptwXY_mapToXsAndAdd( smr.smr( ), m_ptwXY, static_cast<int64_t>( a_offset ), length,
519 a_Xs.data( ), a_results.data( ), a_scaleFactor );
520 if( ( status != nfu_Okay ) && ( status != nfu_tooFewPoints ) )
521 throw Exception( smr.constructMessage( "XYs1d::mapToXsAndAdd", -1, true ) );
522}
@ nfu_tooFewPoints
nfu_status ptwXY_mapToXsAndAdd(statusMessageReporting *a_smr, ptwXYPoints *a_ptwXY, int64_t a_offset, int64_t a_length, double const *a_Xs, double *a_results, double a_scaleFractor)

◆ normalize()

double GIDI::Functions::XYs1d::normalize ( )

This method returns this that is norimalized (i.e., its integral if 1.). The returned value is the integral of this before being normalized.

Returns
A double.

Definition at line 578 of file GIDI_XYs1d.cc.

578 {
579
580 double value = 0.0;
581 LUPI::StatusMessageReporting smr;
582
583 nfu_status status = ptwXY_integrateDomain( smr.smr( ), m_ptwXY, &value );
584 if( status != nfu_Okay ) throw Exception( smr.constructMessage( "XYs1d::normalize", -1, true ) );
585
586 status = ptwXY_normalize( smr.smr( ), m_ptwXY );
587 if( status != nfu_Okay ) throw Exception( smr.constructMessage( "XYs1d::normalize", -1, true ) );
588
589 return( value );
590}
nfu_status ptwXY_normalize(statusMessageReporting *smr, ptwXYPoints *ptwXY1)
nfu_status ptwXY_integrateDomain(statusMessageReporting *smr, ptwXYPoints *ptwXY, double *value)

◆ operator*() [1/2]

XYs1d GIDI::Functions::XYs1d::operator* ( double a_value) const

Multiplies this by a double and returns the result.

Parameters
a_value[in] Number with this instance.
Returns
An XYs1d instance that is the product of this and a_rhs.

Definition at line 286 of file GIDI_XYs1d.cc.

286 {
287
288 XYs1d xys1d( *this );
289
290 xys1d *= a_value;
291 return( xys1d );
292}

◆ operator*() [2/2]

XYs1d GIDI::Functions::XYs1d::operator* ( XYs1d const & a_rhs) const

Multiplies this with another XYs1d instances and returns the result.

Parameters
a_rhs[in] The XYs1d instance to multiply with this instance.
Returns
An XYs1d instance that is the product of this and a_rhs.

Definition at line 302 of file GIDI_XYs1d.cc.

302 {
303
304 XYs1d xys1d( *this );
305
306 xys1d *= a_rhs;
307 return( xys1d );
308}

◆ operator*=() [1/2]

XYs1d & GIDI::Functions::XYs1d::operator*= ( double a_value)

Multiplies a double with this.

Parameters
a_rhs[in] The XYs1d instance to subtract from this instance.
Returns
This instance.

Definition at line 318 of file GIDI_XYs1d.cc.

318 {
319
320 LUPI::StatusMessageReporting smr;
321
322 nfu_status status = ptwXY_mul_double( smr.smr( ), m_ptwXY, a_value );
323 if( status != nfu_Okay )
324 throw Exception( smr.constructMessage( "XYs1d::operator*=: ptwXY_mul_double failed. ", -1, true ) );
325
326 return( *this );
327}
nfu_status ptwXY_mul_double(statusMessageReporting *smr, ptwXYPoints *ptwXY, double value)

◆ operator*=() [2/2]

XYs1d & GIDI::Functions::XYs1d::operator*= ( XYs1d const & a_rhs)

Multiplies this with an XYs1d instance.

Parameters
a_rhs[in] The XYs1d instance to subtract from this instance.
Returns
This instance.

Definition at line 337 of file GIDI_XYs1d.cc.

337 {
338
339 ptwXYPoints *mul, *ptwXY1, *ptwXY2;
340 LUPI::StatusMessageReporting smr;
341
342 mutualifyDomains( m_ptwXY, a_rhs.ptwXY( ), &ptwXY1, &ptwXY2 );
343 mul = ptwXY_mul2_ptwXY( smr.smr( ), ptwXY1, ptwXY2 );
344 ptwXY_free( ptwXY1 );
345 ptwXY_free( ptwXY2 );
346 if( mul == nullptr )
347 throw Exception( smr.constructMessage( "XYs1d::operator*=: ptwXY_mul2_ptwXY failed. ", -1, true ) );
348
349 ptwXY_free( m_ptwXY );
350 m_ptwXY = mul;
351
352 return( *this );
353}
ptwXYPoints * ptwXY_mul2_ptwXY(statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2)

◆ operator+()

XYs1d GIDI::Functions::XYs1d::operator+ ( XYs1d const & a_rhs) const

Adds two XYs1d instances and returns the result.

Parameters
a_rhs[in] The XYs1d instance to add to this instance.
Returns
An XYs1d instance that is the sum of this and a_rhs.

Definition at line 205 of file GIDI_XYs1d.cc.

205 {
206
207 XYs1d xys1d( *this );
208
209 xys1d += a_rhs;
210 return( xys1d );
211}

◆ operator+=()

XYs1d & GIDI::Functions::XYs1d::operator+= ( XYs1d const & a_rhs)

Adds an XYs1d instance to this.

Parameters
a_rhs[in] The XYs1d instance to add to this instance.
Returns
This instance.

Definition at line 220 of file GIDI_XYs1d.cc.

220 {
221
222 ptwXYPoints *sum, *ptwXY1, *ptwXY2;
223 LUPI::StatusMessageReporting smr;
224
225 mutualifyDomains( m_ptwXY, a_rhs.ptwXY( ), &ptwXY1, &ptwXY2 );
226 sum = ptwXY_add_ptwXY( smr.smr( ), ptwXY1, ptwXY2 );
227 ptwXY_free( ptwXY1 );
228 ptwXY_free( ptwXY2 );
229 if( sum == nullptr )
230 throw Exception( smr.constructMessage( "XYs1d::operator+=: ptwXY_add_ptwXY failed. ", -1, true ) );
231
232 ptwXY_free( m_ptwXY );
233 m_ptwXY = sum;
234
235 return( *this );
236}
ptwXYPoints * ptwXY_add_ptwXY(statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2)

◆ operator-()

XYs1d GIDI::Functions::XYs1d::operator- ( XYs1d const & a_rhs) const

Subtracts two XYs1d instances and returns the result.

Parameters
a_rhs[in] The XYs1d instance to substract from this instance.
Returns
An XYs1d instance that is the difference of this and a_rhs.

Definition at line 245 of file GIDI_XYs1d.cc.

245 {
246
247 XYs1d xys1d( *this );
248
249 xys1d -= a_rhs;
250 return( xys1d );
251}

◆ operator-=()

XYs1d & GIDI::Functions::XYs1d::operator-= ( XYs1d const & a_rhs)

Subtracts an XYs1d instance from this.

Parameters
a_rhs[in] The XYs1d instance to subtract from this instance.
Returns
This instance.

Definition at line 260 of file GIDI_XYs1d.cc.

260 {
261
262 ptwXYPoints *sum, *ptwXY1, *ptwXY2;
263 LUPI::StatusMessageReporting smr;
264
265 mutualifyDomains( m_ptwXY, a_rhs.ptwXY( ), &ptwXY1, &ptwXY2 );
266 sum = ptwXY_sub_ptwXY( smr.smr( ), ptwXY1, ptwXY2 );
267 ptwXY_free( ptwXY1 );
268 ptwXY_free( ptwXY2 );
269 if( sum == nullptr )
270 throw Exception( smr.constructMessage( "XYs1d::operator-=: ptwXY_sub_ptwXY failed. ", -1, true ) );
271
272 ptwXY_free( m_ptwXY );
273 m_ptwXY = sum;
274
275 return( *this );
276}
ptwXYPoints * ptwXY_sub_ptwXY(statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2)

◆ operator=()

XYs1d & GIDI::Functions::XYs1d::operator= ( XYs1d const & a_rhs)

The assignment operator. This method sets the members of this to those of a_rhs except for those not set by base classes.

Parameters
a_rhs[in] Instance whose member are used to set the members of this.

Definition at line 168 of file GIDI_XYs1d.cc.

168 {
169
170 if( this != &a_rhs ) {
172
173 LUPI::StatusMessageReporting smr;
174 m_ptwXY = ptwXY_clone2( smr.smr( ), a_rhs.ptwXY( ) );
175 if( m_ptwXY == nullptr ) throw Exception( smr.constructMessage( "XYs1d::operator=", -1, true ) );
176 }
177
178 return( *this );
179}
Function1dForm & operator=(Function1dForm const &a_rhs)
Definition GIDI_form.cc:405

◆ operator[]()

std::pair< double, double > GIDI::Functions::XYs1d::operator[] ( std::size_t a_index) const

The element access methods that returns a point (i.e., an x1, y pair).

Parameters
a_index[in] The index of the element to access.
Returns
The x1, y values at a_index.

Definition at line 188 of file GIDI_XYs1d.cc.

188 {
189
190 if( (int64_t) a_index >= ptwXY_length( nullptr, m_ptwXY ) ) throw Exception( "XYs1d::operator[]: index out of bounds." );
191
192 ptwXYPoint *point = ptwXY_getPointAtIndex_Unsafely( m_ptwXY, (int64_t) a_index );
193 std::pair<double, double> CPPPoint( point->x, point->y );
194
195 return( CPPPoint );
196}

◆ ptwXY() [1/2]

ptwXYPoints * GIDI::Functions::XYs1d::ptwXY ( )
inline

Returns the value of the m_ptwXY member.

Definition at line 1102 of file GIDI.hpp.

◆ ptwXY() [2/2]

ptwXYPoints const * GIDI::Functions::XYs1d::ptwXY ( ) const
inline

◆ size()

std::size_t GIDI::Functions::XYs1d::size ( ) const
inline

Returns the number of points (i.e., x,y pairs) in this.

Definition at line 1100 of file GIDI.hpp.

Referenced by domainMax(), GIDI::Reaction::modifyCrossSection(), toXMLList_func(), xs(), MCGIDI::Functions::XYs1d::XYs1d(), ys(), and ysMappedToXs().

◆ toXMLList_func()

void GIDI::Functions::XYs1d::toXMLList_func ( GUPI::WriteInfo & a_writeInfo,
std::string const & a_indent,
bool a_embedded,
bool a_inRegions ) const
virtual

Fills the argument a_writeInfo with the XML lines that represent this. Recursively enters each sub-node.

Parameters
a_writeInfo[in/out] Instance containing incremental indentation and other information and stores the appended lines.
a_indent[in] The amount to indent this node.
a_embedded[in] If true, this function is embedded in a higher dimensional function.
a_inRegions[in] If true, this is in a Regions1d container.

Reimplemented from GIDI::Functions::FunctionForm.

Definition at line 625 of file GIDI_XYs1d.cc.

625 {
626
627 std::string indent2 = a_writeInfo.incrementalIndent( a_indent );
628 std::string attributes;
629
630 if( a_embedded ) {
632 else {
633 if( a_inRegions ) {
634 attributes = a_writeInfo.addAttribute( GIDI_indexChars, intToString( index( ) ) ); }
635 else {
636 if( label( ) != "" ) attributes = a_writeInfo.addAttribute( GIDI_labelChars, label( ) );
637 }
638 }
639
641
642 a_writeInfo.addNodeStarter( a_indent, moniker( ), attributes );
643 axes( ).toXMLList( a_writeInfo, indent2 );
644
645 std::vector<double> doubles( 2 * size( ) );
646 for( std::size_t i1 = 0; i1 < size( ); ++i1 ) {
647 std::pair<double, double> point = (*this)[i1];
648 doubles[2*i1] = point.first;
649 doubles[2*i1+1] = point.second;
650 }
651
652 doublesToXMLList( a_writeInfo, indent2, doubles );
653 a_writeInfo.addNodeEnder( moniker( ) );
654}
#define GIDI_outerDomainValueChars
Definition GIDI.hpp:436
#define GIDI_interpolationChars
Definition GIDI.hpp:434
#define GIDI_labelChars
Definition GIDI.hpp:438
#define GIDI_indexChars
Definition GIDI.hpp:437
void toXMLList(GUPI::WriteInfo &a_writeInfo, std::string const &a_indent="") const
Definition GIDI_axes.cc:113
std::string const & label() const
Definition GIDI.hpp:658
std::size_t size() const
Definition GIDI.hpp:1100
std::string const & moniker() const
Definition GUPI.hpp:102
void addNodeEnder(std::string const &a_moniker)
Definition GUPI.hpp:59
std::string incrementalIndent(std::string const &indent)
Definition GUPI.hpp:52
void addNodeStarter(std::string const &indent, std::string const &a_moniker, std::string const &a_attributes="")
Definition GUPI.hpp:55
std::string addAttribute(std::string const &a_name, std::string const &a_value) const
Definition GUPI.hpp:60
void doublesToXMLList(GUPI::WriteInfo &a_writeInfo, std::string const &a_indent, std::vector< double > const &a_values, std::size_t a_start=0, bool a_newLine=true, std::string const &a_valueType="")
Definition GIDI_misc.cc:180
std::string intToString(int a_value)
Definition GIDI_misc.cc:415
std::string doubleToShortestString(double a_value, int a_significantDigits=15, int a_favorEFormBy=0)
Definition LUPI_misc.cc:349

◆ toXs_pdf_cdf1d()

Xs_pdf_cdf1d GIDI::Functions::XYs1d::toXs_pdf_cdf1d ( )

This method returns a Xs_pdf_cdf1d representation of this.

Returns
An instance of Xs_pdf_cdf1d.

Definition at line 598 of file GIDI_XYs1d.cc.

598 {
599// FIXME, need to check that two consecutive cdf values are not the same.
600
601 std::vector<double> xs1 = xs( );
602 std::vector<double> pdf1 = ys( );
603
604 LUPI::StatusMessageReporting smr;
605 ptwXPoints *ptwX_cdf = ptwXY_runningIntegral( smr.smr( ), m_ptwXY );
606 if( ptwX_cdf == nullptr ) throw Exception( smr.constructMessage( "XYs1d::toXs_pdf_cdf1d", -1, true ) );
607
608 std::size_t length = static_cast<std::size_t>( ptwX_cdf->length );
609 std::vector<double> cdf1( length );
610 for( std::size_t index = 0; index < length; ++index ) cdf1[index] = ptwX_cdf->points[index];
611 ptwX_free( ptwX_cdf );
612
613 return( Xs_pdf_cdf1d( GIDI::Axes( ), ptwXY_interpolationLinLin, xs1, pdf1, cdf1 ) );
614}
std::vector< double > xs() const
std::vector< double > ys() const
ptwXPoints * ptwXY_runningIntegral(statusMessageReporting *smr, ptwXYPoints *ptwXY)
struct ptwXPoints_s ptwXPoints
ptwXPoints * ptwX_free(ptwXPoints *ptwX)
Definition ptwX_core.c:213
int64_t length
Definition ptwX.h:29
double * points
Definition ptwX.h:32

◆ write()

void GIDI::Functions::XYs1d::write ( FILE * a_file,
std::string const & a_format ) const
virtual

Writes the (x,y) values to a_file. The format string must have two double conversion specifiers (e.g., " %12.3e %.6f").

Parameters
a_file[in] The C FILE instance to write the data to.
a_format[in] The format string passed to the C printf function.

Reimplemented from GIDI::Functions::Function1dForm.

Definition at line 663 of file GIDI_XYs1d.cc.

663 {
664
665 ptwXY_simpleWrite( m_ptwXY, a_file, a_format.c_str( ) );
666}
void ptwXY_simpleWrite(ptwXYPoints *ptwXY, FILE *f, char const *format)
Definition ptwXY_misc.c:329

◆ xs()

std::vector< double > GIDI::Functions::XYs1d::xs ( ) const

Returns the list of x1 values of this.

Returns
The x1 values of this.

Definition at line 361 of file GIDI_XYs1d.cc.

361 {
362
363 auto n1 = size( );
364 std::vector<double> _xs( n1, 0. );
365
366 for( std::size_t i1 = 0; i1 < n1; ++i1 ) {
367 ptwXYPoint const *point = ptwXY_getPointAtIndex_Unsafely( m_ptwXY, static_cast<int64_t>( i1 ) );
368
369 _xs[i1] = point->x;
370 }
371 return( _xs );
372}

Referenced by toXs_pdf_cdf1d().

◆ ys()

std::vector< double > GIDI::Functions::XYs1d::ys ( ) const

Returns the list of y values of this.

Returns
The y values of this.

Definition at line 380 of file GIDI_XYs1d.cc.

380 {
381
382 auto n1 = size( );
383 std::vector<double> _ys( n1, 0. );
384
385 for( std::size_t i1 = 0; i1 < n1; ++i1 ) {
386 ptwXYPoint const *point = ptwXY_getPointAtIndex_Unsafely( m_ptwXY, static_cast<int64_t>( i1 ) );
387
388 _ys[i1] = point->y;
389 }
390 return( _ys );
391}

Referenced by toXs_pdf_cdf1d().

◆ ysMappedToXs()

std::vector< double > GIDI::Functions::XYs1d::ysMappedToXs ( std::vector< double > const & a_xs,
std::size_t * a_offset ) const

Returns a list of values that are this y mapped to the x1 values in a_xs.

Parameters
a_xs[in] The list of x1 values to map this' y values to.
a_offset[out] The index of the first value in a_xs where this starts.
Returns
The liist of y values.

Definition at line 401 of file GIDI_XYs1d.cc.

401 {
402
403 std::size_t n1 = size( ), i2, n2 = a_xs.size( );
404 std::vector<double> _ys;
405
406 *a_offset = 0;
407 if( n1 == 0 ) return( _ys );
408
409 ptwXYPoint const *point1 = ptwXY_getPointAtIndex_Unsafely( m_ptwXY, 0 );
410 for( i2 = 0; i2 < n2; ++i2 ) if( point1->x <= a_xs[i2] ) break;
411 *a_offset = i2;
412 if( i2 == n2 ) return( _ys );
413
414 for( std::size_t i1 = 1; i1 < n1; ++i1 ) {
415 ptwXYPoint const *point2 = ptwXY_getPointAtIndex_Unsafely( m_ptwXY, static_cast<int64_t>( i1 ) );
416
417 while( i2 < n2 ) {
418 double x = a_xs[i2], y;
419 if( x > point2->x ) break; // Happens because of round off errors. Need to fix.
420
421 ptwXY_interpolatePoint( nullptr, ptwXY_interpolationLinLin, x, &y, point1->x, point1->y, point2->x, point2->y );
422 _ys.push_back( y );
423 ++i2;
424 if( x >= point2->x ) break; // This check can fail hence check above.
425 }
426 point1 = point2;
427 }
428
429 return( _ys );
430}
nfu_status ptwXY_interpolatePoint(statusMessageReporting *smr, ptwXY_interpolation interpolation, double x, double *y, double x1, double y1, double x2, double y2)

The documentation for this class was generated from the following files: