def returnAmplitudeFromListOfFunctionValues(self, listOfFunctionValues, additive=False):
"""Helper function for the amplitude setting function
[f(x), g(y), ...]
additive=True => F(x, y, ...) = f(x) + g(y) + ...
additive=False => F(x, y, ...) = f(x) * g(y) * ..."""
output = self.functionSpaceZero()
if additive:
initialValue = 0.0
else:
initialValue = 1.0
for indexTuple, value in np.ndenumerate(output):
newValue = initialValue
for tupleIndex, tupleValue in enumerate(indexTuple):
if additive:
newValue += listOfFunctionValues[tupleIndex][tupleValue]
else:
newValue *= listOfFunctionValues[tupleIndex][tupleValue]
output[indexTuple] = newValue
return output
评论列表
文章目录