Magnetic patterning by means of ion irradiation and implantation