Package org.apache.commons.numbers.field
Class AbstractField<T extends NativeOperators<T>>
- java.lang.Object
-
- org.apache.commons.numbers.field.AbstractField<T>
-
- Type Parameters:
T
- Type of the field elements.
- All Implemented Interfaces:
Field<T>
- Direct Known Subclasses:
BigFractionField
,DDField
,FP64Field
,FractionField
public abstract class AbstractField<T extends NativeOperators<T>> extends Object implements Field<T>
Boiler-plate code for concrete implementations ofField
.
-
-
Constructor Summary
Constructors Constructor Description AbstractField()
Create an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
add(T a, T b)
Add the elements.T
divide(T a, T b)
Divide the elementa
byb
.T
multiply(int n, T a)
Multiply the elementa
by a specified number of timesn
.T
multiply(T a, T b)
Multiply the elements.T
negate(T a)
Negate the element.T
reciprocal(T a)
Return the reciprocal (multiplicative inverse).T
subtract(T a, T b)
Subtract the elementb
froma
.
-
-
-
Constructor Detail
-
AbstractField
public AbstractField()
Create an instance.
-
-
Method Detail
-
add
public T add(T a, T b)
Add the elements.- Specified by:
add
in interfaceField<T extends NativeOperators<T>>
- Parameters:
a
- Field element.b
- Field element.- Returns:
a + b
.
-
subtract
public T subtract(T a, T b)
Subtract the elementb
froma
.- Specified by:
subtract
in interfaceField<T extends NativeOperators<T>>
- Parameters:
a
- Field element.b
- Field element.- Returns:
a - b
.
-
negate
public T negate(T a)
Negate the element.- Specified by:
negate
in interfaceField<T extends NativeOperators<T>>
- Parameters:
a
- Field element.- Returns:
-a
.
-
multiply
public T multiply(int n, T a)
Multiply the elementa
by a specified number of timesn
.- Specified by:
multiply
in interfaceField<T extends NativeOperators<T>>
- Parameters:
n
- Number of timesa
must be added to itself.a
- Field element.- Returns:
n a
.
-
multiply
public T multiply(T a, T b)
Multiply the elements.- Specified by:
multiply
in interfaceField<T extends NativeOperators<T>>
- Parameters:
a
- Field element.b
- Field element.- Returns:
a * b
.
-
divide
public T divide(T a, T b)
Divide the elementa
byb
.- Specified by:
divide
in interfaceField<T extends NativeOperators<T>>
- Parameters:
a
- Field element.b
- Field element.- Returns:
a * b-1
.
-
reciprocal
public T reciprocal(T a)
Return the reciprocal (multiplicative inverse).- Specified by:
reciprocal
in interfaceField<T extends NativeOperators<T>>
- Parameters:
a
- Field element.- Returns:
a-1
.
-
-