  Any lossless transformation on $n_{s}$ spatial and $n_{p}$ internal modes of
light can be described by an $n_{s}n_{p}\times n_{s}n_{p}$ unitary matrix, but
there is no known procedure to effect an arbitrary $n_{s}n_{p}\times
n_{s}n_{p}$ unitary matrix on light in $n_{s}$ spatial and $n_{p}$ internal
modes. We devise an algorithm to realize an arbitrary discrete unitary
transformation on the combined spatial and internal degrees of freedom of
light. Our realization uses beamsplitters and operations on internal modes to
effect arbitrary linear transformations. The number of beamsplitters required
to realize a unitary transformation is reduced as compared to existing
realization by a factor $n_{p}^2/2$ at the cost of increasing the number of
internal optical elements by a factor of two. Our algorithm thus enables the
optical implementation of higher dimensional unitary transformations.
