Creates a matrix from an array.
NOTE: buffer must have the same number of dimensions as the desired matrix for the structure to remain intact.