16 double x2,
double y2,
double z2,
int level );
18 double rangeMin,
double *c );
20 double y1,
double c1,
double y2,
double c2,
double rangeMin );
37 double *v = (
double *) argList;
39 point->
y = pow( point->
y, *v );
50 double x1, y1, z1, x2, y2, z2;
53 if( length < 1 )
return( ptwXY->
status );
66 y2 = a * ptwXY->
points[length-1].
y;
67 z2 = ptwXY->
points[length-1].
y = exp( y2 );
68 for( i = length - 2; i >= 0; i-- ) {
71 z1 = ptwXY->
points[i].
y = exp( y1 );
72 if( ( status = ptwXY_exp_s( smr, ptwXY, x1, y1, z1, x2, y2, z2, 0 ) ) !=
nfu_Okay )
goto Err;
87 double x2,
double y2,
double z2,
int level ) {
90 double x, y, dx, dy, z, zp, s;
92 if( ( x1 == x2 ) || ( y1 == y2 ) )
return(
nfu_Okay );
98 x = 1. / s + x2 - z2 * dx / ( z2 - z1 );
99 y = ( y1 * ( x2 - x ) + y2 * ( x - x1 ) ) / dx;
100 z = z1 * exp( 1 - dy / ( exp( dy ) - 1 ) );
101 zp = ( z2 - z1 ) / ( y2 - y1 );
105 if( ( status = ptwXY_exp_s( smr, ptwXY, x, y, z, x2, y2, z2, level ) ) !=
nfu_Okay )
return( status );
106 return( ptwXY_exp_s( smr, ptwXY, x1, y1, z1, x, y, z, level ) );
118 int64_t i1, i2, n1, n2, n;
119 ptwXYPoints *f1 = ptwXY1, *f2 = ptwXY2, *convolute;
120 double accuracy = ptwXY1->
accuracy, rangeMin, rangeMax, c, y, dy;
145 if( ( n1 == 0 ) || ( n2 == 0 ) ) {
151 if( ( n1 == 1 ) || ( n2 == 1 ) ) {
153 "Too few points: len( source1 ) = %d, len( source1 ) = %d.", (
int) n1, (
int) n2 );
157 if( accuracy < ptwXY2->accuracy ) accuracy = ptwXY2->
accuracy;
161 if( n > 10000 ) mode = -1;
163 if( n > 100000 ) mode = -1;
169 rangeMin = f1->
points[0].
x + f2->points[0].x;
170 rangeMax = f1->
points[n1 - 1].
x + f2->points[n2 - 1].x;
175 dy = ( rangeMax - rangeMin ) / 2000;
176 for( y = rangeMin + dy; y < rangeMax; y += dy ) {
177 if( ptwXY_convolution2( smr, f1, f2, y, rangeMin, &c ) !=
nfu_Okay )
goto Err;
181 for( i1 = 0; i1 < n1; i1++ ) {
182 for( i2 = 0; i2 < n2; i2++ ) {
183 y = rangeMin + ( f1->
points[i1].
x - f1->
points[0].
x ) + ( f2->points[i2].x - f2->points[0].x );
184 if( y <= rangeMin )
continue;
185 if( y >= rangeMax )
continue;
186 if( ptwXY_convolution2( smr, f1, f2, y, rangeMin, &c ) !=
nfu_Okay )
goto Err;
193 for( i1 = convolute->length - 1; i1 > 0; i1-- ) {
194 if( ptwXY_convolution3( smr, convolute, f1, f2, convolute->
points[i1 - 1].
x, convolute->points[i1 - 1].y,
195 convolute->points[i1].x, convolute->points[i1].y, rangeMin ) !=
nfu_Okay )
goto Err;
210 int64_t i1 = 0, i2 = 0, n1 = f1->
length, n2 = f2->
length, mode;
211 double dx1, dx2, x1MinP, x1Min, x2Max;
212 double f1x1 = 0, f1y1 = 0, f1x2 = 0, f1y2 = 0, f2x1 = 0, f2y1 = 0, f2x2 = 0, f2y2 = 0;
213 double f1x1p, f1y1p, f1x2p, f1y2p, f2x1p, f2y1p, f2x2p, f2y2p;
218 x2Max = f2->
points[0].
x + ( y - rangeMin );
221 x1MinP = y - f2->
points[n2 - 1].
x;
222 if( x1Min < x1MinP ) x1Min = x1MinP;
234 i1 = lessThanEqualXPoint.
index;
236 f1y1p = f1y1 = f1->
points[i1].
y;
257 i2 = lessThanEqualXPoint.
index;
258 if( i2 < f2->length - 1 ) i2++;
260 f2y2p = f2y2 = f2->
points[i2].
y;
275 while( ( i1 < n1 ) && ( i2 >= 0 ) ) {
280 if( dx1 < dx2 ) mode = 1;
284 if( f2x1p < f2->points[i2].x ) {
291 *c += ( ( f1y1p + f1y2p ) * ( f2y1p + f2y2p ) + f1y1p * f2y2p + f1y2p * f2y1p ) * dx1;
293 if( i1 == n1 )
break;
297 f1y2p = f1y2 = f1->
points[i1].
y;
303 if( ( f1x2p > f1->
points[i1].
x ) || ( dx1 == dx2 ) ) {
310 *c += ( ( f1y1p + f1y2p ) * ( f2y1p + f2y2p ) + f1y1p * f2y2p + f1y2p * f2y1p ) * dx2;
316 f2y1p = f2y1 = f2->
points[i2].
y;
323 f1y2p = f1y2 = f1->
points[i1].
y; }
337 double y1,
double c1,
double y2,
double c2,
double rangeMin ) {
340 double rangeMid = 0.5 * ( y1 + y2 ), cMid = 0.5 * ( c1 + c2 ), c;
341 double domainMin, domainMax;
346 if( ( y2 - rangeMid ) <= 1e-5 * ( domainMax - domainMin ) )
return(
nfu_Okay );
347 if( ( status = ptwXY_convolution2( smr, f1, f2, rangeMid, rangeMin, &c ) ) !=
nfu_Okay )
return( status );
348 if( fabs( c - cMid ) <= convolute->
accuracy * 0.5 * ( fabs( c ) + fabs( cMid ) ) )
return(
nfu_Okay );
350 if( ( status = ptwXY_convolution3( smr, convolute, f1, f2, y1, c1, rangeMid, c, rangeMin ) ) !=
nfu_Okay )
return( status );
351 return( ptwXY_convolution3( smr, convolute, f1, f2, rangeMid, c, y2, c2, rangeMin ) );
392 length, 10, 0 ) ) == NULL ) {
400 else if( length > 1 ) {
401 int64_t i1, start = 0, order = 1;
409 for( i1 = 1, start += order; i1 < length; ++i1, start += order ) {
412 if( ptwXYInverse->
points[i1-1].
x >= ptwXYInverse->
points[i1].
x ) {
414 "Non-ascending domain values: x[%d] = %.17e >= x[%d] = %.17e.",
415 (
int) (i1-1), ptwXYInverse->
points[i1-1].
x, (
int) i1, ptwXYInverse->
points[i1].
x );
421 ptwXYInverse->
length = length;
422 return( ptwXYInverse );
@ nfu_unsupportedInterpolation
enum nfu_status_e nfu_status
double ptwXY_getAccuracy(ptwXYPoints *ptwXY)
nfu_status ptwXY_setValueAtX(statusMessageReporting *smr, ptwXYPoints *ptwXY, double x, double y)
enum ptwXY_lessEqualGreaterX_e ptwXY_lessEqualGreaterX
struct ptwXYOverflowPoint_s ptwXYOverflowPoint
ptwXY_lessEqualGreaterX ptwXY_getPointsAroundX(statusMessageReporting *smr, ptwXYPoints *ptwXY, double x, ptwXYOverflowPoint *lessThanEqualXPoint, ptwXYOverflowPoint *greaterThanXPoint)
enum ptwXY_interpolation_e ptwXY_interpolation
@ ptwXY_interpolationFlat
@ ptwXY_interpolationLinLog
@ ptwXY_interpolationLinLin
@ ptwXY_interpolationOther
@ ptwXY_interpolationLogLin
struct ptwXYPoints_s ptwXYPoints
double ptwXY_getBiSectionMax(ptwXYPoints *ptwXY)
nfu_status ptwXY_interpolatePoint(statusMessageReporting *smr, ptwXY_interpolation interpolation, double x, double *y, double x1, double y1, double x2, double y2)
@ ptwXY_lessEqualGreaterX_equal
@ ptwXY_lessEqualGreaterX_Error
@ ptwXY_lessEqualGreaterX_empty
@ ptwXY_lessEqualGreaterX_between
@ ptwXY_lessEqualGreaterX_lessThan
@ ptwXY_lessEqualGreaterX_greater
ptwXYPoints * ptwXY_new(statusMessageReporting *smr, ptwXY_interpolation interpolation, char const *interpolationString, double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize, int userFlag)
int64_t ptwXY_length(statusMessageReporting *smr, ptwXYPoints *ptwXY)
nfu_status ptwXY_applyFunction(statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXY_applyFunction_callback func, void *argList, int checkForRoots)
struct ptwXYPoint_s ptwXYPoint
ptwXYPoints * ptwXY_free(ptwXYPoints *ptwXY)
nfu_status ptwXY_domainMax(statusMessageReporting *smr, ptwXYPoints *ptwXY, double *value)
nfu_status ptwXY_simpleCoalescePoints(statusMessageReporting *smr, ptwXYPoints *ptwXY)
nfu_status ptwXY_domainMin(statusMessageReporting *smr, ptwXYPoints *ptwXY, double *value)
ptwXYPoints * ptwXY_convolution(statusMessageReporting *smr, ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, int mode)
nfu_status ptwXY_exp(statusMessageReporting *smr, ptwXYPoints *ptwXY, double a)
nfu_status ptwXY_pow(statusMessageReporting *smr, ptwXYPoints *ptwXY, double v)
ptwXYPoints * ptwXY_inverse(statusMessageReporting *smr, ptwXYPoints *ptwXY)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
#define smr_setReportError2p(smr, libraryID, code, fmt)
ptwXY_interpolation interpolation
char const * interpolationString