|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.lang.Number
|
+--com.rubecula.jquantity.BaseNumber
|
+--com.rubecula.jquantity.Approximation
This Class approximates a value using a double-precision value. Note that this class is limited in its ability to store large numbers. For such numbers, or for numbers which are rational, Rational should be used. This Class should only be used for the results of applying arbitrary mathematical functions to numbers - such numbers are generally less precise than is possible with double precision in any case, so this class is normally adequate - provided that the size limit is not exceeded.
| Field Summary | |
(package private) static Approximation |
$_alpha
Fine structure constant (approx): 7.29735308(33)E-3. |
(package private) static Approximation |
$_au
Astronomical Unit (approx): 1.49597893*E11. |
(package private) static Approximation |
$_e
Electron charge (approx): 1.60217733(49)E-19. |
(package private) static Approximation |
$_F
Faraday constant (approx): 96485.309(29). |
(package private) static Approximation |
$_G
Gravitation constant (approx): 6.67259(85)E-11. |
(package private) static Approximation |
$_K
Boltzmann constant (approx): 1.380658(12)E-23. |
(package private) static Approximation |
$_mp_me
Mass ratio of proton to electron (approx): 1836.152701(37). |
(package private) static Approximation |
$_R
Rydberg constant (approx): 1.0973731534(13). |
static Approximation |
$1
|
static Approximation |
$e
|
static Approximation |
$pi
|
(package private) static int |
$PrecisionDouble
Number of significant figures held by doubles: 15 [pessimistic by half a place - 52 bits are used for mantissa] |
(package private) static int |
$PrecisionFloat
Number of significant figures held by floats: 7 [pessimistic I think] |
| Fields inherited from interface com.rubecula.jquantity.Fuzzy |
$DistGaussian, $DistInvalid, $DistNone, $DistUniform, $Names |
| Constructor Summary | |
protected |
Approximation()
Constructor to create a new (exact) Approximation with value 0. |
|
Approximation(BaseNumber value)
Primary constructor to create a new Approximation equivalent to a given BaseNumber. |
|
Approximation(double value)
Primary constructor to create a new (exact) Approximation. |
|
Approximation(double value,
double boundRel)
Primary constructor to create a new Approximation. |
|
Approximation(double value,
double boundRel,
int model)
Primary constructor to create a new Approximation. |
| Method Summary | |
Trigonometrical |
arctanX2()
Method to evaluate the arctangent function. |
Trigonometrical |
arctanX2(Approximation divisor)
Method to evaluate the arctangent function of this divided by divisor. |
java.lang.String |
audit(java.lang.String label)
Method to return a detailed string from an arithmetical object for debugging purposes. |
double |
doubleValue()
Method to get the value of this approximation. |
Trigonometrical |
exp()
Method to evaluate the exponential function. |
float |
floatValue()
Method to yield this value as a float. |
double |
getBound()
Method to get the relative bound of this Rational. |
double |
getBoundAbs()
Method to get the absolute bound of non-fuzzy value. |
double |
getEstimate()
Method to get the current estimate of an arithmetical value. |
java.lang.String |
getIdentifier()
Get an identifier for this object. |
int |
getModel()
Method to get the error distribution model of this non-fuzzy object. |
(package private) static double |
IntrinsicError()
Method to get the intrinsic error of an ordinary double number. |
(package private) static double |
IntrinsicError(int halfplaces)
Method to get the intrinsic error of a number accurate to 1/2 half-places significant figures. |
int |
intValue()
If possible, get the integer value of this approximation. |
Divisible |
inverse()
Method to yield the reciprocal of this and return it as the result. |
boolean |
isExact()
Method to determine if the quantity represented is non-fuzzy; |
boolean |
isInfinite()
Method to determine if this value is infinite. |
boolean |
isInteger()
Method to determine if this object is an integer. |
boolean |
isUnity()
Method to determine if this is equal to the value 1. |
Trigonometrical |
log()
Method to evaluate the natural log function. |
long |
longValue()
If possible, get the long value of this approximation. |
static void |
main(java.lang.String[] args)
Test program. |
Presentable |
makePresentableInstance(Presentation presentation)
This method always throws an unsupported operation exception. |
protected BaseNumber |
minus()
Method to return this but with changed sign. |
static Approximation |
Parse(NumberPresentation presentation)
Translates the NumberPresentation representation into an Approximation. |
protected BaseNumber |
pow(int power)
Method to yield the value of this to a power. |
Presentation |
present(AttrMap attributes)
Convert this Presentable object into a Presentation, according to the set of attributes provided. |
protected BaseNumber |
product(BaseNumber multiplicand)
Method to yield the product of this approximation with a BaseNumber. |
Divisible |
quotient(BaseNumber divisor)
Method to yield the quotient of this approximation divided by a BaseNumber. |
Divisible |
scaled(double factor)
Method to yield the reciprocal of this and return it as the result. |
protected BaseNumber |
scaled(long factor)
Method to yield the result of scaling an approximation by a factor. |
int |
signum()
Method to get the sign of this approximation. |
protected BaseNumber |
sum(BaseNumber addend)
Method to yield the sum of this approximation with a BaseNumber. |
Trigonometrical |
tan_theta_2()
Method to evaluate the tangent function. |
(package private) void |
test(java.io.PrintStream output,
java.lang.String name)
|
java.lang.String |
toString()
Method to represent this object as a string. |
void |
updateEstimate()
No-op method to update the current estimate. |
static Approximation |
valueOf(java.lang.String valueString)
Method to create an approximation from a string which represents a double, optionally followed by "*" to indicate fuzziness in the last digit. |
| Methods inherited from class com.rubecula.jquantity.BaseNumber |
abs, audit, audit, bestModel, BestModel, Characteristic, compareTo, difference, impartFuzziness, isEqual, isUncertain, isZero, present, test, test, valueOfLog10, Wrap |
| Methods inherited from class java.lang.Number |
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final Approximation $1
public static final Approximation $pi
public static final Approximation $e
static final Approximation $_R
static final Approximation $_mp_me
static final Approximation $_alpha
static final Approximation $_e
static final Approximation $_F
static final Approximation $_K
static final Approximation $_G
static final Approximation $_au
static final int $PrecisionDouble
static final int $PrecisionFloat
| Constructor Detail |
public Approximation(double value,
double boundRel,
int model)
value - the closest known value to the quantity to be represented.boundRel - the relative error bound on the value.model - the error distribution model.
public Approximation(double value,
double boundRel)
value - the closest known value to the quantity to be represented.boundRel - the relative error bound on the value.public Approximation(double value)
value - the closest known value to the quantity to be represented.public Approximation(BaseNumber value)
value - the equivalent Approximation to value.protected Approximation()
| Method Detail |
public static Approximation valueOf(java.lang.String valueString)
throws PresentationException
valueString - The string representation of a double, optionally
followed by "*".
PresentationException - problem parsing valueString.
public static Approximation Parse(NumberPresentation presentation)
throws PresentationException
presentation - NumberPresentation representation of a fuzzy number.
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 the presentation cannot be parsed as a
Rational object.Character.digit(char, int)public void updateEstimate()
updateEstimate in interface Estimablepublic double getEstimate()
getEstimate in interface Estimablepublic Divisible scaled(double factor)
scaled in interface Divisiblefactor - the scale factor.
public Divisible inverse()
inverse in interface Divisiblepublic Divisible quotient(BaseNumber divisor)
quotient in interface Divisibledivisor - the number to divide into this.
public double getBoundAbs()
getBoundAbs in class BaseNumberpublic double getBound()
getBound in interface FuzzygetBound in class BaseNumberpublic int getModel()
getModel in interface FuzzygetModel in class BaseNumberpublic boolean isExact()
isExact in interface FuzzyisExact in class BaseNumberpublic boolean isInteger()
isInteger in interface Arithmeticalprotected BaseNumber scaled(long factor)
scaled in class BaseNumberfactor - a long integer which is to be multiplied by this.
protected BaseNumber product(BaseNumber multiplicand)
product in class BaseNumbermultiplicand - the number to multiply into this.
public java.lang.String getIdentifier()
getIdentifier in interface Auditablepublic int intValue()
longValue().
intValue in class java.lang.Numberjava.lang.RuntimeException - the integer is out of range.public long longValue()
longValue in class java.lang.Numberjava.lang.RuntimeException - this is not equivalent to an long (i.e. not integral).protected BaseNumber sum(BaseNumber addend)
sum in class BaseNumberaddend - the number to add to this.
public int signum()
signum in interface Arithmeticalpublic double doubleValue()
doubleValue in class java.lang.Numberpublic boolean isInfinite()
isInfinite in interface Arithmeticalpublic java.lang.String audit(java.lang.String label)
audit in interface Auditablelabel - String: the label to associate with the data
public boolean isUnity()
isUnity in interface Arithmetical
public Presentation present(AttrMap attributes)
throws PresentationException
Presentable
present in interface Presentableattributes - the map of attributes required for the resulting
presentation.
PresentationException - if unable to parse appropriately.public Trigonometrical exp()
exp in interface Trigonometricalpublic Trigonometrical log()
log in interface Trigonometricaljava.lang.RuntimeException - if this is not positive.public Trigonometrical arctanX2(Approximation divisor)
divisor - the divisor of the value from which to take twice the arctangent.
public Trigonometrical arctanX2()
arctanX2 in interface Trigonometricalpublic Trigonometrical tan_theta_2()
tan_theta_2 in interface Trigonometricalprotected BaseNumber pow(int power)
pow in class BaseNumberpower - the power to which this must be raised.
public Presentable makePresentableInstance(Presentation presentation)
throws PresentationException
makePresentableInstance in interface Presentablepresentation - of a number to be converted into a Presentable number.
PresentationException - in case of parsing error.
PresentationExceptionpublic float floatValue()
floatValue in class java.lang.Numberprotected BaseNumber minus()
minus in class BaseNumberpublic java.lang.String toString()
toString in class BaseNumber
void test(java.io.PrintStream output,
java.lang.String name)
public static void main(java.lang.String[] args)
args - ignored.static double IntrinsicError(int halfplaces)
halfplaces - the number of significant half-places (must be positive).
static double IntrinsicError()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||