A universal interferometer for coupling a plurality of modes of electromagnetic radiation (101, 102, 103, 104, 105) according to a transformation comprising: N inputs for inputting N modes of electromagnetic radiation into the interferometer; N outputs for outputting N modes of electromagnetic radiation from the interferometer; and a plurality of waveguides arranged to pass through the interferometer to connect the N inputs to the N outputs and for carrying the N modes of electromagnetic radiation through the interferometer; wherein: N is a natural number; the plurality of waveguides are arranged to provide a plurality of crossing points between pairs of the plurality of waveguides, wherein a reconfigurable beam splitter arranged to implement a reconfigurable reflectivity and a reconfigurable phase shift is arranged at each of the plurality of crossing points, such that at each reconfigurable beam splitter the two modes of electromagnetic radiation carried by the two respective waveguides to the crossing point are capable of coupling with each other with a reconfigurable reflection coefficient and a reconfigurable phase shift coefficient, wherein the plurality of waveguides and the plurality of crossing points are arranged such that each of the N modes of electromagnetic radiation is capable of coupling with each of the other modes of electromagnetic radiation at respective reconfigurable beam splitters; and the plurality of waveguides are arranged such that the plurality of crossing points are arranged into N groups along the plurality of waveguides from the inputs to the outputs through the interferometer, wherein each group contains the maximum number of possible crossing points between pairs of waveguides, and wherein the crossing points in each group involve pairs of adjacent waveguides whose paths were not crossed in the previous group of crossing points; and the couplings between the pairs of modes at each of the reconfigurable beam splitters are configured such that the interferometer implements a transformation of the N modes between the N inputs and the N outputs. N inputs for inputting N modes of electromagnetic radiation into the interferometer; N outputs for outputting N modes of electromagnetic radiation from the interferometer; and a plurality of waveguides arranged to pass through the interferometer to connect the N inputs to the N outputs and for carrying the N modes of electromagnetic radiation through the interferometer; wherein: N is a natural number; the plurality of waveguides are arranged to provide a plurality of crossing points between pairs of the plurality of waveguides, wherein a reconfigurable beam splitter arranged to implement a reconfigurable reflectivity and a reconfigurable phase shift is arranged at each of the plurality of crossing points, such that at each reconfigurable beam splitter the two modes of electromagnetic radiation carried by the two respective waveguides to the crossing point are capable of coupling with each other with a reconfigurable reflection coefficient and a reconfigurable phase shift coefficient, wherein the plurality of waveguides and the plurality of crossing points are arranged such that each of the N modes of electromagnetic radiation is capable of coupling with each of the other modes of electromagnetic radiation at respective reconfigurable beam splitters; and the plurality of waveguides are arranged such that the plurality of crossing points are arranged into N groups along the plurality of waveguides from the inputs to the outputs through the interferometer, wherein each group contains the maximum number of possible crossing points between pairs of waveguides, and wherein the crossing points in each group involve pairs of adjacent waveguides whose paths were not crossed in the previous group of crossing points; and the couplings between the pairs of modes at each of the reconfigurable beam splitters are configured such that the interferometer implements a transformation of the N modes between the N inputs and the N outputs. N is a natural number; the plurality of waveguides are arranged to provide a plurality of crossing points between pairs of the plurality of waveguides, wherein a reconfigurable beam splitter arranged to implement a reconfigurable reflectivity and a reconfigurable phase shift is arranged at each of the plurality of crossing points, such that at each reconfigurable beam splitter the two modes of electromagnetic radiation carried by the two respective waveguides to the crossing point are capable of coupling with each other with a reconfigurable reflection coefficient and a reconfigurable phase shift coefficient, wherein the plurality of waveguides and the plurality of crossing points are arranged such that each of the N modes of electromagnetic radiation is capable of coupling with each of the other modes of electromagnetic radiation at respective reconfigurable beam splitters; and the plurality of waveguides are arranged such that the plurality of crossing points are arranged into N groups along the plurality of waveguides from the inputs to the outputs through the interferometer, wherein each group contains the maximum number of possible crossing points between pairs of waveguides, and wherein the crossing points in each group involve pairs of adjacent waveguides whose paths were not crossed in the previous group of crossing points; and the couplings between the pairs of modes at each of the reconfigurable beam splitters are configured such that the interferometer implements a transformation of the N modes between the N inputs and the N outputs.