33 realType *Pjm1 = P, *Pj = Pjm1 + m, *Pjp1 = Pj + m;
34 for( i = 0; i < m; ++i )
36 for( i = 0; i < m; ++i )
38 for( j = 1; j < n; ++j )
41 for( i = 0; i < m; ++i )
42 Pjp1[i] = a * x[i] * Pj[i] - b * Pjm1[i];
43 Pjp1 += m, Pj += m, Pjm1 += m;
52 for( i = 1; i <= n - 2; i += 2 )
54 P[i + 1] = ( ( 2 * i + 1 ) * x * P[i] - i * P[i - 1] ) / ( i + 1 );
55 P[i + 2] = ( ( 2 * i + 3 ) * x * P[i - 1] - ( i + 1 ) * P[i] ) / ( i + 2 );
57 P[n] = ( ( 2 * n - 1 ) * x * P[n - 1] - ( n - 1 ) * P[n - 2] ) / n;
65 for( i = 1; i <= n - 2; i += 2 )
67 P[i + 1] = ( ( 2 * i + 1 ) * x * P[i] - i * P[i - 1] ) / ( i + 1 );
68 P[i + 2] = ( ( 2 * i + 3 ) * x * P[i - 1] - ( i + 1 ) * P[i] ) / ( i + 2 );
91 for( i = 0; i < m; ++i, P += n + 1 )
94 for( i = 0; i < m; ++i, P += n + 1 )
110 for( i = 1; i < n; i += 2 )
112 p[0] = ( ( 2 * i + 1 ) * x * p[1] - i * p[0] ) / ( i + 1 );
113 p[1] = ( ( 2 * i + 3 ) * x * p[0] - ( i + 1 ) * p[1] ) / ( i + 2 );
125 for( i = 2; i < n; i += 2 )
127 p[1] = ( ( 2 * i + 1 ) * x * p[0] - ( i + 1 ) * p[1] ) / i;
128 p[0] = ( ( 2 * i + 3 ) * x * p[1] - ( i + 2 ) * p[0] ) / ( i + 1 );
140 for( i = 3; i < n; i += 2 )
142 p[0] = ( ( 2 * i + 1 ) * x * p[1] - ( i + 2 ) * p[0] ) / ( i - 1 );
143 p[1] = ( ( 2 * i + 3 ) * x * p[0] - ( i + 3 ) * p[1] ) / i;
158 for( i = 0; i <= n / 2 - 1; ++i )
168 if( n & 1 ) z[n / 2] = 0;
169 for( j = ( n + 1 ) / 2, i = n / 2 - 1; j < n; ++j, --i )
176 int i, j, np = n + 1;
177 for( i = 0; i <= n / 2 - 1; ++i )
187 if( n & 1 ) z[n / 2] = 0;
188 for( j = ( n + 1 ) / 2, i = n / 2 - 1; j < n; ++j, --i )
195 z[0] = -1, z[n - 1] = 1;
202 for( i = 0; i <= ( n - 1 ) / 2; ++i )
205 w[i] = 2 * ( 1 - z[i] * z[i] ) / ( d * d );
207 for( j = ( n + 1 ) / 2, i = n / 2 - 1; j < n; ++j, --i )
214 for( i = 0; i <= ( n - 1 ) / 2; ++i )
217 w[i] = 2 / ( ( n - 1 ) * n * d * d );
219 for( j = ( n + 1 ) / 2, i = n / 2 - 1; j < n; ++j, --i )
243 for( j = 0; j < n; ++j )
246 for( i = 0; i < n; ++i )
247 *J++ *= ( 2 * i + 1 ) * ww / 2;
259 for( i = 0; i < n; ++i )
262 for( j = 0; j < n; ++j )
277 int i, j, m = ( n + 1 ) / 2;
281 for( j = 0; j < m; ++j, p += n )
284 for( j = 0; j < m; ++j, p += n )
287 for( j = 0; j < m; ++j )
290 for( i = 0; i < n - 1; ++i )
291 *p *= ( 2 * i + 1 ) * ww / 2,
sum += *p++;
294 q = J + ( n / 2 - 1 ) * n;
296 for( ; j < n; ++j, p += n, q -= n )
298 for( i = 0; i < n - 1; i += 2 )
299 p[i] = q[i], p[i + 1] = -q[i + 1];
303 for( ; j < n; ++j, p += n, q -= n )
305 for( i = 0; i < n - 1; i += 2 )
306 p[i] = q[i], p[i + 1] = -q[i + 1];
323 realType *w = work, *d = w + n, *u = d + n, *v = u + n;
324 for( i = 0; i < n; ++i )
327 for( j = 0; j < i; ++j )
329 for( ++j; j < n; ++j )
334 for( i = 0; i < m; ++i )
337 for( j = 0; j < n; ++j )
339 for( j = 0; j < n - 1; ++j )
340 u[j + 1] = d[j] * u[j];
341 for( j = n - 1; j; --j )
342 v[j - 1] = d[j] * v[j];
343 for( j = 0; j < n; ++j )
344 *J++ = w[j] * u[j] * v[j];
363 realType *w = work, *d = w + n, *u = d + n, *v = u + n, *up = v + n, *vp = up + n;
364 for( i = 0; i < n; ++i )
367 for( j = 0; j < i; ++j )
369 for( ++j; j < n; ++j )
374 up[0] = vp[n - 1] = 0;
375 for( i = 0; i < m; ++i )
378 for( j = 0; j < n; ++j )
380 for( j = 0; j < n - 1; ++j )
381 u[j + 1] = d[j] * u[j], up[j + 1] = d[j] * up[j] + u[j];
382 for( j = n - 1; j; --j )
383 v[j - 1] = d[j] * v[j], vp[j - 1] = d[j] * vp[j] + v[j];
384 for( j = 0; j < n; ++j )
385 *J++ = w[j] * u[j] * v[j], *D++ = w[j] * ( up[j] * v[j] + u[j] * vp[j] );
416 unsigned i, n = p->
n;
417 for( i = 0; i < n; ++i )
418 p->
d[i] = x - p->
z[i];
419 for( i = 0; i < n - 1; ++i )
420 p->
u0[i + 1] = p->
d[i] * p->
u0[i];
421 for( i = n - 1; i; --i )
422 p->
v0[i - 1] = p->
d[i] * p->
v0[i];
423 for( i = 0; i < n; ++i )
424 p->
J[i] = p->
w[i] * p->
u0[i] * p->
v0[i];
429 unsigned i, n = p->
n;
430 for( i = 0; i < n; ++i )
431 p->
d[i] = x - p->
z[i];
432 for( i = 0; i < n - 1; ++i )
433 p->
u0[i + 1] = p->
d[i] * p->
u0[i], p->
u1[i + 1] = p->
d[i] * p->
u1[i] + p->
u0[i];
434 for( i = n - 1; i; --i )
435 p->
v0[i - 1] = p->
d[i] * p->
v0[i], p->
v1[i - 1] = p->
d[i] * p->
v1[i] + p->
v0[i];
436 for( i = 0; i < n; ++i )
437 p->
J[i] = p->
w[i] * p->
u0[i] * p->
v0[i], p->
D[i] = p->
w[i] * ( p->
u1[i] * p->
v0[i] + p->
u0[i] * p->
v1[i] );
442 unsigned i, n = p->
n;
443 for( i = 0; i < n; ++i )
444 p->
d[i] = x - p->
z[i];
445 for( i = 0; i < n - 1; ++i )
446 p->
u0[i + 1] = p->
d[i] * p->
u0[i], p->
u1[i + 1] = p->
d[i] * p->
u1[i] + p->
u0[i],
447 p->
u2[i + 1] = p->
d[i] * p->
u2[i] + 2 * p->
u1[i];
448 for( i = n - 1; i; --i )
449 p->
v0[i - 1] = p->
d[i] * p->
v0[i], p->
v1[i - 1] = p->
d[i] * p->
v1[i] + p->
v0[i],
450 p->
v2[i - 1] = p->
d[i] * p->
v2[i] + 2 * p->
v1[i];
451 for( i = 0; i < n; ++i )
452 p->
J[i] = p->
w[i] * p->
u0[i] * p->
v0[i], p->
D[i] = p->
w[i] * ( p->
u1[i] * p->
v0[i] + p->
u0[i] * p->
v1[i] ),
453 p->
D2[i] = p->
w[i] * ( p->
u2[i] * p->
v0[i] + 2 * p->
u1[i] * p->
v1[i] + p->
u0[i] * p->
v2[i] );
458 unsigned i, n = p->
n;
459 for( i = 0; i < n - 1; ++i )
460 p->
u2[i + 1] = p->
d[i] * p->
u2[i] + 2 * p->
u1[i];
461 for( i = n - 1; i; --i )
462 p->
v2[i - 1] = p->
d[i] * p->
v2[i] + 2 * p->
v1[i];
463 for( i = 0; i < n; ++i )
464 p->
D2[i] = p->
w[i] * ( p->
u2[i] * p->
v0[i] + 2 * p->
u1[i] * p->
v1[i] + p->
u0[i] * p->
v2[i] );
473 p->
J = p->
d + n, p->
D = p->
J + n, p->
D2 = p->
D + n;
474 p->
u0 = p->
D2 + n, p->
v0 = p->
u0 + n;
475 p->
u1 = p->
v0 + n, p->
v1 = p->
u1 + n;
476 p->
u2 = p->
v1 + n, p->
v2 = p->
u2 + n;
479 for( i = 0; i < n; ++i )
482 for( j = 0; j < i; ++j )
484 for( ++j; j < n; ++j )
488 p->
u0[0] = p->
v0[n - 1] = 1;
489 p->
u1[0] = p->
v1[n - 1] = 0;
490 p->
u2[0] = p->
v2[n - 1] = 0;