Class RealInt32
java.lang.Object
org.flag4j.algebraic_structures.RealInt32
- All Implemented Interfaces:
Serializable
,Comparable<RealInt32>
,Ring<RealInt32>
,Semiring<RealInt32>
A real number backed by a 32-bit integer number. Immutable.
This class wraps the primitive int type.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RealInt32
The numerical value -1.static final RealInt32
The numerical value 1.static final RealInt32
The numerical value 10.static final RealInt32
The numerical value 4.static final RealInt32
The numerical value 2.static final RealInt32
The numerical value 0. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSums two elements of this field (associative and commutative).addInv()
Computes the additive inverse for an element of this field.int
Compares this element of the ordered ring withb
.double
Converts this semiring value to an equivalent double value.boolean
Checks if an object is equal to this ring element.getOne()
Gets the multiplicative identity for this semiring.float
getValue()
Gets the value of this field element.getZero()
Gets the additive identity for this semiring.int
hashCode()
boolean
isOne()
Checks if this value is a multiplicative identity for this semiring.boolean
isZero()
Checks if this value is an additive identity for this semiring.double
mag()
Computes the magnitude of this ring element.Multiplies two elements of this field (associative and commutative).static RealInt32
Evaluates the signum or sign function on a ring element.Computes difference of two elements of this field.toString()
Converts this ring element to a string representation.
-
Field Details
-
NEGATIVE_ONE
The numerical value -1. -
ZERO
The numerical value 0. -
ONE
The numerical value 1. -
TWO
The numerical value 2. -
THREE
The numerical value 4. -
TEN
The numerical value 10.
-
-
Constructor Details
-
RealInt32
public RealInt32(int value) Constructs a real 32-bit floating point number.- Parameters:
value
- Value of the integer number.
-
RealInt32
Constructs a real 32-bit integer number from aRealInt16
.- Parameters:
value
- Value of the 32-bit integer number.
-
-
Method Details
-
getValue
public float getValue()Gets the value of this field element.- Returns:
- The value of this field element.
-
add
-
sub
-
mult
-
isZero
public boolean isZero()Checks if this value is an additive identity for this semiring.
An element 0 is an additive identity if a + 0 = a for any a in the semiring.
-
isOne
public boolean isOne()Checks if this value is a multiplicative identity for this semiring.
An element 1 is a multiplicative identity if a * 1 = a for any a in the semiring.
-
getZero
-
getOne
-
addInv
-
mag
-
sgn
-
compareTo
Compares this element of the ordered ring withb
.- Specified by:
compareTo
in interfaceComparable<RealInt32>
- Specified by:
compareTo
in interfaceSemiring<RealInt32>
- Parameters:
b
- Second element of the ordered ring.- Returns:
- An int value:
- 0 if this ring element is equal to
b
. - invalid input: '<' 0 if this ring element is less than
b
. - > 0 if this ring element is greater than
b
.
Hence, this method returns zero if and only if the two ring elements are equal, a negative value if and only the ring
element it was called on is less than
b
and positive if and only if the ring element it was called on is greater thanb
. - 0 if this ring element is equal to
-
doubleValue
public double doubleValue()Converts this semiring value to an equivalent double value.- Specified by:
doubleValue
in interfaceSemiring<RealInt32>
- Returns:
- A double value equivalent to this semiring element.
-
equals
-
hashCode
-
toString
-