AvgFunction.java

Go to the documentation of this file.
00001 package com.graphbuilder.math.func;
00002 
00006 public class AvgFunction implements Function {
00007 
00008     public AvgFunction() {}
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 / numParam;
00020     }
00021 
00025     public boolean acceptNumParam(int numParam) {
00026         return numParam > 0;
00027     }
00028 
00029     public String toString() {
00030         return "avg(x1, x2, ..., xn)";
00031     }
00032 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1