Modified to handle less basis functions than total inputs