Nanomagnet switching