This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / MINICERN / mathlib / gen / e / splan3.F
1 *
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.1.1.1  1996/04/01 15:02:26  mclareni
6 * Mathlib gen
7 *
8 *
9 #include "gen/pilot.h"
10       SUBROUTINE SPLAN3(B3,X,X4,X5,X6,X7,X8,ND)
11 #include "gen/imp64.inc"
12       DIMENSION B3(7)
13
14 ************************************************************************
15 *   NORBAS, VERSION: 15.03.1993
16 ************************************************************************
17 *
18 *   TEST-ROUTINE  SPLAN3
19 *   FOR COMPUTING  1-DIMENSIONAL  B-SPLINES OF DEGREE  K = 3
20 *   BY MEANS OF ANALYTIC FORMULAE
21 *
22 ************************************************************************
23
24       DO 1 I = 1,7
25     1 B3(I)=0
26       IF(ND .LT. -1 .OR. ND .GT. 3) RETURN
27       IF(X .LT. X4 .OR. X .GT. X8) RETURN
28       IF(ND .EQ. 0) THEN
29        IF(X4 .LT. X5 .AND. X5 .LT. X6 .AND. X6 .LT. X7
30      1                                .AND. X7 .LT. X8) THEN
31         IF(X .LT. X5) THEN
32          B3(1)=((X5-X)/X5)**3
33          B3(2)=(X*(((X-X6)*X5+(X-X5)*X6)*(X-X6)*X5+(X-X5)**2*X6**2))/
34      1          (X6**2*X5**3)
35          B3(3)=(-X**2*(X*X7*X6+X*X7*X5+X*X6*X5-3*X7*X6*X5))/
36      1         (X7*(X6*X5)**2)
37          B3(4)=X**3/(X7*X6*X5)
38          B3(5)=0
39          B3(6)=0
40          B3(7)=0
41         ELSE IF(X5 .LE. X .AND. X .LT. X6) THEN
42          B3(1)=0
43          B3(2)=(X6-X)**3/(X6**2*(X6-X5))
44          B3(3)=(X*(X-X6)**2*(X7-X5)*X7+((X-X7)*(X-X5)*X6+(X-X6)*
45      1         (X7-X5)*X)*(X-X7)*X6)/((X7-X5)*(X6-X5)*X7*X6**2)
46          B3(4)=(-(((X-X7)*(X5-1)*X-(X-X5)*(X-1)*X7)*(X-X5)*X6+
47      1     (X-X6)*(X7-X5)*(X5-1)*X**2))/((X7-X5)*(X6-X5)*(X5-1)*X7*X6)
48          B3(5)=(X5-X)**3/((X7-X5)*(X6-X5)*(X5-1))
49          B3(6)=0
50          B3(7)=0
51         ELSE IF(X6 .LE. X .AND. X .LT. X7) THEN
52          B3(1)=0
53          B3(2)=0
54          B3(3)=(X7-X)**3/(X7*(X7-X6)*(X7-X5))
55          B3(4)=(((X-X7)*(X5-1)*X-(X-X5)*(X-1)*X7)*(X-X7)*(X6-1)+
56      1       (X-X6)*(X-1)**2*(X7-X5)*X7)/
57      2                  ((X7-X6)*(X7-X5)*(X6-1)*(X5-1)*X7)
58          B3(5)=(((X-X7)*(X-X5)*(X6-1)-(X-X6)*(X-1)*(X7-X5))*(X-X5)
59      1           *(X6-1)-(X-X6)**2*(X-1)*(X7-X5)*(X5-1))/
60      2           ((X7-X6)*(X7-X5)*(X6-1)**2*(X5-1))
61          B3(6)=(X-X6)**3/((X7-X6)*(X6-1)**2)
62          B3(7)=0
63         ELSE
64          B3(1)=0
65          B3(2)=0
66          B3(3)=0
67          B3(4)=(X-1)**3/((X7-1)*(X6-1)*(X5-1))
68          B3(5)=(-(((X-X6)*(X5-1)+(X-X5)*(X6-1))*(X7-1)+(X-X7)*
69      1         (X6-1)*(X5-1))*(X-1)**2)/((X7-1)**2*(X6-1)**2*(X5-1))
70          B3(6)=((((X-X7)*(X6-1)+(X-X6)*(X7-1))*(X-X6)*(X7-1)+
71      1           (X-X7)**2*(X6-1)**2)*(X-1))/((X7-1)**3*(X6-1)**2)
72          B3(7)=((X7-X)/(X7-1))**3
73         END IF
74        ELSE IF(X4 .LT. X5 .AND. X5 .EQ. X6 .AND. X6 .LT. X7
75      1                                     .AND. X7 .LT. X8) THEN
76         IF(X .LT. X5) THEN
77          B3(1)=((X5-X)/X5)**3
78          B3(2)=(3*X*(X-X5)**2)/X5**3
79          B3(3)=(-X**2*((X-X7)*X5+2*(X-X5)*X7))/(X7*X5**3)
80          B3(4)=X**3/(X7*X5**2)
81          B3(5)=0
82          B3(6)=0
83          B3(7)=0
84         ELSE IF(X5 .LE. X .AND. X .LT. X7) THEN
85          B3(1)=0
86          B3(2)=0
87          B3(3)=(X7-X)**3/(X7*(X7-X5)**2)
88          B3(4)=(((X-X7)*(X5-1)*X-(X-X5)*(X-1)*X7)*(X-X7)*(X5-1)+
89      1       (X-X5)*(X-1)**2*(X7-X5)*X7)/((X7-X5)**2*(X5-1)**2*X7)
90          B3(5)=(((X-X7)*(X5-1)-2*(X-1)*(X7-X5))*(X-X5)**2)/
91      1           ((X7-X5)*(X5-1))**2
92          B3(6)=(X-X5)**3/((X7-X5)*(X5-1)**2)
93          B3(7)=0
94         ELSE
95          B3(1)=0
96          B3(2)=0
97          B3(3)=0
98          B3(4)=(X-1)**3/((X7-1)*(X5-1)**2)
99          B3(5)=(-((X-X7)*(X5-1)+2*(X-X5)*(X7-1))*(X-1)**2)/
100      1               ((X7-1)*(X5-1))**2
101          B3(6)=((((X-X7)*(X5-1)+(X-X5)*(X7-1))*(X-X5)*(X7-1)+
102      1       (X-X7)**2*(X5-1)**2)*(X-1))/((X7-1)**3*(X5-1)**2)
103          B3(7)=((X7-X)/(X7-1))**3
104         END IF
105        ELSE IF(X4 .LT. X5 .AND. X5 .LT. X6 .AND. X6 .EQ. X7
106      1                                     .AND. X7 .LT. X8) THEN
107         IF(X .LT. X5) THEN
108          B3(1)=((X5-X)/X5)**3
109          B3(2)=(X*(((X-X6)*X5+(X-X5)*X6)*(X-X6)*X5+(X-X5)**2*X6**2))/
110      1                      (X6**2*X5**3)
111          B3(3)=(-X**2*(2*(X-X6)*X5+(X-X5)*X6))/(X6*X5)**2
112          B3(4)=X**3/(X6**2*X5)
113          B3(5)=0
114          B3(6)=0
115          B3(7)=0
116         ELSE IF(X5 .LE. X .AND. X .LT. X6) THEN
117          B3(1)=0
118          B3(2)=(X6-X)**3/(X6**2*(X6-X5))
119          B3(3)=(((X-X5)*X6+2*(X6-X5)*X)*(X-X6)**2)/((X6-X5)*X6)**2
120          B3(4)=(-(((X-X6)*(X5-1)*X-(X-X5)*(X-1)*X6)*(X-X5)*X6+
121      1          (X-X6)*(X6-X5)*(X5-1)*X**2))/((X6-X5)**2*(X5-1)*X6**2)
122          B3(5)=(X5-X)**3/((X6-X5)**2*(X5-1))
123          B3(6)=0
124          B3(7)=0
125         ELSE
126          B3(1)=0
127          B3(2)=0
128          B3(3)=0
129          B3(4)=(X-1)**3/((X6-1)**2*(X5-1))
130          B3(5)=(-(2*(X-X6)*(X5-1)+(X-X5)*(X6-1))*(X-1)**2)/
131      1                    ((X6-1)**3*(X5-1))
132          B3(6)=3*(X-1)*(X6-X)**2/(X6-1)**3
133          B3(7)=((X6-X)/(X6-1))**3
134         END IF
135        ELSE IF(X4 .LT. X5 .AND. X5 .EQ. X6 .AND. X6 .EQ. X7
136      1                                     .AND. X7 .LT. X8) THEN
137         IF(X .LT. X5) THEN
138          B3(1)=((X5-X)/X5)**3
139          B3(2)=3*X*(X5-X)**2/X5**3
140          B3(3)=3*X**2*(X5-X)/X5**3
141          B3(4)=(X/X5)**3
142          B3(5)=0
143          B3(6)=0
144          B3(7)=0
145         ELSE
146          B3(1)=0
147          B3(2)=0
148          B3(3)=0
149          B3(4)=((X-1)/(X5-1))**3
150          B3(5)=3*(X-1)**2*(X5-X)/(X5-1)**3
151          B3(6)=3*(X-1)*(X5-X)**2/(X5-1)**3
152          B3(7)=((X5-X)/(X5-1))**3
153         END IF
154        END IF
155       ELSE IF(ND .EQ. 1) THEN
156        IF(X4 .LT. X5 .AND. X5 .LT. X6 .AND. X6 .LT. X7
157      1                                .AND. X7 .LT. X8) THEN
158         IF(X .LT. X5) THEN
159          B3(1)=-3*(X-X5)**2/X5**3
160          B3(2)=3*(X**2*(X6**2+X6*X5+X5**2)-2*X*(X6**2*X5+X6*X5**2)
161      .    +X6**2*X5**2)/(X6**2*X5**3)
162          B3(3)=-3*(X*(X7*X6+X7*X5+X6*X5)-2*X7*X6*X5)*X/(X7*X6**2*X5**2)
163          B3(4)=3*X**2/(X7*X6*X5)
164          B3(5)=0
165          B3(6)=0
166          B3(7)=0
167         ELSE IF(X5 .LE. X .AND. X .LT. X6) THEN
168          B3(1)=0
169          B3(2)=-3*(X-X6)**2/((X6-X5)*X6**2)
170          B3(3)=3*(X**2*(X7**2+X7*X6-X7*X5+X6**2-X6*X5)+
171      .    2*X*(-X7**2*X6-X7*X6**2+X7*X6*X5)+X7**2*X6**2)/
172      .    ((X7-X5)*(X6-X5)*X7*X6**2)
173          B3(4)=3*(X**2*(X7*X6-X7*X5+X7-X6*X5+X6+X5**2-X5)
174      .    -2*X*X7*X6+X7*X6*X5)/((X7-X5)*(X6-X5)*(X5-1)*X7*X6)
175          B3(5)=-3*(X-X5)**2/((X7-X5)*(X6-X5)*(X5-1))
176          B3(6)=0
177          B3(7)=0
178         ELSE IF(X6 .LE. X .AND. X .LT. X7) THEN
179          B3(1)=0
180          B3(2)=0
181          B3(3)=-3*(X-X7)**2/((X7-X6)*(X7-X5)*X7)
182          B3(4)=3*(X**2*(X7**2-X7*X6-X7*X5+X7+X6*X5-X6-X5+1)+
183      .    2*X*(-X7**2+X7*X6+X7*X5-X7)+X7**2-X7*X6*X5)/
184      .    ((X7-X6)*(X7-X5)*(X6-1)*(X5-1)*X7)
185          B3(5)=(((X-X7)*(X-X5)*(X6-1)-(X-X6)*(X-1)*(X7-X5))*
186      .    (X6-1)-2*(X*X7-X*X6-X*X5+X-X7+X6*X5)*(X-X5)*(X6-1)-
187      .    (X-X6)**2*(X7-X5)*(X5-1)-2*(X-X6)*(X-1)*(X7-X5)*(X5-1))/
188      .    ((X7-X6)*(X7-X5)*(X6-1)**2*(X5-1))
189          B3(6)=3*(X-X6)**2/((X7-X6)*(X6-1)**2)
190          B3(7)=0
191         ELSE
192          B3(1)=0
193          B3(2)=0
194          B3(3)=0
195          B3(4)=3*(X-1)**2/((X7-1)*(X6-1)*(X5-1))
196          B3(5)=-3*(X*(X7*X6+X7*X5-2*X7+X6*X5-2*X6-2*X5+3)
197      .    -2*X7*X6*X5+X7*X6+X7*X5+X6*X5-1)*(X-1)/
198      .    ((X7-1)**2*(X6-1)**2*(X5-1))
199          B3(6)=3*(X**2*(X7**2+X7*X6-3*X7+X6**2-3*X6+3)+
200      .    X*(-2*X7**2*X6-2*X7*X6**2+6*X7*X6-2)
201      .    +X7**2*X6**2-3*X7*X6+X7+X6)/((X7-1)**3*(X6-1)**2)
202          B3(7)=-3*(X-X7)**2/(X7-1)**3
203         END IF
204        ELSE IF(X4 .LT. X5 .AND. X5 .EQ. X6 .AND. X6 .LT. X7
205      1                                     .AND. X7 .LT. X8) THEN
206         IF(X .LT. X5) THEN
207          B3(1)=-3*(X-X5)**2/X5**3
208          B3(2)=3*(3*X-X5)*(X-X5)/X5**3
209          B3(3)=(3*X**2*(-2*X7-X5)+6*X*X7*X5)/(X7*X5**3)
210          B3(4)=3*X**2/(X7*X5**2)
211          B3(5)=0
212          B3(6)=0
213          B3(7)=0
214         ELSE IF(X5 .LE. X .AND. X .LT. X7) THEN
215          B3(1)=0
216          B3(2)=0
217          B3(3)=-3*(X-X7)**2/((X7-X5)**2*X7)
218          B3(4)=3*(X**2*(X7**2-2*X7*X5+X7+X5**2-2*X5+1)+
219      .    X*(-2*X7**2+4*X7*X5-2*X7)+X7**2-X7*X5**2)/
220      .    ((X7-X5)**2*(X5-1)**2*X7)
221          B3(5)=-3*(X*(2*X7-3*X5+1)-2*X7+X5**2+X5)*(X-X5)/
222      .    ((X7-X5)**2*(X5-1)**2)
223          B3(6)=3*(X-X5)**2/((X7-X5)*(X5-1)**2)
224          B3(7)=0
225         ELSE
226          B3(1)=0
227          B3(2)=0
228          B3(3)=0
229          B3(4)=3*(X-1)**2/((X7-1)*(X5-1)**2)
230          B3(5)=-3*(X*(2*X7+X5-3)-2*X7*X5+X5+1)*(X-1)/
231      .    ((X7-1)**2*(X5-1)**2)
232          B3(6)=3*(X**2*(X7**2+X7*X5-3*X7+X5**2-3*X5+3)+
233      .    X*(-2*X7**2*X5-2*X7*X5**2+6*X7*X5-2)
234      .    +X7**2*X5**2-3*X7*X5+X7+X5)/((X7-1)**3*(X5-1)**2)
235          B3(7)=-3*(X-X7)**2/(X7-1)**3
236         END IF
237        ELSE IF(X4 .LT. X5 .AND. X5 .LT. X6 .AND. X6 .EQ. X7
238      1                                     .AND. X7 .LT. X8) THEN
239         IF(X .LT. X5) THEN
240          B3(1)=-3*(X-X5)**2/X5**3
241          B3(2)=(3*X**2*(X6**2+X6*X5+X5**2)-(6*X*X6*X5)*(X6+X5)+3
242      .    *X6**2*X5**2)/(X6**2*X5**3)
243          B3(3)=(3*X**2*(-X6-2*X5)+6*X*X6*X5)/(X6**2*X5**2)
244          B3(4)=3*X**2/(X6**2*X5)
245          B3(5)=0
246          B3(6)=0
247          B3(7)=0
248         ELSE IF(X5 .LE. X .AND. X .LT. X6) THEN
249          B3(1)=0
250          B3(2)=-3*(X-X6)**2/((X6-X5)*X6**2)
251          B3(3)=3*(X*(3*X6-2*X5)-X6**2)*(X-X6)/((X6-X5)**2*X6**2)
252          B3(4)=3*(X**2*(X6**2-2*X6*X5+2*X6+X5**2-X5)
253      .    -2*X*X6**2+X6**2*X5)/((X6-X5)**2*(X5-1)*X6**2)
254          B3(5)=-3*(X-X5)**2/((X6-X5)**2*(X5-1))
255          B3(6)=0
256          B3(7)=0
257         ELSE
258          B3(1)=0
259          B3(2)=0
260          B3(3)=0
261          B3(4)=3*(X-1)**2/((X6-1)**2*(X5-1))
262          B3(5)=-3*(X*(X6+2*X5-3)-2*X6*X5+X6+1)*(X-1)/
263      .    ((X6-1)**3*(X5-1))
264          B3(6)=3*(3*X-X6-2)*(X-X6)/(X6-1)**3
265          B3(7)=-3*(X-X6)**2/(X6-1)**3
266         END IF
267        ELSE IF(X4 .LT. X5 .AND. X5 .EQ. X6 .AND. X6 .EQ. X7
268      1                                     .AND. X7 .LT. X8) THEN
269         IF(X .LT. X5) THEN
270          B3(1)=-3*(X-X5)**2/X5**3
271          B3(2)=3*(3*X-X5)*(X-X5)/X5**3
272          B3(3)=-3*(2*(X-X5)+X)*X/X5**3
273          B3(4)=3*X**2/X5**3
274          B3(5)=0
275          B3(6)=0
276          B3(7)=0
277         ELSE
278          B3(1)=0
279          B3(2)=0
280          B3(3)=0
281          B3(4)=3*(X-1)**2/(X5-1)**3
282          B3(5)=-3*(2*(X-X5)+(X-1))*(X-1)/(X5-1)**3
283          B3(6)=3*(3*X-X5-2)*(X-X5)/(X5-1)**3
284          B3(7)=-3*(X-X5)**2/(X5-1)**3
285         END IF
286        END IF
287       ELSE IF(ND .EQ. 2) THEN
288        IF(X4 .LT. X5 .AND. X5 .LT. X6 .AND. X6 .LT. X7
289      1                                .AND. X7 .LT. X8) THEN
290         IF(X .LT. X5) THEN
291          B3(1)=6*(-X+X5)/X5**3
292          B3(2)=(6*X*(X6**2+X6*X5+X5**2)-(6*X6*X5)*(X6+X5))/(X6**2*X5**3)
293          B3(3)=(-6*X*(X7*X6+X7*X5+X6*X5)+6*X7*X6*X5)/(X7*X6**2*X5**2)
294          B3(4)=6*X/(X7*X6*X5)
295          B3(5)=0
296          B3(6)=0
297          B3(7)=0
298         ELSE IF(X5 .LE. X .AND. X .LT. X6) THEN
299          B3(1)=0
300          B3(2)=-6*(X-X6)/((X6-X5)*X6**2)
301          B3(3)=6*(((X6-X5)*X7+X7**2+X6**2-X6*X5)*X-(X6-X5)*X7*
302      .    X6-X7**2*X6)/((X7-X5)*(X6-X5)*X7*X6**2)
303          B3(4)=6*(((X6-X5+1)*X7-(X5-1)*X6+X5**2-X5)*X-X7*X6)/
304      .    ((X7-X5)*(X6-X5)*(X5-1)*X7*X6)
305          B3(5)=-6*(X-X5)/((X7-X5)*(X6-X5)*(X5-1))
306          B3(6)=0
307          B3(7)=0
308         ELSE IF(X6 .LE. X .AND. X .LT. X7) THEN
309          B3(1)=0
310          B3(2)=0
311          B3(3)=-6*(X-X7)/((X7-X6)*(X7-X5)*X7)
312          B3(4)=-6*(((X6+X5-1)*X7-(X5-1)*X6-X7**2+X5-1)*X-
313      .    (X6+X5-1)*X7+X7**2)/((X7-X6)*(X7-X5)*(X6-1)*(X5-1)*X7)
314          B3(5)=-6*(X*(X7*X6+X7*X5-2*X7-X6**2-X6*X5+2*X6-X5**2+2*X5-1)
315      .    -X7*X6*X5+X7+X6**2*X5+X6*X5**2-2*X6*X5)/
316      .    ((X7-X6)*(X7-X5)*(X6-1)**2*(X5-1))
317          B3(6)=6*(X-X6)/((X7-X6)*(X6-1)**2)
318          B3(7)=0
319         ELSE
320          B3(1)=0
321          B3(2)=0
322          B3(3)=0
323          B3(4)=6*(X-1)/((X7-1)*(X6-1)*(X5-1))
324          B3(5)=-6*(X*(X7*X6+X7*X5-2*X7+X6*X5-2*X6-2*X5+3)
325      .    -X7*X6*X5+X7+X6+X5-2)/((X7-1)**2*(X6-1)**2*(X5-1))
326          B3(6)=6*(((X6-3)*X7+X7**2+X6**2-3*X6+3)*X-(X6-3)*
327      .    X7*X6-X7**2*X6-1)/((X7-1)**3*(X6-1)**2)
328          B3(7)=-6*(X-X7)/(X7-1)**3
329         END IF
330        ELSE IF(X4 .LT. X5 .AND. X5 .EQ. X6 .AND. X6 .LT. X7
331      1                                     .AND. X7 .LT. X8) THEN
332         IF(X .LT. X5) THEN
333          B3(1)=6*(-X+X5)/X5**3
334          B3(2)=(18*X-12*X5)/X5**3
335          B3(3)=(6*X*(-2*X7-X5)+6*X7*X5)/(X7*X5**3)
336          B3(4)=6*X/(X7*X5**2)
337          B3(5)=0
338          B3(6)=0
339          B3(7)=0
340         ELSE IF(X5 .LE. X .AND. X .LT. X7) THEN
341          B3(1)=0
342          B3(2)=0
343          B3(3)=-6*(X-X7)/((X7-X5)**2*X7)
344          B3(4)=-6*(((2*X5-1)*X7-X7**2-X5**2+2*X5-1)*X-
345      .    (2*X5-1)*X7+X7**2)/((X7-X5)**2*(X5-1)**2*X7)
346          B3(5)=-6*(X*(2*X7-3*X5+1)-X7*X5-X7+2*X5**2)/
347      .    ((X7-X5)**2*(X5-1)**2)
348          B3(6)=6*(X-X5)/((X7-X5)*(X5-1)**2)
349          B3(7)=0
350         ELSE
351          B3(1)=0
352          B3(2)=0
353          B3(3)=0
354          B3(4)=6*(X-1)/((X7-1)*(X5-1)**2)
355          B3(5)=-6*(X*(2*X7+X5-3)-X7*X5-X7+2)/((X7-1)**2*(X5-1)**2)
356          B3(6)=6*(((X5-3)*X7+X7**2+X5**2-3*X5+3)*X-(X5-3)*
357      .    X7*X5-X7**2*X5-1)/((X7-1)**3*(X5-1)**2)
358          B3(7)=-6*(X-X7)/(X7-1)**3
359         END IF
360        ELSE IF(X4 .LT. X5 .AND. X5 .LT. X6 .AND. X6 .EQ. X7
361      1                                     .AND. X7 .LT. X8) THEN
362         IF(X .LT. X5) THEN
363          B3(1)=6*(-X+X5)/X5**3
364          B3(2)=(6*X*(X6**2+X6*X5+X5**2)-(6*X6*X5)*(X6+X5))/(X6**2*X5**3)
365          B3(3)=(6*X*(-X6-2*X5)+6*X6*X5)/(X6**2*X5**2)
366          B3(4)=6*X/(X6**2*X5)
367          B3(5)=0
368          B3(6)=0
369          B3(7)=0
370         ELSE IF(X5 .LE. X .AND. X .LT. X6) THEN
371          B3(1)=0
372          B3(2)=-6*(X-X6)/((X6-X5)*X6**2)
373          B3(3)=6*(3*X*X6-2*X*X5-2*X6**2+X6*X5)/((X6-X5)**2*X6**2)
374          B3(4)=-6*((2*(X5-1)*X6-X6**2-X5**2+X5)*X+X6**2)/
375      .    ((X6-X5)**2*(X5-1)*X6**2)
376          B3(5)=-6*(X-X5)/((X6-X5)**2*(X5-1))
377          B3(6)=0
378          B3(7)=0
379         ELSE
380          B3(1)=0
381          B3(2)=0
382          B3(3)=0
383          B3(4)=6*(X-1)/((X6-1)**2*(X5-1))
384          B3(5)=-6*(X*(X6+2*X5-3)-X6*X5-X5+2)/((X6-1)**3*(X5-1))
385          B3(6)=6*(3*X-2*X6-1)/(X6-1)**3
386          B3(7)=-6*(X-X6)/(X6-1)**3
387         END IF
388        ELSE IF(X4 .LT. X5 .AND. X5 .EQ. X6 .AND. X6 .EQ. X7
389      1                                     .AND. X7 .LT. X8) THEN
390         IF(X .LT. X5) THEN
391          B3(1)=6*(-X+X5)/X5**3
392          B3(2)=(18*X-12*X5)/X5**3
393          B3(3)=(-18*X+6*X5)/X5**3
394          B3(4)=6*X/X5**3
395          B3(5)=0
396          B3(6)=0
397          B3(7)=0
398         ELSE
399          B3(1)=0
400          B3(2)=0
401          B3(3)=0
402          B3(4)=6*(X-1)/(X5-1)**3
403          B3(5)=-6*(3*X-X5-2)/(X5-1)**3
404          B3(6)=6*(3*X-2*X5-1)/(X5-1)**3
405          B3(7)=-6*(X-X5)/(X5-1)**3
406         END IF
407        END IF
408       ELSE IF(ND .EQ. 3) THEN
409        IF(X4 .LT. X5 .AND. X5 .LT. X6 .AND. X6 .LT. X7
410      1                                .AND. X7 .LT. X8) THEN
411         IF(X .LT. X5) THEN
412          B3(1)=-6/X5**3
413          B3(2)=6*(X6**2+X6*X5+X5**2)/(X6**2*X5**3)
414          B3(3)=-6*(X7*X6+X7*X5+X6*X5)/(X7*X6**2*X5**2)
415          B3(4)=6/(X7*X6*X5)
416          B3(5)=0
417          B3(6)=0
418          B3(7)=0
419         ELSE IF(X5 .LE. X .AND. X .LT. X6) THEN
420          B3(1)=0
421          B3(2)=-6/(X6**2*(X6-X5))
422          B3(3)=6*((X6-X5)*X7+X7**2+X6**2-X6*X5)/
423      .    ((X7-X5)*(X6-X5)*X7*X6**2)
424          B3(4)=6*((X6-X5+1)*X7-(X5-1)*X6+X5**2-X5)/
425      .    ((X7-X5)*(X6-X5)*(X5-1)*X7*X6)
426          B3(5)=-6/((X7-X5)*(X6-X5)*(X5-1))
427          B3(6)=0
428          B3(7)=0
429         ELSE IF(X6 .LE. X .AND. X .LT. X7) THEN
430          B3(1)=0
431          B3(2)=0
432          B3(3)=-6/((X7-X6)*(X7-X5)*X7)
433          B3(4)=-6*((X6+X5-1)*X7-(X5-1)*X6-X7**2+X5-1)/
434      .    ((X7-X6)*(X7-X5)*(X6-1)*(X5-1)*X7)
435          B3(5)=-6*((X6+X5-2)*X7-(X5-2)*X6-X6**2-X5**2+2*X5-1)/
436      .    ((X7-X6)*(X7-X5)*(X6-1)**2*(X5-1))
437          B3(6)=6/((X7-X6)*(X6-1)**2)
438          B3(7)=0
439         ELSE
440          B3(1)=0
441          B3(2)=0
442          B3(3)=0
443          B3(4)=6/((X7-1)*(X6-1)*(X5-1))
444          B3(5)=-6*((X6+X5-2)*X7+(X5-2)*X6-2*X5+3)/
445      .    ((X7-1)**2*(X6-1)**2*(X5-1))
446          B3(6)=6*((X6-3)*X7+X7**2+X6**2-3*X6+3)/((X7-1)**3*(X6-1)**2)
447          B3(7)=-6/(X7-1)**3
448         END IF
449        ELSE IF(X4 .LT. X5 .AND. X5 .EQ. X6 .AND. X6 .LT. X7
450      1                                     .AND. X7 .LT. X8) THEN
451         IF(X .LT. X5) THEN
452          B3(1)=-6/X5**3
453          B3(2)=18/X5**3
454          B3(3)=6*(-2*X7-X5)/(X7*X5**3)
455          B3(4)=6/(X7*X5**2)
456          B3(5)=0
457          B3(6)=0
458          B3(7)=0
459         ELSE IF(X5 .LE. X .AND. X .LT. X7) THEN
460          B3(1)=0
461          B3(2)=0
462          B3(3)=-6/((X7-X5)**2*X7)
463          B3(4)=-6*((2*X5-1)*X7-X7**2-X5**2+2*X5-1)/
464      .    ((X7-X5)**2*(X5-1)**2*X7)
465          B3(5)=-6*(2*X7-3*X5+1)/((X7-X5)**2*(X5-1)**2)
466          B3(6)=6/((X7-X5)*(X5-1)**2)
467          B3(7)=0
468         ELSE
469          B3(1)=0
470          B3(2)=0
471          B3(3)=0
472          B3(4)=6/((X7-1)*(X5-1)**2)
473          B3(5)=-6*(2*X7+X5-3)/((X7-1)**2*(X5-1)**2)
474          B3(6)=6*((X5-3)*X7+X7**2+X5**2-3*X5+3)/((X7-1)**3*(X5-1)**2)
475          B3(7)=-6/(X7-1)**3
476         END IF
477        ELSE IF(X4 .LT. X5 .AND. X5 .LT. X6 .AND. X6 .EQ. X7
478      1                                     .AND. X7 .LT. X8) THEN
479         IF(X .LT. X5) THEN
480          B3(1)=-6/X5**3
481          B3(2)=6*(X6**2+X6*X5+X5**2)/(X6**2*X5**3)
482          B3(3)=6*(-X6-2*X5)/(X6**2*X5**2)
483          B3(4)=6/(X6**2*X5)
484          B3(5)=0
485          B3(6)=0
486          B3(7)=0
487         ELSE IF(X5 .LE. X .AND. X .LT. X6) THEN
488          B3(1)=0
489          B3(2)=-6/(X6**2*(X6-X5))
490          B3(3)=6*(3*X6-2*X5)/((X6-X5)**2*X6**2)
491          B3(4)=-6*(2*(X5-1)*X6-X6**2-X5**2+X5)/((X6-X5)**2*(X5-1)*X6**2)
492          B3(5)=-6/((X6-X5)**2*(X5-1))
493          B3(6)=0
494          B3(7)=0
495         ELSE
496          B3(1)=0
497          B3(2)=0
498          B3(3)=0
499          B3(4)=6/((X6-1)**2*(X5-1))
500          B3(5)=-6*(X6+2*X5-3)/((X6-1)**3*(X5-1))
501          B3(6)=18/(X6-1)**3
502          B3(7)=-6/(X6-1)**3
503         END IF
504        ELSE IF(X4 .LT. X5 .AND. X5 .EQ. X6 .AND. X6 .EQ. X7
505      1                                     .AND. X7 .LT. X8) THEN
506         IF(X .LT. X5) THEN
507          B3(1)=-6/X5**3
508          B3(2)=18/X5**3
509          B3(3)=-18/X5**3
510          B3(4)=6/X5**3
511          B3(5)=0
512          B3(6)=0
513          B3(7)=0
514         ELSE
515          B3(1)=0
516          B3(2)=0
517          B3(3)=0
518          B3(4)=6/(X5-1)**3
519          B3(5)=-18/(X5-1)**3
520          B3(6)=18/(X5-1)**3
521          B3(7)=-6/(X5-1)**3
522         END IF
523        END IF
524       ELSE IF(ND .EQ. -1) THEN
525        IF(X4 .LT. X5 .AND. X5 .LT. X6 .AND. X6 .LT. X7
526      1                                .AND. X7 .LT. X8) THEN
527         IF(X .LT. X5) THEN
528          B3(1)=-(X**2-2*X*X5+2*X5**2)*(X-2*X5)*X/(4*X5**3)
529          B3(2)=((X6**2+X6*X5+X5**2)*X**2-4*(X6+X5)*X*X6*X5+
530      .    6*X6**2*X5**2)*X**2/(4*X6**2*X5**3)
531          B3(3)=-(((X6+X5)*X7+X6*X5)*X-4*X7*X6*X5)*X**3/
532      .    (4*X7*X6**2*X5**2)
533          B3(4)=X**4/(4*X7*X6*X5)
534          B3(5)=0
535          B3(6)=0
536          B3(7)=0
537         ELSE IF(X5 .LE. X .AND. X .LT. X6) THEN
538          B3(1)=X5/4
539          B3(2)=-(X**4-4*X**3*X6+6*X**2*X6**2-4*X*X6**3+X6**3*X5)/
540      .    (4*(X6-X5)*X6**2)
541          B3(3)=(X**4*(X7**2+X7*X6-X7*X5+X6**2-X6*X5)+
542      .    X**3*(-4*X7**2*X6-4*X7*X6**2+4*X7*X6*X5)+
543      .    6*X**2**X7**2*X6**2-4*X*X7**2*X6**2*X5+X7**2*X6**2*X5**2)/
544      .    (4*(X7-X5)*(X6-X5)*X7*X6**2)
545          B3(4)=(X**4*(X7*X6-X7*X5+X7-X6*X5+X6+X5**2-X5)
546      .    -4*X**3*X7*X6+6*X**2*X7*X6*X5-4*X*X7*X6*X5**2+X7*X6*X5**3)/
547      .    (4*(X7-X5)*(X6-X5)*(X5-1)*X7*X6)
548          B3(5)=-(X-X5)**4/(4*(X7-X5)*(X6-X5)*(X5-1))
549          B3(6)=0
550          B3(7)=0
551         ELSE IF(X6 .LE. X .AND. X .LT. X7) THEN
552          B3(1)=X5/4
553          B3(2)=X6/4
554          B3(3)=-(X**4-4*X**3*X7+6*X**2*X7**2-4*X*X7**3+X7**3*X6
555      .    +X7**3*X5-X7**2*X6*X5)/(4*(X7-X6)*(X7-X5)*X7)
556          B3(4)=(X**4*(X7**2-X7*X6-X7*X5+X7+X6*X5-X6-X5+1)+
557      .    X**3*(-4*X7**2+4*X7*X6+4*X7*X5-4*X7)+
558      .    X**2*(6*X7**2-6*X7*X6*X5)+
559      .    X*(4*X7**2*X6*X5-4*X7**2*X6-4*X7**2*X5+4*X7*X6*X5)+
560      .    X7**2*(-X6**2*X5+X6**2-X6*X5**2+X6*X5+X5**2)+
561      .    X7*(X6**2*X5**2-X6**2*X5-X6*X5**2))/
562      .    (4*(X7-X6)*(X7-X5)*(X6-1)*(X5-1)*X7)
563          B3(5)=(-(X**4*(X7*X6+X7*X5-2*X7-X6**2-X6*X5
564      .    +2*X6-X5**2+2*X5-1)+
565      .    X**3*(-4*X7*X6*X5+4*X7+4*X6**2*X5+4*X6*X5**2-8*X6*X5)+
566      .    X**2*(12*X7*X6*X5-6*X7*X6-6*X7*X5-6*X6**2*X5**2+6*X6*X5)+
567      .    X*(4*X7*X6**2*X5**2-
568      .    8*X7*X6**2*X5+4*X7*X6**2-8*X7*X6*X5**2+4*X7*X6*X5+
569      .    4*X7*X5**2+8*X6**2*X5**2-4*X6**2*X5-4*X6*X5**2)+
570      .    X7*(-X6**3*X5**2+2*X6**3*X5-X6**3-X6**2*X5**3
571      .    +2*X6**2*X5**2-X6**2*X5+2*X6*X5**3-X6*X5**2-X5**3)+
572      .    X6**3*(X5**3-2*X5**2+X5)+X6**2*(-2*X5**3+X5**2)+X6*X5**3))/
573      .    (4*(X7-X6)*(X7-X5)*(X6-1)**2*(X5-1))
574          B3(6)=(X-X6)**4/(4*(X7-X6)*(X6-1)**2)
575          B3(7)=0
576         ELSE
577          B3(1)=X5/4
578          B3(2)=X6/4
579          B3(3)=X7/4
580          B3(4)=(X**4-4*X**3+6*X**2-4*X+X7*X6*X5-X7*X6-X7*X5+X7-
581      .    X6*X5+X6+X5)/(4*(X7-1)*(X6-1)*(X5-1))
582          B3(5)=(-(X**4*(X7*X6+X7*X5-2*X7+X6*X5-2*X6-2*X5+3)+
583      .    X**3*(-4*X7*X6*X5+4*X7+4*X6+4*X5-8)+
584      .    X**2*(12*X7*X6*X5-6*X7*X6-6*X7*X5-6*X6*X5+6)+
585      .    X*(-12*X7*X6*X5+8*X7*X6+8*X7*X5-4*X7+8*X6*X5-4*X6-4*X5)+
586      .    X7**2*(X6**2*X5**2-2*X6**2*X5+X6**2-
587      .    2*X6*X5**2+4*X6*X5-2*X6+X5**2-2*X5+1)+
588      .    X7*(-2*X6**2*X5**2+4*X6**2*X5-2*X6**2+
589      .    4*X6*X5**2-4*X6*X5+X6-2*X5**2+X5)+X6**2*X5**2
590      .    -2*X6**2*X5+X6**2-2*X6*X5**2+X6*X5+X5**2))/
591      .    (4*(X7-1)**2*(X6-1)**2*(X5-1))
592          B3(6)=(X**4*(X7**2+X7*X6-3*X7+X6**2-3*X6+3)+
593      .    X**3*(-4*X7**2*X6-4*X7*X6**2+12*X7*X6-4)+
594      .    X**2*(6*X7**2*X6**2-18*X7*X6+6*X7+6*X6)+
595      .    X*(-12*X7**2*X6**2+12*X7**2*X6-4*X7**2
596      .    +12*X7*X6**2-4*X7*X6-4*X6**2)+
597      .    X7**3*(-X6**3+3*X6**2-3*X6+1)+X7**2*(3*X6**3-3*X6**2+X6)+
598      .    X7*(-3*X6**3+X6**2)+X6**3)/(4*(X7-1)**3*(X6-1)**2)
599          B3(7)=-(X-X7)**4/(4*(X7-1)**3)
600         END IF
601        ELSE IF(X4 .LT. X5 .AND. X5 .EQ. X6 .AND. X6 .LT. X7
602      1                                     .AND. X7 .LT. X8) THEN
603         IF(X .LT. X5) THEN
604          B3(1)=-(X**2-2*X*X5+2*X5**2)*(X-2*X5)*X/(4*X5**3)
605          B3(2)=(3*X**2-8*X*X5+6*X5**2)*X**2/(4*X5**3)
606          B3(3)=-((2*X7+X5)*X-4*X7*X5)*X**3/(4*X7*X5**3)
607          B3(4)=X**4/(4*X7*X5**2)
608          B3(5)=0
609          B3(6)=0
610          B3(7)=0
611         ELSE IF(X5 .LE. X .AND. X .LT. X7) THEN
612          B3(1)=X5/4
613          B3(2)=X5/4
614          B3(3)=-(X**2-2*X*X7+2*X7**2-X7*X5)*(X**2-2*X*X7+X7*X5)/
615      .    (4*(X7-X5)**2*X7)
616          B3(4)=(X**4*(X7**2-2*X7*X5+X7+X5**2-2*X5+1)+
617      .    X**3*(-4*X7**2+8*X7*X5-4*X7)+X**2*(6*X7**2-6*X7*X5**2)+
618      .    X*(4*X7**2*X5**2-8*X7**2*X5+4*X7*X5**2)+
619      .    X7**2*(-2*X5**3+3*X5**2)+X7*(X5**4-2*X5**3))/
620      .    (4*(X7-X5)**2*(X5-1)**2*X7)
621          B3(5)=-(2*X*X7-3*X*X5+X+2*X7*X5-4*X7-X5**2+3*X5)*(X-X5)**3/
622      .    (4*(X7-X5)**2*(X5-1)**2)
623          B3(6)=(X-X5)**4/(4*(X7-X5)*(X5-1)**2)
624          B3(7)=0
625         ELSE
626          B3(1)=X5/4
627          B3(2)=X5/4
628          B3(3)=X7/4
629          B3(4)=(X**4-4*X**3+6*X**2-4*X+X7*(X5**2-2*X5+1)-X5**2+2*X5)/
630      .    (4*(X7-1)*(X5-1)**2)
631          B3(5)=-(X**4*(2*X7+X5-3)+X**3*(-4*X7*X5-4*X7+8)+
632      .    X**2*(12*X7*X5-6*X5-6)+X*(-12*X7*X5+4*X7+8*X5)+
633      .    X7**2*(X5**3-3*X5**2+3*X5-1)+
634      .    X7*(-2*X5**3+6*X5**2-2*X5)+X5**3-3*X5**2)/
635      .    (4*(X7-1)**2*(X5-1)**2)
636          B3(6)=(X**4*(X7**2+X7*X5-3*X7+X5**2-3*X5+3)+
637      .    X**3*(-4*X7**2*X5-4*X7*X5**2+12*X7*X5-4)+
638      .    X**2*(6*X7**2*X5**2-18*X7*X5+6*X7+6*X5)+
639      .    X*(-12*X7**2*X5**2+12*X7**2*X5-4*X7**2
640      .    +12*X7*X5**2-4*X7*X5-4*X5**2)+
641      .    X7**3*(-X5**3+3*X5**2-3*X5+1)+X7**2*(3*X5**3-3*X5**2+X5)+
642      .    X7*(-3**X5**3+X5**2)+X5**3)/(4*(X7-1)**3*(X5-1)**2)
643          B3(7)=-(X-X7)**4/(4*(X7-1)**3)
644         END IF
645        ELSE IF(X4 .LT. X5 .AND. X5 .LT. X6 .AND. X6 .EQ. X7
646      1                                     .AND. X7 .LT. X8) THEN
647         IF(X .LT. X5) THEN
648          B3(1)=-(X**2-2*X*X5+2*X5**2)*(X-2*X5)*X/(4*X5**3)
649          B3(2)=(((X6**2+X6*X5+X5**2)*X**2-4*(X6+X5)*X*X6*X5
650      .    +6*X6**2*X5**2)*X**2)/(4*X6**2*X5**3)
651          B3(3)=-((X6+2*X5)*X-4*X6*X5)*X**3/(4*X6**2*X5**2)
652          B3(4)=X**4/(4*X6**2*X5)
653          B3(5)=0
654          B3(6)=0
655          B3(7)=0
656         ELSE IF(X5 .LE. X .AND. X .LT. X6) THEN
657          B3(1)=X5/4
658          B3(2)=-(X**4-4*X**3*X6+6*X**2*X6**2-4*X*X6**3+X6**3*X5)/
659      .    (4*(X6-X5)*X6**2)
660          B3(3)=(X**4*(3*X6-2*X5)+X**3*(-8*X6**2+4*X6*X5)+
661      .    6*X**2*X6**3-4*X*X6**3*X5+X6**3*X5**2)/(4*(X6-X5)**2*X6**2)
662          B3(4)=(X**4*(X6**2-2*X6*X5+2*X6+X5**2-X5)
663      .    -4*X**3*X6**2+6*X**2*X6**2*X5-4*X*X6**2*X5**2+X6**2*X5**3)/
664      .    (4*(X6-X5)**2*(X5-1)*X6**2)
665          B3(5)=-(X-X5)**4/(4*(X6-X5)**2*(X5-1))
666          B3(6)=0
667          B3(7)=0
668         ELSE
669          B3(1)=X5/4
670          B3(2)=X6/4
671          B3(3)=X6/4
672          B3(4)=(X**4-4*X**3+6*X**2-4*X+X6**2*X5-X6**2-2*X6*X5+2*X6+X5)/
673      .  (4*(X6-1)**2*(X5-1))
674          B3(5)=-(X**4*(X6+2*X5-3)+X**3*(-4*X6*X5-4*X5+8)+
675      .    X**2*(12*X6*X5-6*X6-6)+X*(-12*X6*X5+8*X6+4*X5)+
676      .    X6**3*(X5**2-2*X5+1)+
677      .    X6**2*(-3*X5**2+6*X5-3)+3*X6*X5**2-2*X6*X5-X5**2)/
678      .    (4*(X6-1)**3*(X5-1))
679          B3(6)=(3*X+X6-4)*(X-X6)**3/(4*(X6-1)**3)
680          B3(7)=-(X-X6)**4/(4*(X6-1)**3)
681         END IF
682        ELSE IF(X4 .LT. X5 .AND. X5 .EQ. X6 .AND. X6 .EQ. X7
683      1                                     .AND. X7 .LT. X8) THEN
684         IF(X .LT. X5) THEN
685          B3(1)=-(X**2-2*X*X5+2*X5**2)*(X-2*X5)*X/(4*X5**3)
686          B3(2)=(3*X**2-8*X*X5+6*X5**2)*X**2/(4*X5**3)
687          B3(3)=-(3*X-4*X5)*X**3/(4*X5**3)
688          B3(4)=X**4/(4*X5**3)
689          B3(5)=0
690          B3(6)=0
691          B3(7)=0
692         ELSE
693          B3(1)=X5/4
694          B3(2)=X5/4
695          B3(3)=X5/4
696          B3(4)=(X**4-4*X**3+6*X**2-4*X+X5**3-3*X5**2+3*X5)/(4*(X5-1)**3)
697          B3(5)=-(3*X**2+X*(2*X5-8)+X5**2-4*X5+6)*(X-X5)**2/(4*(X5-1)**3)
698          B3(6)=(3*X+X5-4)*(X-X5)**3/(4*(X5-1)**3)
699          B3(7)=-(X-X5)**4/(4*(X5-1)**3)
700         END IF
701        END IF
702       END IF
703       RETURN
704       END
705
706