kernel.h: split out mathematical helpers