Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. (* Interval domain *)
  2.  
  3. let bot = (infinity, neg_infinity)
  4.  
  5. let leq (l,h) (l',h') = l' <= l && h <= h'
  6.  
  7. let join (l,h) (l',h') = (min l l', max h h')
  8.  
  9. let incr : float*float -> float*float = fun (l, h) -> (l +. 1.0, h +. 1.0)
  10.  
  11. let decr : float*float -> float*float = fun (l, h) -> (l -. 1.0, h -. 1.0)
  12.  
  13. let iszero : float*float -> float*float = fun (l, h) ->
  14. if l <= 0.0 && 0.0 <= h then (0.0,0.0) else (infinity, neg_infinity)
  15.  
  16. let notzero : float*float -> float*float = fun (l, h) ->
  17. if l > 0.0 || h < 0.0 || (l < 0.0 && 0.0 < h)
  18. then (l, h)
  19. else if h == 0.0 then (l, h -. 1.0)
  20. else (l +. 1.0, h)
  21.  
  22.  
  23. let wide_op : float*float -> float*float -> float*float = fun (l,h) (l',h') ->
  24. if (l,h) == bot then (l',h')
  25. else if (l',h') == bot then (l,h)
  26. else
  27. begin
  28. let a = if l' < l then neg_infinity else l in
  29. let b = if h' > h then infinity else h in
  30. (a, b)
  31. end
  32.  
  33. let wide : (float*float -> float*float) -> float*float -> float*float = fun func i -> wide_op i (func i)
  34.  
  35. let narrow_op : float*float -> float*float -> float*float = fun (l,h) (l',h') ->
  36. if (l,h) == bot then bot
  37. else if (l',h') == bot then bot
  38. else
  39. begin
  40. let a = if l == neg_infinity then l' else l in
  41. let b = if h == infinity then h' else h in
  42. (a, b)
  43. end
  44.  
  45. let narrow : (float*float -> float*float) -> float*float -> float*float = fun func i -> narrow_op i (func i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement