SqrtFunction.java

Go to the documentation of this file.
00001 package com.graphbuilder.math.func;
00002 
00008 public class SqrtFunction implements Function {
00009 
00010     public SqrtFunction() {}
00011 
00015     public double of(double[] d, int numParam) {
00016         double root = d[0];
00017         //----------------------------------------------------------
00018         // hack: if the root is negative, we need to return 0
00019         //----------------------------------------------------------
00020         if (root< 0.0) {
00021             //System.err.println("neg sqrt " + root);
00022             return 0.0;
00023         }
00024         return java.lang.Math.sqrt(root);
00025     }
00026 
00030     public boolean acceptNumParam(int numParam) {
00031         return numParam == 1;
00032     }
00033 
00034     public String toString() {
00035         return "sqrt(x)";
00036     }
00037 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1