A closed-form formula for magnetic dipole localization by measurement of its magnetic field vector and magnetic gradient tensor