Debugging PARGEN and supporting routines.
authorilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Fri, 2 Feb 2018 23:10:18 +0000 (23:10 +0000)
committerilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Fri, 2 Feb 2018 23:10:18 +0000 (23:10 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15357 ba61647d-9d00-f842-95cd-605cb4296b96

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

index 2cb707f..3e2b29b 100644 (file)
@@ -720,7 +720,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                                        DEFN[TXCO - 1] = TABC;\r
                                                        NUMDER[IA - 1] = true;\r
                                                } else {\r
-                                                       DEFN[TXCO - 1] = TABC + TXT.substring(0, L);\r
+                                                       DEFN[TXCO - 1] = TXT.substring(0, L);\r
                                                }\r
                                                if ((J == 1) && (TYPE == 4)) {\r
                                                        System.out.println("(... = ZRAD)");\r
@@ -837,15 +837,22 @@ public class SymmsIntegralMapping extends AlgorithmBase {
 \r
                String TAB6 = "      ";\r
 \r
-               String LINE = TAB6 + "private void " + TXT + "(int IA, double TT[]) {\n";\r
+               String LINE = TAB6 + "private double[] " + TXT + "(int IA, double TT[]) {\n";\r
                try {\r
                        raFile.writeBytes(LINE);\r
 \r
-                       LINE = "//" + TAB6 + "IMPLICIT REAL(A-H,O-S),INTEGER(I-N),COMPLEX(T-Z)\n";\r
-                       raFile.writeBytes(LINE);\r
+               LINE = TAB6 + "double " + TXT + "ANS[] = new double[2];\n";\r
+               raFile.writeBytes(LINE);\r
+               LINE = TAB6 + " double ZRAD[] = new double[2];\n";\r
+               raFile.writeBytes(LINE);\r
+               LINE = TAB6 + "int IA;\n";\r
+               raFile.writeBytes(LINE);\r
+               LINE = TAB6 + "double T[] = new double[2];\n";\r
+               raFile.writeBytes(LINE);\r
+               LINE = TAB6 + "double TT[] = new double[2];\n";\r
+               raFile.writeBytes(LINE);\r
 \r
                        raFile.writeBytes("      double PI = " + Math.PI + ";\n");\r
-                       raFile.writeBytes("      double UI[] = new double[]{0.0,1.0};\n");\r
                        raFile.writeBytes("//\n");\r
                } catch (IOException e) {\r
                        MipavUtil.displayError("IOException " + e + " in HEADER");\r
@@ -1440,9 +1447,9 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                C2[1] = 0.5 * (STAPT[1][1] - STAPT[0][1]);\r
                                raFile.writeBytes("//\n");\r
                                raFile.writeBytes(\r
-                                               VAR + "[0] = " + C1[0] + "+" + CHTT + "[0]*" + C2[0] + " - " + CHTT + "[1]*" + C2[1] + ";\n");\r
+                                               VAR + "ANS[0] = " + C1[0] + "+" + CHTT + "[0]*(" + C2[0] + ") - " + CHTT + "[1]*(" + C2[1] + ");\n");\r
                                raFile.writeBytes(\r
-                                               VAR + "[1] = " + C1[1] + "+" + CHTT + "[0]*" + C2[1] + " + " + CHTT + "[1]*" + C2[0] + ";\n");\r
+                                               VAR + "ANS[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
@@ -1454,20 +1461,20 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                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(VAR + "ANS[0] = " + CENTR[0] + "+" + RAD + " * " + "Math.exp(-" + CHTT + "[1]*(" + HA\r
+                                               + "))*" + "Math.cos(" + MD + "+" + CHTT + "[0]*(" + HA + "));\n");\r
+                               raFile.writeBytes(VAR + "ANS[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
+                               raFile.writeBytes("T[0] = " + MD + "+" + CHTT + "[0] * (" + HA + ");\n");\r
+                               raFile.writeBytes("T[1] = " + CHTT + "[1] * (" + HA + ");\n");\r
 \r
-                               raFile.writeBytes(VAR + "[0] = ");\r
+                               raFile.writeBytes(VAR + "ANS[0] = ");\r
                                // NTX = 1 if statements are entered without newlines for\r
                                // multiple lines\r
                                for (I = 1; I <= NTX; I++) {\r
@@ -1485,7 +1492,7 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                                raFile.writeBytes(";\n");\r
                                        }\r
                                }\r
-                               raFile.writeBytes(VAR + "[1] = ");\r
+                               raFile.writeBytes(VAR + "ANS[1] = ");\r
                                // NTX = 1 if statements are entered without newlines for\r
                                // multiple lines\r
                                for (I = 1; I <= NTX; I++) {\r
@@ -1505,18 +1512,19 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                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
-                               raFile.writeBytes("     ZRAD = ");\r
+                               raFile.writeBytes("T[0] = " + MD + "+" + CHTT + "[0] * (" + HA + ");\n");\r
+                               raFile.writeBytes("T[1] = " + CHTT + "[1] * (" + HA + ");\n");\r
+                               raFile.writeBytes("ZRAD = ");\r
                                // NTX = 1 if statements are entered without newlines for\r
                                // multiple lines\r
                                for (I = 1; I <= NTX; I++) {\r
                                        raFile.writeBytes(TXT[I - 1]);\r
                                }\r
-                               raFile.writeBytes(VAR + "[0] = Math.exp(-T[1])*(ZRAD * Math.cos(T[0]));\n");\r
-                               raFile.writeBytes(VAR + "[1] = Math.exp(-T[1])*(ZRAD * Math.sin(T[0]));\n");\r
+                               raFile.writeBytes(VAR + "ANS[0] = ZRAD[0]*Math.exp(-T[1])*Math.cos(T[0]) - ZRAD[1]*Math.exp(-T[1])*Math.sin(T[0]);\n");\r
+                               raFile.writeBytes(VAR + "ANS[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
+                       raFile.writeBytes("return " + VAR + "ANS;\n");\r
                } // try\r
                catch (IOException e) {\r
                        MipavUtil.displayError("IOException " + e + " in PTFUN1");\r
@@ -1794,8 +1802,8 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                raFile.writeBytes("//\n");\r
                                R = C1[0];\r
                                A = C1[1];\r
-                               raFile.writeBytes("      " + VAR + "[0] = " + R + ";\n");\r
-                               raFile.writeBytes("      " + VAR + "[1] = " + A + ";\n");\r
+                               raFile.writeBytes("      " + VAR + "ANS[0] = " + R + ";\n");\r
+                               raFile.writeBytes("      " + VAR + "ANS[1] = " + A + ";\n");\r
                                raFile.writeBytes("//\n");\r
                        } // if (TYPE == 1)\r
                        else if (TYPE == 2) {\r
@@ -1808,13 +1816,13 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                RAD = zabs(C1[0], C1[1]);\r
                                raFile.writeBytes("//\n");\r
                                raFile.writeBytes(\r
-                                               VAR + "[0] = -" + RAD + "*" + HA + "*Math.sin(" + MD + "+" + CHTT + "*" + HA + ");\n");\r
-                               raFile.writeBytes(VAR + "[1] = " + RAD + "*" + HA + "*Math.cos(" + MD + "+" + CHTT + "*" + HA + ");\n");\r
+                                               VAR + "ANS[0] = (-" + RAD + ")*(" + HA + ")*Math.exp((-"+CHTT + "[1])*(" + HA +"))*Math.sin(" + MD + "+(" + CHTT + "[0])*(" + HA + "));\n");\r
+                               raFile.writeBytes(VAR + "ANS[1] = (" + RAD + ")*(" + HA + ")*Math.exp((-"+CHTT + "[1])*Math.cos(" + MD + "+" + CHTT + "[0])*(" + HA + "));\n");\r
                                raFile.writeBytes("//\n");\r
                        } // else if (TYPE == 2)\r
                        else if (NUMDER) {\r
                                raFile.writeBytes("//\n");\r
-                               raFile.writeBytes("      " + VAR + " = ZDPARF(" + CHIA + "," + CHTT + ");\n");\r
+                               raFile.writeBytes("      " + VAR + "ANS = ZDPARF(" + CHIA + "," + CHTT + ");\n");\r
                                raFile.writeBytes("//\n");\r
                        } // else if (NUMDER)\r
                        else if (TYPE == 3) {\r
@@ -1822,11 +1830,38 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                HA = 0.5 * (RGM[1] - RGM[0]);\r
                                raFile.writeBytes("//\n");\r
                                raFile.writeBytes("      T = " + MD + "+" + CHTT + "*" + "(" + HA + ");\n");\r
-                               raFile.writeBytes("      " + VAR + " = " + HA + "*(");\r
+                               raFile.writeBytes("      " + VAR + "ANS[0] = " + HA + "*(");\r
+                               // NTX2 = 1 if statements are entered without newlines for\r
+                               // multiple lines\r
                                for (I = 1; I <= NTX2; I++) {\r
-                                       raFile.writeBytes(TXT2[I - 1]);\r
+                                       int index = TXT2[I - 1].indexOf("ui");\r
+                                       String realString = null;\r
+                                       if (index == -1) {\r
+                                               realString = TXT2[I - 1];\r
+                                       } else {\r
+                                               realString = TXT2[I - 1].substring(0, index);\r
+                                       }\r
+                                       if ((index == -1) || (index > 0)) {\r
+                                               raFile.writeBytes(realString);\r
+                                       }\r
+                                       if (I == NTX2) {\r
+                                               raFile.writeBytes(");\n");\r
+                                       }\r
+                               }\r
+                               raFile.writeBytes("      " + VAR + "ANS[1] = " + HA + "*(");\r
+                               // NTX2 = 1 if statements are entered without newlines for\r
+                               // multiple lines\r
+                               for (I = 1; I <= NTX2; I++) {\r
+                                       int index = TXT2[I - 1].indexOf("ui");\r
+                                       String imagString = null;\r
+                                       if ((index >= 0) && (index + 2 < TXT2[I - 1].length())) {\r
+                                               imagString = TXT2[I - 1].substring(index + 2);\r
+                                               raFile.writeBytes(imagString);\r
+                                       }\r
+                                       if (I == NTX2) {\r
+                                               raFile.writeBytes(");\n");\r
+                                       }\r
                                }\r
-                               raFile.writeBytes(");\n");\r
                                raFile.writeBytes("//\n");\r
                        } // else if (TYPE == 3)\r
                        else {\r
@@ -1844,10 +1879,11 @@ public class SymmsIntegralMapping extends AlgorithmBase {
                                        raFile.writeBytes(TXT2[I - 1]);\r
                                }\r
                                raFile.writeBytes(";\n");\r
-                               raFile.writeBytes("      " + VAR + "[0] = (ZDER * Math.cos(T) - ZRAD * Math.sin(T))*(" + HA + ");\n");\r
-                               raFile.writeBytes("      " + VAR + "[1] = (ZDER * Math.sin(T) + ZRAD * Math.cos(T))*(" + HA + ");\n");\r
+                               raFile.writeBytes("      " + VAR + "ANS[0] = (ZDER * Math.cos(T) - ZRAD * Math.sin(T))*(" + HA + ");\n");\r
+                               raFile.writeBytes("      " + VAR + "ANS[1] = (ZDER * Math.sin(T) + ZRAD * Math.cos(T))*(" + HA + ");\n");\r
                                raFile.writeBytes("//\n");\r
                        } // else\r
+                       raFile.writeBytes("return " + VAR + "ANS;\n");\r
                } // try\r
                catch (IOException e) {\r
                        MipavUtil.displayError("IOException " + e + " in PTFUN2");\r
@@ -15586,5 +15622,20 @@ public class SymmsIntegralMapping extends AlgorithmBase {
 \r
                return;\r
        }\r
+       \r
+       private double[] cos(double t[]) {\r
+               double result[] = new double[2];\r
+               result[0] = Math.cos(t[0])*Math.cosh(t[1]);\r
+               result[1] = -Math.sin(t[0])*Math.sinh(t[1]);\r
+               return result;\r
+       }\r
+       \r
+       private double[] sin(double t[]) {\r
+               double result[] = new double[2];\r
+               result[0] = Math.sin(t[0])*Math.cosh(t[1]);\r
+               result[1] = Math.cos(t[0])*Math.sinh(t[1]);\r
+               return result;\r
+       }\r
+                       \r
 \r
 }
\ No newline at end of file