Use constraints more widely in matrix functions.