Use float32 to reduce memory footprint.
[master-thesis.git] / Parasitemia / Parasitemia / EEOver.fs
index 528632a..5a3c9e4 100644 (file)
@@ -514,9 +514,9 @@ let private biquadroots (p: float[]) (r: float[,]) =
     quad ()
 
 // Return a tuple (area, x intersections, y intersections)
-let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : (float * float[] * float[]) option =
-    let h1, k1, a1, b1, phi_1 = e1.Cx, e1.Cy, e1.A, e1.B, e1.Alpha
-    let h2, k2, a2, b2, phi_2 = e2.Cx, e2.Cy, e2.A, e2.B, e2.Alpha
+let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : (float32 * float32[] * float32[]) option =
+    let h1, k1, a1, b1, phi_1 = float e1.Cx, float e1.Cy, float e1.A, float e1.B, float e1.Alpha
+    let h2, k2, a2, b2, phi_2 = float e2.Cx, float e2.Cy, float e2.A, float e2.B, float e2.Alpha
 
     if a1 <= EPS || b1 <= EPS || a2 <= EPS || b2 <= EPS
     then
@@ -718,11 +718,11 @@ let EEOverlapArea (e1: Types.Ellipse) (e2: Types.Ellipse) : (float * float[] * f
                 | 4 -> fourintpts xint yint a1 b1 phi_1 a2 b2 h2_tr k2_tr phi_2 aa bb cc dd ee ff
                 | _ -> -1.0
             if nintpts = 0
-            then Some (area, [||], [||])
+            then Some (float32 area, [||], [||])
             else
-                let xTransform = Array.zeroCreate nintpts
-                let yTransform = Array.zeroCreate nintpts
+                let xTransform : float32[] = Array.zeroCreate nintpts
+                let yTransform : float32[] = Array.zeroCreate nintpts
                 for i in 0 .. (nintpts - 1) do
-                    xTransform.[i] <- cos phi_1 * xint.[i] - sin phi_1 * yint.[i] + h1
-                    yTransform.[i] <- sin phi_1 * xint.[i] + cos phi_1 * yint.[i] + k1
-                Some (area, xTransform, yTransform)
\ No newline at end of file
+                    xTransform.[i] <- float32 <| cos phi_1 * xint.[i] - sin phi_1 * yint.[i] + h1
+                    yTransform.[i] <- float32 <| sin phi_1 * xint.[i] + cos phi_1 * yint.[i] + k1
+                Some (float32 area, xTransform, yTransform)
\ No newline at end of file