Tensor formulation of spin-1 and spin-2 fields