Class FieldSqrt
- java.lang.Object
-
- com.singularsys.jep.functions.PostfixMathCommand
-
- com.singularsys.jep.functions.UnaryFunction
-
- com.singularsys.extensions.field.functions.FieldSqrt
-
- All Implemented Interfaces:
PostfixMathCommandI
,java.io.Serializable
public class FieldSqrt extends UnaryFunction
Calculate the square root of a number using any field. Uses the Babylonian method with the iterative formulax_{n+1} = (x_n + S / x_n) / 2
whereS
is the input number scaled to lie between 1/16 and 16. Algorithm will stop until convergence or the maximum number of iterations is reached.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
eval(java.lang.Object arg)
int
getNum_itts()
void
setNum_itts(int num_itts)
java.lang.String
toString()
-
Methods inherited from class com.singularsys.jep.functions.UnaryFunction
instanceOf, instanceOf, run
-
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkNumberOfParameters, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString
-
-
-
-
Constructor Detail
-
FieldSqrt
public FieldSqrt(FieldI f, int num_itts)
Constructor- Parameters:
f
- the field for all computationsnum_itts
- maximum number of iterations
-
-
Method Detail
-
eval
public java.lang.Object eval(java.lang.Object arg) throws EvaluationException
- Specified by:
eval
in classUnaryFunction
- Throws:
EvaluationException
-
getNum_itts
public int getNum_itts()
-
setNum_itts
public void setNum_itts(int num_itts)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classPostfixMathCommand
-
-