this is a utility function to generate multidimensional arrays - like the spread function in fortran

spread(A, loc, dims)