diff options
author | lloyd <[email protected]> | 2008-09-29 20:17:08 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-09-29 20:17:08 +0000 |
commit | 7c0319368d1948d54db514e5f72c589a397e2909 (patch) | |
tree | 2d52b6dd8715a6ea0fc21b3a66673fb38a8d4ebb /doc/scripts/comba.py | |
parent | 0f2dfff90fe3882a85308d66a05803178a452023 (diff) |
Remove the misc dir:
Moved XS, Boost Python, and SWIG wrappers to new toplevel directory 'wrappers'
Moved NIST X.509 test suite into checks directory
Move the build information used by configure.pl to src/build-data
Move scripts directory to doc (for lack of a better spot)
Diffstat (limited to 'doc/scripts/comba.py')
-rwxr-xr-x | doc/scripts/comba.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/doc/scripts/comba.py b/doc/scripts/comba.py new file mode 100755 index 000000000..ce3cfed77 --- /dev/null +++ b/doc/scripts/comba.py @@ -0,0 +1,65 @@ +#!/usr/bin/python + +import sys + +def comba_indexes(N): + + indexes = [] + + for i in xrange(0, 2*N): + x = [] + + for j in xrange(max(0, i-N+1), min(N, i+1)): + x += [(j,i-j)] + indexes += [sorted(x)] + + return indexes + +def comba_sqr_indexes(N): + + indexes = [] + + for i in xrange(0, 2*N): + x = [] + + for j in xrange(max(0, i-N+1), min(N, i+1)): + if j < i-j: + x += [(j,i-j)] + else: + x += [(i-j,j)] + indexes += [sorted(x)] + + return indexes + +def comba_multiply_code(N): + indexes = comba_indexes(N) + + for (i,idx) in zip(range(0, len(indexes)), indexes): + for pair in idx: + print "word3_muladd(&w2, &w1, &w0, x[%2d], y[%2d]);" % (pair) + print "z[%2d] = w0; w0 = w1; w1 = w2; w2 = 0;" % (i) + +def comba_square_code(N): + indexes = comba_sqr_indexes(N) + + for (rnd,idx) in zip(range(0, len(indexes)), indexes): + for (i,pair) in zip(range(0, len(idx)), idx): + if pair[0] == pair[1]: + print " word3_muladd(&w2, &w1, &w0, x[%2d], x[%2d]);" % (pair) + elif i % 2 == 0: + print " word3_muladd_2(&w2, &w1, &w0, x[%2d], x[%2d]);" % (pair[0], pair[1]) + if rnd < len(idx)-2: + print " z[%2d] = w0; w0 = w1; w1 = w2; w2 = 0;\n" % (rnd) + elif rnd == len(idx)-1: + print " z[%2d] = w0;\n" % (rnd) + else: + print " z[%2d] = w1;\n" % (rnd) + +def main(args = None): + if args is None: + args = sys.argv + #comba_square_code(int(args[1])) + comba_multiply_code(int(args[1])) + +if __name__ == '__main__': + sys.exit(main()) |