  We present the implementation and use of algorithms for matching point-spread
functions (PSFs) within the Pan-STARRS Image Processing Pipeline (IPP).
PSF-matching is an essential part of the IPP for the detection of supernovae
and asteroids, but it is also used to homogenize the PSF of inputs to stacks,
resulting in improved photometric precision compared to regular coaddition,
especially in data with a high masked fraction. We report our experience in
constructing and operating the image subtraction pipeline, and make
recommendations about particular basis functions for constructing the
PSF-matching convolution kernel, determining a suitable kernel, parallelisation
and quality metrics. We introduce a method for reliably tracking the noise in
an image throughout the pipeline, using the combination of a variance map and a
`covariance pseudo-matrix'. We demonstrate these algorithms with examples from
both simulations and actual data from the Pan-STARRS1 telescope.
