Examples 2 and 4 added to PARFUN and DPARFN.
authorilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Thu, 8 Feb 2018 19:01:00 +0000 (19:01 +0000)
committerilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Thu, 8 Feb 2018 19:01:00 +0000 (19:01 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15365 ba61647d-9d00-f842-95cd-605cb4296b96

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

index c730a36..0baf63b 100644 (file)
@@ -451,7 +451,6 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                // String FMT2;\r
 \r
                // PARAMETER (MNARC=100,TABC=' +',CHNL=20,CHIN=21)\r
-               final String TABC = "     +";\r
                final int CHNL = 20;\r
                // final int CHIN = 21;\r
                String line;\r
@@ -460,7 +459,6 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                File file;\r
                RandomAccessFile raFile = null;\r
                boolean validInput;\r
-               String junk;\r
 \r
                // EXTERNAL CHRIN,HEADER,R1MACH,SYINF1,WRFUN1,WRFUN2,WRHEAD,WRSYM1,\r
                // +WRSYM2,WRSYM3,WRTAIL\r
@@ -555,7 +553,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                        line = input.next();\r
                                        tokens = line.split(",");\r
                                        CENSY[0] = Double.valueOf(tokens[0]);\r
-                                       CENSY[1] = Double.valueOf(tokens[0]);\r
+                                       CENSY[1] = Double.valueOf(tokens[1]);\r
                                        validInput = true;\r
                                    }\r
                                    catch (Exception e) {};\r
@@ -1007,6 +1005,32 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                   PARFUNANS[1] = ZRAD[0]*Math.exp(-T[1])*Math.sin(T[0]) + ZRAD[1]*Math.exp(-T[1])*Math.cos(T[0]);\r
            }   \r
        } // if (example == 1)\r
+       else if (example == 2) {\r
+           if(IA == 1) {\r
+              PARFUNANS[0] = 1.0+TT[0]*(0.050000000000000044) - TT[1]*(0.0);\r
+                  PARFUNANS[1] = 0.0+TT[0]*(0.0) + TT[1]*(0.050000000000000044);\r
+          }\r
+          else if(IA == 2) {\r
+              T[0] = 6.283185307179586+TT[0] * (6.283185307179586);\r
+                  T[1] = TT[1] * (6.283185307179586);\r
+                  ZRAD[0] = 1.05-0.2*T[0]/Math.PI;\r
+                  ZRAD[1] = -2.0*T[1]/Math.PI;\r
+                  PARFUNANS[0] = ZRAD[0]*Math.exp(-T[1])*Math.cos(T[0]) - ZRAD[1]*Math.exp(-T[1])*Math.sin(T[0]);\r
+                  PARFUNANS[1] = ZRAD[0]*Math.exp(-T[1])*Math.sin(T[0]) + ZRAD[1]*Math.exp(-T[1])*Math.cos(T[0]);\r
+          }\r
+          else if(IA == 3) {\r
+                  PARFUNANS[0] = 0.2+TT[0]*(-0.05) - TT[1]*(0.0);\r
+                  PARFUNANS[1] = 0.0+TT[0]*(0.0) + TT[1]*(-0.05);\r
+          }\r
+          else {\r
+                  T[0] = -6.283185307179586+TT[0] * (-6.283185307179586);\r
+                  T[1] = TT[1] * (-6.283185307179586);\r
+                  ZRAD[0] = 0.15-0.2*T[0]/Math.PI;\r
+                  ZRAD[1] = -0.2*T[1]/Math.PI;\r
+                  PARFUNANS[0] = ZRAD[0]*Math.exp(-T[1])*Math.cos(T[0]) - ZRAD[1]*Math.exp(-T[1])*Math.sin(T[0]);\r
+                  PARFUNANS[1] = ZRAD[0]*Math.exp(-T[1])*Math.sin(T[0]) + ZRAD[1]*Math.exp(-T[1])*Math.cos(T[0]);\r
+          }\r
+       } // else if (example == 2)\r
        else if (example == 3) {\r
           int IB, IR;\r
           double ZETA[] = new double[2];\r
@@ -1041,6 +1065,71 @@ public class SymmsIntegralMapping extends AlgorithmBase {
               PARFUNANS[1] = WW[IR-1][0]*ZETA[1] + WW[IR-1][1]*ZETA[0];\r
           }   \r
        } // else if (example == 3)\r
+       else if (example == 4) {\r
+          int IB, IR, IS;\r
+          double TS[] = new double[2];\r
+          double ZETA[] = new double[2];\r
+          double U2[] = new double[]{-0.4999999967225801, 0.8660254056766582};\r
+          double ZCEN[] = new double[]{0.0, -5.1961524};\r
+          double WW[][] = new double[5][2];\r
+          WW[0][0] = 0.5000000000000001;\r
+          WW[0][1] = 0.8660254037844386;\r
+          WW[1][0] = -0.4999999999999998;\r
+          WW[1][1] = 0.8660254037844388;\r
+          WW[2][0] = -1.0;\r
+          WW[2][1] = 3.885780586188048E-16;\r
+          WW[3][0] = -0.5000000000000004;\r
+          WW[3][1] = -0.8660254037844384;\r
+          WW[4][0] = 0.4999999999999994;\r
+          WW[4][1] = -0.866025403784439;\r
+          IB = IA%8;\r
+          if (IB == 0) IB = 8;\r
+          if (IB > 4) {\r
+              IB = 9 - IB;\r
+              TS[0] = -TT[0];\r
+              TS[1] = TT[1];\r
+          }\r
+          else {\r
+              TS[0] = TT[0];\r
+              TS[1] = TT[1];\r
+          }\r
+          if(IB == 1) {\r
+              ZETA[0] = 8.0+TS[0]*(-1.0) - TS[1]*(0.0);\r
+              ZETA[1] = 0.0+TS[0]*(0.0) + TS[1]*(-1.0);\r
+          }\r
+          else if(IB == 2) {\r
+              ZETA[0] = 6.5+TS[0]*(-0.5) - TS[1]*(0.8660255);\r
+              ZETA[1] = 0.8660255+TS[0]*(0.8660255) + TS[1]*(-0.5);\r
+          }\r
+          else if(IB == 3) {\r
+              ZETA[0] = 5.5+TS[0]*(-0.5) - TS[1]*(-0.8660255);\r
+              ZETA[1] = 0.8660255+TS[0]*(-0.8660255) + TS[1]*(-0.5);\r
+          }\r
+          else {\r
+              ZETA[0] = 4.0+TS[0]*(-1.0) - TS[1]*(0.0);\r
+              ZETA[1] = 0.0+TS[0]*(0.0) + TS[1]*(-1.0);\r
+          }\r
+          IS = (IA-IB)%8;\r
+          IR = (IA-IB-IS)/8;\r
+          if ((IR == 0) && (IS == 0)) {\r
+              PARFUNANS[0] = ZETA[0];\r
+              PARFUNANS[1] = ZETA[1];\r
+          }\r
+          else if ((IR > 0) && (IS == 0)) {\r
+              PARFUNANS[0] = ZCEN[0] + WW[IR-1][0]*(ZETA[0] - ZCEN[0]) - WW[IR-1][1]*(ZETA[1] - ZCEN[1]);\r
+              PARFUNANS[1] = ZCEN[1] + WW[IR-1][0]*(ZETA[1] - ZCEN[1]) + WW[IR-1][1]*(ZETA[0] - ZCEN[0]);\r
+          }\r
+          else if ((IR == 0) && (IS > 0)) {\r
+              PARFUNANS[0] = ZCEN[0] + U2[0]*(ZETA[0]-ZCEN[0]) + U2[1]*(ZETA[1]-ZCEN[1]);\r
+              PARFUNANS[1] = ZCEN[1] - U2[0]*(ZETA[1]-ZCEN[1]) + U2[1]*(ZETA[0]-ZCEN[0]);\r
+          }\r
+          else {\r
+              double realPart = U2[0]*WW[IR-1][0] - U2[1]*WW[IR-1][1];\r
+              double imagPart = U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0];\r
+              PARFUNANS[0] = ZCEN[0] + realPart*(ZETA[0]-ZCEN[0]) + imagPart*(ZETA[1]-ZCEN[1]);\r
+              PARFUNANS[1] = ZCEN[1] - realPart*(ZETA[1]-ZCEN[1]) + imagPart*(ZETA[0]-ZCEN[0]);\r
+          }\r
+       } // else if (example == 4)\r
        return PARFUNANS;\r
        } // private double[] PARFUN\r
 \r
@@ -1083,6 +1172,36 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                        DPARFNANS[1] = ((ZDER[0] - ZRAD[1])* Math.sin(T[0]) + (ZRAD[0] + ZDER[1])* Math.cos(T[0]))*Math.exp(-T[1])*(0.7853981633974483);\r
                 }      \r
            } // if (example == 1)\r
+           else if (example == 2) {\r
+               if (IA == 1) {\r
+                   DPARFNANS[0] = 0.050000000000000044;\r
+                       DPARFNANS[1] = 0.0;\r
+               }\r
+               else if (IA == 2) {\r
+                   T[0] = 6.283185307179586+TT[0]*(6.283185307179586);\r
+                       T[1] = TT[1]*(6.283185307179586);\r
+                       ZRAD[0] = 1.05-0.2*T[0]/Math.PI;\r
+                       ZRAD[1] = -2.0*T[1]/Math.PI;\r
+                       ZDER[0] = -2.0/Math.PI;\r
+                       ZDER[1] = 0.0;\r
+                       DPARFNANS[0] = ((ZDER[0] - ZRAD[1])* Math.cos(T[0]) - (ZRAD[0] + ZDER[1])* Math.sin(T[0]))*Math.exp(-T[1])*(6.283185307179586);\r
+                       DPARFNANS[1] = ((ZDER[0] - ZRAD[1])* Math.sin(T[0]) + (ZRAD[0] + ZDER[1])* Math.cos(T[0]))*Math.exp(-T[1])*(6.283185307179586);\r
+               }\r
+               else if (IA == 3) {\r
+                       DPARFNANS[0] = -0.05;\r
+                       DPARFNANS[1] = 0.0;\r
+               }\r
+               else {\r
+                       T[0] = -6.283185307179586+TT[0]*(-6.283185307179586);\r
+                       T[1] = TT[1]*(-6.283185307179586);\r
+                       ZRAD[0] = 0.15-0.2*T[0]/Math.PI;\r
+                       ZRAD[1] = -0.2*T[1]/Math.PI;\r
+                       ZDER[0] = -0.2/Math.PI;\r
+                       ZDER[1] = 0.0;\r
+                       DPARFNANS[0] = ((ZDER[0] - ZRAD[1])* Math.cos(T[0]) - (ZRAD[0] + ZDER[1])* Math.sin(T[0]))*Math.exp(-T[1])*(-6.283185307179586);\r
+                       DPARFNANS[1] = ((ZDER[0] - ZRAD[1])* Math.sin(T[0]) + (ZRAD[0] + ZDER[1])* Math.cos(T[0]))*Math.exp(-T[1])*(-6.283185307179586);\r
+               }\r
+           } // else if (example == 2)\r
            else if (example == 3) {\r
                int IB, IR;\r
                double ZETA[] = new double[2];\r
@@ -1119,6 +1238,70 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                    DPARFNANS[1]= WW[IR-1][0]*ZETA[1] + WW[IR-1][1]*ZETA[0];\r
                }\r
            } // else if (example == 3)\r
+           else if (example == 4) {\r
+               int IB, IR, IS;\r
+               double ZETA[] = new double[2];\r
+               double TS[] = new double[2];\r
+               double U2[] = new double[]{-0.4999999967225801, 0.8660254056766582};\r
+               double WW[][] = new double[5][2];\r
+               WW[0][0] = 0.5000000000000001;\r
+               WW[0][1] = 0.8660254037844386;\r
+               WW[1][0] = -0.4999999999999998;\r
+               WW[1][1] = 0.8660254037844388;\r
+               WW[2][0] = -1.0;\r
+               WW[2][1] = 3.885780586188048E-16;\r
+               WW[3][0] = -0.5000000000000004;\r
+               WW[3][1] = -0.8660254037844384;\r
+               WW[4][0] = 0.4999999999999994;\r
+               WW[4][1] = -0.866025403784439;\r
+               IB = IA%8;\r
+               if (IB == 0) IB = 8;\r
+               if (IB > 4) {\r
+                   IB = 9 - IB;\r
+                   TS[0] = -TT[0];\r
+                   TS[1] = TT[1];\r
+               }\r
+               else {\r
+                   TS[0] = TT[0];\r
+                   TS[1] = TT[1];\r
+               }\r
+               if (IB == 1) {\r
+                   ZETA[0] = -1.0;\r
+                   ZETA[1] = 0.0;\r
+               }\r
+               else if (IB == 2) {\r
+                   ZETA[0] = -0.5;\r
+                   ZETA[1] = 0.8660255;\r
+               }\r
+               else if (IB == 3) {\r
+                   ZETA[0] = -0.5;\r
+                   ZETA[1] = -0.8660255;\r
+               }\r
+               else {\r
+                   ZETA[0] = -1.0;\r
+                   ZETA[1] = 0.0;\r
+               }\r
+               IS = (IA-IB)%8;\r
+               IR=(IA-IB-IS)/8;\r
+               if ((IR == 0) && (IS == 0)) {\r
+                   DPARFNANS[0] =ZETA[0];\r
+                   DPARFNANS[1] =ZETA[1];\r
+               }\r
+               else if ((IR > 0) && (IS == 0)) {\r
+                   DPARFNANS[0] = WW[IR-1][0]*ZETA[0] - WW[IR-1][1]*ZETA[1];\r
+                   DPARFNANS[1] = WW[IR-1][0]*ZETA[1] + WW[IR-1][1]*ZETA[0];\r
+               }\r
+               else if ((IR == 0) && (IS > 0)) {\r
+                   DPARFNANS[0] = -U2[0]*ZETA[0] -U2[1]*ZETA[1];\r
+                   DPARFNANS[1] = U2[0]*ZETA[1] -U2[1]*ZETA[0];\r
+               }\r
+               else {\r
+                   double realPart = -U2[0]*WW[IR-1][0] + U2[1]*WW[IR-1][1];\r
+                   double imagPart = -U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0];\r
+                   DPARFNANS[0] = realPart*ZETA[0] + imagPart*ZETA[1];\r
+                   DPARFNANS[1] = imagPart*ZETA[0] - realPart*ZETA[1];\r
+               }\r
+           } // else if (example == 4)\r
            return DPARFNANS;\r
        } // double[] DPARFN\r
 \r
@@ -1362,37 +1545,30 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                        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
+                                               raFile.writeBytes("      double U2[] = new double[]{"+R+", " + 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
+                                               raFile.writeBytes("      double ZCEN[] = new double[]{"+R+", " + 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
+                                               raFile.writeBytes("      double ZCEN[] = new double[]{"+R+", " + 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
+                                               raFile.writeBytes("      double U2[] = new double[]{"+R+", " + A + "};\n");\r
                                        } // else\r
                                        raFile.writeBytes("//\n");\r
                                } // if (NEEDC || REFLN)\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("      double U2[] = new double[]{"+R+", " + A + "};\n");\r
                                raFile.writeBytes("//\n");\r
                        }\r
 \r
@@ -1433,7 +1609,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                                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("          TS[1] = TT[1];\n");\r
                                                raFile.writeBytes("      }\n");\r
                                                raFile.writeBytes("      else {\n");\r
                                                raFile.writeBytes("          TS[0] = TT[0];\n");\r
@@ -1457,7 +1633,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                                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("          TS[1] = TT[1];\n");\r
                                                raFile.writeBytes("      }\n");\r
                                                raFile.writeBytes("      else {\n");\r
                                                raFile.writeBytes("          IB = IA;\n");\r
@@ -1468,7 +1644,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                        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("          TS[1] = TT[1];\n");\r
                                                raFile.writeBytes("      }\n");\r
                                                raFile.writeBytes("      else {\n");\r
                                                raFile.writeBytes("          TS[0] = TT[0];\n");\r
@@ -1548,7 +1724,11 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                        DEFN2 = null;\r
                                }\r
                                if (NARCS == 1) {\r
-                                       PTFUN1(ARCTY[IA - 1], STAPT2, RGM2, NTX[IA - 1], DEFN2, CHNL, CHTT, VAR, REDD, raFile, writeReturn);\r
+                                       PTFUN1(ARCTY[IA - 1], STAPT2, RGM2, NTX[IA - 1], DEFN2, CHNL, CHTT, VAR, REDD, raFile);\r
+                                       if (writeReturn) {\r
+                                           raFile.writeBytes("      return " + VAR + ";\n");\r
+                                           raFile.writeBytes("    }\n");\r
+                                       }\r
                                } else {\r
                                        if (IA == 1) {\r
                                                raFile.writeBytes(TX1 + IA + ") {\n");\r
@@ -1557,10 +1737,14 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                        } else {\r
                                                raFile.writeBytes(TX2 + IA + ") {\n");\r
                                        }\r
-                                       PTFUN1(ARCTY[IA - 1], STAPT2, RGM2, NTX[IA - 1], DEFN2, CHNL, CHTT, VAR, REDD, raFile, writeReturn);\r
+                                       PTFUN1(ARCTY[IA - 1], STAPT2, RGM2, NTX[IA - 1], DEFN2, CHNL, CHTT, VAR, REDD, raFile);\r
                                        raFile.writeBytes("      }\n");\r
-                                       if (IA == NARCS)\r
-                                               raFile.writeBytes("    }\n");\r
+                                       if (IA == NARCS) {\r
+                                               if (writeReturn) {\r
+                                                   raFile.writeBytes("      return " + VAR + ";\n");\r
+                                                   raFile.writeBytes("    }\n");\r
+                                               }\r
+                                       }\r
                                } // else\r
                        } // for (IA=1; IA <= NARCS; IA++)\r
                } // try\r
@@ -1572,7 +1756,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
        } // private void WRFUN1\r
 \r
        private void PTFUN1(int TYPE, double STAPT[][], double RGM[], int NTX, String TXT[], int CHNL, String CHTT,\r
-                       String VAR, String REDD, RandomAccessFile raFile, boolean writeReturn) {\r
+                       String VAR, String REDD, RandomAccessFile raFile) {\r
         // When TT goes from -1,0 to 1,0 T[0] traces out the original parameterization of the curve\r
                // COMPLEX STAPT(*)\r
                // CHARACTER TXT(*)*72,CHTT*2,VAR*6,REDD*6\r
@@ -1790,9 +1974,6 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                raFile.writeBytes(PAD + VAR + "[1] = ZRAD[0]*Math.exp(-T[1])*Math.sin(T[0]) + ZRAD[1]*Math.exp(-T[1])*Math.cos(T[0]);\n");\r
                                raFile.writeBytes("//\n");\r
                        }\r
-                       if (writeReturn) {\r
-                           raFile.writeBytes(PAD + "return " + VAR + ";\n");\r
-                       }\r
                } // try\r
                catch (IOException e) {\r
                        MipavUtil.displayError("IOException " + e + " in PTFUN1");\r
@@ -1847,6 +2028,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                        else {\r
                                                raFile.writeBytes("      PARFUNANS[0] = WW[IR-1][0]*ZETA[0] - WW[IR-1][1]*ZETA[1];\n");\r
                                        }\r
+                                       raFile.writeBytes("      }\n");\r
                                        raFile.writeBytes("      else if ((IR == 0) && (IS > 0)) {\n");\r
                                        if (NEEDC) {\r
                                                raFile.writeBytes(\r
@@ -1860,19 +2042,19 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                        raFile.writeBytes("      }\n");\r
                                        raFile.writeBytes("      else {\n");\r
                                        if (NEEDC) {\r
-                                               raFile.writeBytes("      double realPart = U2[0]*WW[IR-1][0] - U2[1]*WW[IR-1][1];\n");\r
-                                               raFile.writeBytes("      double imagPart = U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0];\n");\r
-                                               raFile.writeBytes("      PARFUNANS[0] = ZCEN[0] + realPart*(ZETA[0]-ZCEN[0]) + "\r
+                                               raFile.writeBytes("          double realPart = U2[0]*WW[IR-1][0] - U2[1]*WW[IR-1][1];\n");\r
+                                               raFile.writeBytes("          double imagPart = U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0];\n");\r
+                                               raFile.writeBytes("          PARFUNANS[0] = ZCEN[0] + realPart*(ZETA[0]-ZCEN[0]) + "\r
                                                                + "imagPart*(ZETA[1]-ZCEN[1]);\n");\r
-                                               raFile.writeBytes("      PARFUNANS[1] = ZCEN[1] - realPart*(ZETA[1]-ZCEN[1]) + "\r
+                                               raFile.writeBytes("          PARFUNANS[1] = ZCEN[1] - realPart*(ZETA[1]-ZCEN[1]) + "\r
                                                                + "imagPart*(ZETA[0]-ZCEN[0]);\n");\r
                                        } else {\r
-                                               raFile.writeBytes("      double realPart = U2[0]*WW[IR-1][0] - U2[1]*WW[IR-1][1];\n");\r
-                                               raFile.writeBytes("      double imagPart = U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0];\n");\r
-                                               raFile.writeBytes("      PARFUNANS[0] = realPart * ZETA[0] + imagPart * ZETA[1];\n");\r
-                                               raFile.writeBytes("      PARFUNANS[1] = -realPart * ZETA[1] + imagPart * ZETA[0];\n");\r
+                                               raFile.writeBytes("          double realPart = U2[0]*WW[IR-1][0] - U2[1]*WW[IR-1][1];\n");\r
+                                               raFile.writeBytes("              double imagPart = U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0];\n");\r
+                                               raFile.writeBytes("          PARFUNANS[0] = realPart * ZETA[0] + imagPart * ZETA[1];\n");\r
+                                               raFile.writeBytes("          PARFUNANS[1] = -realPart * ZETA[1] + imagPart * ZETA[0];\n");\r
                                        }\r
-                                       raFile.writeBytes("}\n");\r
+                                       raFile.writeBytes("    }\n");\r
                                } // if (ORDRG > 1)\r
                                else { // ORDRG <= 1\r
                                        if (NARCS > 1) {\r
@@ -2005,7 +2187,11 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                }\r
                                if (NARCS == 1) {\r
                                        PTFUN2(ARCTY[IA - 1], STAPT2, RGM2, N1, DEFN2, N2, DEFN3, CHNL, CHTT, VAR, " 1", NUMDER[IA - 1],\r
-                                                       REDD, raFile, writeReturn);\r
+                                                       REDD, raFile);\r
+                                       if (writeReturn) {\r
+                                           raFile.writeBytes("      return " + VAR + ";\n");\r
+                                           raFile.writeBytes("    }\n");\r
+                                       }\r
                                } else {\r
                                        if (IA == 1) {\r
                                                raFile.writeBytes(TX1 + IA + ") {\n");\r
@@ -2015,10 +2201,13 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                                raFile.writeBytes(TX2 + IA + ") {\n");\r
                                        }\r
                                        PTFUN2(ARCTY[IA - 1], STAPT2, RGM2, N1, DEFN2, N2, DEFN3, CHNL, CHTT, VAR, CHIA, NUMDER[IA - 1],\r
-                                                       REDD, raFile, writeReturn);\r
+                                                       REDD, raFile);\r
                                        raFile.writeBytes("      }\n");\r
                                        if (IA == NARCS) {\r
-                                               raFile.writeBytes("    }\n");\r
+                                               if (writeReturn) {\r
+                                                   raFile.writeBytes("      return " + VAR + ";\n");\r
+                                                   raFile.writeBytes("    }\n");\r
+                                               }\r
                                        }\r
                                } // else\r
                        } // for (IA=1; IA <= NARCS; IA++)\r
@@ -2031,8 +2220,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
        } // private void WRFUN2\r
 \r
        private void PTFUN2(int TYPE, double STAPT[][], double RGM[], int NTX1, String TXT1[], int NTX2, String TXT2[],\r
-                       int CHNL, String CHTT, String VAR, String CHIA, boolean NUMDER, String REDD, RandomAccessFile raFile,\r
-                       boolean writeReturn) {\r
+                       int CHNL, String CHTT, String VAR, String CHIA, boolean NUMDER, String REDD, RandomAccessFile raFile) {\r
                // COMPLEX STAPT(*)\r
                // CHARACTER TXT1(*)*72,TXT2(*)*72,CHTT*2,VAR*6,CHIA*2,REDD*6\r
 \r
@@ -2323,9 +2511,6 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                raFile.writeBytes(PAD + VAR + "[1] = ((ZDER[0] - ZRAD[1])* Math.sin(T[0]) + (ZRAD[0] + ZDER[1])* Math.cos(T[0]))*Math.exp(-T[1])*(" + HA + ");\n");\r
                                raFile.writeBytes("//\n");\r
                        } // else\r
-                       if (writeReturn) {\r
-                           raFile.writeBytes(PAD + "return " + VAR + ";\n");\r
-                       }\r
                } // try\r
                catch (IOException e) {\r
                        MipavUtil.displayError("IOException " + e + " in PTFUN2");\r
@@ -2368,16 +2553,16 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                        raFile.writeBytes("          DPARFNANS[0] = WW[IR-1][0]*ZETA[0] - WW[IR-1][1]*ZETA[1];\n");\r
                                        raFile.writeBytes("          DPARFNANS[1] = WW[IR-1][0]*ZETA[1] + WW[IR-1][1]*ZETA[0];\n");\r
                                        raFile.writeBytes("      }\n");\r
-                                       raFile.writeBytes("       else if ((IR == 0 && (IS > 0)) {\n");\r
-                                       raFile.writeBytes("           DPARFNANS[0] = -U2[0]*ZETA[0] -U2[1]*ZETA[1];\n");\r
-                                       raFile.writeBytes("           DPARFNANS[1] = U2[0]*ZETA[1] -U2[1]*ZETA[0];\n");\r
-                                       raFile.writeBytes("       }\n");\r
-                                       raFile.writeBytes("       else {\n");\r
-                                       raFile.writeBytes("           double realPart = -U2[0]*WW[IR-1][0] + U2[1]*WW[IR-1][1]);\n");\r
-                                       raFile.writeBytes("           double imagPart = -U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0]);\n");\r
-                                       raFile.writeBytes("           DPARFNANS[0] = realPart*ZETA[0] + imagPart*ZETA[1]);\n");\r
-                                       raFile.writeBytes("           DPARFNANS[1] = imagPart*ZETA[0] - realPart*ZETA[1]);\n");\r
-                                       raFile.writeBytes("       }\n");\r
+                                       raFile.writeBytes("      else if ((IR == 0) && (IS > 0)) {\n");\r
+                                       raFile.writeBytes("          DPARFNANS[0] = -U2[0]*ZETA[0] -U2[1]*ZETA[1];\n");\r
+                                       raFile.writeBytes("          DPARFNANS[1] = U2[0]*ZETA[1] -U2[1]*ZETA[0];\n");\r
+                                       raFile.writeBytes("      }\n");\r
+                                       raFile.writeBytes("      else {\n");\r
+                                       raFile.writeBytes("          double realPart = -U2[0]*WW[IR-1][0] + U2[1]*WW[IR-1][1];\n");\r
+                                       raFile.writeBytes("          double imagPart = -U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0];\n");\r
+                                       raFile.writeBytes("          DPARFNANS[0] = realPart*ZETA[0] + imagPart*ZETA[1];\n");\r
+                                       raFile.writeBytes("          DPARFNANS[1] = imagPart*ZETA[0] - realPart*ZETA[1];\n");\r
+                                       raFile.writeBytes("      }\n");\r
                                } // if (ORDRG > 1)\r
                                else {\r
                                        if (NARCS > 1) {\r
@@ -2389,10 +2574,10 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                        raFile.writeBytes("          DPARFNANS[0] = ZETA[0]\n");\r
                                        raFile.writeBytes("          DPARFNANS[0] = ZETA[0]\n");\r
                                        raFile.writeBytes("      }\n");\r
-                                       raFile.writeBytes("         else {\n");\r
-                                       raFile.writeBytes("             DPARFNANS[0] = -U2[0]*ZETA[0] + U2[1]*ZETA[1]);\n");\r
-                                       raFile.writeBytes("             DPARFNANS[1] = U2[0]*ZETA[1] - U2[1]*ZETA[0]);\n");\r
-                                       raFile.writeBytes("         }\n");\r
+                                       raFile.writeBytes("      else {\n");\r
+                                       raFile.writeBytes("          DPARFNANS[0] = -U2[0]*ZETA[0] + U2[1]*ZETA[1];\n");\r
+                                       raFile.writeBytes("          DPARFNANS[1] = U2[0]*ZETA[1] - U2[1]*ZETA[0];\n");\r
+                                       raFile.writeBytes("      }\n");\r
                                } // else\r
                        } // if (REFLN)\r
                        else {\r