[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Example of interactive use

Here is an example of interactive use. First build a custom toplevel: make polkatopg ret in the `caml' directory of the distribution. Then enter it by typing polkatopg ret. The following program:
 
#load "polka.cma";;
open Format;;
open PolkaIO;;

#install_printer vector_print_constraint;;
#install_printer matrix_print_constraints;;
#install_printer poly_print;;

initialize true ["x";"y";"z";"w"] 1000;;
let p = Poly.universe 4;;

let c1 = vector_of_constraint "2x>y";;
let p1 = Poly.add_constraint p c1;;

let m1 = matrix_of_lconstraints ["2x>=y";"3y>=z";"5z>w";"2y>7z"];;
let p2 = Poly.add_constraints p m1;;

let pu = Poly.union p1 p2;;
let pi = Poly.inter p1 p2;;
will give this output:
 
	Objective Caml version 3.04

# #load "polka.cma";;
# open Format;;
# open PolkaIO;;
# #install_printer vector_print_constraint;;
# #install_printer matrix_print_constraints;;
# #install_printer poly_print;;
# initialize true ["x";"y";"z";"w"] 1000;;
- : unit = ()
# let p = Poly.universe 4;;
val p : Poly.t = ({$>=0,1>=0},
		  {L:w,L:z,L:y,L:x,R:$,V:0})
# let c1 = vector_of_constraint "2x>y";;
val c1 : Vector.t = 2x>y
# let p1 = Poly.add_constraint p c1;;
val p1 : Poly.t = ({$>=0,1>=0,2x>y},
		   {L:w,L:z,L:-x-2y,R:-y,R:$-y,V:0})
# let m1 = matrix_of_lconstraints ["2x>=y";"3y>=z";"5z>w";"2y>7z"];;
val m1 : Matrix.t = {2x>=y,3y>=z,5z>w,2y>7z}
# let p2 = Poly.add_constraints p m1;;
val p2 : Poly.t =
  ({$>=0,1>=0,2x>=y,3y>=z,5z>w,2y>7z},
   {R:-x-2y-6z-30w,R:-w,R:7x+14y+4z+20w,R:x,R:38$-x-2y-6z-68w,V:0})
# let pu = Poly.union p1 p2;;
val pu : Poly.t = ({1>=0,$>=0,2x>=y},
		   {L:w,L:z,L:x+2y,R:x,R:$,V:0})
# let pi = Poly.inter p1 p2;;
val pi : Poly.t =
  ({$>=0,1>=0,5z>w,2y>7z,3y>=z,2x>y},
   {R:7x+14y+4z+20w,R:-x-2y-6z-30w,R:-w,V:0,R:x,R:19$+9x-y-3z-34w})
#



This document was generated on October, 27 2006 using texi2html