From: Ian Jackson Date: Sun, 19 Nov 2017 11:47:12 +0000 (+0000) Subject: symbolic.py: wip making output good X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=82fdfdb90f9f78665eac55922a65b9019ad69491;p=moebius3.git symbolic.py: wip making output good Signed-off-by: Ian Jackson --- diff --git a/symbolic.py b/symbolic.py index 08da2bd..f219788 100755 --- a/symbolic.py +++ b/symbolic.py @@ -168,8 +168,15 @@ dbg('result_dirnscaled') params = ('sh','th','la','mu','gamma','kappa') +def ourccode(*a, **kw): + return ccode(*a, user_functions={'sinc':'sinc'}, **kw) + +def cprintraw(*s): + print(*s) + def cprint(s): - print(s) + for l in s.split('\n'): + cprintraw(l, '\\') def cse_prep_cprint(v, tmp_prefix): # => v, but also having cprint'd the common subexpression assignments @@ -177,12 +184,12 @@ def cse_prep_cprint(v, tmp_prefix): itertools.count()) (defs, vs) = cse(v, symbols=sym_iter) for defname, defval in defs: - cprint(ccode(defval, assign_to=defname)) + cprint('double '+ourccode(defval, assign_to=defname)) return vs[0] def cassign(v, assign_to, tmp_prefix): v = cse_prep_cprint(v, tmp_prefix) - cprint(ccode(v, assign_to=assign_to)) + cprint(ourccode(v, assign_to=assign_to)) def gen_diff(current, smalls): global j @@ -197,12 +204,12 @@ def gen_diff(current, smalls): dbg('j') j = cse_prep_cprint(j, 'jtmp') for ix in range(0, j.cols): - cprint(ccode(j.col(ix), 'J(%d)' % ix)) + cprint(ourccode(j.col(ix), 'J(%d)' % ix)) cprint('J_END_COL(%d)' % ix) else: small = smalls[0] smalls = smalls[1:] - cprint('if (!IS_SMALL(' + ccode(small) + ')) {') + cprint('if (!IS_SMALL(' + ourccode(small) + ')) {') gen_diff(current, smalls) cprint('} else { /* %s small */' % small) gen_diff(current.replace( @@ -211,9 +218,11 @@ def gen_diff(current, smalls): ), smalls ) - print('} /* %s small */' % small) + cprint('} /* %s small */' % small) +cprintraw('#define J_POPULATE \\') gen_diff(result_dirnscaled, (sh*sh*la, th*th*la)) +cprintraw('') #bad = q_orgcoords[0] #badd = diff(bad, la)