53 m_ptwXY =
ptwXY_create2(
nullptr, a_interpolation, 0, 0, 0, dummy, 0 );
70 int64_t length =
static_cast<int64_t
>( a_values.size( ) ) / 2;
72 m_ptwXY =
ptwXY_create2(
nullptr, a_interpolation, length, 0, length, a_values.data( ), 0 );
89 int a_index,
double a_outerDomainValue ) :
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( ) );
95 m_ptwXY =
ptwXY_createFrom_Xs_Ys2(
nullptr, a_interpolation, length, 0, length, a_xs.data( ), a_ys.data( ), 0 );
128 nf_Buffer<double> vals;
131 int primarySize =
static_cast<int>( vals.size() / 2 ), secondarySize = 0;
132 double *dvals =
new double[vals.size()];
133 for(
size_t idx = 0; idx < vals.size(); idx++ ) dvals[idx] = vals[idx];
136 if( m_ptwXY ==
nullptr )
throw Exception(
"XYs1d::XYs1d: ptwXY_fromString failed" );
150 if( m_ptwXY ==
nullptr )
throw Exception(
"XYs1d::XYs1d:2: ptwXY_clone2 failed" );
170 if(
this != &a_rhs ) {
190 if( (int64_t) a_index >=
ptwXY_length(
nullptr, m_ptwXY ) )
throw Exception(
"XYs1d::operator[]: index out of bounds." );
193 std::pair<double, double> CPPPoint( point->
x, point->
y );
207 XYs1d xys1d( *
this );
225 mutualifyDomains( m_ptwXY, a_rhs.
ptwXY( ), &ptwXY1, &ptwXY2 );
247 XYs1d xys1d( *
this );
265 mutualifyDomains( m_ptwXY, a_rhs.
ptwXY( ), &ptwXY1, &ptwXY2 );
288 XYs1d xys1d( *
this );
304 XYs1d xys1d( *
this );
342 mutualifyDomains( m_ptwXY, a_rhs.
ptwXY( ), &ptwXY1, &ptwXY2 );
364 std::vector<double> _xs( n1, 0. );
366 for( std::size_t i1 = 0; i1 < n1; ++i1 ) {
383 std::vector<double> _ys( n1, 0. );
385 for( std::size_t i1 = 0; i1 < n1; ++i1 ) {
403 std::size_t n1 =
size( ), i2, n2 = a_xs.size( );
404 std::vector<double> _ys;
407 if( n1 == 0 )
return( _ys );
410 for( i2 = 0; i2 < n2; ++i2 )
if( point1->
x <= a_xs[i2] )
break;
412 if( i2 == n2 )
return( _ys );
414 for( std::size_t i1 = 1; i1 < n1; ++i1 ) {
418 double x = a_xs[i2], y;
419 if( x > point2->
x )
break;
424 if( x >= point2->
x )
break;
468 if( _ptwXY ==
nullptr )
throw Exception(
"domainSliceMax: ptwXY_clone2 failed" );
472 if( ptwXYSliced ==
nullptr )
throw Exception(
"domainSliceMax: ptwXY_domainMaxSlice failed" );
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." );
490 if( point->
x >= a_x1 )
return( point->
y );
493 if( point->
x <= a_x1 )
return( point->
y );
497 if( status !=
nfu_Okay )
throw Exception(
"XYs1d::evaluate: status != nfu_Okay" );
511void XYs1d::mapToXsAndAdd( std::size_t a_offset, std::vector<double>
const &a_Xs, std::vector<double> &a_results,
double a_scaleFactor )
const {
513 if( a_Xs.size( ) != a_results.size( ) )
throw Exception(
"XYs1d::mapToXsAndAdd: a_Xs.size( ) != a_results.size( )" );
516 int64_t length =
static_cast<int64_t
>( a_Xs.size( ) );
519 a_Xs.data( ), a_results.data( ), a_scaleFactor );
548 if( ptwXY2 ==
nullptr )
return(
nullptr );
601 std::vector<double> xs1 =
xs( );
602 std::vector<double> pdf1 =
ys( );
608 std::size_t length =
static_cast<std::size_t
>( ptwX_cdf->
length );
609 std::vector<double> cdf1( length );
628 std::string attributes;
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;
680 std::vector<double> points( 4 );
682 points[0] = a_domainMin;
684 points[2] = a_domainMax;
705 double lowerEps = 1e-12, upperEps = 1e-12;
708 if( *a_ptwXY1 ==
nullptr )
throw GIDI::Exception(
"mutualifyDomains: ptwXY_clone2 failed for a_ptwXY1" );
711 if( *a_ptwXY2 ==
nullptr ) {
713 throw GIDI::Exception(
"mutualifyDomains: ptwXY_clone2 failed form a_ptwXY2" );
720 throw GIDI::Exception(
"XYs1d::operator(+|-)=: mutualifyDomains in ptwXY_mutualifyDomains" );
#define GIDI_outerDomainValueChars
#define GIDI_interpolationChars
void toXMLList(GUPI::WriteInfo &a_writeInfo, std::string const &a_indent="") const
std::vector< double > ysMappedToXs(std::vector< double > const &a_xs, std::size_t *a_offset) const
double integrate(double a_dommainMin, double a_dommainMax)
XYs1d & operator+=(XYs1d const &a_XYs1d)
XYs1d operator*(double a_value) const
XYs1d & operator-=(XYs1d const &a_XYs1d)
Xs_pdf_cdf1d toXs_pdf_cdf1d()
void write(FILE *a_file, std::string const &a_format) const
XYs1d operator-(XYs1d const &a_XYs1d) const
void mapToXsAndAdd(std::size_t a_offset, std::vector< double > const &a_Xs, std::vector< double > &a_results, double a_scaleFactor) const
std::pair< double, double > operator[](std::size_t a_index) const
double evaluate(double a_x1) const
ptwXYPoints const * ptwXY() const
void toXMLList_func(GUPI::WriteInfo &a_writeInfo, std::string const &a_indent, bool a_embedded, bool a_inRegions) const
XYs1d & operator=(XYs1d const &a_rhs)
XYs1d domainSliceMax(double a_domainMax) const
XYs1d & operator*=(double a_value)
XYs1d domainSlice(double a_domainMin, double a_domainMax, bool a_fill) const
XYs1d * asXYs1d(bool a_asLinlin, double a_accuray, double a_lowerEps, double a_upperEps) const
XYs1d operator+(XYs1d const &a_XYs1d) const
static XYs1d * makeConstantXYs1d(Axes const &a_axes, double a_domainMin, double a_domainMax, double a_value)
std::vector< double > xs() const
std::vector< double > ys() const
std::string const & moniker() const
void addNodeEnder(std::string const &a_moniker)
std::string incrementalIndent(std::string const &indent)
void addNodeStarter(std::string const &indent, std::string const &a_moniker, std::string const &a_attributes="")
std::string addAttribute(std::string const &a_name, std::string const &a_value) const
Node child(const char *name) const
statusMessageReporting * smr()
std::string constructMessage(std::string a_prefix, int a_reports=1, bool a_clear=false)
void parseValuesOfDoubles(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, nf_Buffer< double > &a_vector)
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="")
std::string intToString(int a_value)
std::string doubleToShortestString(double a_value, int a_significantDigits=15, int a_favorEFormBy=0)
enum nfu_status_e nfu_status
ptwXYPoints * ptwXY_domainSlice(statusMessageReporting *smr, ptwXYPoints *ptwXY, double domainMin, double domainMax, int64_t secondarySize, int fill)
ptwXY_interpolation ptwXY_getInterpolation(ptwXYPoints *ptwXY)
ptwXYPoints * ptwXY_clone2(statusMessageReporting *smr, ptwXYPoints const *ptwXY)
ptwXPoints * ptwXY_runningIntegral(statusMessageReporting *smr, ptwXYPoints *ptwXY)
nfu_status ptwXY_normalize(statusMessageReporting *smr, ptwXYPoints *ptwXY1)
ptwXYPoints * ptwXY_add_ptwXY(statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2)
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)
nfu_status ptwXY_integrate(statusMessageReporting *smr, ptwXYPoints *ptwXY, double domainMin, double domainMax, double *value)
nfu_status ptwXY_mul_double(statusMessageReporting *smr, ptwXYPoints *ptwXY, double value)
enum ptwXY_interpolation_e ptwXY_interpolation
ptwXYPoints * ptwXY_sub_ptwXY(statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2)
@ ptwXY_interpolationFlat
@ ptwXY_interpolationLinLin
ptwXYPoints * ptwXY_mul2_ptwXY(statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2)
struct ptwXYPoints_s ptwXYPoints
nfu_status ptwXY_mutualifyDomains(statusMessageReporting *smr, ptwXYPoints *ptwXY1, double lowerEps1, double upperEps1, int positiveXOnly1, ptwXYPoints *ptwXY2, double lowerEps2, double upperEps2, int positiveXOnly2)
ptwXYPoints * ptwXY_domainMaxSlice(statusMessageReporting *smr, ptwXYPoints *ptwXY, double domainMax, int64_t secondarySize, int fill)
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)
nfu_status ptwXY_interpolatePoint(statusMessageReporting *smr, ptwXY_interpolation interpolation, double x, double *y, double x1, double y1, double x2, double y2)
void ptwXY_simpleWrite(ptwXYPoints *ptwXY, FILE *f, char const *format)
ptwXYPoints * ptwXY_create2(statusMessageReporting *smr, ptwXY_interpolation interpolation, int64_t primarySize, int64_t secondarySize, int64_t length, double const *xy, int userFlag)
int64_t ptwXY_length(statusMessageReporting *smr, ptwXYPoints *ptwXY)
struct ptwXYPoint_s ptwXYPoint
ptwXYPoints * ptwXY_free(ptwXYPoints *ptwXY)
ptwXYPoint * ptwXY_getPointAtIndex_Unsafely(ptwXYPoints const *ptwXY, int64_t index)
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)
ptwXYPoints * ptwXY_toOtherInterpolation(statusMessageReporting *smr, ptwXYPoints *ptwXY, ptwXY_interpolation interpolation, double accuracy)
nfu_status ptwXY_getValueAtX(statusMessageReporting *smr, ptwXYPoints *ptwXY, double x, double *y)
nfu_status ptwXY_integrateDomain(statusMessageReporting *smr, ptwXYPoints *ptwXY, double *value)
ptwXYPoints * ptwXY_flatInterpolationToLinear(statusMessageReporting *smr, ptwXYPoints *ptwXY, double lowerEps, double upperEps)
struct ptwXPoints_s ptwXPoints
ptwXPoints * ptwX_free(ptwXPoints *ptwX)