A new technique to calculate dipolar energy and its implementation onto an application specific processor