This requires a lot of allocation and copying of arrays, which can be unfeasible for very large data. This could be avoided by reimplementing some of the multiexp methods to skip the ones and zeroes, and process these separately, all in a single pass.