In the paper, we study the problem of optimal matching of two generalized functions (distributions) via a diffeomorphic transformation of the ambient space. In the particular case of discrete distributions (weighted sums of Dirac measures), we provide a new algorithm to compare two arbitrary unlabelled sets of points, and show that it behaves properly in limit of continuous distributions on submanifolds. As a consequence, the algorithm may apply to various matching problems, such as curve or surface matching (via a sub-sampling), or mixings of landmark and curve data. As the solution forbids high energy solutions, it is also robust towards addition of noise and the technique can be used for nonlinear projection of datasets. We present 2D and 3D experiments.