96 {
97
98
99
100
101
102
103 int64_t i1, i2, n1, n2,
n;
104 ptwXYPoints *f1 = ptwXY1, *f2 = ptwXY2, *convolute;
105 double accuracy = ptwXY1->
accuracy, yMin, yMax, c, y, dy;
106
109
113
115 n2 = f2->length;
116
117 if( ( n1 == 0 ) || ( n2 == 0 ) ) {
119 return( convolute );
120 }
121
122 if( ( n1 == 1 ) || ( n2 == 1 ) ) {
124 return( NULL );
125 }
126
127 if( accuracy < ptwXY2->accuracy ) accuracy = ptwXY2->
accuracy;
129 if( mode == 0 ) {
130 mode = 1;
131 if( n > 1000 ) mode = -1;
132 }
133 if( n > 100000 ) mode = -1;
135
136 yMin = f1->
points[0].
x + f2->points[0].x;
137 yMax = f1->
points[n1 - 1].
x + f2->points[n2 - 1].x;
138
140
141 if( mode < 0 ) {
142 dy = ( yMax - yMin ) / 400;
143 for( y = yMin + dy; y < yMax; y += dy ) {
144 if( ( *status = ptwXY_convolution2( f1, f2, y, yMin, &c ) ) !=
nfu_Okay )
goto Err;
146 } }
147 else {
148 for( i1 = 0; i1 < n1; i1++ ) {
149 for( i2 = 0; i2 < n2; i2++ ) {
150 y = yMin + ( f1->
points[i1].
x - f1->
points[0].
x ) + ( f2->points[i2].x - f2->points[0].x );
151 if( y <= yMin ) continue;
152 if( y >= yMax ) continue;
153 if( ( *status = ptwXY_convolution2( f1, f2, y, yMin, &c ) ) !=
nfu_Okay )
goto Err;
155 }
156 }
157 }
160 for( i1 = convolute->length - 1; i1 > 0; i1-- ) {
161 if( ( *status = ptwXY_convolution3( convolute, f1, f2, convolute->points[i1 - 1].x, convolute->points[i1 - 1].y,
162 convolute->points[i1].x, convolute->points[i1].y, yMin ) ) !=
nfu_Okay )
goto Err;
163 }
164
165 return( convolute );
166
167Err:
169 return( NULL );
170}
@ nfu_unsupportedInterpolation
nfu_status ptwXY_setValueAtX(ptwXYPoints *ptwXY, double x, double y)
nfu_status ptwXY_simpleCoalescePoints(ptwXYPoints *ptwXY)
ptwXYPoints * ptwXY_new(ptwXY_interpolation interpolation, ptwXY_interpolationOtherInfo const *interpolationOtherInfo, double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize, nfu_status *status, int userFlag)
@ ptwXY_interpolationLinLin
ptwXYPoints * ptwXY_free(ptwXYPoints *ptwXY)
ptwXY_interpolation interpolation