Okay, someone stopped by here during the week by googling for a "sparse matrix" in Squeak or Smalltalk, I forget. Not that I incessantly click on my referer log minute after minute looking for hits, but, gee whillikers, I felt bad that I could not accommodate whoever it was.
The lame implementation is really simple: take a Dictionary (either subclass from it or make it a Component of a Composite pattern), then use Points to index into it. Have any index misses yield a zero. Simple! If you want to be safe, make any index misses that are not Points or out of your bounds throw an exception if your system implements them, or return just call a halt.
It’s probably not up to doing high-speed production matrix work, but you’ll never know until testing it, eh?
2:58:36 PM
|
|