A library of simulated-diffraction signals and hypothetical profiles of a periodic
grating can be generated by generating diffraction calculations for a plurality
of blocks of hypothetical layers. A diffraction calculation for a block of hypothetical
layers characterizes, in part, the behavior of a diffraction beam in the block
of hypothetical layers. Each block of hypothetical layers includes two or more
hypothetical layers, and each hypothetical layer characterizes a layer within a
hypothetical profile. The diffraction calculations for the blocks of hypothetical
layers are stored prior to generating the library. The simulated-diffraction signals
to be stored in the library are then generated based on the stored diffraction
calculations for the blocks of hypothetical layers.