Class ShortField
- java.lang.Object
-
- com.singularsys.extensions.field.implementations.AbstractComparativeField
-
- com.singularsys.extensions.field.implementations.GenericField<E>
-
- com.singularsys.extensions.field.implementations.GenericPowerField<java.lang.Short>
-
- com.singularsys.extensions.field.implementations.ShortField
-
- All Implemented Interfaces:
FieldI
,IntegerConvertor
,java.io.Serializable
public class ShortField extends GenericPowerField<java.lang.Short>
A integer field where overflows are ignored.- Author:
- Richard Morris
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.singularsys.extensions.field.implementations.GenericPowerField
one, zero
-
-
Constructor Summary
Constructors Constructor Description ShortField()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Short
addG(java.lang.Short l, java.lang.Short r)
Adds two elements of type E.java.lang.Short
cast(java.lang.Object l)
Convert the input to type E.java.lang.Integer
cmpG(java.lang.Short l, java.lang.Short r)
Compare two objects of the same type.java.lang.Short
convertFromInt(java.lang.Integer l)
Attempt to convert argument from an integerjava.lang.Integer
convertToIntE(java.lang.Short l)
If possible convert the argument to an Integer to enable integral powers.java.lang.Short
divG(java.lang.Short l, java.lang.Short r)
Divides two elements of type E.java.lang.Short
getOne()
Get the multiplicative identity for this field.java.lang.Short
getZero()
Get the additive identity for this fieldjava.lang.Short
modG(java.lang.Short l, java.lang.Short r)
Modulus of two elements of type E.java.lang.Short
mulG(java.lang.Short l, java.lang.Short r)
Multiplies two elements of type E.java.lang.Short
negG(java.lang.Short l)
Negates an elements of type E.java.lang.Short
powNonInt(java.lang.Short l, java.lang.Short r)
Called when the power is not an integerjava.lang.Short
subG(java.lang.Short l, java.lang.Short r)
Subtracts two elements of type E.-
Methods inherited from class com.singularsys.extensions.field.implementations.GenericPowerField
powG, powI
-
Methods inherited from class com.singularsys.extensions.field.implementations.GenericField
add, and, cmp, convertToInt, div, mod, mul, neg, not, or, pow, sub
-
-
-
-
Method Detail
-
cast
public java.lang.Short cast(java.lang.Object l)
Description copied from class:GenericField
Convert the input to type E.- Specified by:
cast
in classGenericField<java.lang.Short>
- Returns:
- l cast to type E if possible or null if casting is not possible
-
addG
public java.lang.Short addG(java.lang.Short l, java.lang.Short r) throws EvaluationException
Description copied from class:GenericField
Adds two elements of type E.- Specified by:
addG
in classGenericField<java.lang.Short>
- Parameters:
l
- lhs argumentr
- rhs argument- Returns:
- the sum
- Throws:
EvaluationException
- on error
-
subG
public java.lang.Short subG(java.lang.Short l, java.lang.Short r) throws EvaluationException
Description copied from class:GenericField
Subtracts two elements of type E.- Specified by:
subG
in classGenericField<java.lang.Short>
- Parameters:
l
- lhs argumentr
- rhs argument- Returns:
- the difference
- Throws:
EvaluationException
- on error
-
negG
public java.lang.Short negG(java.lang.Short l) throws EvaluationException
Description copied from class:GenericField
Negates an elements of type E.- Specified by:
negG
in classGenericField<java.lang.Short>
- Parameters:
l
- the argument- Returns:
- the negation
- Throws:
EvaluationException
- on error
-
mulG
public java.lang.Short mulG(java.lang.Short l, java.lang.Short r) throws EvaluationException
Description copied from class:GenericField
Multiplies two elements of type E.- Specified by:
mulG
in classGenericField<java.lang.Short>
- Parameters:
l
- lhs argumentr
- rhs argument- Returns:
- the product
- Throws:
EvaluationException
- on error
-
divG
public java.lang.Short divG(java.lang.Short l, java.lang.Short r) throws EvaluationException
Description copied from class:GenericField
Divides two elements of type E.- Specified by:
divG
in classGenericField<java.lang.Short>
- Parameters:
l
- numeratorr
- denominator- Returns:
- the division
- Throws:
EvaluationException
- on error
-
modG
public java.lang.Short modG(java.lang.Short l, java.lang.Short r) throws EvaluationException
Description copied from class:GenericField
Modulus of two elements of type E.- Specified by:
modG
in classGenericField<java.lang.Short>
- Parameters:
l
- lhs argumentr
- rhs argument- Returns:
- the modulus
- Throws:
EvaluationException
- on error
-
powNonInt
public java.lang.Short powNonInt(java.lang.Short l, java.lang.Short r) throws EvaluationException
Description copied from class:GenericPowerField
Called when the power is not an integer- Specified by:
powNonInt
in classGenericPowerField<java.lang.Short>
- Returns:
- Throws:
EvaluationException
-
cmpG
public java.lang.Integer cmpG(java.lang.Short l, java.lang.Short r) throws EvaluationException
Description copied from class:GenericField
Compare two objects of the same type.- Specified by:
cmpG
in classGenericField<java.lang.Short>
- Parameters:
l
- left argumentr
- right argument- Returns:
- -1, 0, 1 or null
- Throws:
EvaluationException
-
convertFromInt
public java.lang.Short convertFromInt(java.lang.Integer l) throws EvaluationException
Description copied from interface:IntegerConvertor
Attempt to convert argument from an integer- Specified by:
convertFromInt
in interfaceIntegerConvertor
- Specified by:
convertFromInt
in classGenericField<java.lang.Short>
- Parameters:
l
- value to convert- Returns:
- corresponding value in this field or null if it cannot be converted
- Throws:
EvaluationException
- probably never
-
getOne
public java.lang.Short getOne()
Description copied from interface:FieldI
Get the multiplicative identity for this field.- Specified by:
getOne
in interfaceFieldI
- Specified by:
getOne
in classGenericField<java.lang.Short>
- Returns:
- object representing one or null if undefined for this field
-
getZero
public java.lang.Short getZero()
Description copied from interface:FieldI
Get the additive identity for this field- Specified by:
getZero
in interfaceFieldI
- Specified by:
getZero
in classGenericField<java.lang.Short>
- Returns:
- object representing zero or null if undefined for this field
-
convertToIntE
public java.lang.Integer convertToIntE(java.lang.Short l) throws EvaluationException
Description copied from class:GenericField
If possible convert the argument to an Integer to enable integral powers. If the argument cannot be converted null should be returned and thepowG(E,E)
method will be called.- Specified by:
convertToIntE
in classGenericField<java.lang.Short>
- Parameters:
l
- argument to convert.- Returns:
- an integer or null if argument cannot be converted
- Throws:
EvaluationException
-
-