cleaned up regression matrix function for linear kernel fitting