Reikriam

recursive-iterative py

Jun 28th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. def foo1(toptr, fromptr, ndim, shape, strides):
  2. if ndim == 1:
  3. for i in range(shape[0]):
  4. toptr[i] = fromptr[i*strides[0]]
  5. else:
  6. for i in range(shape[0]):
  7. temptoptr = toptr[i*shape[1]:]
  8. tempfromptr = fromptr[i*strides[0]:]
  9. err = foo1(temptoptr, fromptr, ndim - 1, shape[1:], strides[1:])
  10. toptr[i*shape[i]:] = temptoptr
  11. fromptr[i*strides[0]:] = tempfromptr
  12. if err != 1:
  13. return err
  14. return 1
Add Comment
Please, Sign In to add comment