w is window size (defaults to n1,n2,...)
p is number of patches in different dimensions (defaults to 1,1,...)
If inv=n, the number of output dimensions is twice the number of input dimensions.
If inv=y, the number of output dimensions is half the number of input dimensions.