Index: .vscode/launch.json
===================================================================
--- .vscode/launch.json	(revision 71c5f4dba5152d6c32ed27f1ae53af28d1931ab8)
+++ .vscode/launch.json	(revision 71c5f4dba5152d6c32ed27f1ae53af28d1931ab8)
@@ -0,0 +1,223 @@
+{
+    // Use IntelliSense to learn about possible attributes.
+    // Hover to view descriptions of existing attributes.
+    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "Python",
+            "type": "python",
+            "request": "launch",
+            "stopOnEntry": true,
+            "pythonPath": "${config:python.pythonPath}",
+            "program": "${file}",
+            "cwd": "${workspaceRoot}",
+            "env": {},
+            "envFile": "${workspaceRoot}/.env",
+            "debugOptions": [
+                "WaitOnAbnormalExit",
+                "WaitOnNormalExit",
+                "RedirectOutput"
+            ]
+        },
+        {
+            "name": "sascomp",
+            "type": "python",
+            "request": "launch",
+            "stopOnEntry": true,
+            "pythonPath": "${config:python.pythonPath}",
+            "program": "${workspaceRoot}/sascomp",
+            "cwd": "${workspaceRoot}",
+            "args": ["cylinder,_cylpy","-double!"],
+            "envFile": "${workspaceRoot}/.env",
+            "debugOptions": [
+                "WaitOnAbnormalExit",
+                "WaitOnNormalExit",
+                "RedirectOutput"
+            ]
+        },        {
+            "name": "Python: Attach",
+            "type": "python",
+            "request": "attach",
+            "localRoot": "${workspaceRoot}",
+            "remoteRoot": "${workspaceRoot}",
+            "port": 3000,
+            "secret": "my_secret",
+            "host": "localhost"
+        },
+        {
+            "name": "Python: Terminal (integrated)",
+            "type": "python",
+            "request": "launch",
+            "stopOnEntry": true,
+            "pythonPath": "${config:python.pythonPath}",
+            "program": "${file}",
+            "cwd": "",
+            "console": "integratedTerminal",
+            "env": {},
+            "envFile": "${workspaceRoot}/.env",
+            "debugOptions": [
+                "WaitOnAbnormalExit",
+                "WaitOnNormalExit"
+            ]
+        },
+        {
+            "name": "Python: Terminal (external)",
+            "type": "python",
+            "request": "launch",
+            "stopOnEntry": true,
+            "pythonPath": "${config:python.pythonPath}",
+            "program": "${file}",
+            "cwd": "",
+            "console": "externalTerminal",
+            "env": {},
+            "envFile": "${workspaceRoot}/.env",
+            "debugOptions": [
+                "WaitOnAbnormalExit",
+                "WaitOnNormalExit"
+            ]
+        },
+        {
+            "name": "Python: Django",
+            "type": "python",
+            "request": "launch",
+            "stopOnEntry": true,
+            "pythonPath": "${config:python.pythonPath}",
+            "program": "${workspaceRoot}/manage.py",
+            "cwd": "${workspaceRoot}",
+            "args": [
+                "runserver",
+                "--noreload",
+                "--nothreading"
+            ],
+            "env": {},
+            "envFile": "${workspaceRoot}/.env",
+            "debugOptions": [
+                "WaitOnAbnormalExit",
+                "WaitOnNormalExit",
+                "RedirectOutput",
+                "DjangoDebugging"
+            ]
+        },
+        {
+            "name": "Python: Flask (0.11.x or later)",
+            "type": "python",
+            "request": "launch",
+            "stopOnEntry": false,
+            "pythonPath": "${config:python.pythonPath}",
+            "program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter",
+            "cwd": "${workspaceRoot}",
+            "env": {
+                "FLASK_APP": "${workspaceRoot}/quickstart/app.py"
+            },
+            "args": [
+                "run",
+                "--no-debugger",
+                "--no-reload"
+            ],
+            "envFile": "${workspaceRoot}/.env",
+            "debugOptions": [
+                "WaitOnAbnormalExit",
+                "WaitOnNormalExit",
+                "RedirectOutput"
+            ]
+        },
+        {
+            "name": "Python: Flask (0.10.x or earlier)",
+            "type": "python",
+            "request": "launch",
+            "stopOnEntry": false,
+            "pythonPath": "${config:python.pythonPath}",
+            "program": "${workspaceRoot}/run.py",
+            "cwd": "${workspaceRoot}",
+            "args": [],
+            "env": {},
+            "envFile": "${workspaceRoot}/.env",
+            "debugOptions": [
+                "WaitOnAbnormalExit",
+                "WaitOnNormalExit",
+                "RedirectOutput"
+            ]
+        },
+        {
+            "name": "Python: PySpark",
+            "type": "python",
+            "request": "launch",
+            "stopOnEntry": true,
+            "osx": {
+                "pythonPath": "${env:SPARK_HOME}/bin/spark-submit"
+            },
+            "windows": {
+                "pythonPath": "${env:SPARK_HOME}/bin/spark-submit.cmd"
+            },
+            "linux": {
+                "pythonPath": "${env:SPARK_HOME}/bin/spark-submit"
+            },
+            "program": "${file}",
+            "cwd": "${workspaceRoot}",
+            "env": {},
+            "envFile": "${workspaceRoot}/.env",
+            "debugOptions": [
+                "WaitOnAbnormalExit",
+                "WaitOnNormalExit",
+                "RedirectOutput"
+            ]
+        },
+        {
+            "name": "Python: Module",
+            "type": "python",
+            "request": "launch",
+            "stopOnEntry": true,
+            "pythonPath": "${config:python.pythonPath}",
+            "module": "module.name",
+            "cwd": "${workspaceRoot}",
+            "env": {},
+            "envFile": "${workspaceRoot}/.env",
+            "debugOptions": [
+                "WaitOnAbnormalExit",
+                "WaitOnNormalExit",
+                "RedirectOutput"
+            ]
+        },
+        {
+            "name": "Python: Pyramid",
+            "type": "python",
+            "request": "launch",
+            "stopOnEntry": true,
+            "pythonPath": "${config:python.pythonPath}",
+            "cwd": "${workspaceRoot}",
+            "env": {},
+            "envFile": "${workspaceRoot}/.env",
+            "args": [
+                "${workspaceRoot}/development.ini"
+            ],
+            "debugOptions": [
+                "WaitOnAbnormalExit",
+                "WaitOnNormalExit",
+                "RedirectOutput",
+                "Pyramid"
+            ]
+        },
+        {
+            "name": "Python: Watson",
+            "type": "python",
+            "request": "launch",
+            "stopOnEntry": true,
+            "pythonPath": "${config:python.pythonPath}",
+            "program": "${workspaceRoot}/console.py",
+            "cwd": "${workspaceRoot}",
+            "args": [
+                "dev",
+                "runserver",
+                "--noreload=True"
+            ],
+            "env": {},
+            "envFile": "${workspaceRoot}/.env",
+            "debugOptions": [
+                "WaitOnAbnormalExit",
+                "WaitOnNormalExit",
+                "RedirectOutput"
+            ]
+        }
+    ]
+}
Index: run.txt
===================================================================
--- run.txt	(revision 71c5f4dba5152d6c32ed27f1ae53af28d1931ab8)
+++ run.txt	(revision 71c5f4dba5152d6c32ed27f1ae53af28d1931ab8)
@@ -0,0 +1,22 @@
+D:\Omer\Source\sasmodels\sasmodels\kernelcl.py:67: UserWarning: OpenCL startup failed with ***DLL load failed: The specified procedure could not be found.***; using C compiler instead
+  + str(exc) + "***; using C compiler instead")
+Traceback (most recent call last):
+  File "sascomp", line 24, in <module>
+    main()
+  File "sascomp", line 21, in main
+    sasmodels.compare.main(*sys.argv[1:])
+  File "D:\Omer\Source\sasmodels\sasmodels\compare.py", line 1486, in main
+    opts = parse_opts(argv)
+  File "D:\Omer\Source\sasmodels\sasmodels\compare.py", line 1177, in parse_opts
+    model_info = [core.load_model_info(k) for k in names]
+  File "D:\Omer\Source\sasmodels\sasmodels\compare.py", line 1177, in <listcomp>
+    model_info = [core.load_model_info(k) for k in names]
+  File "D:\Omer\Source\sasmodels\sasmodels\core.py", line 183, in load_model_info
+    return modelinfo.make_model_info(kernel_module)
+  File "D:\Omer\Source\sasmodels\sasmodels\modelinfo.py", line 821, in make_model_info
+    autoc.convert(info, kernel_module)
+  File "D:\Omer\Source\sasmodels\sasmodels\autoc.py", line 136, in convert
+    constants)
+  File "D:\Omer\Source\sasmodels\sasmodels\py2c.py", line 1027, in translate
+    print ("Size of functions is: " + len(functions))
+TypeError: must be str, not int
Index: run_c.bat
===================================================================
--- run_c.bat	(revision 71c5f4dba5152d6c32ed27f1ae53af28d1931ab8)
+++ run_c.bat	(revision 71c5f4dba5152d6c32ed27f1ae53af28d1931ab8)
@@ -0,0 +1,3 @@
+rm xlate.c
+python sascomp cylinder,_cylpy -double!
+gcc -c xlate.c 2> err.txt
Index: sasmodels/autoc.py
===================================================================
--- sasmodels/autoc.py	(revision 7a40b085628f7be3e20baa601368383796076155)
+++ sasmodels/autoc.py	(revision 71c5f4dba5152d6c32ed27f1ae53af28d1931ab8)
@@ -10,5 +10,5 @@
 import numpy as np
 
-from . import codegen
+from . import py2c
 from . import special
 
@@ -129,5 +129,5 @@
 
     # translate source
-    functions = codegen.translate(
+    functions = py2c.translate(
         [code[name] for name in ordered_dag(depends) if name in code],
         constants)
@@ -136,5 +136,5 @@
     print("\n".join(snippets))
     #return
-    raise RuntimeError("not yet converted...")
+#    raise RuntimeError("not yet converted...")
 
     # update model info
Index: sasmodels/py2c.py
===================================================================
--- sasmodels/py2c.py	(revision 3f9db6ed1e057839dbf05e4bed09ac980021463c)
+++ sasmodels/py2c.py	(revision 71c5f4dba5152d6c32ed27f1ae53af28d1931ab8)
@@ -48,4 +48,5 @@
 import ast
 import sys
+import os
 from ast import NodeVisitor
 
@@ -88,5 +89,5 @@
 
 #def to_source(node, indent_with=' ' * 4, add_line_information=False):
-def to_source(node, func_name):
+def to_source(node, func_name, global_vectors):
     """This function can convert a node tree back into python sourcecode.
     This is useful for debugging purposes, especially if you're dealing with
@@ -105,11 +106,53 @@
     of the nodes are added to the output.  This can be used to spot wrong line
     number information of statement nodes.
+
+    global_vectors arguments is a list of strings, holding the names of global
+    variables already declared as arrays
     """
+#    print(str(node))
+#    return
     generator = SourceGenerator(' ' * 4, False)
-    generator.required_functions = func_name
+    generator.global_vectors = global_vectors
+#    generator.required_functions = func_name
     generator.visit(node)
 
 #    return ''.join(generator.result)
     return ''.join(generator.c_proc)
+
+EXTREN_DOUBLE = "extern double "
+
+def get_c_array_value(val):
+    val_str = str(val).strip()
+    val_str = val_str.replace('[','')
+    val_str = val_str.replace(']','')
+    val_str = val_str.strip()
+    double_blank = "  " in val_str
+    while (double_blank):
+        val_str = val_str.replace('  ',' ')
+        double_blank = "  " in val_str
+    val_str = val_str.replace(' ',',')
+    return (val_str)
+
+def write_include_const (snippets, constants):
+    c_globals=[]
+    snippets.append("#include <math.h>\n")
+    const_names = constants.keys()
+    for name in const_names:
+        c_globals.append(name)
+        val = constants[name]
+        var_dcl = "double "# + " = "
+        if (hasattr(val, "__len__")): # the value is an array
+            val_str = get_c_array_value(val)
+            var_dcl += str(name) + "[] = {" + str(val_str) + "}"
+        else:
+            var_dcl += str(name) + " = " + str(val)
+        var_dcl += ";\n"
+        snippets.append(var_dcl)
+            
+    return (c_globals)
+#    for c_var in constants:
+#        sTmp = EXTREN_DOUBLE + str(c_var) + ";"
+#        c_externs.append (EXTREN_DOUBLE + c_var + ";")
+#    snippets.append (c_externs)
 
 def isevaluable(s):
@@ -154,4 +197,5 @@
         self.is_sequence = False
         self.visited_args = False
+        self.global_vectors = []
 
     def write_python(self, x):
@@ -342,4 +386,21 @@
         return (s)
 
+    def write_C_Pointers (self, start_var):
+        if (len (self.C_DclPointers) > 0):
+            vars = ""
+            for c_ptr in self.C_DclPointers:
+                if (len(vars) > 0):
+                    vars += ", "
+                if (c_ptr not in self.arguments):
+                    vars += "*" + c_ptr
+                if (c_ptr in self.C_Vars):
+                    if (c_ptr in self.C_Vars):
+                        self.C_Vars.remove (c_ptr)
+            if (len(vars) > 0):
+                c_dcl = "    double " + vars + ";"
+                self.c_proc.insert (start_var, c_dcl + "\n")
+                start_var += 1
+        return start_var
+
     def insert_C_Vars (self, start_var):
         fLine = False
@@ -372,18 +433,9 @@
                 self.c_proc.insert (start_var, c_dcl + "\n")
                 start_var += 1
-        if (len (self.C_DclPointers) > 0):
-            vars = ''
-            for n in range(len(self.C_DclPointers)):
-                if (len(vars) > 0):
-                    vars += ', '
-                vars += "*" + self.C_DclPointers[n]
-            if (len(vars) > 0):
-                c_dcl = "    double " + vars + ";"
-                self.c_proc.insert (start_var, c_dcl + "\n")
-                start_var += 1
         self.C_Vars.clear()
         self.C_IntVars.clear()
         self.C_Vectors.clear()
         self.C_Pointers.clear()
+        self.C_DclPointers.clear()
         if (fLine == True):
             self.c_proc.insert (start_var, "\n")
@@ -398,9 +450,9 @@
             self.c_proc.insert (start_var + 1, "\n")
 
-    def writeInclude (self):
-        if (self.MathIncludeed == False):
-            self.add_c_line("#include <math.h>\n")
-            self.add_c_line("static double pi = 3.14159265359;\n")
-            self.MathIncludeed = True
+#    def writeInclude (self):
+#        if (self.MathIncludeed == False):
+#            self.add_c_line("#include <math.h>\n")
+#            self.add_c_line("static double pi = 3.14159265359;\n")
+#            self.MathIncludeed = True
 
     def ListToString (self, strings):
@@ -431,5 +483,5 @@
                 args_str += ", "
         self.strMethodSignature = 'double ' + self.name + ' (' + args_str + ")"
-        if (self.signature_line > 0):
+        if (self.signature_line >= 0):
             self.c_proc.insert (self.signature_line, self.strMethodSignature)
 
@@ -440,6 +492,6 @@
         self.arguments = []
         self.name = node.name
-        if self.name not in self.required_functions[0]:
-            return
+#        if self.name not in self.required_functions[0]:
+#            return
         print("Parsing '" + self.name + "'")
         args_str = ""
@@ -447,5 +499,5 @@
         self.visit(node.args)
 # for C
-        self.writeInclude()
+#        self.writeInclude()
         self.getMethodSignature ()
 # for C
@@ -547,4 +599,5 @@
                     self.body_or_else(node)
                     self.write_c ("}")
+                    self.add_current_line () # just for breaking point. to be deleted. 
                     fForDone = True
         if (fForDone == False):
@@ -731,9 +784,10 @@
             name = node.id
 #       add variable to C_Vars if it ins't there yet, not an argument and not a number
-        if ((name not in self.C_Functions) and (name not in self.C_Vars) and (name not in self.C_IntVars) and (name not in self.arguments) and (name.isnumeric () == False)):
-            if (self.InSubscript):
-                self.C_IntVars.append (node.id)
-            else:
-                self.C_Vars.append (node.id)
+        if (name not in self.global_vectors):
+            if ((name not in self.C_Functions) and (name not in self.C_Vars) and (name not in self.C_IntVars) and (name not in self.arguments) and (name.isnumeric () == False)):
+                if (self.InSubscript):
+                    self.C_IntVars.append (node.id)
+                else:
+                    self.C_Vars.append (node.id)
 
     def visit_Str(self, node):
@@ -1023,5 +1077,36 @@
         print(tree_source)
 
-def translate (functions, constants=0):
+
+def write_consts (constants):
+    f = False
+    if (constants is not None):
+        f = True
+
+def translate(functions, constants):
+    # type: (List[Tuple[str, str, int]], Dict[str, Any]) -> str
+#    print ("Size of functions is: " + str(len(functions)))
+    if (os.path.exists ("xlate.c")):
+        os.remove("xlate.c")
+    snippets = []
+    global_vectors = write_include_const (snippets, constants)
+    const_keys = constants.keys ()
+    for source, filename, offset in functions:
+        tree = ast.parse(source)
+        snippet = to_source(tree, filename, global_vectors)#, offset)
+        snippets.append(snippet)
+    if (constants is not None):
+        write_consts (constants)
+    c_text = "\n".join(snippets)
+    try:
+        translated = open ("xlate.c", "a+")
+        translated.write (c_text)
+        translated.close()
+    except Exception as excp:
+        strErr = "Error:\n" + str(excp.args)
+        print(strErr)
+    return (c_text)
+
+def translate_from_file (functions, constants=0):
+    print ("Size of functions is: " + len(functions))
     sniplets = []
     fname = functions[1]
Index: vcvarsall.bat
===================================================================
--- vcvarsall.bat	(revision 71c5f4dba5152d6c32ed27f1ae53af28d1931ab8)
+++ vcvarsall.bat	(revision 71c5f4dba5152d6c32ed27f1ae53af28d1931ab8)
@@ -0,0 +1,57 @@
+@echo off
+
+if "%1" == "" goto x86
+if not "%2" == "" goto usage
+
+if /i %1 == x86       goto x86
+if /i %1 == amd64     goto amd64
+if /i %1 == x64       goto amd64
+if /i %1 == x86_amd64 goto x86_amd64
+goto usage
+
+:x86
+echo Setting environment for using Microsoft Visual Studio 2008 x86 tools.
+set VCINSTALLDIR=%~dp0VC\
+set WindowsSdkDir=%~dp0WinSDK\
+if not exist "%VCINSTALLDIR%bin\cl.exe" goto missing
+set PATH=%VCINSTALLDIR%Bin;%WindowsSdkDir%Bin;%PATH%
+set INCLUDE=%VCINSTALLDIR%Include;%WindowsSdkDir%Include;%INCLUDE%
+set LIB=%VCINSTALLDIR%Lib;%WindowsSdkDir%Lib;%LIB%
+set LIBPATH=%VCINSTALLDIR%Lib;%WindowsSdkDir%Lib;%LIBPATH%
+goto :eof
+
+:amd64
+echo Setting environment for using Microsoft Visual Studio 2008 x64 tools.
+set VCINSTALLDIR=%~dp0VC\
+set WindowsSdkDir=%~dp0WinSDK\
+if not exist "%VCINSTALLDIR%Bin\amd64\cl.exe" goto missing
+set PATH=%VCINSTALLDIR%Bin\amd64;%WindowsSdkDir%Bin\x64;%WindowsSdkDir%Bin;%PATH%
+set INCLUDE=%VCINSTALLDIR%Include;%WindowsSdkDir%Include;%INCLUDE%
+set LIB=%VCINSTALLDIR%Lib\amd64;%WindowsSdkDir%Lib\x64;%LIB%
+set LIBPATH=%VCINSTALLDIR%Lib\amd64;%WindowsSdkDir%Lib\x64;%LIBPATH%
+goto :eof
+
+:x86_amd64
+echo Setting environment for using Microsoft Visual Studio 2008 x64 cross tools.
+set VCINSTALLDIR=%~dp0VC\
+set WindowsSdkDir=%~dp0WinSDK\
+if not exist "%VCINSTALLDIR%Bin\x86_amd64\cl.exe" goto missing
+set PATH=%VCINSTALLDIR%Bin\x86_amd64;%WindowsSdkDir%Bin;%PATH%
+set INCLUDE=%VCINSTALLDIR%Include;%WindowsSdkDir%Include;%INCLUDE%
+set LIB=%VCINSTALLDIR%Lib\amd64;%WindowsSdkDir%Lib\x64;%LIB%
+set LIBPATH=%VCINSTALLDIR%Lib\amd64;%WindowsSdkDir%Lib\x64;%LIBPATH%
+goto :eof
+
+:usage
+echo Error in script usage. The correct usage is:
+echo     %0 [option]
+echo where [option] is: x86 ^| amd64 ^| x86_amd64
+echo:
+echo For example:
+echo     %0 x86_ia64
+goto :eof
+
+:missing
+echo The specified configuration type is missing.  The tools for the
+echo configuration might not be installed.
+goto :eof
Index: xlate.c
===================================================================
--- xlate.c	(revision 71c5f4dba5152d6c32ed27f1ae53af28d1931ab8)
+++ xlate.c	(revision 71c5f4dba5152d6c32ed27f1ae53af28d1931ab8)
@@ -0,0 +1,84 @@
+#include <math.h>
+
+double pi = 3.141592653589793;
+
+double GAUSS_N = 76;
+
+double GAUSS_Z[] = {-0.99950595,-0.99739779,-0.99360877,-0.98814445,-0.98101394,-0.97222923
+,-0.96180513,-0.94975921,-0.93611178,-0.92088586,-0.90410712,-0.88580385
+,-0.86600691,-0.84474969,-0.82206804,-0.79800019,-0.77258673,-0.74587051
+,-0.71789659,-0.68871214,-0.65836635,-0.62691042,-0.59439737,-0.56088203
+,-0.52642092,-0.49107214,-0.45489531,-0.41795142,-0.38030277,-0.34201284
+,-0.3031462,-0.26376839,-0.2239458,-0.18374559,-0.14323555,-0.10248398
+,-0.06155959,-0.0205314,0.0205314,0.06155959,0.10248398,0.14323555
+,0.18374559,0.2239458,0.26376839,0.3031462,0.34201284,0.38030277
+,0.41795142,0.45489531,0.49107214,0.52642092,0.56088203,0.59439737
+,0.62691042,0.65836635,0.68871214,0.71789659,0.74587051,0.77258673
+,0.79800019,0.82206804,0.84474969,0.86600691,0.88580385,0.90410712
+,0.92088586,0.93611178,0.94975921,0.96180513,0.97222923,0.98101394
+,0.98814445,0.99360877,0.99739779,0.99950595};
+
+double GAUSS_W[] = {0.00126779,0.0029491,0.00462794,0.00629918,0.00795985,0.00960711
+,0.01123817,0.01285028,0.01444073,0.01600683,0.01754594,0.01905546
+,0.02053285,0.02197561,0.02338133,0.02474761,0.02607216,0.02735276
+,0.02858722,0.02977349,0.03090955,0.03199348,0.03302347,0.03399778
+,0.03491476,0.03577286,0.03657064,0.03730676,0.03797996,0.03858913
+,0.03913322,0.03961133,0.04002265,0.04036647,0.04064223,0.04084946
+,0.04098781,0.04105704,0.04105704,0.04098781,0.04084946,0.04064223
+,0.04036647,0.04002265,0.03961133,0.03913322,0.03858913,0.03797996
+,0.03730676,0.03657064,0.03577286,0.03491476,0.03399778,0.03302347
+,0.03199348,0.03090955,0.02977349,0.02858722,0.02735276,0.02607216
+,0.02474761,0.02338133,0.02197561,0.02053285,0.01905546,0.01754594
+,0.01600683,0.01444073,0.01285028,0.01123817,0.00960711,0.00795985
+,0.00629918,0.00462794,0.0029491,0.00126779};
+
+double fq (double qab, double qc, double radius, double length)
+{
+    return (sas_2J1x_x(qab * radius) * sas_sinx_x(qc * 0.5 * length));
+}
+
+
+double form_volume (double radius, double length)
+{
+    return (pi * square (radius)  * length);
+}
+
+
+double orient_avg_1D (double q, double radius, double length)
+{
+    double zm,zb,total,theta,sin_theta,cos_theta,form;
+    int n,i;
+    double *GAUSS_Z, *GAUSS_W;
+
+    zm = pi / 4;
+    zb = pi / 4;
+    total = 0.0;
+    for (n=0 ; n < len(GAUSS_N) ; n++) {
+        theta = GAUSS_Z[i] * zm + zb;
+        sin_theta = sin(theta);
+        cos_theta = cos(theta);
+        form = fq(q * sin_theta, q * cos_theta, radius, length);
+        total += GAUSS_W[i] * form * form * sin_theta;
+    }
+    return (total * zm);
+}
+
+
+double Iqxy (double qab, double qc, double sld, double solvent_sld, double radius, double length)
+{
+    double s,form;
+
+    s = sld - solvent_sld * form_volume(radius, length);
+    form = fq(qab, qc, radius, length);
+    return (0.0001 * square(s * form));
+}
+
+
+double Iq (double q, double sld, double solvent_sld, double radius, double length)
+{
+    double s;
+
+    s = sld - solvent_sld * form_volume(radius, length);
+    return (0.0001 * s * s * orient_avg_1D(q, radius, length));
+}
+
