Magnetic anisotropy of ferro- and Ferrimagnets