Package org.hipparchus
Interface FieldElement<T extends FieldElement<T>>
-
- Type Parameters:
T- the type of the field elements
- All Known Subinterfaces:
CalculusFieldElement<T>,Derivative<T>,Derivative1<T>,FieldDerivative<S,T>,FieldDerivative1<S,T>
- All Known Implementing Classes:
BigFraction,BigReal,Binary64,Complex,DerivativeStructure,Dfp,DfpDec,FieldComplex,FieldDerivativeStructure,FieldGradient,FieldTuple,FieldUnivariateDerivative,FieldUnivariateDerivative1,FieldUnivariateDerivative2,Fraction,Gradient,SparseGradient,Tuple,UnivariateDerivative,UnivariateDerivative1,UnivariateDerivative2
public interface FieldElement<T extends FieldElement<T>>Interface representing field elements.- See Also:
Field
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Tadd(T a)Compute this + a.Tdivide(T a)Compute this ÷ a.Field<T>getField()Get theFieldto which the instance belongs.doublegetReal()Get the real value of the number.default booleanisZero()Check if an element is semantically equal to zero.Tmultiply(int n)Compute n × this.Tmultiply(T a)Compute this × a.Tnegate()Returns the additive inverse ofthiselement.Treciprocal()Returns the multiplicative inverse ofthiselement.Tsubtract(T a)Compute this - a.
-
-
-
Method Detail
-
getReal
double getReal()
Get the real value of the number.- Returns:
- real value
-
add
T add(T a) throws NullArgumentException
Compute this + a.- Parameters:
a- element to add- Returns:
- a new element representing this + a
- Throws:
NullArgumentException- ifaisnull.
-
subtract
T subtract(T a) throws NullArgumentException
Compute this - a.- Parameters:
a- element to subtract- Returns:
- a new element representing this - a
- Throws:
NullArgumentException- ifaisnull.
-
negate
T negate()
Returns the additive inverse ofthiselement.- Returns:
- the opposite of
this.
-
multiply
T multiply(int n)
Compute n × this. Multiplication by an integer number is defined as the following sum \[ n \times \mathrm{this} = \sum_{i=1}^n \mathrm{this} \]- Parameters:
n- Number of timesthismust be added to itself.- Returns:
- A new element representing n × this.
-
multiply
T multiply(T a) throws NullArgumentException
Compute this × a.- Parameters:
a- element to multiply- Returns:
- a new element representing this × a
- Throws:
NullArgumentException- ifaisnull.
-
divide
T divide(T a) throws NullArgumentException, MathRuntimeException
Compute this ÷ a.- Parameters:
a- element to divide by- Returns:
- a new element representing this ÷ a
- Throws:
NullArgumentException- ifaisnull.MathRuntimeException- ifais zero
-
reciprocal
T reciprocal() throws MathRuntimeException
Returns the multiplicative inverse ofthiselement.- Returns:
- the inverse of
this. - Throws:
MathRuntimeException- ifthisis zero
-
getField
Field<T> getField()
Get theFieldto which the instance belongs.- Returns:
Fieldto which the instance belongs
-
isZero
default boolean isZero()
Check if an element is semantically equal to zero.The default implementation simply calls
equals(getField().getZero()). However, this may need to be overridden in some cases as due to compatibility withhashCode()some classes implementsequals(Object)in such a way that -0.0 and +0.0 are different, which may be a problem. It prevents for example identifying a diagonal element is zero and should be avoided when doing partial pivoting in LU decomposition.- Returns:
- true if the element is semantically equal to zero
- Since:
- 1.8
-
-