瀏覽代碼

Fixed the loop operator to have an initial state.

Paul Downen 14 年之前
父節點
當前提交
2287ecd600
共有 2 個文件被更改,包括 9 次插入7 次删除
  1. 4 3
      include/flow_graph.hrl
  2. 5 4
      src/flow_graph.erl

+ 4 - 3
include/flow_graph.hrl

@@ -57,6 +57,7 @@
 
 % loop (A_1 * ... * A_n) (B_1 * ... * B_m) ::=
 %   { in = n : number, out = m : number,
-%     size : number,
-%     op   : operation (A_1 * ... * A_n+size) (B_1 * ... * B_m+size) }
--record(loop, {in, out, size, op}).
+%     init : operation () (S_1 * ... * S_i),
+%     op   : operation (A_1 * ... * A_n * S_1 * ... * S_i)
+%                      (B_1 * ... * B_m * S_1 * ... * S_i) }
+-record(loop, {in, out, init, op}).

+ 5 - 4
src/flow_graph.erl

@@ -79,12 +79,13 @@ switch(Switch, Map = [{_, Op1}|Rest]) ->
 	error:function_clause -> erlang:error(badarg, [Switch, Map])
     end.
 
-loop(N, Op) ->
-    {In, Out} = case {in_arity(Op)-N, out_arity(Op)-N} of
+loop(Init, Op) ->
+    S = out_arity(Init),
+    {In, Out} = case {in_arity(Op)-S, out_arity(Op)-S} of
 		    {I, O} when I >= 0, O > 0 -> {I, O};
-		    {_, _} -> erlang:error(badarg, [N, Op])
+		    {_, _} -> erlang:error(badarg, [Init, Op])
 		end,
-    #loop{in=In, out=Out, size=N, op=Op}.
+    #loop{in=In, out=Out, init=Init, op=Op}.
 
 %%%-----------------------------------------------------------------------------
 %%% Operation querying