Automatic differentiation of large sparse systems