Try looking up array manipulations (maybe under array translation) in an advanced algebra, calculus or statics & dynamics text book. They should give you some good manipulation techniques for that application. There is a name for it, but it escapes me at the moment and I can't remember, but I think it's in a calculus textbook.