fix memory leak and change interface of incident field package
algorithm now return shared_ptr<n> instead of objects array and matrix