3 Description: beam definition and operations
5 Created: 21/07/2013 Modified: 21/07/2013
8 exception Beam_matching of string;;
13 class beam : signal_type array -> beam_type =
14 fun (signals_init : signal_type array) ->
16 val signals = signals_init
19 method width = Array.length signals
21 method sub : int -> int -> beam_type =
24 new beam (Array.sub self#get start len)
26 method append : beam_type -> beam_type =
27 fun (b : beam_type) ->
28 new beam (Array.append self#get b#get)
30 method private add_memory : int -> unit =
32 let signal_add_memory : int -> signal_type -> unit =
36 let _ = Array.map (signal_add_memory window) self#get in ()
38 method matching : int -> beam_type =
40 if size = self#width then new beam self#get
42 else if (size > self#width) && (size mod self#width = 0) then
43 let () = self#add_memory 1 in
45 Array.concat (Array.to_list
46 (Array.make (size/self#width) self#get)) in
47 new beam split_signals
49 else if (size < self#width) && (self#width mod size = 0) then
51 fun (sa : signal_type array) ->
54 if i + l < Array.length sa then
55 (sa.(i))#add (merge_rec sa l (i + l))
57 let merge_signals = Array.init size (merge_rec self#get size) in
58 new beam merge_signals
60 else raise (Beam_matching "matching size error")
62 method time : time -> value_type array =
64 let signal_at = fun (t : time) -> fun (s : signal_type) -> s#at t in
65 Array.map (signal_at t) self#get
67 method output : int -> (int array) * (float array array) =
68 fun (length_max : int) ->