General tensor decomposition, moment matrices and applications