Parcourir la source

Added support for general initialization operations for flow_graph:loop.

Paul Downen il y a 14 ans
Parent
commit
4bedede70b
2 fichiers modifiés avec 5 ajouts et 5 suppressions
  1. 4 4
      include/flow_graph.hrl
  2. 1 1
      src/flow_graph.erl

+ 4 - 4
include/flow_graph.hrl

@@ -58,9 +58,9 @@
 %                {Tag_m, operation (A_1 * ... * A_n) B_m} ] }
 -record(switch, {in, out, switch, map}).
 
-% loop (A_1 * ... * A_n) (B_1 * ... * B_m) ::=
+% loop (A_1 * ... * A_n * C_1 * ... * C_i) (B_1 * ... * B_m) ::=
 %   { in = n : number, out = m : number,
-%     init : operation () (S_1 * ... * S_i),
-%     op   : operation (A_1 * ... * A_n * S_1 * ... * S_i)
-%                      (B_1 * ... * B_m * S_1 * ... * S_i) }
+%     init : operation (C_1 * ... * C_i) (S_1 * ... * S_j),
+%     op   : operation (A_1 * ... * A_n * S_1 * ... * S_j)
+%                      (B_1 * ... * B_m * S_1 * ... * S_j) }
 -record(loop, {in, out, init, op}).

+ 1 - 1
src/flow_graph.erl

@@ -84,7 +84,7 @@ switch(Switch, Map = [{_, Op1}|Rest]) ->
 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};
+		    {I, O} when I >= 0, O > 0 -> {I+in_arity(Init), O};
 		    {_, _} -> erlang:error(badarg, [Init, Op])
 		end,
     #loop{in=In, out=Out, init=Init, op=Op}.