|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.rubecula.util.Item
com.rubecula.jquantity.BaseNumber
com.rubecula.jquantity.MutableNumber
com.rubecula.jquantity.WholeNumber
com.rubecula.jquantity.FuzzInt
This class extends a WholeNumber by adding fuzzy parameters. In particular,
the FuzzInt class implements setModel(), setBoundAbs() and setBoundRel().
It might seem odd at first that we have a class for fuzzy integers. How
can integers be fuzzy, you might ask? The reason is that when we define a
Rational as a ratio of two numbers, we want each of the top and bottom to
potentially have its own error bounds and model.
Nested Class Summary | |
(package private) class |
FuzzInt.FuzzIntException
|
Nested classes inherited from class com.rubecula.jquantity.WholeNumber |
WholeNumber.WholeNumberException |
Field Summary | |
private double |
_Bound
_Bound is the estimate of the size order of any error in the value itself (according to the model), expressed relative value of this. |
private int |
_Model
_Model is the distribution model of possible errors in the value itself. |
Fields inherited from class com.rubecula.jquantity.WholeNumber |
$1, $10, $10B |
Fields inherited from class com.rubecula.jquantity.MutableNumber |
$__1, $0, $2, $3 |
Fields inherited from class com.rubecula.jquantity.BaseNumber |
|
Fields inherited from class com.rubecula.util.Item |
JQUANTITY_TEST |
Fields inherited from interface com.rubecula.jquantity.Fuzzy |
$DistGaussian, $DistInvalid, $DistNone, $DistUniform, $Names |
Constructor Summary | |
(package private) |
FuzzInt()
Empty constructor. |
(package private) |
FuzzInt(java.math.BigInteger bigInteger)
Constructor to create an exact FuzzInt from a BigInteger. |
(package private) |
FuzzInt(java.math.BigInteger bigInteger,
double bound)
Constructor to create a FuzzInt from a BigInteger and its bound (a uniform error model is assumed). |
(package private) |
FuzzInt(java.math.BigInteger bigInteger,
double bound,
int model)
Primary constructor to create a FuzzInt from a BigInteger, its bound and error model. |
(package private) |
FuzzInt(java.math.BigInteger bigInteger,
int model)
Constructor to create an exact FuzzInt from a BigInteger and its error bound model. |
(package private) |
FuzzInt(Manifest integer)
Constructor to create an exact FuzzInt from a Manifest. |
(package private) |
FuzzInt(Manifest integer,
double bound)
Constructor to create a FuzzInt from a Manifest and its bound (a uniform error model is assumed). |
(package private) |
FuzzInt(Manifest integer,
double bound,
int model)
Constructor to create a FuzzInt from a Manifest and its bound (a uniform error model is assumed). |
(package private) |
FuzzInt(Manifest integer,
int model)
Constructor to create an exact FuzzInt from a Manifest and its error bound model. |
(package private) |
FuzzInt(NumberPresentation presentation)
Primary Constructor to create a FuzzInt by translating the given NumberPresentation representation of a FuzzInt in the specified radix. |
(package private) |
FuzzInt(java.lang.String string)
Secondary constructor (translates String into a NumberPresentation and then calls the primary constructor FuzzInt(NumberPresentation)). |
|
FuzzInt(WholeNumber number)
Constructor to create an exact FuzzInt from a BigInteger. |
Method Summary | |
void |
add(BaseNumber that)
MUTATING Instance method to add another BaseNumber into this object. |
java.lang.String |
audit(java.lang.String label)
Method to return a detailed string from an arithmetical object for debugging purposes. |
java.lang.Object |
clone()
Creates and returns a copy of this object. |
int |
compareTo(FuzzInt val)
Compares this FuzzInt with the specified WoleNumber. |
protected void |
factor(Integral x)
MUTATING METHOD: Replaces value with (this / x). |
double |
getBound()
Method to get the relative bound of fuzzy value. |
int |
getModel()
Method to get the error distribution model. |
boolean |
isExact()
Method to return true for this non-fuzzy instance. |
static void |
main(java.lang.String[] args)
Main method for testing this class. |
void |
multiply(BaseNumber that)
MUTATING Instance method to multiply another BaseNumber into this object. |
Presentable |
parse(Presentation presentation)
Instance method to convert a Presentation into a Presentable. |
protected BaseNumber |
pow(Integral power)
Method to raise this to the power power return the result. |
Presentation |
present(AttrMap attributes)
Convert this Presentable object into a Presentation, according to the set of attributes provided. |
void |
raiseToPower(int power)
MUTATING Instance method to raise this to power x. |
void |
scale(long factor)
MUTATING Instance method to multiply this by a scale factor. |
(package private) void |
setAbsError(double absBound,
int model)
MUTATING Instance method to set the abs error and model appropriately. |
void |
setBound(double bound)
Method to set the relative bound of fuzzy value. |
protected void |
setBoundAbs(double bound)
Method to set the absolute bound of fuzzy value. // TODO Move this from here to the protected class-specific methods (it is not part of FuzzyMutable). |
private void |
setExact()
|
void |
setModel(int model)
Method to set the error distribution model; |
java.math.BigInteger |
toBigInteger(boolean strict)
Convert this into a BigInteger. |
static FuzzInt |
valueOf(WholeNumber source)
Factory method to create a subclass instance of a superclass instance or, if the source is itself a FuzzInt, then to create a clone. |
Methods inherited from class com.rubecula.jquantity.WholeNumber |
compareTo, compareTo, compareTo, divide, divideAndRemainder, doubleValue, equals, floatValue, gcd, getEstimate, getValue, hashCode, intValue, isInfinite, isInteger, isPowerOfTen, isUnity, logTen, longValue, makePresentableInstance, max, min, minus, negate, pow, quotient, scaled, signum, subtract, TenToPower, toBigInteger, toString, toString, updateEstimate, valueOf, valueOf, valueOf, valueOfExponent, valueOfExponent, valueOfExponent |
Methods inherited from class com.rubecula.jquantity.MutableNumber |
assertMutable, defaultIdentifier, factored, forcePositive, getIdentifier, getIdentifier, isLong, isMutable, product, setConstant, setIdentifier, setIdentifierPost, setIdentifierPre, setIdentifierPrePost, sum, test, toIntegral |
Methods inherited from class com.rubecula.jquantity.BaseNumber |
abs, bestModel, BestModel, byteValue, characteristic, Characteristic, difference, getBoundAbs, impartFuzziness, isEqual, isUncertain, isZero, shortValue, valueOf, valueOf, valueOfLog10 |
Methods inherited from class com.rubecula.util.Item |
audit, audit, compareTo, Debug, getClassNameShort, getType, IsDebug, present, SetDebug, test, test, Wrap |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.rubecula.jquantity.Mutable |
isMutable, setConstant |
Methods inherited from interface com.rubecula.jquantity.Integral |
isZero |
Methods inherited from interface com.rubecula.util.Auditable |
audit, audit |
Methods inherited from interface com.rubecula.util.Identifiable |
getIdentifier |
Field Detail |
private double _Bound
private int _Model
Constructor Detail |
FuzzInt()
FuzzInt(NumberPresentation presentation)
presentation
- representation of FuzzInt.FuzzInt(java.math.BigInteger bigInteger, double bound, int model)
bigInteger
- the BigInteger we wish to widen into a FuzzInt.bound
- the absolute value of the bounds of the errors on new
FuzzInt.model
- the error model for the new FuzzInt.FuzzInt(java.lang.String string) throws PresentationException
string
- String representation of WholeNumber followed by fuzzy
information.
java.lang.NumberFormatException
- val is not a valid representation of a
WholeNumber in the specified radix, or radix is
outside the range from Character.MIN_RADIX (2) to
Character.MAX_RADIX (36), inclusive.
PresentationException
- if unable to parse string.Character.digit(char, int)
FuzzInt(java.math.BigInteger bigInteger, double bound)
bigInteger
- the BigInteger we wish to widen into a FuzzInt.bound
- the absolute value of the bounds of the errors on new
FuzzInt.FuzzInt(java.math.BigInteger bigInteger, int model)
bigInteger
- the BigInteger we wish to widen into a FuzzInt.model
- the error model for the new FuzzInt.public FuzzInt(WholeNumber number)
number
- the WholeNumber we wish to widen into a FuzzInt.FuzzInt(java.math.BigInteger bigInteger)
bigInteger
- the BigInteger we wish to widen into a FuzzInt.FuzzInt(Manifest integer, double bound, int model)
integer
- the Manifest we wish to widen into a FuzzInt.bound
- the absolute value of the bounds of the errors on new
FuzzInt.model
- the error model for the new FuzzInt.FuzzInt(Manifest integer, double bound)
integer
- the Manifest we wish to widen into a FuzzInt.bound
- the absolute value of the bounds of the errors on new
FuzzInt.FuzzInt(Manifest integer, int model)
integer
- the Manifest we wish to widen into a FuzzInt.model
- the error model for the new FuzzInt.FuzzInt(Manifest integer)
integer
- the Manifest we wish to widen into a FuzzInt.Method Detail |
public static void main(java.lang.String[] args)
args
- the command line options.public static FuzzInt valueOf(WholeNumber source)
source
- the source value to be "widened".
public Presentable parse(Presentation presentation) throws PresentationException
presentation
- a presentation of a number which you want to convert into a
number.
PresentationException
public Presentation present(AttrMap attributes) throws PresentationException
present
in interface Presentable
present
in class WholeNumber
attributes
- a map of the attributes desired for this presentation.
PresentationException
- if unable to present object with given attributes.public java.lang.Object clone()
clone
in class WholeNumber
WholeNumberException
- :
WholeNumber not Cloneable (should be impossible)Cloneable
protected BaseNumber pow(Integral power)
power
- the exponent for this.
protected void factor(Integral x)
factor
in class WholeNumber
x
- value by which this WholeNumber is to be divided.
WholeNumberException
- WholeNumber.factor: x is not a factor
WholeNumberException
- WholeNumber.factor: x should be positivepublic void raiseToPower(int power)
raiseToPower
in interface Arithmutable
raiseToPower
in class WholeNumber
power
- the number of times this should be multiplied by itself.
JQuantityException:
- non-negative power. (This would cause the operation to yield
a non-integer value.)BigInteger.pow(int)
public void scale(long factor)
scale
in interface Arithmutable
scale
in class WholeNumber
factor
- the scale factor.public void add(BaseNumber that)
add
in interface Arithmutable
add
in class WholeNumber
that
- the addend.public void multiply(BaseNumber that) throws InvalidOperandException
multiply
in interface Arithmutable
multiply
in class WholeNumber
that
- the multiplicand.
InvalidOperandException
public double getBound()
getBound
in interface Fuzzy
getBound
in class BaseNumber
public int getModel()
getModel
in interface Fuzzy
getModel
in class BaseNumber
public boolean isExact()
isExact
in interface Fuzzy
isExact
in class BaseNumber
protected void setBoundAbs(double bound)
bound
- the absolute bound.public void setBound(double bound)
setBound
in interface FuzzyMutable
bound
- the relative bound.public void setModel(int model)
setModel
in interface FuzzyMutable
model
- the distribution model: $DistNone, $DistUniform or
$DistGaussian.public java.math.BigInteger toBigInteger(boolean strict)
strict
- if true, then this must be exact, otherwise we just return
the equivalent big integer.
public java.lang.String audit(java.lang.String label)
audit
in interface Auditable
audit
in class WholeNumber
label
- the label to associate with the data
void setAbsError(double absBound, int model)
absBound
- the absolute error bound.model
- the error model.private void setExact()
public int compareTo(FuzzInt val)
val
- WholeNumber to which this WholeNumber is to be compared.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |