Skip to content

Commit

Permalink
[Trifocal+P2Pt] dag evaluator: support for direct expression w 3 link…
Browse files Browse the repository at this point in the history
…s per node
  • Loading branch information
rfabbri committed Oct 30, 2023
1 parent 4292757 commit 57252ed
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
7 changes: 4 additions & 3 deletions scripts/dag/dag.sce
Original file line number Diff line number Diff line change
Expand Up @@ -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")(:));
Expand Down
44 changes: 28 additions & 16 deletions scripts/dag/direct_expression.sce
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 57252ed

Please sign in to comment.