Fixed definition of vec

vec is supposed to take a multidimensional array and return a vector (1D array) of the entries. The previous definition attempted to reshape the multidimensional array A into a vector that had length max(size(A)) when it should be prod(size(A)).