13 #if defined __cplusplus
21 void *argList,
int level,
int checkForRoots,
double eps );
25 void *argList,
int level,
int checkForRoots );
50 for( i = 1; i <
n; i++ ) {
56 if( ( *status =
func( x1, &y1, argList ) ) !=
nfu_Okay )
return( NULL );
58 for( i = 1; i <
n; i++ ) {
70 for( i = ptwXY->
length - 1, p2 = NULL; i >= 0; i--, p2 = p1 ) {
73 if( ( p1->
y * p2->
y ) < 0. ) {
98 void *argList,
int level,
int checkForRoots,
double eps ) {
105 x = 0.5 * ( x1 +
x2 );
107 if( ( status =
func( x, &f, argList ) ) !=
nfu_Okay )
return( status );
108 if( std::fabs( f - y ) <= 0.8 * std::fabs( f * ptwXY->
accuracy ) )
return(
nfu_Okay );
126 for( i = 0; i < 16; i++ ) {
127 if( y2 == y1 )
break;
128 x = ( y2 * x1 - y1 *
x2 ) / ( y2 - y1 );
129 if( x <= x1 ) x = x1 + 0.1 * ( x2 -
x1 );
130 if( x >= x2 ) x = x2 - 0.1 * ( x2 -
x1 );
131 if( ( status =
func( x, &y, argList ) ) !=
nfu_Okay )
return( status );
148 int64_t i, originalLength = ptwXY1->
length, notFirstPass = 0;
158 for( i = originalLength - 1; i >= 0; i-- ) {
160 if( ( status =
func( &(ptwXY1->
points[i]), argList ) ) !=
nfu_Okay )
return( status );
176 void *argList,
int level,
int checkForRoots ) {
183 if( level >= ptwXY1->
biSectionMax )
goto checkForZeroCrossing;
184 p.
x = 0.5 * ( p1->
x + p2->
x );
187 if( ( status =
func( &p, argList ) ) !=
nfu_Okay )
return( status );
188 if( std::fabs( ( p.
x - p1->
x ) * ( p2->
y - p1->
y ) + ( p2->
x - p1->
x ) * ( p1->
y - p.
y ) ) <= 0.8 * std::fabs( ( p2->
x - p1->
x ) * p.
y * ptwXY1->
accuracy ) )
189 goto checkForZeroCrossing;
191 if( ( status =
ptwXY_applyFunction2( ptwXY1, y1, y, p1, &p, func, argList, level + 1, checkForRoots ) ) )
return( status );
192 return(
ptwXY_applyFunction2( ptwXY1, y, y2, &p, p2, func, argList, level + 1, checkForRoots ) );
194 checkForZeroCrossing:
205 double y,
x1 = p1->
x,
x2 = p2->
x, nY1 = p1->
y, nY2 = p2->
y, refY = 0.5 * ( std::fabs( p1->
y ) + std::fabs( p2->
y ) );
212 for( i = 0; i < 6; i++ ) {
213 if( nY2 == nY1 )
break;
214 p.
x = ( nY2 * x1 - nY1 *
x2 ) / ( nY2 - nY1 );
215 if( p.
x <= x1 ) p.
x = 0.5 * ( x1 +
x2 );
216 if( p.
x >=
x2 ) p.
x = 0.5 * ( x1 +
x2 );
219 if( ( status =
func( &p, argList ) ) !=
nfu_Okay )
return( status );
220 if( p.
y == 0 )
break;
221 if( 0.5 * refY < std::fabs( p.
y ) )
break;
222 refY = std::fabs( p.
y );
223 if( p1->
y * p.
y < 0 ) {
237 double biSectionMax,
double accuracy,
char **endCharacter,
nfu_status *status ) {
239 int64_t numberConverted;
245 if( ( numberConverted % 2 ) == 0 )
246 ptwXY =
ptwXY_create( interpolation, interpolationOtherInfo, biSectionMax, accuracy, numberConverted, 10, numberConverted / 2, doublePtr, status, 0 );
259 fprintf( f,
"status = %d interpolation = %d length = %d allocatedSize = %d\n",
261 fprintf( f,
"userFlag = %d biSectionMax = %.8e accuracy = %.2e minFractional_dx = %.6e\n",
264 fprintf( f,
"getValueFunc is NULL = %d. argList is NULL = %d.\n",
266 fprintf( f,
" overflowLength = %d overflowAllocatedSize = %d mallocFailedSize = %d\n",
268 fprintf( f,
" Points data, points = %20p\n", ( printPointersAsNull ? NULL : (
void*)ptwXY->
points ) );
269 for( i = 0; i <
n; i++, point++ ) fprintf( f,
" %14.7e %14.7e\n", point->
x, point->
y );
270 fprintf( f,
" Overflow points data; %20p\n", ( printPointersAsNull ? NULL : (
void*)&(ptwXY->
overflowHeader) ) );
272 fprintf( f,
" %14.7e %14.7e %8d %20p %20p %20p\n", overflowPoint->
point.
x, overflowPoint->
point.
y, (
int) overflowPoint->
index,
273 (
void*) ( printPointersAsNull ? NULL : overflowPoint ), (
void*) ( printPointersAsNull ? NULL : overflowPoint->prior ),
274 (
void*) ( printPointersAsNull ? NULL : overflowPoint->next ) );
276 fprintf( f,
" Points in order\n" );
277 for( i = 0; i < ptwXY->
length; i++ ) {
279 fprintf( f,
" %14.7e %14.7e\n", point->
x, point->
y );
290 for( i = 0; i < ptwXY->
length; i++ ) {
292 fprintf( f, format, point->
x, point->
y );
303 #if defined __cplusplus