added rolling and unrolling for matrices