Index: pr_inversion/test/test_output.txt
===================================================================
--- pr_inversion/test/test_output.txt	(revision 75789610284735400155f1efbde9ac7a3fb8ab61)
+++ pr_inversion/test/test_output.txt	(revision f1e0c1ebe7c5c6df65f842c5980bbe596943193a)
@@ -3,5 +3,5 @@
 #alpha=0.0007
 #chi2=836.797
-#elapsed=0
+#elapsed=0.000865936
 #qmin=None
 #qmax=None
@@ -10,5 +10,5 @@
 #background=0
 #has_bck=0
-#alpha_estimate=4.58991e-006
+#alpha_estimate=4.58991e-06
 #C_0=217.876478953+-2522.42314999
 #C_1=0.30164617344+-226.644556603
Index: sansdataloader/test/write_test.xml
===================================================================
--- sansdataloader/test/write_test.xml	(revision 62dc94b494b1f5a2daf3815a00c38371194ef8a1)
+++ sansdataloader/test/write_test.xml	(revision f1e0c1ebe7c5c6df65f842c5980bbe596943193a)
@@ -2,260 +2,118 @@
 <SASroot version="1.0" xmlns="cansas1d/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="cansas1d/1.0 http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd">
 	<SASentry>
-		<Title>
-			Test title
-		</Title>
-		<Run name="run name">
-			1234
-		</Run>
+		<Title>Test title</Title>
+		<Run name="run name">1234</Run>
 		<SASdata>
 			<Idata>
-				<Q unit="1/A">
-					0.02
-				</Q>
-				<I unit="1/cm">
-					1000.0
-				</I>
-				<Qdev unit="1/A">
-					0.01
-				</Qdev>
-				<dQl unit="1/A">
-					0.0
-				</dQl>
-				<dQw unit="1/A">
-					0.0
-				</dQw>
-				<Idev unit="1/cm">
-					3.0
-				</Idev>
+				<Q unit="1/A">0.02</Q>
+				<I unit="1/cm">1000.0</I>
+				<Qdev unit="1/A">0.01</Qdev>
+				<dQl unit="1/A">0.0</dQl>
+				<dQw unit="1/A">0.0</dQw>
+				<Idev unit="1/cm">3.0</Idev>
 			</Idata>
 			<Idata>
-				<Q unit="1/A">
-					0.03
-				</Q>
-				<I unit="1/cm">
-					1001.0
-				</I>
-				<Qdev unit="1/A">
-					0.02
-				</Qdev>
-				<dQl unit="1/A">
-					0.0
-				</dQl>
-				<dQw unit="1/A">
-					0.0
-				</dQw>
-				<Idev unit="1/cm">
-					4.0
-				</Idev>
+				<Q unit="1/A">0.03</Q>
+				<I unit="1/cm">1001.0</I>
+				<Qdev unit="1/A">0.02</Qdev>
+				<dQl unit="1/A">0.0</dQl>
+				<dQw unit="1/A">0.0</dQw>
+				<Idev unit="1/cm">4.0</Idev>
 			</Idata>
 		</SASdata>
 		<SASsample name="my sample">
-			<ID>
-				SI600-new-long
-			</ID>
-			<thickness unit="mm">
-				1.03
-			</thickness>
-			<transmission>
-				0.327
-			</transmission>
-			<temperature unit="C">
-				0.0
-			</temperature>
-			<details>
-				http://chemtools.chem.soton.ac.uk/projects/blog/blogs.php/bit_id/2720
-			</details>
-			<details>
-				Some text here
-			</details>
+			<ID>SI600-new-long</ID>
+			<thickness unit="mm">1.03</thickness>
+			<transmission>0.327</transmission>
+			<temperature unit="C">0.0</temperature>
+			<details>http://chemtools.chem.soton.ac.uk/projects/blog/blogs.php/bit_id/2720</details>
+			<details>Some text here</details>
 			<position>
-				<x unit="mm">
-					10.0
-				</x>
-				<y unit="mm">
-					0.0
-				</y>
+				<x unit="mm">10.0</x>
+				<y unit="mm">0.0</y>
 			</position>
 			<orientation>
-				<roll unit="degree">
-					22.5
-				</roll>
-				<pitch unit="degree">
-					0.02
-				</pitch>
+				<roll unit="degree">22.5</roll>
+				<pitch unit="degree">0.02</pitch>
 			</orientation>
 		</SASsample>
 		<SASinstrument>
-			<name>
-				canSAS instrument
-			</name>
+			<name>canSAS instrument</name>
 			<SASsource name="source name">
-				<radiation>
-					neutron
-				</radiation>
-				<beam_shape>
-					disc
-				</beam_shape>
+				<radiation>neutron</radiation>
+				<beam_shape>disc</beam_shape>
 				<beam_size name="bm">
-					<x unit="mm">
-						12.0
-					</x>
-					<y unit="mm">
-						13.0
-					</y>
+					<x unit="mm">12.0</x>
+					<y unit="mm">13.0</y>
 				</beam_size>
-				<wavelength unit="A">
-					6.0
-				</wavelength>
-				<wavelength_min unit="nm">
-					0.22
-				</wavelength_min>
-				<wavelength_max unit="nm">
-					1.0
-				</wavelength_max>
-				<wavelength_spread unit="percent">
-					14.3
-				</wavelength_spread>
+				<wavelength unit="A">6.0</wavelength>
+				<wavelength_min unit="nm">0.22</wavelength_min>
+				<wavelength_max unit="nm">1.0</wavelength_max>
+				<wavelength_spread unit="percent">14.3</wavelength_spread>
 			</SASsource>
 			<SAScollimation name="test coll name">
-				<length unit="mm">
-					123.0
-				</length>
+				<length unit="mm">123.0</length>
 				<aperture name="source" type="radius">
-					<distance unit="mm">
-						11000
-					</distance>
+					<distance unit="mm">11000</distance>
 					<size>
-						<x unit="mm">
-							50.0
-						</x>
+						<x unit="mm">50.0</x>
 					</size>
 				</aperture>
 				<aperture name="sample" type="radius">
 					<size name="size name">
-						<x unit="mm">
-							1.0
-						</x>
+						<x unit="mm">1.0</x>
 					</size>
 				</aperture>
 			</SAScollimation>
 			<SASdetector>
-				<name>
-					fictional hybrid
-				</name>
-				<SDD unit="mm">
-					4150
-				</SDD>
+				<name>fictional hybrid</name>
+				<SDD unit="mm">4150</SDD>
 				<offset>
-					<x unit="m">
-						0.001
-					</x>
-					<y unit="m">
-						0.002
-					</y>
+					<x unit="m">0.001</x>
+					<y unit="m">0.002</y>
 				</offset>
 				<beam_center>
-					<x unit="mm">
-						322.64
-					</x>
-					<y unit="mm">
-						327.68
-					</y>
+					<x unit="mm">322.64</x>
+					<y unit="mm">327.68</y>
 				</beam_center>
 				<pixel_size>
-					<x unit="mm">
-						5.0
-					</x>
-					<y unit="mm">
-						5.0
-					</y>
+					<x unit="mm">5.0</x>
+					<y unit="mm">5.0</y>
 				</pixel_size>
 				<orientation>
-					<roll unit="degree">
-						1.0
-					</roll>
-					<pitch unit="degree">
-						0.0
-					</pitch>
-					<yaw unit="degree">
-						0.0
-					</yaw>
+					<roll unit="degree">1.0</roll>
+					<pitch unit="degree">0.0</pitch>
+					<yaw unit="degree">0.0</yaw>
 				</orientation>
 			</SASdetector>
 		</SASinstrument>
 		<SASprocess>
-			<name>
-				spol
-			</name>
-			<date>
-				04-Sep-2007 18:35:02
-			</date>
-			<description>
-				
-			</description>
-			<term name="radialstep" unit="mm">
-				10.000
-			</term>
-			<term name="sector_width" unit="degree">
-				180.0
-			</term>
-			<term name="sector_orient" unit="degree">
-				0.0
-			</term>
-			<term name="MASK_file">
-				USER:MASK.COM
-			</term>
-			<SASprocessnote>
-				AvA1 0.0000E+00 AsA2 1.0000E+00 XvA3 1.0526E+03 XsA4
-				5.2200E-02 XfA5 0.0000E+00
-			</SASprocessnote>
-			<SASprocessnote>
-				S... 13597 0 2.26E+02 2A 5mM 0%D2O Sbak 13594 0 1.13E+02
-				H2O Buffer
-			</SASprocessnote>
-			<SASprocessnote>
-				V... 13552 3 1.00E+00 H2O5m
-			</SASprocessnote>
+			<name>spol</name>
+			<date>04-Sep-2007 18:35:02</date>
+			<description></description>
+			<term name="radialstep" unit="mm">10.000</term>
+			<term name="sector_width" unit="degree">180.0</term>
+			<term name="sector_orient" unit="degree">0.0</term>
+			<term name="MASK_file">USER:MASK.COM</term>
+			<SASprocessnote>AvA1 0.0000E+00 AsA2 1.0000E+00 XvA3 1.0526E+03 XsA4
+				5.2200E-02 XfA5 0.0000E+00</SASprocessnote>
+			<SASprocessnote>S... 13597 0 2.26E+02 2A 5mM 0%D2O Sbak 13594 0 1.13E+02
+				H2O Buffer</SASprocessnote>
+			<SASprocessnote>V... 13552 3 1.00E+00 H2O5m</SASprocessnote>
 		</SASprocess>
 		<SASprocess>
-			<name>
-				NCNR-IGOR
-			</name>
-			<date>
-				03-SEP-2006 11:42:47
-			</date>
-			<description>
-				
-			</description>
-			<term name="average_type">
-				Circular
-			</term>
-			<term name="SAM_file">
-				SEP06064.SA3_AJJ_L205
-			</term>
-			<term name="BKD_file">
-				SEP06064.SA3_AJJ_L205
-			</term>
-			<term name="EMP_file">
-				SEP06064.SA3_AJJ_L205
-			</term>
-			<term name="DIV_file">
-				SEP06064.SA3_AJJ_L205
-			</term>
-			<term name="MASK_file">
-				SEP06064.SA3_AJJ_L205
-			</term>
-			<term name="ABS:TSTAND">
-				1
-			</term>
-			<term name="ABS:DSTAND" unit="mm">
-				1
-			</term>
-			<term name="ABS:IZERO">
-				230.09
-			</term>
-			<term name="ABS:XSECT" unit="mm">
-				1
-			</term>
+			<name>NCNR-IGOR</name>
+			<date>03-SEP-2006 11:42:47</date>
+			<description></description>
+			<term name="average_type">Circular</term>
+			<term name="SAM_file">SEP06064.SA3_AJJ_L205</term>
+			<term name="BKD_file">SEP06064.SA3_AJJ_L205</term>
+			<term name="EMP_file">SEP06064.SA3_AJJ_L205</term>
+			<term name="DIV_file">SEP06064.SA3_AJJ_L205</term>
+			<term name="MASK_file">SEP06064.SA3_AJJ_L205</term>
+			<term name="ABS:TSTAND">1</term>
+			<term name="ABS:DSTAND" unit="mm">1</term>
+			<term name="ABS:IZERO">230.09</term>
+			<term name="ABS:XSECT" unit="mm">1</term>
 		</SASprocess>
 	</SASentry>
Index: sansmodels/src/c_models/starpolymer.cpp
===================================================================
--- sansmodels/src/c_models/starpolymer.cpp	(revision a8d3b4f00c3cb3fbfe0f00d3bd3465a4fc6f1842)
+++ sansmodels/src/c_models/starpolymer.cpp	(revision f1e0c1ebe7c5c6df65f842c5980bbe596943193a)
@@ -6,5 +6,4 @@
 
 **/
-
 
 #include <math.h>
@@ -29,10 +28,10 @@
 
   double u = d_R2 * pow(q,2);
-  double v = pow(u,2) * d_arms / (3 * d_arms - 2);
+  double v = pow(u,2.0) * d_arms / (3.0 * d_arms - 2.0);
 
-  double term1 = v - 1 + exp(-v);
-  double term2 = ((d_arms - 1)/2)* pow((1 - exp(-v)),2);
+  double term1 = v - 1.0 + exp(-v);
+  double term2 = ((d_arms - 1.0)/2.0)* pow((1.0 - exp(-v)),2.0);
 
-  return 2 * d_scale / (d_arms * pow(v,2)) * (term1 + term2) + d_background;
+  return 2.0 * d_scale / (d_arms * pow(v,2.0)) * (term1 + term2) + d_background;
 
 }
Index: sansmodels/test/utest_nonshape.py
===================================================================
--- sansmodels/test/utest_nonshape.py	(revision 18e250cb66e3283c50a57dddaf692b17263dd72c)
+++ sansmodels/test/utest_nonshape.py	(revision f1e0c1ebe7c5c6df65f842c5980bbe596943193a)
@@ -248,5 +248,6 @@
         value = self._func(self.scale, self.length, self.back, x)*self._func(self.scale, self.length, self.back, y)
         self.assertAlmostEquals(self.model.run([x, y]), value,1)
-        
+
+
 class TestPowerLaw(unittest.TestCase):
     """
@@ -521,2 +522,3 @@
 if __name__ == '__main__':
     unittest.main()
+
Index: sansmodels/test/utest_other_models.py
===================================================================
--- sansmodels/test/utest_other_models.py	(revision 279e37161048e12a618886d8865fcba5c0444dc2)
+++ sansmodels/test/utest_other_models.py	(revision f1e0c1ebe7c5c6df65f842c5980bbe596943193a)
@@ -1233,4 +1233,57 @@
         """ Test DABModel at the critical point"""
         self.assert_(numpy.isfinite(self.comp.run(0.0)))           
+
+class TestStarPolymer(unittest.TestCase):
+    """ Unit tests for StarPolymer"""
+    
+    def setUp(self):
+        from sans.models.StarPolymer import StarPolymer
+        self.comp = StarPolymer()
+        self.comp.setParam('arms',3.0)
+        self.comp.setParam('scale',5.0)
+        self.comp.setParam('background',1.0)
+        self.comp.setParam('R2',100.0)
+        
+        
+    def test1D(self):
+        """ Test 1D model for a StarPolymer"""
+        # our variables
+        q = 0.001
+        rg = 100.0
+        f = 3.0
+        bkg = 1.0
+        scale = 5.0
+
+        # equation set up
+        u = rg * q * q
+        v = u * u * f / (3*f - 2)
+        p = 2 / (f * v * v)
+        temp = v - 1 + math.exp(-v)
+        temp += (f - 1)/2 * math.pow(1 - math.exp(-v), 2)
+        p *= (temp * scale)
+        p += bkg
+        
+        self.assertAlmostEquals(self.comp.run(q), p, 5)
+        
+    def test1D_2(self):
+        """ Test 2D model for a StarPolymer"""
+        qx = 0.001
+        qy = 1.3
+        q = math.sqrt(qx*qx + qy*qy)
+        rg = 100.0
+        f = 3.0
+        bkg = 1.0
+        scale = 5.0
+
+        # equation set up
+        u = rg * q * q
+        v = u * u * f / (3*f - 2)
+        p = 2 / (f * v * v)
+        temp = v - 1 + math.exp(-v)
+        temp += (f - 1)/2 * math.pow(1 - math.exp(-v), 2)
+        p *= (temp * scale)
+        p += bkg
+
+        self.assertAlmostEqual(self.comp.runXY([0.001, 1.3]), p, 5)
              
     
