111 {
112
113
114
115
116
117
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;
121
124 return( NULL );
125 }
128 return( NULL );
129 }
130
134 return( NULL );
135 }
139 return( NULL );
140 }
141
143 n2 = f2->length;
144
145 if( ( n1 == 0 ) || ( n2 == 0 ) ) {
148 return( convolute );
149 }
150
151 if( ( n1 == 1 ) || ( n2 == 1 ) ) {
153 "Too few points: len( source1 ) = %d, len( source1 ) = %d.", (int) n1, (int) n2 );
154 return( NULL );
155 }
156
157 if( accuracy < ptwXY2->accuracy ) accuracy = ptwXY2->
accuracy;
159 if( mode == 0 ) {
160 mode = 1;
161 if( n > 10000 ) mode = -1;
162 }
163 if( n > 100000 ) mode = -1;
166 return( NULL );
167 }
168
169 rangeMin = f1->
points[0].
x + f2->points[0].x;
170 rangeMax = f1->
points[n1 - 1].
x + f2->points[n2 - 1].x;
171
173
174 if( mode < 0 ) {
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;
179 } }
180 else {
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;
188 }
189 }
190 }
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;
196 }
197
198 return( convolute );
199
200Err:
203 return( NULL );
204}
@ nfu_unsupportedInterpolation
nfu_status ptwXY_setValueAtX(statusMessageReporting *smr, ptwXYPoints *ptwXY, double x, double y)
@ ptwXY_interpolationLinLin
struct ptwXYPoints_s ptwXYPoints
ptwXYPoints * ptwXY_new(statusMessageReporting *smr, ptwXY_interpolation interpolation, char const *interpolationString, double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize, int userFlag)
ptwXYPoints * ptwXY_free(ptwXYPoints *ptwXY)
nfu_status ptwXY_simpleCoalescePoints(statusMessageReporting *smr, ptwXYPoints *ptwXY)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
#define smr_setReportError2p(smr, libraryID, code, fmt)
ptwXY_interpolation interpolation
char const * interpolationString