diff --git a/scripts/dag/dag.sce b/scripts/dag/dag.sce index 232a0dc..24210b6 100644 --- a/scripts/dag/dag.sce +++ b/scripts/dag/dag.sce @@ -13,9 +13,10 @@ exec chicago_bare_new.sce; //exec dag_input.sce; //txt=mgetl('chicago.bare'); txtc = strcat(txt,"",'r'); -n_Xs = evstr(unix_g("echo " + "''"+ txtc + "''" + "|sed ''s/;/;\n/g'' | egrep -o X[0-9]+ |sort|tail -n 1|grep -o [0-9]*")(:))+1 -n_Cs = evstr(unix_g("echo " + "''"+ txtc + "''" + "|sed ''s/;/;\n/g'' | egrep -o C[0-9]+ |sort|tail -n 1|grep -o [0-9]*")(:))+1 -n_Gs = evstr(unix_g("echo " + "''"+ txtc + "''" + "|sed ''s/;/;\n/g'' | egrep -o G[0-9]+ |sort|tail -n 1|grep -o [0-9]*")(:))+1 +n_Xs = evstr(unix_g("echo " + "''"+ txtc + "''" + "|sed ''s/;/;\n/g'' | egrep -o X[0-9]+ |grep -o [0-9]*|sort -n|tail -n 1")(:))+1 +n_Cs = evstr(unix_g("echo " + "''"+ txtc + "''" + "|sed ''s/;/;\n/g'' | egrep -o C[0-9]+ |grep -o [0-9]*|sort -n|tail -n 1")(:))+1 +n_Gs = evstr(unix_g("echo " + "''"+ txtc + "''" + "|sed ''s/;/;\n/g'' | egrep -o G[0-9]+ |grep -o [0-9]*|sort -n|tail -n 1")(:))+1 + //n_Xs = evstr(unix_g("echo " + "''"+ txtc + "''" + "|sed ''s/;/;\n/g'' | egrep -o X[0-9]+ |sort|wc -l")(:)); //n_Cs = evstr(unix_g("echo " + "''"+ txtc + "''" + "|sed ''s/;/;\n/g'' | egrep -o C[0-9]+ |sort|wc -l")(:)); //n_Gs = evstr(unix_g("echo " + "''"+ txtc + "''" + "|sed ''s/;/;\n/g'' | egrep -o G[0-9]+ |sort|wc -l")(:)); diff --git a/scripts/dag/direct_expression.sce b/scripts/dag/direct_expression.sce index 5909757..f3eeded 100644 --- a/scripts/dag/direct_expression.sce +++ b/scripts/dag/direct_expression.sce @@ -35,28 +35,40 @@ function de = direct_expression(i) if isempty(dag_from(i)) de = nodename(i); else - if isempty(dag_from(dag_from(i)(1))) - p1a = '' - p1b = '' - else - p1a = '(' - p1b = ')' + p1a = '', p1b = ''; + if ~isempty(dag_from(dag_from(i)(1))) + if (node_type(dag_from(i)(1)) == '+') + p1a = '(', p1b = ')'; + end end - if isempty(dag_from(dag_from(i)(2))) - p2a = '' - p2b = '' - else - p2a = '(' - p2b = ')' + p2a = '', p2b = ''; + if ~isempty(dag_from(dag_from(i)(2))) + if (node_type(dag_from(i)(2)) == '+') + p2a = '(', p2b = ')'; + end + end + de = p1a + direct_expression(dag_from(i)(1)) + p1b + node_type(i) .. + + p2a + direct_expression(dag_from(i)(2)) + p2b; + if length(dag_from(i)) == 3 // up to 3 sums per gate are supported + p3a = '', p3b = ''; + if ~isempty(dag_from(dag_from(i)(3))) + if (node_type(dag_from(i)(3)) == '+') + p3a = '(', p3b = ')'; + end + end + de = de + node_type(i) + p3a + direct_expression(dag_from(i)(3)) + p3b end - de = p1a + direct_expression(dag_from(i)(1)) + p1b + node_type(i) + p2a + direct_expression(dag_from(i)(2)) + p2b end end endfunction disp roots: l = get_roots() +nr = size(l,'*'); -//for i=1:size(l,'*') -// direct_expression(l(i)) -//end +de = ''; +de(max_n_nodes) = ''; +for i=1:size(l,'*') + de(l(i)) = nodename(l(i)) + ' = ' + direct_expression(l(i)); +end +// "(C0+(C1*X14))*X15"