Composition and rank of n-way matrices and multilinear forms