SumFunction.java
Go to the documentation of this file.00001 package com.graphbuilder.math.func;
00002
00006 public class SumFunction implements Function {
00007
00008 public SumFunction() {}
00009
00013 public double of(double[] d, int numParam) {
00014 double sum = 0;
00015
00016 for (int i = 0; i < numParam; i++)
00017 sum += d[i];
00018
00019 return sum;
00020 }
00021
00025 public boolean acceptNumParam(int numParam) {
00026 return numParam > 0;
00027 }
00028
00029 public String toString() {
00030 return "sum(x1, x2, ..., xn)";
00031 }
00032 }