C     SSA2                                                              SA2   1 
C     GUTTMAN-LINGOES SMALLEST SPACE ANALYSIS FOR ASYMMETRIC            SA2   2 
C     AND/OR PARTLY-ORDERED DISTANCE MATRICES. G-L(SSA-II)              SA2   3 
C     PROGRAMMED IN FORTRAN II FOR THE U. OF M. IBM-7090                SA2   4 
C     BY J. C. LINGOES (1/21/65).                                       SA2   5 
C                                                                       SA2   6 
C     DECK SET-UP FOR G-L(SSA-II) -                                     SA2   7 
C                                                                       SA2   8 
C        1.  SYSTEM ID CARD/S.                                          SA2   9 
C        2.  BINARY PROGRAM.                                            SA2  10 
C        3.  TITLE CARD (PUNCH A 1 IN COLUMN 1 AND ANY BCD TITLE IN COL-SA2  11 
C            UMNS 2-72, WHICH WILL BE PRINTED OUT FOR EACH PAGE OF OUT- SA2  12 
C            PUT).                                                      SA2  13 
C        4.  PARAMETER CARD, 7 4-COLUMN FIELDS CONTAINING THE FOLLOWING         
C            INFORMATION SERIATUM -                                     SA2  15 
C            A)  NR=THE NUMBER OF VARIABLES .LE. 70,                            
C            B)  MIND (SEE G-L(SSA-I),                                  SA2  17 
C            C)  MAXD (SEE G-L(SSA-I),                                  SA2  18 
C            D)  ISIM (SEE G-L(SSA-I),                                  SA2  19 
C            E)  NSYM=1 IF FULL MATRIX IS PUNCHED AND 0 OR BLANK OTHER- SA2  20 
C                WISE FOR HALF-MATRIX AS IN G-L(SSA-I),                 SA2  21 
C            F)  IFD=1 IF DISTANCE MATRIX IS TO BE PRINTED FOR 2 OR MORESA2  22 
C                DIMENSIONS, OTHERWISE SET TO ZERO OR LEAVE BLANK,      SA2  23 
C            G)  IFC=1 IF COORDINATES ARE TO BE PUNCHED FOR 2 OR MORE   SA2  24 
C                DIMENSIONS, OTHERWISE SET TO ZERO OR LEAVE BLANK.      SA2  25 
C        5.  FORMAT CARD (DESCRIBING IN F-NOTATION HOW DATA IS PUNCHED).SA2  29 
C        6.  DATA (SEE G-L(SSA-I) FOR SYMMETRIC DATA INPUT.  FOR ASYMME-SA2  30 
C            TRIC DATA PUNCH A COMPLETE SQUARE MATRIX BY ROWS, INCLUDINGSA2  31 
C            THE DIAGONAL ELEMENTS (WHICH MAY BE ANYTHING SINCE THEY ARESA2  32 
C            NOT USED IN THE ANALYSIS), STARTING A NEW ROW ON A NEW SET SA2  33 
C            OF CARDS, YIELDING NR SETS).                               SA2  34 
C        7.  2ND TITLE CARD (IF NSYM=1 ON PREVIOUS CONTROL CARD, OTHER- SA2  35 
C            WISE REPEAT ITEMS 3-6 FOR ADDITIONAL RUNS).  THE 1ST SSA   SA2  36 
C            OUTPUT IS BASED UPON WITHIN-COLUMN RANKINGS, WHILE THE 2ND SA2  37 
C            IS BASED UPON WITHIN-ROW RANKINGS.  EVEN IF NSYM=1 A PERSONSA2  38 
C            MAY ONLY BE INTERESTED IN ONE OF THESE TWO SOLUTIONS IN    SA2  39 
C            WHICH CASE HE SHOULD INPUT THE ASYMMETRIC MATRIX BUT       SA2  40 
C            OMIT THIS AND THE FOLLOWING CONTROL CARD.  IF THIS OPTION  SA2  41 
C            IS CHOSEN, HOWEVER, ONE CANNOT DO MULTIPLE JOB PROCESSING).SA2  42 
C        8.  2ND PARAMETER CARD (IF NSYM=1 ON 1ST CONTROL CARD, REPEAT  SA2  43 
C            ALL PARAMETERS BUT SET COLUMN 20 TO A 0 OR LEAVE BLANK. FORSA2  44 
C            MULTIPLE JOBS WHERE 2 SOLUTIONS ARE DESIRED FOR ASYMMETRIC SA2  45 
C            MATRICES, REPEAT ITEMS 3-8).                               SA2  46 
C                                                                       SA2  47 
C     *** REFERENCES - LINGOES, J. C.  AN IBM-7090 PROGRAM FOR GUTTMAN- SA2  48 
C                                  LINGOES SMALLEST SPACE ANALYSIS - II.SA2  49 
C                                  BEHAV. SCI., 1965, 10, 487.          SA2  50 
C                                                                       SA2  51 
      DIMENSION FMT(18), DIST(70,70), INDI(69,70), NOTIES(70,70), NT(70)        
     1, C(70,70), EVAL(1900), EVEC(4900), STR(100), X(70,10), INDJ(69,70        
     2), DSTAR(70,70), ITIE(4900),STRESS(70), PD(70,70), Y(70,70)               
      EQUIVALENCE (DIST,Y), (C,EVEC,ITIE,PD), (EVAL,DSTAR)              SA2  55 
C                                                                       SA2  57 
C     SUBROUTINES CALLED = MXOUT, PLOT, EIGEN, AND ORDER ***            SA2  58 
C                                                                       SA2  59 
C     *** TAPE ASSIGNMENTS                                                      
      ITAPE=5                                                           SA2  62 
      JTAPE=6                                                           SA2  63 
      KTAPE=3                                                                   
C     *** SUBROUTINE DIMENSIONING                                               
      MD=70                                                                     
      ND=10                                                             SA2  66 
      MD3=MD*3+1                                                                
      MD4=MD3+MD                                                                
      MD5=MD4+MD                                                                
      MD6=MD5+MD                                                                
      MD7=MD6+MD                                                                
C     READ IN TITLE, PARAMETERS, AND DATA                               SA2  64 
1     WRITE (JTAPE,169)                                                         
      READ (ITAPE,159)                                                          
      READ (ITAPE,160) NR,MIND,MAXD,ISIM,NSYM,IFD,IFC                   SA2  68 
      READ (ITAPE,161) (FMT(J),J=1,18)                                  SA2  69 
      NRM1=NR-1                                                         SA2  70 
      NRP1=NR+1                                                         SA2  71 
      IF (NSYM) 5,5,2                                                   SA2  72 
2     DO 3 I=1,NR                                                       SA2  73 
3     READ (ITAPE,FMT) (DSTAR(I,J),J=1,NR)                              SA2  74 
C     PRINT INPUT VALUES FOR ASYMMETRIC MATRIX                          SA2  75 
      WRITE (JTAPE,159)                                                 SA2  76 
      WRITE (JTAPE,162)                                                 SA2  77 
      DO 4 I=1,NR                                                       SA2  78 
      WRITE (JTAPE,163) I                                               SA2  79 
4     WRITE (JTAPE,164) (DSTAR(I,J),J=1,NR)                             SA2  80 
      GO TO 7                                                           SA2  81 
5     DO 6 I=1,NRM1                                                     SA2  82 
      DSTAR(I,I)=0.                                                     SA2  83 
      IP1=I+1                                                           SA2  84 
      READ (ITAPE,FMT) (DSTAR(I,J),J=IP1,NR)                            SA2  85 
      DO 6 K=IP1,NR                                                     SA2  86 
6     DSTAR(K,I)=DSTAR(I,K)                                             SA2  87 
      DSTAR(NR,NR)=0.                                                   SA2  88 
C     PRINT INPUT VALUES                                                SA2  89 
      CALL MXOUT (DSTAR,NR,0,MD)                                        SA2  90 
C     INITIALIZATION                                                    SA2  91 
7     DO 8 I=1,NRM1                                                     SA2  92 
      IP1=I+1                                                           SA2  93 
      DO 8 J=IP1,NR                                                     SA2  94 
8     DSTAR(J-1,I)=DSTAR(J,I)                                           SA2  95 
      FNR=NR                                                            SA2  96 
      CALL REWIND (KTAPE)                                                       
      KK=0                                                              SA2  98 
      DO 9 I=1,NR                                                       SA2  99 
      DO 9 J=1,NRM1                                                     SA2 100 
      KK=KK+1                                                           SA2 101 
9     EVEC(KK)=DSTAR(J,I)                                               SA2 102 
      NSIZE=KK                                                          SA2 103 
      WRITE (KTAPE) (EVEC(J),J=1,NSIZE)                                         
10    CALL REWIND (KTAPE)                                                       
C     SORT DATA BY ORDER SUBROUTINE WHICH REORDERS SUBSCRIPTS OF INDI   SA2 106 
C     ACCORDING TO MAGNITUDES OF INPUT AND DIRECTION OF ISIM.  ORDER    SA2 107 
C     TAKES ADVANTAGE OF PARTIAL ORDERING, I.E., THE SUBSCRIPTS ARE NOT SA2 108 
C     GENERATED FOR EACH ITERATION.                                     SA2 109 
      DO 12 J=1,NR                                                      SA2 110 
C     IT IS HIGHLY DESIRABLE THAT A MACHINE-CODED VERSION OF A SORT SUB-SA2 111 
C     ROUTINE BE CALLED UPON HERE.                                      SA2 112 
      CALL ORDER (-1,NRM1,DSTAR(1,J),ISIM,INDI(1,J))                    SA2 113 
C     COMPUTE C-MATRIX ON RANKS                                         SA2 114 
      S=0.                                                              SA2 115 
      DO 11 I=1,NRM1                                                    SA2 116 
      II=INDI(I,J)                                                      SA2 117 
      S=S+1.                                                            SA2 118 
11    DIST(II,J)=S                                                      SA2 119 
12    CONTINUE                                                          SA2 120 
C     CHECK FOR TIES IN INPUT                                           SA2 121 
      NOT=0                                                             SA2 122 
      DO 20 I=1,NR                                                      SA2 123 
      NT(I)=0                                                           SA2 124 
      JJ=1                                                              SA2 125 
      II=-1                                                             SA2 126 
      KK=JJ                                                             SA2 127 
13    LL=1                                                              SA2 128 
      MM=INDI(JJ,I)                                                     SA2 129 
      S=DIST(MM,I)                                                      SA2 130 
14    KK=KK+1                                                           SA2 131 
      NN=INDI(KK,I)                                                     SA2 132 
      IF (DSTAR(MM,I)-DSTAR(NN,I)) 16,15,16                             SA2 133 
15    LL=LL+1                                                           SA2 134 
      NOT=NOT+1                                                         SA2 135 
      S=S+DIST(NN,I)                                                    SA2 136 
      IF (KK-NRM1) 14,17,17                                             SA2 137 
16    IF (LL-2) 19,17,17                                                SA2 138 
17    II=II+2                                                           SA2 139 
      NT(I)=NT(I)+2                                                     SA2 140 
      NOTIES(I,II)=LL                                                   SA2 141 
      NOTIES(I,II+1)=JJ                                                 SA2 142 
      S=S/FLOAT(LL)                                                     SA2 143 
      IJ=JJ                                                             SA2 144 
      DO 18 KL=1,LL                                                     SA2 145 
      MM=INDI(IJ,I)                                                     SA2 146 
      DIST(MM,I)=S                                                      SA2 147 
18    IJ=IJ+1                                                           SA2 148 
19    JJ=KK                                                             SA2 149 
      IF (JJ-NRM1) 13,20,20                                             SA2 150 
20    CONTINUE                                                          SA2 151 
C     FORM SYMMETRIC MATRIX                                             SA2 152 
      DO 22 I=1,NR                                                      SA2 153 
      C(I,I)=1.                                                         SA2 154 
      JJ=0                                                              SA2 155 
      DO 22 J=1,NR                                                      SA2 156 
      IF (I-J) 21,22,21                                                 SA2 157 
21    JJ=JJ+1                                                           SA2 158 
      C(I,J)=DIST(JJ,I)                                                 SA2 159 
22    CONTINUE                                                          SA2 160 
      S=2*NRM1                                                          SA2 161 
      DO 23 I=1,NRM1                                                    SA2 162 
      IP1=I+1                                                           SA2 163 
      DO 23 J=IP1,NR                                                    SA2 164 
      C(I,J)=(C(I,J)+C(J,I))/S                                          SA2 165 
23    C(J,I)=C(I,J)                                                     SA2 166 
      DO 25 I=1,NR                                                      SA2 167 
      STRESS(I)=0.                                                      SA2 168 
      DO 25 J=1,NR                                                      SA2 169 
      IF (I-J) 24,25,24                                                 SA2 170 
24    C(I,I)=C(I,I)+C(I,J)                                              SA2 171 
25    CONTINUE                                                          SA2 172 
      DO 26 I=1,NRM1                                                    SA2 173 
      IP1=I+1                                                           SA2 174 
      DO 26 J=IP1,NR                                                    SA2 175 
      C(I,J)=1.-C(I,J)                                                  SA2 176 
26    C(J,I)=C(I,J)                                                     SA2 177 
C     COMPUTE INITIAL CONFIGURATION                                     SA2 178 
      KK=MAXD+1                                                         SA2 179 
C     CALL ON HOUSEHOLDER SUBROUTINE                                    SA2 180 
      CALL EIGEN (C,Y,NR,STR,KK,MD,X(1,1),X(1,4),X(1,5),X(1,6),X(1,7),X(SA2 181 
     11,8))                                                             SA2 182 
      DO 27 J=2,KK                                                      SA2 183 
      STR(J-1)=STR(J)                                                   SA2 184 
      DO 27 I=1,NR                                                      SA2 185 
27    X(I,J-1)=Y(I,J)                                                   SA2 186 
      ITER=100                                                          SA2 187 
      LFACT=1                                                           SA2 188 
C     DETERMINE WHETHER TO GO UP OR DOWN                                SA2 189 
      IF (MIND) 28,28,35                                                SA2 190 
28    DIM=NRM1*2                                                        SA2 191 
      DIM=FNR**2/DIM                                                    SA2 192 
      II=0                                                              SA2 193 
      DO 30 J=1,MAXD                                                    SA2 194 
      IF (STR(J)-DIM) 31,29,29                                          SA2 195 
29    II=II+1                                                           SA2 196 
30    CONTINUE                                                          SA2 197 
31    IF (II) 32,32,33                                                  SA2 198 
32    MAXD=1                                                            SA2 199 
      GO TO 34                                                          SA2 200 
33    MAXD=II                                                           SA2 201 
34    MIND=MAXD                                                         SA2 202 
      LFACT=0                                                           SA2 203 
      ITER=25                                                           SA2 204 
35    M=MIND-1                                                          SA2 205 
      PRESTR=1.                                                         SA2 206 
      ASSIGN 48 TO N1                                                   SA2 207 
C     INITIALIZATION                                                    SA2 208 
36    II=0                                                              SA2 209 
      JJ=0                                                              SA2 210 
      M=M+1                                                             SA2 211 
      NTIE=NOT                                                          SA2 212 
37    II=II+1                                                           SA2 213 
38    ITCT=0                                                            SA2 214 
C     COMPUTE DISTANCES                                                 SA2 215 
39    DO 44 I=1,NRM1                                                            
      IP1=I+1                                                           SA2 225 
      DO 44 J=IP1,NR                                                    SA2 226 
      DIST(I,J)=0.                                                      SA2 227 
      DO 43 K=1,M                                                       SA2 228 
43    DIST(I,J)=DIST(I,J)+(X(I,K)-X(J,K))**2                            SA2 229 
      DIST(I,J)=SQRT(DIST(I,J))                                         SA2 230 
44    DIST(J,I)=DIST(I,J)                                               SA2 231 
      IF (ITCT) 46,46,86                                                        
46    DO 47 I=1,NRM1                                                    SA2 233 
      KK=I-1                                                            SA2 234 
      IP1=I+1                                                           SA2 235 
      DO 47 J=IP1,NR                                                    SA2 236 
      KK=KK+1                                                           SA2 237 
47    DIST(KK,I)=DIST(J,I)                                              SA2 238 
      GO TO N1, (48,50)                                                 SA2 239 
C     SORT D'S LOW TO HIGH                                              SA2 240 
48    DO 49 J=1,NR                                                      SA2 241 
C     *** SEE NOTES ABOVE REGARDING SORT SUBROUTINE.                    SA2 242 
49    CALL ORDER (0,0,DIST(1,J),0,INDJ(1,J))                            SA2 243 
      ASSIGN 50 TO N1                                                   SA2 244 
      GO TO 52                                                          SA2 245 
50    DO 51 J=1,NR                                                      SA2 246 
C     *** SEE NOTES ABOVE REGARDING SORT SUBROUTINE.                    SA2 247 
51    CALL ORDER (1,0,DIST(1,J),0,INDJ(1,J))                            SA2 248 
C     OPTIMALLY PERMUTE INDICES OF INDI ON FIRST AND LAST ITERATION IF  SA2 249 
C     TIES EXIST IN INPUT DATA                                          SA2 250 
52    IF (NTIE) 63,63,53                                                SA2 251 
53    NTIE=0                                                            SA2 252 
      DO 62 I=1,NR                                                      SA2 253 
      IF (NT(I)) 54,62,54                                               SA2 254 
54    KK=NT(I)                                                          SA2 255 
      DO 61 J=1,KK,2                                                    SA2 256 
      LL=NOTIES(I,J)                                                    SA2 257 
      MM=NOTIES(I,J+1)                                                  SA2 258 
      NN=MM                                                             SA2 259 
      DO 55 K=1,LL                                                      SA2 260 
      IJ=INDI(NN,I)                                                     SA2 261 
      EVAL(K)=DIST(IJ,I)                                                SA2 262 
      ITIE(K)=IJ                                                        SA2 263 
55    NN=NN+1                                                           SA2 264 
      IJ=LL-1                                                           SA2 265 
56    JI=0                                                              SA2 266 
      DO 58 L=1,IJ                                                      SA2 267 
      LP1=L+1                                                           SA2 268 
      DO 58 N=LP1,LL                                                    SA2 269 
      IF (EVAL(N)-EVAL(L)) 57,58,58                                     SA2 270 
57    S=EVAL(L)                                                         SA2 271 
      EVAL(L)=EVAL(N)                                                   SA2 272 
      EVAL(N)=S                                                         SA2 273 
      JI=1                                                              SA2 274 
      NN=ITIE(L)                                                        SA2 275 
      ITIE(L)=ITIE(N)                                                   SA2 276 
      ITIE(N)=NN                                                        SA2 277 
58    CONTINUE                                                          SA2 278 
      IF (JI) 59,59,56                                                  SA2 279 
59    NN=MM                                                             SA2 280 
      DO 60 KL=1,LL                                                     SA2 281 
      INDI(NN,I)=ITIE(KL)                                               SA2 282 
60    NN=NN+1                                                           SA2 283 
61    CONTINUE                                                          SA2 284 
62    CONTINUE                                                          SA2 285 
C     OBTAIN RANK-IMAGES                                                SA2 286 
63    DO 64 I=1,NR                                                      SA2 287 
      DO 64 J=1,NRM1                                                    SA2 288 
      KK=INDI(J,I)                                                      SA2 289 
      LL=INDJ(J,I)                                                      SA2 290 
64    PD(KK,I)=DIST(LL,I)                                               SA2 291 
C     SYMMETRIZE                                                        SA2 292 
      DO 66 I=1,NR                                                      SA2 293 
      KK=0                                                              SA2 294 
      DO 66 J=1,NR                                                      SA2 295 
      IF (I-J) 65,66,65                                                 SA2 296 
65    KK=KK+1                                                           SA2 297 
      DSTAR(I,J)=PD(KK,I)                                               SA2 298 
66    CONTINUE                                                          SA2 299 
      DO 67 I=1,NRM1                                                    SA2 300 
      IP1=I+1                                                           SA2 301 
      DO 67 J=IP1,NR                                                    SA2 302 
      DSTAR(I,J)=(DSTAR(I,J)+DSTAR(J,I))/2.                             SA2 303 
67    DSTAR(J,I)=DSTAR(I,J)                                             SA2 304 
C     COMPUTE PHI                                                       SA2 305 
      OSTR=0.                                                           SA2 306 
      S=0.                                                              SA2 307 
      DO 68 I=1,NRM1                                                    SA2 308 
      IP1=I+1                                                           SA2 309 
      DO 68 J=IP1,NR                                                    SA2 310 
      S=S+DIST(I,J)**2                                                  SA2 311 
68    OSTR=OSTR+(DIST(I,J)-DSTAR(I,J))**2                               SA2 312 
      OSTR=OSTR/(2.*S)                                                  SA2 313 
      IF (JJ) 69,69,113                                                 SA2 314 
69    STR(II)=OSTR                                                      SA2 315 
C     TIE D'S IF TIES EXIST IN INPUT                                            
      IF (NOT) 81,81,70                                                 SA2 317 
70    DO 72 I=1,NR                                                      SA2 318 
      KK=0                                                              SA2 319 
      DO 72 J=1,NR                                                      SA2 320 
      IF (I-J) 71,72,71                                                 SA2 321 
71    KK=KK+1                                                           SA2 322 
      PD(KK,I)=DSTAR(I,J)                                               SA2 323 
72    CONTINUE                                                          SA2 324 
      DO 77 I=1,NR                                                      SA2 325 
      IF (NT(I)) 73,77,73                                               SA2 326 
73    KK=NT(I)                                                          SA2 327 
      DO 76 J=1,KK,2                                                    SA2 328 
      LL=NOTIES(I,J)                                                    SA2 329 
      MM=NOTIES(I,J+1)                                                  SA2 330 
      NN=MM                                                             SA2 331 
      A=0.                                                              SA2 332 
      DO 74 K=1,LL                                                      SA2 333 
      IJ=INDI(NN,I)                                                     SA2 334 
      A=A+PD(IJ,I)                                                      SA2 335 
74    NN=NN+1                                                           SA2 336 
      NN=MM                                                             SA2 337 
      A=A/FLOAT(LL)                                                     SA2 338 
      DO 75 L=1,LL                                                      SA2 339 
      IJ=INDI(NN,I)                                                     SA2 340 
      PD(IJ,I)=A                                                        SA2 341 
75    NN=NN+1                                                           SA2 342 
76    CONTINUE                                                          SA2 343 
77    CONTINUE                                                          SA2 344 
C     SYMMETRIZE                                                        SA2 345 
      DO 79 I=1,NR                                                      SA2 346 
      KK=0                                                              SA2 347 
      DO 79 J=1,NR                                                      SA2 348 
      IF (I-J) 78,79,78                                                 SA2 349 
78    KK=KK+1                                                           SA2 350 
      DSTAR(I,J)=PD(KK,I)                                               SA2 351 
79    CONTINUE                                                          SA2 352 
      DO 80 I=1,NRM1                                                    SA2 353 
      IP1=I+1                                                           SA2 354 
      DO 80 J=IP1,NR                                                    SA2 355 
80    DSTAR(I,J)=(DSTAR(I,J)+DSTAR(J,I))/2.                             SA2 356 
81    DO 85 I=1,NR                                                      SA2 357 
      KK=0                                                              SA2 358 
      DO 83 J=1,NR                                                      SA2 359 
      IF (I-J) 82,83,82                                                 SA2 360 
82    KK=KK+1                                                           SA2 361 
      PD(I,J)=DIST(KK,I)                                                SA2 362 
83    CONTINUE                                                          SA2 363 
      DO 84 K=1,NR                                                      SA2 364 
84    DIST(K,I)=PD(I,K)                                                 SA2 365 
85    CONTINUE                                                          SA2 366 
C     TEST FOR ZERO DISTANCES                                           SA2 367 
86    DO 87 J=1,NR                                                      SA2 368 
      KK=INDJ(1,J)                                                      SA2 369 
      IF (DIST(KK,J)) 87,88,87                                          SA2 370 
87    CONTINUE                                                          SA2 371 
      GO TO 91                                                          SA2 372 
88    DO 89 I=2,NRM1                                                    SA2 373 
      KK=INDJ(I,J)                                                      SA2 374 
      IF (DIST(KK,J)) 90,89,90                                          SA2 375 
89    CONTINUE                                                          SA2 376 
90    LL=INDJ(NRM1,J)                                                   SA2 377 
      GL=DIST(LL,J)/DIST(KK,J)                                          SA2 378 
      GO TO 92                                                          SA2 379 
91    GL=0.                                                             SA2 380 
C     COMPUTE C-MATRIX                                                  SA2 381 
92    DO 98 I=1,NRM1                                                    SA2 382 
      IP1=I+1                                                           SA2 383 
      DO 98 J=IP1,NR                                                    SA2 384 
      IF (GL) 93,97,93                                                  SA2 385 
93    IF (DSTAR(I,J)+DIST(I,J)) 95,94,95                                SA2 386 
94    C(I,J)=1.                                                         SA2 387 
      GO TO 98                                                          SA2 388 
95    IF (DIST(I,J)) 97,96,97                                           SA2 389 
96    C(I,J)=GL                                                         SA2 390 
      GO TO 98                                                          SA2 391 
97    C(I,J)=DSTAR(I,J)/DIST(I,J)                                       SA2 392 
98    C(J,I)=C(I,J)                                                     SA2 393 
      DO 101 I=1,NR                                                     SA2 394 
      C(I,I)=1.                                                         SA2 395 
      DO 100 J=1,NR                                                     SA2 396 
      IF (I-J) 99,100,99                                                SA2 397 
99    C(I,I)=C(I,I)+C(I,J)                                              SA2 398 
100   CONTINUE                                                          SA2 399 
101   CONTINUE                                                          SA2 400 
      DO 102 I=1,NRM1                                                   SA2 401 
      IP1=I+1                                                           SA2 402 
      DO 102 J=IP1,NR                                                   SA2 403 
      C(I,J)=1.-C(I,J)                                                  SA2 404 
102   C(J,I)=C(I,J)                                                     SA2 405 
C     PERFORM CORRECTIONS ON X                                          SA2 406 
      DO 104 K=1,M                                                      SA2 407 
      DO 104 I=1,NR                                                     SA2 408 
      Y(I,K)=0.                                                         SA2 409 
      DO 103 J=1,NR                                                     SA2 410 
103   Y(I,K)=Y(I,K)+X(J,K)*C(I,J)                                       SA2 411 
104   Y(I,K)=Y(I,K)/FNR                                                 SA2 412 
      DO 105 K=1,M                                                      SA2 413 
      DO 105 I=1,NR                                                     SA2 414 
105   X(I,K)=Y(I,K)                                                     SA2 415 
      ITCT=ITCT+1                                                       SA2 416 
C     TEST FOR TERMINATION                                              SA2 417 
      IF (10-ITCT) 106,106,39                                           SA2 418 
106   IF (II-6) 37,107,107                                              SA2 419 
107   IF (STR(II-5)-STR(II)-1E-06) 109,109,108                          SA2 420 
108   IF (II-ITER) 37,109,109                                           SA2 421 
109   IF (LFACT) 112,112,110                                            SA2 422 
110   IF (PRESTR-OSTR) 155,155,111                                      SA2 423 
111   PRESTR=OSTR                                                       SA2 424 
112   WRITE (JTAPE,159)                                                 SA2 425 
      WRITE (JTAPE,165) M,(KK,KK=1,M)                                   SA2 426 
      WRITE (JTAPE,166)                                                 SA2 427 
      JJ=1                                                              SA2 428 
      NTIE=NOT                                                          SA2 429 
      GO TO 38                                                          SA2 430 
C     COMPUTE INDIVIDUAL PHI'S                                          SA2 431 
113   S=0.                                                              SA2 432 
      DO 115 I=1,NR                                                     SA2 433 
      STRESS(I)=0.                                                      SA2 434 
      KK=0                                                              SA2 435 
      DO 115 J=1,NR                                                     SA2 436 
      IF (I-J) 114,115,114                                              SA2 437 
114   KK=KK+1                                                           SA2 438 
      STRESS(I)=STRESS(I)+(DIST(KK,I)-DSTAR(I,J))**2                    SA2 439 
      S=S+DIST(KK,I)**2                                                 SA2 440 
115   CONTINUE                                                          SA2 441 
      S=2.*S                                                            SA2 442 
      DO 116 J=1,NR                                                     SA2 443 
116   STRESS(J)=STRESS(J)/S                                             SA2 444 
      IF (M-2) 122,117,117                                              SA2 445 
C     PERFORM PRINCIPAL AXIS ROTATION                                   SA2 447 
117   DO 120 I=1,NR                                                             
      DO 120 J=1,NR                                                     SA2 449 
      C(I,J)=0.                                                         SA2 450 
      DO 119 K=1,M                                                      SA2 451 
119   C(I,J)=C(I,J)+X(I,K)*X(J,K)                                       SA2 452 
120   C(J,I)=C(I,J)                                                     SA2 453 
C     CALL ON HOUSEHOLDER SUBROUTINE                                    SA2 454 
      CALL EIGEN (C,Y,NR,STR,M,MD,EVAL(1),EVAL(MD3),EVAL(MD4),EVAL(MD5),        
     1EVAL(MD6),EVAL(MD7))                                                      
      DO 121 J=1,M                                                      SA2 457 
      DO 121 I=1,NR                                                     SA2 458 
121   X(I,J)=Y(I,J)                                                     SA2 459 
C     NORMALIZE COORDINATES TO LIE IN RANGE +1 TO -1                    SA2 460 
122   A=0.                                                              SA2 461 
      DO 124 K=1,M                                                      SA2 462 
      DSTAR(1,K)=0.                                                     SA2 463 
      DSTAR(2,K)=0.                                                     SA2 464 
      DO 123 I=1,NR                                                     SA2 465 
      DSTAR(1,K)=AMIN1(DSTAR(1,K),X(I,K))                               SA2 466 
123   DSTAR(2,K)=AMAX1(DSTAR(2,K),X(I,K))                               SA2 467 
124   A=AMAX1(A,(DSTAR(2,K)-DSTAR(1,K)))                                SA2 468 
      A=2./A                                                            SA2 469 
      DO 125 K=1,M                                                      SA2 470 
      DO 125 I=1,NR                                                     SA2 471 
125   Y(I,K)=A*(X(I,K)-DSTAR(1,K))-1.                                   SA2 472 
C     COMPUTE CENTRALITY INDEX                                          SA2 473 
      KK=M+1                                                            SA2 474 
      DO 129 I=1,NR                                                     SA2 475 
      Y(I,KK)=0.                                                        SA2 476 
      DO 126 K=1,M                                                      SA2 477 
126   Y(I,KK)=Y(I,KK)+X(I,K)**2                                         SA2 478 
      Y(I,KK)=A*(SQRT(Y(I,KK)))                                                 
129   CONTINUE                                                          SA2 483 
C     PRINT OUT FINAL CONFIGURATION                                     SA2 484 
      DO 130 I=1,NR                                                     SA2 485 
130   WRITE (JTAPE,167) I,STRESS(I),(Y(I,K),K=1,KK)                     SA2 486 
      CAL=SQRT(1.-(1.-OSTR)**2)                                         SA2 487 
      WRITE (JTAPE,168) OSTR,II,CAL                                     SA2 488 
      IF (LFACT) 131,143,131                                            SA2 489 
131   IF (M-2) 153,132,132                                              SA2 490 
C     CALL ON PLOT SUBROUTINE                                           SA2 491 
132   CALL PLOT (Y,DSTAR(1,1),DSTAR(1,2),DSTAR(1,3),DSTAR(1,4),DSTAR(1,5SA2 492 
     1),NR,M,MD,ND)                                                     SA2 493 
      IF (IFC) 133,135,133                                              SA2 494 
133   DO 134 I=1,NR                                                     SA2 495 
134   PUNCH 170, (Y(I,J),J=1,M)                                         SA2 496 
135   IF (IFD) 136,153,136                                              SA2 497 
136   DO 139 I=1,NRM1                                                           
      DSTAR(I,I)=0.                                                     SA2 500 
      IP1=I+1                                                           SA2 501 
      DO 139 J=IP1,NR                                                   SA2 502 
      DSTAR(J,I)=0.                                                     SA2 503 
      DO 138 K=1,M                                                      SA2 504 
138   DSTAR(J,I)=DSTAR(J,I)+(Y(I,K)-Y(J,K))**2                          SA2 505 
139   DSTAR(J,I)=SQRT(DSTAR(J,I))                                       SA2 506 
      DSTAR(NR,NR)=0.                                                           
      CALL MXOUT (DSTAR,NR,1,MD)                                        SA2 516 
      GO TO 153                                                         SA2 517 
C     DETERMINE HOW MANY DIMENSIONS TO DROP                             SA2 521 
143   LL=1                                                                      
      DO 147 J=2,M                                                      SA2 523 
      S=STR(J)/STR(1)                                                   SA2 524 
      IF (S-.3) 148,148,146                                             SA2 525 
146   LL=LL+1                                                           SA2 526 
147   CONTINUE                                                          SA2 527 
148   M=LL-1                                                            SA2 528 
      MAXD=LL                                                           SA2 529 
      IF (ITER-100) 149,150,150                                         SA2 530 
149   ITER=ITER+25                                                      SA2 531 
150   IF (KK-1-LL) 151,151,36                                           SA2 532 
151   LFACT=1                                                           SA2 533 
      IF (M) 155,155,152                                                SA2 534 
152   M=M+1                                                             SA2 535 
      GO TO 131                                                         SA2 536 
C     TEST FOR END                                                      SA2 537 
153   IF (.000001-OSTR) 154,155,155                                     SA2 538 
154   IF (M-MAXD) 36,155,155                                            SA2 539 
155   IF (NSYM) 1,1,156                                                 SA2 540 
C     TRANSPOSE INPUT FOR SECOND SOLUTION                               SA2 541 
156   READ (KTAPE) (EVEC(J),J=1,NSIZE)                                          
      JJ=0                                                              SA2 543 
      DO 157 J=1,NR                                                     SA2 544 
      DO 157 I=1,NRM1                                                   SA2 545 
      JJ=JJ+1                                                           SA2 546 
157   DIST(I,J)=EVEC(JJ)                                                SA2 547 
      DO 158 I=1,NRM1                                                   SA2 548 
      IP1=I+1                                                           SA2 549 
      DO 158 J=IP1,NR                                                   SA2 550 
      DSTAR(J-1,I)=DIST(I,J)                                            SA2 551 
158   DSTAR(I,J)=DIST(J-1,I)                                            SA2 552 
      READ (ITAPE,159)                                                  SA2 553 
      READ (ITAPE,160) NR,MIND,MAXD,ISIM,NSYM,IFD,IFC                   SA2 554 
      GO TO 10                                                          SA2 555 
C     *** FORMAT STATEMENTS ***                                         SA2 556 
C                                                                       SA2 557 
159   FORMAT (72H                                                       SA2 558 
     1                 )                                                SA2 559 
160   FORMAT (7I4)                                                              
161   FORMAT (18A4)                                                     SA2 561 
162   FORMAT (19H0INPUT COEFFICIENTS)                                   SA2 562 
163   FORMAT (4H0ROW,I3)                                                SA2 563 
164   FORMAT (10F13.4)                                                  SA2 564 
165   FORMAT (51H0GUTTMAN-LINGOES SMALLEST SPACE COORDINATES FOR M =,I3,SA2 565 
     11H./1H0,9X10H DIMENSION,10I10)                                    SA2 566 
166   FORMAT (1H ,130(1H-)/9H0VARIABLE,5X6HN. PHI)                      SA2 567 
167   FORMAT (I5,5XF10.5,2P11F10.3)                                     SA2 568 
168   FORMAT (17H0NORMALIZED PHI =,F7.5,4H FOR,I4,11H ITERATIONS/28H COESA2 569 
     1FFICIENT OF ALIENATION =,E12.6)                                   SA2 570 
169   FORMAT ('1')                                                              
170   FORMAT (9F8.5)                                                    SA2 572 
      END                                                               SA2 573-
1A COMPLETE ANTI-SYMMETRIC GRAPH (FIG. 14.2 - BERGE).                           
   6   4   5   1   1   1                                                        
(13F1.0)                                                                        
 11011                                                                          
0 0110                                                                          
01 111                                                                          
100 00                                                                          
0001 1                                                                          
01010                                                                           
1A COMPLETE ANTI-SYMMETRIC GRAPH (FIG. 14.2 - BERGE), ROW SOLUTION.             
   6       5   1                                                                
1YOUTH STUDY - G-L(SSA-II).                                                     
  38   2   4   1   1                                                            
(38F1.0)                                                                        
10001010010001011101111100100110001001                                          
01000100110010100010010101110110010010                                          
00100100001010010001000111001001000110                                          
00010011000110010101000011001001100110                                          
11001000110111101100110101110110011000                                          
00100100001011101110001100100100000010                                          
00000010001110010100000100001001000101                                          
00010001001110010001001010001000100100                                          
01001100100011001000110101110110011000                                          
10001100010001100110010000010110000000                                          
00100101001000010000000010000001100110                                          
00010011000110010001001011101101100101                                          
00010100100110001100101101100001110001                                          
11001100110001000001010010100110001100                                          
00101100001000100011010010010010000010                                          
00100011001000010010000010001001100100                                          
11001100100000101000110001110110010000                                          
00010110010111000100001101100000101001                                          
00100011001000010010000000011001000110                                          
00100011001000010001000010001001100110                                          
10001000100111001001100000010110011000                                          
01000100010001101110010001110010010000                                          
00010111001100010110001000101001100101                                          
00100110001000000110000100100001000111                                          
00110011001010010001000010101001100110                                          
00111001100110011100010101000101010100                                          
11001100001001000010101100100010000001                                          
11101100010000100010110100010110001000                                          
00110011001000010001101010001000100010                                          
11101100110111001000110001010100011001                                          
11001100110010100110010000110010000100                                          
10100010001000010000001100001001000111                                          
00010011001010010101001010001000100111                                          
01001000110011011110010001110110010000                                          
11001000110001100101100000010110001000                                          
10100011001000010011000010001001100100                                          
00100111001000100011000010001001100010                                          
10010011000111010001001100101001100001                                          
