Efficient 3D Gravity and Magnetic Modeling