public class UnsignedLogNumber extends java.lang.Number implements Field<UnsignedLogNumber>, java.lang.Comparable<UnsignedLogNumber>
LogNumber. However, when you are dealing with unsigned numbers like
probabilities, this class will be more efficient.LogNumber,
LogMath,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected double |
logValue
The log of the value represented by this object, log(value).
|
| Modifier | Constructor and Description |
|---|---|
|
UnsignedLogNumber()
Creates the
LogNumber representing zero. |
protected |
UnsignedLogNumber(double logValue)
Creates a new
LogNumber from the given value in log-space. |
|
UnsignedLogNumber(UnsignedLogNumber other)
Copies a given LogNumber.
|
| Modifier and Type | Method and Description |
|---|---|
UnsignedLogNumber |
clone()
Returns a smart copy of
this, such that changing the values
of the return class will not effect this |
int |
compareTo(UnsignedLogNumber other) |
static UnsignedLogNumber |
createFromLogValue(double logValue)
Creates a new
LogNumber from the given value that is already in
log-space. |
static UnsignedLogNumber |
createFromValue(double value)
Creates a new
LogNumber from the given value. |
UnsignedLogNumber |
divide(UnsignedLogNumber other)
Divides this value by another value and returns the result.
|
void |
divideEquals(UnsignedLogNumber other)
Divides this value by another value and stores the result in
this value.
|
UnsignedLogNumber |
dotTimes(UnsignedLogNumber other)
Element-wise multiplication of
this and other |
void |
dotTimesEquals(UnsignedLogNumber other)
Inline element-wise multiplication of
this and
other |
double |
doubleValue() |
boolean |
equals(java.lang.Object other)
Determines if two RingType objects are equal
|
boolean |
equals(UnsignedLogNumber other,
double effectiveZero)
Determines if two RingType objects are effectively equal
|
float |
floatValue() |
double |
getLogValue()
Gets the log of the value represented by this object, which is what is
stored in the object.
|
double |
getValue()
Gets the value represented by the log number.
|
int |
hashCode() |
int |
intValue() |
UnsignedLogNumber |
inverse()
Returns the inverse of
this. |
void |
inverseEquals()
Changes this value to be its inverse.
|
boolean |
isZero()
Determines if this ring is equal to zero.
|
boolean |
isZero(double effectiveZero)
Determines if this ring is equal to zero using the element-wise effective
zero value.
|
long |
longValue() |
UnsignedLogNumber |
max(UnsignedLogNumber other)
A new
LogNumber that is the maximum of this and another. |
void |
maxEquals(UnsignedLogNumber other)
Changes this value to be the maximum of this value or the given value.
|
UnsignedLogNumber |
min(UnsignedLogNumber other)
A new
LogNumber that is the minimum of this and another. |
void |
minEquals(UnsignedLogNumber other)
Changes this value to be the minimum of this value or the given value.
|
UnsignedLogNumber |
minus(UnsignedLogNumber other)
Arithmetic subtraction of
other from this |
void |
minusEquals(UnsignedLogNumber other)
Inline arithmetic subtraction of
other from
this |
UnsignedLogNumber |
negative()
Returns the element-wise negation of
this, such that
this.plus( this.negative() ) has only zero elements. |
void |
negativeEquals()
Inline element-wise negation of
this |
UnsignedLogNumber |
plus(UnsignedLogNumber other)
Arithmetic addition of
this and other |
void |
plusEquals(UnsignedLogNumber other)
Inline arithmetic addition of
this and other |
UnsignedLogNumber |
power(double power)
Returns a new
LogNumber representing this log number taken
to the given power. |
void |
powerEquals(double power)
Transforms this log number by taking it to the given power.
|
UnsignedLogNumber |
scale(double scaleFactor)
Element-wise scaling of
this by scaleFactor |
UnsignedLogNumber |
scaledMinus(double scaleFactor,
UnsignedLogNumber other)
Arithmetic subtraction
other after element-wise scaling of
other by scaleFactor from this. |
void |
scaledMinusEquals(double scaleFactor,
UnsignedLogNumber other)
Inline arithmetic subtraction of
other after element-wise
scaling of other by scaleFactor from this. |
UnsignedLogNumber |
scaledPlus(double scaleFactor,
UnsignedLogNumber other)
Arithmetic addition of
this and other after
element-wise scaling of other by scaleFactor. |
void |
scaledPlusEquals(double scaleFactor,
UnsignedLogNumber other)
Inline arithmetic addition of
this and other after
element-wise scaling of other by scaleFactor. |
void |
scaleEquals(double scaleFactor)
Inline element-wise scaling of
this by
scaleFactor |
void |
setLogValue(double logValue)
Sets the log of the value represented by this object, which is what is
stored in the object.
|
void |
setValue(double value)
Sets the value represented by the log number.
|
UnsignedLogNumber |
times(UnsignedLogNumber other)
Multiples this value times another value and returns the result.
|
void |
timesEquals(UnsignedLogNumber other)
Multiplies this value times another value and stores the result in
this value.
|
java.lang.String |
toString() |
void |
zero()
Zeros out all elements of
this, so that the following are
equivalent
r1.scaleEquals( 0.0 );
and
r1.zero();
Furthermore,
r1.zero(); anything.dotTimes( r1 ).equals( r1 ); |
protected double logValue
public UnsignedLogNumber()
LogNumber representing zero.protected UnsignedLogNumber(double logValue)
LogNumber from the given value in log-space. This
method is protected to avoid people calling it with being unsure if
value or log(value) should be given. Thus, two separate static utility
functions createFromValue and createFromLogValue are to be used instead.logValue - The log(value) for the value to be represented by this LogNumber.public UnsignedLogNumber(UnsignedLogNumber other)
other - The LogNumber to copy.public static UnsignedLogNumber createFromValue(double value)
LogNumber from the given value.value - A normal value.public static UnsignedLogNumber createFromLogValue(double logValue)
LogNumber from the given value that is already in
log-space. Equivalent to calling createFromValue(exp(logValue)).logValue - The value that is already in log-space.public UnsignedLogNumber clone()
Ringthis, such that changing the values
of the return class will not effect thisclone in interface Ring<UnsignedLogNumber>clone in interface CloneableSerializableclone in class java.lang.Objectthispublic boolean equals(java.lang.Object other)
Ringequals in interface Ring<UnsignedLogNumber>equals in class java.lang.Objectother - RingType to compare against thispublic boolean equals(UnsignedLogNumber other, double effectiveZero)
Ringequals in interface Ring<UnsignedLogNumber>other - RingType to compare against thiseffectiveZero - tolerance threshold for element-wise equalitypublic int compareTo(UnsignedLogNumber other)
compareTo in interface java.lang.Comparable<UnsignedLogNumber>public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic UnsignedLogNumber plus(UnsignedLogNumber other)
Ringthis and otherplus in interface Ring<UnsignedLogNumber>other - object to add to thisthis and otherpublic void plusEquals(UnsignedLogNumber other)
Ringthis and otherplusEquals in interface Ring<UnsignedLogNumber>other - object to add to thispublic UnsignedLogNumber minus(UnsignedLogNumber other)
Ringother from thisminus in interface Ring<UnsignedLogNumber>other - object to subtract from thisthis and otherpublic void minusEquals(UnsignedLogNumber other)
Ringother from
thisminusEquals in interface Ring<UnsignedLogNumber>other - object to subtract from thispublic UnsignedLogNumber times(UnsignedLogNumber other)
times in interface EuclideanRing<UnsignedLogNumber>other - The other value.public void timesEquals(UnsignedLogNumber other)
timesEquals in interface EuclideanRing<UnsignedLogNumber>other - The other value.public UnsignedLogNumber divide(UnsignedLogNumber other)
divide in interface EuclideanRing<UnsignedLogNumber>other - The other value.public void divideEquals(UnsignedLogNumber other)
divideEquals in interface EuclideanRing<UnsignedLogNumber>other - The other value.public UnsignedLogNumber dotTimes(UnsignedLogNumber other)
Ringthis and otherdotTimes in interface Ring<UnsignedLogNumber>other - elements of other will be multiplied to the corresponding
elements of thisthis and
otherpublic void dotTimesEquals(UnsignedLogNumber other)
Ringthis and
otherdotTimesEquals in interface Ring<UnsignedLogNumber>other - elements of other will be multiplied to the corresponding
elements of thispublic UnsignedLogNumber scale(double scaleFactor)
Ringthis by scaleFactorscale in interface Ring<UnsignedLogNumber>scaleFactor - amount to scale the elements of thisthispublic void scaleEquals(double scaleFactor)
Ringthis by
scaleFactorscaleEquals in interface Ring<UnsignedLogNumber>scaleFactor - amount to scale the elements of thispublic UnsignedLogNumber scaledPlus(double scaleFactor, UnsignedLogNumber other)
Ringthis and other after
element-wise scaling of other by scaleFactor.
If this is x, other is y, and scaleFactor is a, then this method is
equivalent to x + a * y. It is typically a more efficient way of doing
this.plus(other.scale(scaleFactor)) since it can avoid
intermediate object creation.scaledPlus in interface Ring<UnsignedLogNumber>scaleFactor - The scale factor to multiply by the elements of other before
adding to the elements of this.other - Object to scale and then add to this.public void scaledPlusEquals(double scaleFactor,
UnsignedLogNumber other)
Ringthis and other after
element-wise scaling of other by scaleFactor.
If this is x, other is y, and scaleFactor is a, then this method is
equivalent to x += a * y. It is typically a more efficient way of doing
this.plusEquals(other.scale(scaleFactor)) since it can avoid
intermediate object creation.scaledPlusEquals in interface Ring<UnsignedLogNumber>scaleFactor - The scale factor to multiply by the elements of other before
adding to the elements of this.other - Object to scale and then add to this.public UnsignedLogNumber scaledMinus(double scaleFactor, UnsignedLogNumber other)
Ringother after element-wise scaling of
other by scaleFactor from this.
If this is x, other is y, and scaleFactor is a, then this method is
equivalent to x - a * y. It is typically a more efficient way of doing
this.minus(other.scale(scaleFactor)) since it can avoid
intermediate object creation.scaledMinus in interface Ring<UnsignedLogNumber>scaleFactor - The scale factor to multiply by the elements of other before
subtracting from the elements of this.other - Object to scale and then subtract from this.public void scaledMinusEquals(double scaleFactor,
UnsignedLogNumber other)
Ringother after element-wise
scaling of other by scaleFactor from this.
If this is x, other is y, and scaleFactor is a, then this method is
equivalent to x -= a * y. It is typically a more efficient way of doing
this.minusEquals(other.scale(scaleFactor)) since it can avoid
intermediate object creation.scaledMinusEquals in interface Ring<UnsignedLogNumber>scaleFactor - The scale factor to multiply by the elements of other before
adding to the elements of this.other - Object to scale and then add to this.public UnsignedLogNumber negative()
Ringthis, such that
this.plus( this.negative() ) has only zero elements.negative in interface Ring<UnsignedLogNumber>thispublic void negativeEquals()
RingthisnegativeEquals in interface Ring<UnsignedLogNumber>public UnsignedLogNumber inverse()
Fieldthis.inverse in interface Field<UnsignedLogNumber>public void inverseEquals()
FieldinverseEquals in interface Field<UnsignedLogNumber>public void zero()
Ringthis, so that the following are
equivalent
r1.scaleEquals( 0.0 );
and
r1.zero();
Furthermore,
r1.zero(); anything.dotTimes( r1 ).equals( r1 );zero in interface Ring<UnsignedLogNumber>public boolean isZero()
RingisZero in interface Ring<UnsignedLogNumber>public boolean isZero(double effectiveZero)
RingisZero in interface Ring<UnsignedLogNumber>effectiveZero - Tolerance threshold for element-wise equalitypublic UnsignedLogNumber power(double power)
LogNumber representing this log number taken
to the given power.power - The power.public void powerEquals(double power)
power - The power.public UnsignedLogNumber min(UnsignedLogNumber other)
LogNumber that is the minimum of this and another.other - Another value.public void minEquals(UnsignedLogNumber other)
other - Another value.public UnsignedLogNumber max(UnsignedLogNumber other)
LogNumber that is the maximum of this and another.other - Another value.public void maxEquals(UnsignedLogNumber other)
other - Another value.public double getValue()
public void setValue(double value)
value - The value for this object to represent.public double getLogValue()
public void setLogValue(double logValue)
logValue - The log of the value for this object to represent.public int intValue()
intValue in class java.lang.Numberpublic long longValue()
longValue in class java.lang.Numberpublic float floatValue()
floatValue in class java.lang.Numberpublic double doubleValue()
doubleValue in class java.lang.Number