1 SUBROUTINE POLSYS
(N
,NUMT
,COEF
,KDEG
,IFLG1
,IFLG2
,EPSBIG
,EPSSML
,
2 $ SSPAR
,NUMRR
,NN
,MMAXT
,TTOTDG
,LENWK
,LENIWK
,
3 $ LAMBDA
,ROOTS
,ARCLEN
,NFE
,WK
,IWK
)
5 C POLSYS FINDS ALL (COMPLEX) SOLUTIONS TO A SYSTEM
6 C F(X)=0 OF N POLYNOMIAL EQUATIONS IN N UNKNOWNS
7 C WITH REAL COEFFICIENTS. IF IFLG=10 OR IFLG=11, POLSYS
8 C RETURNS THE SOLUTIONS AT INFINITY ALSO.
10 C THE SYSTEM F(X)=0 IS DESCRIBED VIA THE COEFFICENTS,
11 C "COEF", AND THE PARAMETERS "N, NUMT, KDEG", AS FOLLOWS.
16 C F(J) = SUM COEF(J,K) * X(1)**KDEG(J,1,K)...X(N)**KDEG(J,N,K)
23 C POLSYS HAS TWO MAIN RUN OPTIONS: AUTOMATIC SCALING AND
24 C THE PROJECTIVE TRANSFORMATION. THESE ARE EVOKED VIA THE
25 C FLAG "IFLG1", AS DESCRIBED BELOW. THE OTHER INPUT
26 C PARAMETERS ARE THE SAME WHETHER ONE OR BOTH OF THESE OPTIONS
27 C ARE SPECIFIED, AND THE OUTPUT IS ALWAYS RETURNED UNSCALED
30 C IF AUTOMATIC SCALING IS SPECIFIED, THEN THE INPUT
31 C COEFFICIENTS ARE MODIFIED BY SUBROUTINE SCLGNP . THE PROBLEM
32 C IS SOLVED WITH THE SCALED COEFFICIENTS AND SCALED VARIABLES.
33 C THE COEFFICIENTS ARE RETURNED SCALED.
35 C IF THE PROJECTIVE TRANSFORMATION IS SPECIFIED, THEN
36 C ESSENTIALLY THE SYSTEM IS REFORMULATED IN HOMOGENEOUS
37 C COORDINATES, Z(1), ..., Z(N+1), AND SOLVED IN COMPLEX
38 C PROJECTIVE SPACE. THE RESULTING SOLUTIONS ARE
41 C X(J) = Z(J)/Z(N+1) J=1, ..., N.
45 C ROOTS(1,J,M) = REAL PART OF X(J) FOR THE M-TH PATH,
47 C ROOTS(2,J,M) = IMAGINARY PART OF X(J) FOR THE M-TH PATH,
49 C FOR J=1, ..., N, AND
51 C ROOTS(1,N+1,M) = REAL PART OF Z(N+1) FOR THE M-TH PATH,
53 C ROOTS(2,N+1,M) = IMAGINARY PART OF Z(N+1) FOR THE M-TH PATH.
55 C IF ROOTS(*,N+1,M) IS SMALL, THEN THE ASSOCIATED SOLUTION
56 C SHOULD BE REGARDED AS BEING "NEAR INFINITY". NOTE THAT,
57 C WHEN THE PROJECTIVE TRANSFORMATION HAS BEEN SPECIFIED, THE
58 C ROOTS VALUES HAVE BEEN UNTRANSFORMED -- THAT IS, DIVIDED
59 C THROUGH BY Z(N+1) -- UNLESS SUCH DIVISION WOULD HAVE CAUSED
60 C OVERFLOW. IN THIS LATTER CASE, THE AFFECTED COMPONENTS OF
61 C ROOTS ARE SET TO THE LARGEST FLOATING POINT NUMBER (MACHINE
64 C THE CODE CAN BE MODIFIED EASILY TO SOLVE SYSTEMS WITH COMPLEX
65 C COEFFICIENTS, COEF . ONLY THE SUBROUTINES INITP AND FFUNP
68 C THE FORTRAN COMPLEX DECLARATION IS NOT USED IN POLSYS.
69 C COMPLEX VARIABLES ARE REPRESENTED BY REAL ARRAYS WITH FIRST
70 C INDEX DIMENSIONED 2 AND COMPLEX OPERATIONS ARE EVOKED BY
73 C THE TOTAL NUMBER OF PATHS THAT WILL THE TRACKED (IF
74 C IFLG2(M)=-2 FOR ALL M) IS EQUAL TO THE "TOTAL DEGREE" OF THE
75 C SYSTEM, TOTDG. TOTDG IS EQUAL TO THE PRODUCTS OF THE
76 C DEGREES OF ALL THE EQUATIONS IN THE SYSTEM. THE DEGREE OF
77 C AN EQUATION IS THE MAXIMUM OF THE DEGREES OF ITS TERMS. THE
78 C DEGREE OF A TERM IS THE SUM OF THE DEGREES OF THE VARIABLES.
79 C THUS, TOTDG = IDEG(1) * ... * IDEG(N) WHERE IDEG(J) =
80 C MAX {JDEG(J,K) | K=1,...,NUMT(J)} WHERE JDEG(J,K) = KDEG(J,1,K) +
83 C IFLG1 DETERMINES WHETHER THE SYSTEM IS TO BE AUTOMATICALLY
84 C SCALED BY POLSYS AND WHETHER THE PROJECTIVE TRANSFORMATION
85 C OF THE SYSTEM IS TO BE AUTOMATICALLY EVOKED BY POLSYS. SEE
88 C IFLG2, EPSBIG, EPSSML, AND SSPAR TELL THE PATH TRACKER
89 C POLYNF WHICH PATHS TO TRACK AND SET PARAMETERS FOR THE PATH
92 C NUMRR TELLS POLSYS HOW MANY MULTIPLES OF 1000 STEPS TO TRY
93 C BEFORE ABANDONING A PATH.
95 C NN, MMAXT, TTOTDG, LENWK, LENIWK GIVE THE DIMENSIONS OF ARRAYS.
97 C THE OUTPUT CONSISTS OF IFLG1, AND OF LAMBDA, ROOTS, ARCLEN, AND
98 C NFE FOR EACH PATH. IFLG1 RETURNS INPUT DATA ERROR INFORMATION.
99 C ROOTS GIVES THE SOLUTIONS THEMSELVES, WHILE LAMBDA, ARCLEN,
100 C AND NFE GIVE INFORMATION ABOUT THE ASSOCIATED PATHS.
102 C THE FOLLOWING SUBROUTINES ARE USED DIRECTLY OR INDIRECTLY BY
104 C SPECIAL FOR POLSYS:
105 C POLYP , INITP , STRPTP ,
106 C OTPUTP , RHO , RHOJAC ,
107 C HFUNP , HFUN1P , GFUNP , FFUNP ,
108 C MULP , POWP , DIVP,
110 C FROM THE GENERAL HOMPACK ROUTINES:
111 C POLYNF , STEPNF , TANGNF , ROOTNF , ROOT ,
112 C QRFAQF, QRSLQF , D1MACH , DDOT , DNRM2.
116 C N IS THE NUMBER OF EQUATIONS AND VARIABLES.
118 C NUMT(1:NN) IS AN INTEGER ARRAY. NUMT(J) IS THE NUMBER OF TERMS
119 C IN THE JTH EQUATION FOR J=1 TO N.
121 C COEF(1:NN,1:MMAXT) IS A REAL ARRAY. COEF(J,K) IS
122 C THE K-TH COEFFICIENT OF THE J-TH EQUATION FOR J=1 TO N,
125 C KDEG(1:NN,1:NN+1,1:MMAXT) IS AN INTEGER ARRAY.
126 C KDEG(J,L,K) IS THE DEGREE OF THE L-TH VARIABLE IN THE K-TH
127 C TERM OF THE J-TH EQUATION FOR J=1 TO N, L=1 TO N, K=1 TO NUMT(J).
130 C 00 IF THE PROBLEM IS TO BE SOLVED WITHOUT
131 C CALLING POLSYS' SCALING ROUTINE, SCLGNP, AND
132 C WITHOUT USING THE PROJECTIVE TRANSFORMTION.
134 C 01 IF SCALING BUT NO PROJECTIVE TRANSFORMATION IS TO BE USED.
136 C 10 IF NO SCALING BUT PROJECTIVE TRANSFORMATION IS TO BE USED.
138 C 11 IF BOTH SCALING AND PROJECTIVE TRANSFORMATION ARE TO BE USED.
140 C IFLG2(1:TTOTDG) IS AN INTEGER ARRAY. IF IFLG2(M) = -2, THEN THE
141 C M-TH PATH IS TRACKED. OTHERWISE THE M-TH PATH IS SKIPPED.
142 C THUS, TO FIND ALL SOLUTIONS SET IFLG2(M) = -2 FOR M=1,...,TOTDG.
143 C SELECTED PATHS CAN BE RERUN BY SETTING IFLG2(M)=-2 FOR
144 C THE PATHS TO BE RERUN AND IFLG(M).NE.-2 FOR THE OTHERS.
146 C EPSBIG IS THE LOCAL ERROR TOLERANCE ALLOWED THE PATH TRACKER ALONG
147 C THE PATH. ARCRE AND ARCAE (IN POLYNF ) ARE SET TO EPSBIG.
149 C EPSSML IS THE ACCURACY DESIRED FOR THE FINAL SOLUTION. ANSRE AND
150 C ANSAE (IN POLYNF ) ARE SET TO EPSSML.
152 C SSPAR(1:8) = (LIDEAL, RIDEAL, DIDEAL, HMIN, HMAX, BMIN, BMAX, P) IS
153 C A VECTOR OF PARAMETERS USED FOR THE OPTIMAL STEP SIZE ESTIMATION.
154 C IF SSPAR(J) .LE. 0.0 ON INPUT, IT IS RESET TO A DEFAULT VALUE
155 C BY POLYNF . OTHERWISE THE INPUT VALUE OF SSPAR(J) IS USED.
156 C SEE THE COMMENTS IN POLYNF AND IN STEPNF FOR MORE INFORMATION
157 C ABOUT THESE CONSTANTS.
159 C NUMRR IS THE NUMBER OF MULTIPLES OF 1000 STEPS THAT WILL BE TRIED
160 C BEFORE ABANDONING A PATH.
162 C NN IS THE DECLARED DIMENSION OF NUMT AND OF THE
163 C FIRST INDEX OF COEF AND KDEG . THE SECOND INDEX OF
164 C KDEG AND ROOTS IS DIMENSIONED NN+1. NN MUST
165 C BE GREATER THAN OR EQUAL TO N.
167 C MMAXT IS THE DECLARED DIMENSION OF THE SECOND INDEX OF
168 C COEF AND THE THIRD INDEX OF KDEG. MMAXT MUST BE
169 C GREATER THAN OR EQUAL TO THE MAXIMUM NUMBER OF
170 C TERMS IN EACH EQUATION. IN OTHER WORDS,
171 C MMAXT .GE. MAX {NUMT(J) | J=1, ..., N} .
173 C TTOTDG IS THE DECLARED DIMENSION OF IFLG2 , LAMBDA , ARCLEN ,
174 C NFE , AND OF THE THIRD INDEX OF ROOTS. TTOTDG
175 C MUST BE GREATER THAN OR EQUAL TO TOTDG, THE TOTAL
176 C DEGREE OF THE SYSTEM.
178 C LENWK IS THE DIMENSION OF THE WORKSPACE WK . LENWK MUST
179 C BE GREATER THAN OR EQUAL TO
180 C 21 + 61*N + 10*N**2 + 7*N*MMAXT + 4*N**2*MMAXT.
182 C LENIWK IS THE DIMENSION OF THE WORKSPACE IWK . LENIWK MUST BE
183 C GREATER THAN OR EQUAL TO 43 + 7*N + N*(N+1)*MMAXT.
188 C N, NUMT, COEF, KDEG, NN, MMAXT, TTOTDG, LENWK, AND LENIWK
192 C -1 IF NN IS TOO SMALL.
193 C -2 IF MMAXT IS TOO SMALL.
194 C -3 IF TTOTDG IS TOO SMALL.
195 C -4 IF LENWK IS TOO SMALL.
196 C -5 IF LENIWK IS TOO SMALL.
197 C -6 IF IFLG1 ON INPUT IS NOT 00 OR 01 OR 10 OR 11.
198 C UNCHANGED OTHERWISE.
200 C IFLG2(1:TOTDG) GIVES INFORMATION ABOUT HOW THE M-TH PATH TERMINATED:
204 C 2 SPECIFIED ERROR TOLERANCE CANNOT BE MET. INCREASE EPSBIG
205 C AND EPSSML AND RERUN.
207 C 3 MAXIMUM NUMBER OF STEPS EXCEEDED. TO TRACK THE PATH FURTHER,
208 C INCREASE NUMRR AND RERUN THE PATH. HOWEVER, THE PATH MAY
209 C BE DIVERGING, IF THE LAMBDA VALUE IS NEAR 1 AND THE ROOTS
212 C 4 JACOBIAN MATRIX DOES NOT HAVE FULL RANK. THE ALGORITHM
213 C HAS FAILED (THE ZERO CURVE OF THE HOMOTOPY MAP CANNOT BE
214 C FOLLOWED ANY FURTHER).
216 C 5 THE TRACKING ALGORITHM HAS LOST THE ZERO CURVE OF THE
217 C HOMOTOPY MAP AND IS NOT MAKING PROGRESS. THE ERROR TOLERANCES
218 C EPSBIG AND EPSSML WERE TOO LENIENT. THE PROBLEM SHOULD BE
219 C RESTARTED WITH SMALLER ERROR TOLERANCES.
221 C 6 THE NORMAL FLOW NEWTON ITERATION IN STEPNF OR ROOTNF
222 C FAILED TO CONVERGE. THE ERROR TOLERANCE EPSBIG MAY BE TOO
225 C 7 ILLEGAL INPUT PARAMETERS, A FATAL ERROR.
227 C LAMBDA(M) IS THE FINAL LAMBDA VALUE FOR THE M-TH PATH, M = 1, ...,
228 C TOTDG, WHERE LAMBDA IS THE CONTINUATION PARAMETER.
230 C ROOTS(1,J,M), ROOTS(2,J,M) ARE THE REAL AND IMAGINARY PARTS
231 C OF THE JTH VARIABLE RESPECTIVELY, FOR J = 1,...,N, FOR
232 C THE M-TH PATH, FOR M = 1,...,TOTDG. IF IFLG1 = 10 OR 11, THEN
233 C ROOTS(1,N+1,M) AND ROOTS(2,N+1,M) ARE THE REAL AND
234 C IMAGINARY PARTS RESPECTIVELY OF THE PROJECTIVE
235 C COORDINATE OF THE SOLUTION.
237 C ARCLEN(M) IS THE ARC LENGTH OF THE M-TH PATH FOR M = 1, ..., TOTDG.
239 C NFE(M) IS THE NUMBER OF JACOBIAN MATRIX EVALUATIONS REQUIRED TO
240 C TRACK THE M-TH PATH FOR M =1, ..., TOTDG.
242 C ----------------------------------------------------------------------
243 C TYPE DECLARATIONS FOR INPUT AND OUTPUT
244 INTEGER N
,NUMT
,KDEG
,IFLG1
,IFLG2
,NUMRR
,NN
,MMAXT
,
245 $ TTOTDG
,LENWK
,LENIWK
,NFE
,IWK
246 DOUBLE PRECISION COEF
,EPSBIG
,EPSSML
,SSPAR
,LAMBDA
,ROOTS
,
249 C ARRAY DECLARATIONS FOR INPUT AND OUTPUT
250 DIMENSION NUMT
(NN
),KDEG
(NN
,NN
+1,MMAXT
),IFLG2
(TTOTDG
),
251 $ NFE
(TTOTDG
),IWK
(LENIWK
)
252 DIMENSION COEF
(NN
,MMAXT
),SSPAR
(8),LAMBDA
(TTOTDG
),
253 $ ROOTS
(2,NN
+1,TTOTDG
), ARCLEN
(TTOTDG
),WK
(LENWK
)
255 C TYPE DECLARATIONS FOR VARIABLES
256 INTEGER I
,IDEG
,IIDEG
,IWKOFF
,J
,K
,L
,LENIWW
,LENWKK
,LIWK
,LWK
,
257 $ MAXT
,N2
,TOTDG
,WKOFF
259 C ARRAY DECLARATIONS FOR VARIABLES
260 DIMENSION LWK
(19),LIWK
(4),WKOFF
(19),IWKOFF
(4)
262 C CHECK THAT BASIC DIMENSIONAL PARAMETERS ARE BIG ENOUGH
270 IF(MAXT
.LT
.NUMT
(J
))MAXT
=NUMT
(J
)
272 IF(MMAXT
.LT
.MAXT
) THEN
282 IIDEG
=IIDEG
+KDEG
(J
,L
,K
)
284 IF(IIDEG
.GT
.IDEG
)IDEG
=IIDEG
288 IF(TTOTDG
.LT
.TOTDG
) THEN
292 LENWKK
= 21 + 61*N
+ 10*N**2
+ 7*N*MMAXT
+ 4*N**2*MMAXT
293 IF(LENWK
.LT
.LENWKK
) THEN
297 LENIWW
= 43 + 7*N
+ N*
(N
+1)*MMAXT
298 IF(LENIWK
.LT
.LENIWW
) THEN
302 IF(IFLG1
.NE
.0.AND
.IFLG1
.NE
.1.AND
.IFLG1
.NE
.10.AND
.IFLG1
.NE
.11) THEN
307 C VARIABLES THAT ARE PASSED IN ARRAY WK: (LENGTHS ARE IN THE
308 C INTEGER ARRAY LWK.)
310 C VARIABLE NAME LENGTH
329 C 18 PAR 2 + 28*N + 6*N**2 + 7*N*MMAXT + 4*N**2*MMAXT
331 C VARIABLES THAT ARE PASSED IN ARRAY IWK: (LENGTHS ARE IN THE
332 C INTEGER ARRAY LIWK.)
334 C VARIABLE NAME LENGTH
339 C 4 IPAR 42 + 2*N + N*(N+1)*MMAXT
359 LWK
(18)= 2 + 28*N
+ 6* N**2
+ 7*N*MMAXT
+ 4* N**2
*MMAXT
364 LIWK
(4)= 42 + 2*N
+ N*
(N
+1)*MMAXT
366 C WKOFF AND IWKOFF ARE OFFSETS THAT DEFINE THE VARIABLES LISTED ABOVE
370 WKOFF
(I
)=WKOFF
(I
-1)+LWK
(I
-1)
374 IWKOFF
(I
)=IWKOFF
(I
-1)+LIWK
(I
-1)
377 WK
(WKOFF
(17) + (J
-1))=SSPAR
(J
)
380 CALL POLYP
(N
,NUMT
,COEF
,KDEG
,IFLG1
,IFLG2
,EPSBIG
,EPSSML
,
381 $ NUMRR
,NN
,MMAXT
,TTOTDG
,LAMBDA
,ROOTS
,ARCLEN
,NFE
,TOTDG
,
382 $ WK
( WKOFF
( 1)),WK
( WKOFF
( 2)),WK
( WKOFF
( 3)),WK
( WKOFF
( 4)),
383 $ WK
( WKOFF
( 5)),WK
( WKOFF
( 6)),WK
( WKOFF
( 7)),WK
( WKOFF
( 8)),
384 $ WK
( WKOFF
( 9)),WK
( WKOFF
(10)),WK
( WKOFF
(11)),WK
( WKOFF
(12)),
385 $ WK
( WKOFF
(13)),WK
( WKOFF
(14)),WK
( WKOFF
(15)),WK
( WKOFF
(16)),
386 $ WK
( WKOFF
(17)),WK
( WKOFF
(18)),
387 $IWK
(IWKOFF
( 1)),IWK
(IWKOFF
( 2)),IWK
(IWKOFF
( 3)),IWK
(IWKOFF
( 4)))