Point Test:

The file point_test.ml tests the code generation for the point module.

The POINT module type is defind in the the file src/point.ml. A model
implementation for n-dimensional point types is in functor 'En_Point'
in the file src/pointen.ml.

The following instantiation is an example for creating a point module
over the floating point number type with a 2-record representation
for its coordinate tuple:

module V2R = VectorStaged (Float_Real_Exact) (Record2D)
module P2R = En_Point (Float_Real_Exact) (V2R) (Record2D) 

The file point_test.ml, however, tests a variant of the POINT type, namely,
ISO_AXIS_ORDERED_POINT which is an ordered point type with axis-oriented
ordering. Code generation for the following functions are tested:

(* Substract two points a - b to get a vector *)
val sub : 'a point_s -> 'a point_s -> 'a V.vector_s
(* Test if point a < point b *)
val lt : 'a point_s -> 'a point_s -> 'a Bool.b
(* Compute min(a,b) of two points a and b *)
val min : 'a point_s -> 'a point_s -> 'a point_s  

It is instructive to describe one of the generators in details. Consider
the function Gen.sub in point_test.ml which has the following code:

let sub _ =
    .< fun a b -> .~(Staged.to_code
	     (P.sub (of_atom .< a >.) (of_atom .< b >. ))) >.

First, the output is a code for a function with two parameter, 'a' and 'b',
both of type P.point. Two atomic code expressions are constructed from 'a'
and 'b' and passed to P.sub. The resultant /vector/ expression is converted
to code before inling it.

The output file point_out.ml contains the outputs. We show here a snippet
for the generator cmp_x defined as:

(* Compare the x-coordinate of two points according to relator
   P.lt 0 a b which is equivalent to a <_x b *)
let cmp_x _ =
    .< fun a b -> .~(Staged.to_code
         (P.lt 0 (of_atom .< a >.) (of_atom .< b >.))) >.

The first instantiation is a 2D point type:

module V2R = VectorStaged (Float_Real_Exact) (Record2D)
module P2R = Iso_Axis_Ordered_En_Point (Float_Real_Exact) (V2R) (Record2D) 
module GP2R = Gen (P2R)
GP2R.cmp_x ()
which produces the code:

- : ('a, P2R.point -> P2R.point -> bool) code =
. fun b_2 -> (a_1.c0 <= b_2.c0)>.

The second instantiation is has a 3D point type:

module V3R = VectorStaged (Float_Real_Exact) (Record3D)
module P3R = Iso_Axis_Ordered_En_Point (Float_Real_Exact) (V3R) (Record3D) 
module GP3R = Gen (P3R)
GP3R.cmp_x ()

which produces the code:

- : ('a, P3R.point -> P3R.point -> bool) code =
. fun b_2 -> (a_1.x <= b_2.x)>.