X-Git-Url: https://svn.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/66f23d4fabf89ad09adbd4dfc15ac6b5b2b7da83..4745d0cba82b458d491320c72e564b23899a5310:/interpreter/beam.ml diff --git a/interpreter/beam.ml b/interpreter/beam.ml index bec7ed0..fd6fca6 100644 --- a/interpreter/beam.ml +++ b/interpreter/beam.ml @@ -11,6 +11,7 @@ open Types;; open Basic;; open Value;; open Signal;; +open Aux;; class beam : signal_type array -> beam_type = fun (signals_init : signal_type array) -> @@ -72,11 +73,6 @@ class beam : signal_type array -> beam_type = method output : int -> data = fun (length_max : int) -> - let transpose : 'a array array -> 'a array array = - fun matrix -> - let get_element = fun i -> fun array -> array.(i) in - let get_column = fun m -> fun i -> Array.map (get_element i) m in - Array.init self#width (get_column matrix) in let value2float = fun (v : value_type) -> v#to_float_array in let init = [|0.|] in let container = Array.make length_max @@ -88,14 +84,36 @@ class beam : signal_type array -> beam_type = container.(!index) <- Array.map value2float (self#at !index); incr index; done; - transpose container + transpose self#width container with x -> match x with | Invalid_argument s -> - transpose (Array.sub container 0 !index) + transpose self#width (Array.sub container 0 !index) | _ -> raise x + + method output_values : int -> raw_data = + fun (length_max : int) -> + let init = new value (N 0) in + let container = Array.make length_max + (Array.make self#width init) in + let index = ref 0 in + + try + while !index < length_max do + container.(!index) <- self#at !index; + incr index; + done; + container + + with x -> + match x with + | Invalid_argument s -> + Array.sub container 0 !index + | _ -> raise x + + method frequency : rate_type array = let each_rate : signal -> rate = fun (s : signal) ->