Porting continues.
authorilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Tue, 19 Dec 2017 23:12:00 +0000 (23:12 +0000)
committerilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Tue, 19 Dec 2017 23:12:00 +0000 (23:12 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15314 ba61647d-9d00-f842-95cd-605cb4296b96

mipav/src/gov/nih/mipav/model/algorithms/SymmsIntegralMapping.java

index 7b4997a..4ac6e3f 100644 (file)
@@ -299,13 +299,14 @@ public class SymmsIntegralMapping extends AlgorithmBase  {
                        System.out.println("          ISYGP = " + (ORDSG[0]));          \r
                }\r
                WRSYM1(NARCS,ORDRG[0],ORDSG[0],RTUNI,U2,CENSY,REFLN,true,REDD,CHNL,raFile);\r
-               IF (REFLN) THEN\r
-                 CH='TS'\r
-               ELSE\r
-                 CH='TT'\r
-               ENDIF\r
-               CALL WRFUN1(NARCS,STAPT,ARCTY,PGM,RGM,PTX,NTX,DEFN,CHNL,\r
-            +             'IB',CH,'ZETA  ',REDD)\r
+               if (REFLN) {\r
+                 CH = "TS";\r
+               }\r
+               else {\r
+                 CH = "TT";\r
+               }\r
+               WRFUN1(NARCS,STAPT,ARCTY,PGM,RGM,PTX,NTX,DEFN,CHNL,\r
+                        "IB",CH,"ZETA  ",REDD, raFile);\r
                CALL WRSYM2(NARCS,ORDRG,CENSY,REFLN,CHNL)\r
              }\r
              else {\r
@@ -767,122 +768,283 @@ public class SymmsIntegralMapping extends AlgorithmBase  {
                \r
                FMT="(A12,"+REDD+",A1,"+REDD+",A2)";\r
                \r
-               /*if (PARFUN) {\r
-                       NEEDC = ((CENSY[0] != 0.0) && (CENSY[1] != 0.0));\r
-                   if (NEEDC || REFLN) {\r
-                       raFile.writeBytes("      PARAMETER (\n");\r
-                       if (NEEDC && REFLN) {\r
-                           R=U2[0];\r
-                           A=U2[1];\r
-                           raFile.writeBytes("U2[0] = " + R + ";\n");\r
-                           raFile.writeBytes("U2[1] = " + A + ";\n");\r
-                           R=CENSY[0];\r
-                           A=CENSY[1];\r
-                           raFile.writeBytes("ZCEN[0] = " + R +";\n");\r
-                           raFile.writeBytes("ZCEN[1] = " + A + ";)\n");\r
-                       } // if (NEEDC && REFLN)\r
-                       else if (NEEDC && (!REFLN)) {\r
-                           R=CENSY[0];\r
-                           A=CENSY[1];\r
-                           raFile.writeBytes("ZCEN[0] = " + R + ";\n");\r
-                           raFile.writeBytes("ZCEN[1] = " + A + ";)\n");\r
-                       } // else if (NEEDC && (!REFLN)) \r
-                       else {\r
-                           R=U2[0];\r
-                           A=U2[1];\r
-                           raFile.writeBytes("U2[0] = " + R + ";\n");\r
-                           raFile.writeBytes("U2[1] = " + A + ";)\n");\r
-                       } // else\r
-                       raFile.writeBytes("//\n");\r
-                   } // if (NEEDC || REFLN)\r
-               }\r
-               else if (REFLN) {\r
-                   R=U2[0];\r
-                   A=U2[1];\r
-                   raFile.writeBytes("      PARAMETER (\n");\r
-                   raFile.writeBytes("U2[0] = " + R + ";\n");\r
-                   raFile.writeBytes("U2[1] = " + A + ";)\n");\r
-                   raFile.writeBytes("//\n");\r
+               try {\r
+                       if (PARFUN) {\r
+                               NEEDC = ((CENSY[0] != 0.0) && (CENSY[1] != 0.0));\r
+                           if (NEEDC || REFLN) {\r
+                               raFile.writeBytes("      PARAMETER (\n");\r
+                               if (NEEDC && REFLN) {\r
+                                   R=U2[0];\r
+                                   A=U2[1];\r
+                                   raFile.writeBytes("U2[0] = " + R + ";\n");\r
+                                   raFile.writeBytes("U2[1] = " + A + ";\n");\r
+                                   R=CENSY[0];\r
+                                   A=CENSY[1];\r
+                                   raFile.writeBytes("ZCEN[0] = " + R +";\n");\r
+                                   raFile.writeBytes("ZCEN[1] = " + A + ";)\n");\r
+                               } // if (NEEDC && REFLN)\r
+                               else if (NEEDC && (!REFLN)) {\r
+                                   R=CENSY[0];\r
+                                   A=CENSY[1];\r
+                                   raFile.writeBytes("ZCEN[0] = " + R + ";\n");\r
+                                   raFile.writeBytes("ZCEN[1] = " + A + ";)\n");\r
+                               } // else if (NEEDC && (!REFLN)) \r
+                               else {\r
+                                   R=U2[0];\r
+                                   A=U2[1];\r
+                                   raFile.writeBytes("U2[0] = " + R + ";\n");\r
+                                   raFile.writeBytes("U2[1] = " + A + ";)\n");\r
+                               } // else\r
+                               raFile.writeBytes("//\n");\r
+                           } // if (NEEDC || REFLN)\r
+                       }\r
+                       else if (REFLN) {\r
+                           R=U2[0];\r
+                           A=U2[1];\r
+                           raFile.writeBytes("      PARAMETER (\n");\r
+                           raFile.writeBytes("U2[0] = " + R + ";\n");\r
+                           raFile.writeBytes("U2[1] = " + A + ";)\n");\r
+                           raFile.writeBytes("//\n");\r
+                       }\r
+                       \r
+                       FMT="(A7,"+REDD+",A1,"+REDD+",A2)";\r
+                       \r
+                   if (ORDRG >= 2) {\r
+                       raFile.writeBytes("double WW[] = new double["+(ORDRG-1)+"];\n");\r
+                       ZT[0] = 1.0;\r
+                       ZT[1] = 0.0;\r
+                           for (I=0; I < ORDRG-2; I++) {\r
+                               zmlt(ZT[0],ZT[1],RTUNI[0],RTUNI[1],cr,ci);\r
+                               ZT[0] = cr[0];\r
+                               ZT[1] = ci[0];\r
+                               raFile.writeBytes("WW["+I+"][0] = " + ZT[0] + ";\n");\r
+                               raFile.writeBytes("WW["+I+"][1] = " + ZT[1] + ";\n");\r
+                           }\r
+                           zmlt(ZT[0],ZT[1],RTUNI[0],RTUNI[1],cr,ci);\r
+                               ZT[0] = cr[0];\r
+                               ZT[1] = ci[0];\r
+                               raFile.writeBytes("WW["+I+"][0] = " + ZT[0] + ";\n");\r
+                               raFile.writeBytes("WW["+I+"][1] = " + ZT[1] + ";)\n");\r
+                               raFile.writeBytes("//\n");\r
+                   } // if (ORDRG >= 2)\r
+                   \r
+                       if (ORDRG > 19) {\r
+                           System.out.println("\n");\r
+                           System.out.println("             ****WARNING****");\r
+                           System.out.println("MORE THAN 19 CONTINUTATION LINES HAVE BEEN WRITTEN");\r
+                       }\r
+                       \r
+                       if (REFLN) {\r
+                       if (ORDRG > 1) {\r
+                               if (NARCS > 1) {\r
+                                   I=2*NARCS;\r
+                                   raFile.writeBytes("IB = IA%"+I+";\n");\r
+                                   raFile.writeBytes("if (IB == 0) IB = " + I + ";\n");\r
+                                   I=I+1;\r
+                                   raFile.writeBytes("if (IB > " + NARCS + ") {\n");\r
+                                   raFile.writeBytes("    IB = " + I + " - IB;\n");\r
+                                   raFile.writeBytes("    TS[0] = -TT[0];\n");\r
+                                   raFile.writeBytes("    TS[1] = TT[1]);\n");\r
+                                   raFile.writeBytes("}\n");\r
+                                   raFile.writeBytes("else {\n");\r
+                                   raFile.writeBytes("    TS[0] = TT[0];\n");\r
+                                   raFile.writeBytes("    TS[1] = TT[1];\n");\r
+                                   raFile.writeBytes("}\n");\r
+                               } // if (NARCS > 1)\r
+                               else {\r
+                                       raFile.writeBytes("if ((IA%2) == 0) {\n");\r
+                                   raFile.writeBytes("    TS[0] = -TT[0];\n");\r
+                                   raFile.writeBytes("    TS[1] = TT[1];\n");\r
+                                   raFile.writeBytes("}\n");\r
+                                   raFile.writeBytes("else {\n");\r
+                                   raFile.writeBytes("    TS[0] = TT[0];\n");\r
+                                   raFile.writeBytes("    TS[1] = TT[1];\n");\r
+                                   raFile.writeBytes("}\n");\r
+                               } // else\r
+                       } // if (ORDRG > 1)\r
+                       else {\r
+                               if (NARCS > 1) {\r
+                                   I=2*NARCS+1;\r
+                                   raFile.writeBytes("if (IA > " + NARCS + "){\n");\r
+                                   raFile.writeBytes("    IB = " + I + " -IA;\n");\r
+                                   raFile.writeBytes("    TS[0] = -TT[0];\n");\r
+                                   raFile.writeBytes("    TS[1] = TT[1]);\n");\r
+                                   raFile.writeBytes("}\n");\r
+                                   raFile.writeBytes("else {\n");\r
+                                   raFile.writeBytes("    IB = IA;\n");\r
+                                   raFile.writeBytes("    TS[0] = TT[0];\n");\r
+                                   raFile.writeBytes("    TS[1] = TT[1];\n");\r
+                                   raFile.writeBytes("}\n");\r
+                               } // if (NARCS)\r
+                               else {\r
+                                       raFile.writeBytes("if (IA == 2) {\n");\r
+                                       raFile.writeBytes("    TS[0] = -TT[0];\n");\r
+                                   raFile.writeBytes("    TS[1] = TT[1]);\n");\r
+                                   raFile.writeBytes("}\n");\r
+                                   raFile.writeBytes("else {\n");\r
+                                   raFile.writeBytes("    TS[0] = TT[0];\n");\r
+                                   raFile.writeBytes("    TS[1] = TT[1];\n");\r
+                                   raFile.writeBytes("}\n");     \r
+                               } // else\r
+                       } // else\r
+                       } // if (REFLN)\r
+                       else if (NARCS > 1) {\r
+                               raFile.writeBytes("IB = IA%" + NARCS + ";\n");\r
+                           raFile.writeBytes("if (IB == 0) IB = " + NARCS + ";\n");\r
+                       } // else if (NARCS > 1)\r
+                       \r
+                       raFile.writeBytes("//\n");\r
+               } // try\r
+               catch (IOException e) {\r
+                       MipavUtil.displayError("IOException " + e + " in WRSYM1");\r
+                       System.exit(-1);\r
                }\r
                \r
-               FMT="(A7,"+REDD+",A1,"+REDD+",A2)";\r
+      }\r
+\r
+      private void WRFUN1(int NARCS,double STAPT[][],int ARCTY[],int PGM[], \r
+                 int RGM[], int PTX[], int NTX[], String DEFN[],\r
+                 int CHNL, String CHIA, String CHTT, String VAR, String REDD, RandomAccessFile raFile) {\r
+          //COMPLEX STAPT(*)\r
+          //CHARACTER DEFN(*)*72,CHIA*2,CHTT*2,VAR*6,REDD*6\r
+               \r
+          //**** TO WRITE THE SOURCE CODE FOR PARFUN IN THE CASE WHERE NO\r
+         //**** SYMMETRY IS INVOLVED.\r
                \r
-           if (ORDRG >= 2) {\r
-               raFile.writeBytes("double WW[] = new double["+(ORDRG-1)+"];");\r
-               ZT[0] = 1.0;\r
-               ZT[1] = 0.0;\r
-                   for (I=0; I < ORDRG-2; I++) {\r
-                       zmlt(ZT[0],ZT[1],RTUNI[0],RTUNI[1],cr,ci);\r
-                       ZT[0] = cr[0];\r
-                       ZT[1] = ci[0];\r
-                       raFile.writeBytes("WW["+I+"][0] = " + ZT[0] + "\n");\r
-                       raFile.writeBytes("WW["+I+"][1] = " + ZT[1] + "\n");\r
-                   }\r
-                   zmlt(ZT[0],ZT[1],RTUNI[0],RTUNI[1],cr,ci);\r
-                       ZT[0] = cr[0];\r
-                       ZT[1] = ci[0];\r
-                       raFile.writeBytes("WW["+I+"][0] = " + ZT[0] + "\n");\r
-                       raFile.writeBytes("WW["+I+"][1] = " + ZT[1] + ")\n");\r
-                       raFile.writeBytes("//\n");\r
-           } // if (ORDRG >= 2)\r
-           \r
-               if (ORDRG > 19) {\r
-                   System.out.println("\n");\r
-                   System.out.println("             ****WARNING****");\r
-                   System.out.println("MORE THAN 19 CONTINUTATION LINES HAVE BEEN WRITTEN");\r
-               }\r
+         //.......................................................................\r
+         //     AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
+         //     LAST UPDATE: 4 AUG 1990\r
+         //.......................................................................\r
+       \r
+         //     LOCAL VARIABLES\r
+       \r
+          int IA,I,J;\r
+         //CHARACTER TX1*16,TX2*21,FMT1*11,FMT2*11\r
+          String TX1,TX2,FMT1,FMT2;\r
+         // EXTERNAL PTFUN1\r
+         TX1 = "     if("+CHIA+ " == ";\r
+         TX2 = "     else if("+CHIA+ " == ";\r
+          FMT1="(A16,I3,A6)";\r
+          FMT2="(A21,I3,A6)";\r
                \r
-               if (REFLN) {\r
-                         IF (ORDRG.GT.1) THEN\r
-                             IF (NARCS.GT.1) THEN\r
-                                 I=2*NARCS\r
-                                 WRITE(CHNL,'(A16,I3,A1)') '      IB=MOD(IA,',I,')'\r
-                                 WRITE(CHNL,'(A22,I3)') '      IF (IB.EQ.0) IB=',I\r
-                                 I=I+1\r
-                                 WRITE(CHNL,'(A16,I3,A6)') '      IF (IB.GT.',NARCS,')\r
-                    +THEN'\r
-                                 WRITE(CHNL,'(A13,I3,A3)') '          IB=',I,'-IB'\r
-                                 WRITE(CHNL,'(A23)') '          TS=-CONJG(TT)'\r
-                                 WRITE(CHNL,'(A10)') '      ELSE'\r
-                                 WRITE(CHNL,'(A15)') '          TS=TT'\r
-                                 WRITE(CHNL,'(A11)') '      ENDIF'\r
-                             ELSE\r
-                                 WRITE(CHNL,'(A30)') '      IF (MOD(IA,2).EQ.0) THEN'\r
-                                 WRITE(CHNL,'(A23)') '          TS=-CONJG(TT)'\r
-                                 WRITE(CHNL,'(A10)') '      ELSE'\r
-                                 WRITE(CHNL,'(A15)') '          TS=TT'\r
-                                 WRITE(CHNL,'(A11)') '      ENDIF'\r
-                             ENDIF\r
-                         ELSE\r
-                             IF (NARCS.GT.1) THEN\r
-                                 I=2*NARCS+1\r
-                                 WRITE(CHNL,'(A16,I3,A6)') '      IF (IA.GT.',NARCS,') \r
-                    +THEN'\r
-                                 WRITE(CHNL,'(A13,I3,A3)') '          IB=',I,'-IA'\r
-                                 WRITE(CHNL,'(A23)') '          TS=-CONJG(TT)'\r
-                                 WRITE(CHNL,'(A10)') '      ELSE'\r
-                                 WRITE(CHNL,'(A15)') '          IB=IA'\r
-                                 WRITE(CHNL,'(A15)') '          TS=TT'\r
-                                 WRITE(CHNL,'(A11)') '      ENDIF'\r
-                             ELSE\r
-                                 WRITE(CHNL,'(A23)') '      IF (IA.EQ.2) THEN'\r
-                                 WRITE(CHNL,'(A23)') '          TS=-CONJG(TT)'\r
-                                 WRITE(CHNL,'(A10)') '      ELSE'\r
-                                 WRITE(CHNL,'(A15)') '          TS=TT'\r
-                                 WRITE(CHNL,'(A11)') '      ENDIF'\r
-                             ENDIF\r
-                         ENDIF\r
-               } // if (REFLN)\r
-               else if (NARCS > 1) {\r
-                         WRITE(CHNL,'(A16,I3,A1)') '      IB=MOD(IA,',NARCS,')'\r
-                         WRITE(CHNL,'(A22,I3)') '      IF (IB.EQ.0) IB=',NARCS\r
-               }\r
-               C\r
-                     WRITE(CHNL,'(A1)') 'C'\r
-               C*/\r
-      }\r
+        /* try {\r
+                 for (IA=1; IA <= NARCS; IA++) {\r
+                     I=PGM[IA-1];\r
+                         J=PTX[IA-1];\r
+                         if (NARCS == 1) {\r
+                             PTFUN1(ARCTY[IA-1],STAPT[IA-1],RGM[I-1],NTX[IA-1],DEFN[J-1],\r
+                                        CHNL,CHTT,VAR,REDD, raFile);\r
+                         }\r
+                         else {\r
+                                 if (IA == 1) {\r
+                                         raFile.writeBytes(TX1 + IA + ") {\n");\r
+                                 }\r
+                                 else if (IA == NARCS) {\r
+                                         raFile.writeBytes("      else {\n");\r
+                                 }\r
+                                 else {\r
+                                         raFile.writeBytes(TX2 + IA + ") {\n");\r
+                                 }\r
+                                 PTFUN1(ARCTY[IA-1],STAPT[IA-1],RGM[I-1],NTX[IA-1],DEFN[J-1],\r
+                                        CHNL,CHTT,VAR,REDD, raFile);\r
+                                 if (IA == NARCS) raFile.writeBytes("      }\n");\r
+                         } // else\r
+                 } // for (IA=1; IA <= NARCS; IA++)\r
+         } // try\r
+         catch (IOException e) {\r
+             MipavUtil.displayError("IOException " + e + " in WRFUN1");\r
+             System.exit(-1);\r
+         }*/\r
+               \r
+      } // private void WRFUN1\r
 \r
+      private void PTFUN1(int TYPE, double STAPT[], double RGM[],int NTX,\r
+                 String TXT[],int CHNL, String CHTT,String VAR, String REDD,\r
+                 RandomAccessFile raFile) {\r
+      \r
+          //COMPLEX STAPT(*)\r
+          //CHARACTER TXT(*)*72,CHTT*2,VAR*6,REDD*6\r
+\r
+          //.......................................................................\r
+          // AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
+          // LAST UPDATE: 8 AUG 1990\r
+          // .......................................................................C\r
+          //**** LOCAL VARIABLES\r
+\r
+      int I;\r
+      double HA,MD,RAD,A,R;\r
+      double C1[] = new double[2];\r
+      double C2[] = new double[2];\r
+      double CENTR[] = new double[2];\r
+      //COMPLEX C1,C2,CENTR\r
+      String TX1, TX1B, TX2, TX2B, CTX1B, FMT1, FMT2, FMT3, FMT4, FMT5;\r
+      //CHARACTER TX1*4,TX1B*5,TX2*13,TX2B*14,CTX1B*10,\r
+      //+FMT1*25,FMT2*25,FMT3*14,FMT4*25,FMT5*24\r
 \r
+      TX1 = "+"+CHTT+"*";\r
+      TX1B = TX1 + "(";\r
+      CTX1B="     " + TX1B;\r
+      TX2="      "+VAR+" = ";\r
+      TX2B=TX2+"(";\r
+\r
+      //FMT1='(A14,'//REDD//',A1,'//REDD//',A2)'\r
+      //FMT2='(A10,'//REDD//',A1,'//REDD//',A1)'\r
+      //FMT3='(A6,'//REDD//',A1)'\r
+      //FMT4='(A14,'//REDD//',A5,'//REDD//',A3)'\r
+      //FMT5='(A8,'//REDD//',A5,'//REDD//',A1)'\r
+\r
+      /*if (TYPE == 1) {\r
+       C1[0] = 0.5*(STAPT[1][0] + STAPT[0][0]);\r
+       C1[1] = 0.5*(STAPT[1][1] + STAPT[0][1]);\r
+        C2[0] = 0.5*(STAPT[1][0] - STAPT[0][0]);\r
+        C2[1] = 0.5*(STAPT[1][1] - STAPT[0][1]);\r
+        raFile.writeBytes("//\n");\r
+        raFile.writeBytes(VAR+"[0] = " + C1[0] + "+" + CHTT+"[0]*"+C2[0]+" - "+CHTT+"[1]*"+C2[1]+";\n");\r
+        raFile.writeBytes(VAR+"[1] = " + C1[1] + "+" + CHTT+"[0]*"+C2[1]+" + "+CHTT+"[1]*"+C2[0]+";\n");\r
+        raFile.writeBytes("//\n");\r
+      } // if (TYPE == 1)\r
+      else if (TYPE == 2) {\r
+       CENTR[0] = RGM[0];\r
+       CENTR[1] = RGN[1];\r
+        C1[0] = STAPT[0][0] - CENTR[0];\r
+        C1[1] = STAPT[0][1] - CENTR[1];\r
+        HA=0.5*RGM[2];\r
+        MD = Math.atan2(C1[1], C1[0]) + HA;\r
+        RAD=zabs(C1[0],C1[1]);\r
+        raFile.writeBytes("//\n");\r
+        raFile.writeBytes(VAR+"[0] = " + CENTR[0] + "+" + RAD + " * " + "Math.exp(-"+CHTT+"[1]*"+HA+")*"\r
+        +"Math.cos("+MD+CHTT+"[0]*"+HA+");\n");\r
+        raFile.writeBytes(VAR+"[1] = " + CENTR[1] + "+" + RAD + " * " + "Math.exp(-"+CHTT+"[1]*"+HA+")*"\r
+                +"Math.sin("+MD+CHTT+"[0]*"+HA+");\n");\r
+        raFile.writeBytes("//\n");\r
+      } // else if (TYPE == 2)\r
+      else if (TYPE == 3) {\r
+        MD=0.5*(RGM[1]+RGM[0]);\r
+        HA=0.5*(RGM[1]-RGM[0]);\r
+        raFile.writeBytes("//\n");\r
+        raFile.writeBytes("T[0] = " + MD + "+" CHTT + "[0] * " + HA + ";\n");\r
+        raFile.writeBytes("T[1] = " + MD + "+" CHTT + "[1] * " + HA + ";\n");\r
+        \r
+        WRITE(CHNL,'(A13)') TX2\r
+        DO 10 I=1,NTX\r
+          WRITE(CHNL,'(A72)') TXT(I)\r
+10      CONTINUE\r
+        WRITE(CHNL,'(A1)') 'C'\r
+      } // else if (TYPE == 3)\r
+      ELSE\r
+        MD=5E-1*(RGM(2)+RGM(1))\r
+        HA=5E-1*(RGM(2)-RGM(1))\r
+        WRITE(CHNL,'(A1)') 'C'\r
+        WRITE(CHNL,FMT5) '      T=',MD,TX1B,HA,')'\r
+        WRITE(CHNL,'(A11)') '      ZRAD='\r
+        DO 20 I=1,NTX\r
+          WRITE(CHNL,'(A72)') TXT(I)\r
+20      CONTINUE\r
+        WRITE(CHNL,'(A13,A14)') TX2,'ZRAD*EXP(UI*T)'\r
+        WRITE(CHNL,'(A1)') 'C'\r
+      ENDIF\r
+C*/\r
+      }\r
 \r
       \r
       /**\r