I'm dealing a lot with large sparse linear operators these days and I'm quite new to them. A lot of the matrices I deal with originate with only a few unique integers, however, there are lots of them. As a result I have tons of memory locked up for the same values and fetching them from RAM seems like quite the bottle neck. It seems like a well designed for loop could replace these matrices for matrix multiplication, but writing custom loops for that seems like a chore. Are there tools or techniques to do this?