Nanomagnetism: fundamentals and applications