Electronic structure and magnetism of Mn-doped GaN