Question: Best way to modify this script to sum over certain indicies

I have a list of coefficients each assigned a triple of indices. E.g. CF_{x,y,z}. These indicies are also able to take other values between +-2. E.g. CF_{x+2,y-1,z} or CF_{x,y-2,z+1} as examples. I have a working loop that cycles through the list of these coefficients and I am able to call a particular one by specifying the triple of indicies. This script has been attached:

triple_index_script.mw

I would like to modify this script to have more control over single indexes. As an example, say I want to add up all the coefficients which have z as a subscript (so not z+1,z-2 etc...) and I don't care what the x and y subscripts are; I want to be able to call that sum using the same notation in the script but with a single index. e.g. (using a new example function called RR_MapZ):

RR_MapZ[0]; ## This would return the sum of all coefficients that had z in their subscript

and this would return the sum of all the coefficients which have subscript Z. If I wanted to add up all the coefficients which had index Z+1 I would do:

RR_MapN[1]; ## This would return the sum of all coefficients that had z+1 in their subscript

What would be the most efficient way to do this?

-Yeti

Please Wait...