# coding=utf-8
"""
Created on 18 January 2014
@author: Cenk Bircanoglu
"""
import math
[docs]class SumFormula:
def __init__(self):
self._data = []
[docs] def calculate(self, data, is_tuple=False, index=None, power=1):
if is_tuple:
self._data = [obj[index] for obj in data]
else:
self._data = data
self.power = power
return self.__algorithm()
def __algorithm(self):
total = 0.0
for num in self._data:
total += self.exponential(float(num), self.power)
return total