Magnet and device for magnetic density separation