utils.py 481 B

1234567891011121314151617181920212223242526
  1. import numpy
  2. w = 32
  3. def new_array(n, dtype=numpy.object):
  4. return numpy.empty(n, dtype)
  5. def _new_array(n):
  6. return [None]*n
  7. def new_zero_array(n):
  8. return numpy.zeros(n)
  9. def new_boolean_matrix(n, m):
  10. return numpy.zeros([n, m], numpy.bool_)
  11. def new_boolean_array(n):
  12. return numpy.zeros(n, numpy.bool_)
  13. def new_int_array(n, init=0):
  14. a = numpy.empty(n, numpy.int32)
  15. a.fill(init)
  16. return a
  17. def binfmt(n):
  18. return "{0:012b}".format(n)