nndistx_matrix function added