  We show how to design an optical device that can perform any linear function
or coupling between inputs and outputs. This design method is progressive,
requiring no global optimization. We also show how the device can configure
itself progressively, avoiding design calculations and allowing the device to
stabilize itself against drifts in component properties and to continually
adjust itself to changing conditions. This self-configuration operates by
training with the desired pairs of orthogonal input and output functions, using
sets of detectors and local feedback loops to set individual optical elements
within the device, with no global feedback or multiparameter optimization
required. Simple mappings, such as spatial mode conversions and polarization
control, can be implemented using standard planar integrated optics. In the
spirit of a universal machine, we show that other linear operations, including
frequency and time mappings, as well as non-reciprocal operation, are possible
in principle, even if very challenging in practice, thus proving there is at
least one constructive design for any conceivable linear optical component;
such a universal device can also be self-configuring. This approach is general
for linear waves, and could be applied to microwaves, acoustics and quantum
mechanical superpositions.
