|
JScience v2.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavolution.realtime.RealtimeObject
org.jscience.mathematics.numbers.Number<Quantity>
org.jscience.physics.quantities.Quantity
public class Quantity
This class represents a measurable amount. The nature of the amount is deduced from the quantity unit. The quality of the measurement is given by the measurement error.
Errors (including numeric errors) are calculated using numeric intervals.
It is possible to resolve systems of linear equations involving physical
quantities (e.g. using Matrix),
even if the system is close to singularity; in which case the error
associated with some (or all) components of the solution may be large.
The decimal representations of quantities instances are indicative of
their precision as only digits guaranteed to be exact are written out.
For example, the string "2.000 km/s" represents a
Velocity of (2.0 ± 0.001) km/s.
Finally, operations between quantities may or may not be authorized
based upon the current PhysicalModel (e.g. adding a length to a duration is not allowed by the
StandardModel,
but is authorized with the RelativisticModel).
| Nested Class Summary | |
|---|---|
static class |
Quantity.Factory<Q extends Quantity>
This inner-class represents the factory producing quantity instances. |
| Nested classes/interfaces inherited from interface javolution.realtime.Realtime |
|---|
Realtime.ObjectSpace |
| Constructor Summary | |
|---|---|
protected |
Quantity()
Default constructor. |
| Method Summary | ||
|---|---|---|
boolean |
approxEquals(Quantity that)
Indicates if this quantity is approximately equals to the specified quantity (regardless of the quantity unit). |
|
int |
compareTo(Quantity that)
Compares this quantity with the specified quantity for order. |
|
Quantity |
divide(double divisor)
Returns this quantity divided by the specified divisor. |
|
double |
doubleValue()
Returns the estimated value stated in base units represented as a double. |
|
boolean |
equals(java.lang.Object obj)
Indicates if this quantity is strictly equals to the object specified (same amount and same system unit). |
|
double |
getAbsoluteError()
Returns the value by which the estimated value
may differ from the true value (all stated in base units). |
|
double |
getAmount()
Returns this quantity estimated amount stated in this quantity unit. |
|
double |
getMaximum()
Returns the maximum value for this quantity stated in base units. |
|
double |
getMinimum()
Returns the minimum value for this quantity stated in base units. |
|
double |
getRelativeError()
Returns the percentage by which the estimated amount may differ from the true amount. |
|
Unit |
getUnit()
Returns the unit identifying this quantity type; it is also the unit in which this quantity is displayed by default. |
|
int |
hashCode()
Returns a well distributed hash code value for this quantity. |
|
boolean |
isLargerThan(Quantity that)
Compares this quantity amount with that quantity amount ignoring the sign. |
|
long |
longValue()
Returns the estimated value stated in base units represented as a long. |
|
Quantity |
minus(Quantity that)
Returns the difference of this quantity with the one specified. |
|
Quantity |
norm()
Returns the magnitude (positive) of this quantity. |
|
Quantity |
opposite()
Returns the opposite of this quantity. |
|
Quantity |
plus(Quantity that)
Returns the sum of this quantity with the one specified. |
|
static
|
rangeOf(double minimum,
double maximum,
Unit<Q> unit)
Returns the quantity whose amount is in the specified range. |
|
Quantity |
reciprocal()
Returns the reciprocal of this quantity. |
|
Quantity |
root(int n)
Returns the given root of this quantity. |
|
Quantity |
sqrt()
Returns the square root of this quantity. |
|
Quantity |
times(double factor)
Returns this quantity multiplied by the specified factor. |
|
Quantity |
times(Quantity that)
Returns the product of this quantity with the one specified. |
|
|
to(Unit<Q> unit)
Returns the quantity equivalent to this quantity but stated using the specified unit. |
|
Text |
toText()
Returns the textual representation of this quantity. |
|
static
|
valueOf(java.lang.CharSequence csq)
Returns the quantity corresponding to the specified character sequence. |
|
static
|
valueOf(double amount,
double error,
Unit<Q> unit)
Returns the quantity of specified amount and measurement error. |
|
static
|
valueOf(double amount,
Unit<Q> unit)
Returns the quantity for the specified amount. |
|
| Methods inherited from class org.jscience.mathematics.numbers.Number |
|---|
abs, byteValue, divide, floatValue, intValue, inverse, isGreaterThan, isLessThan, pow, shortValue |
| Methods inherited from class javolution.realtime.RealtimeObject |
|---|
export, move, moveHeap, preserve, recycle, toString, unpreserve |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface javolution.realtime.Realtime |
|---|
move |
| Constructor Detail |
|---|
protected Quantity()
| Method Detail |
|---|
public static <Q extends Quantity> Q valueOf(java.lang.CharSequence csq)
Quantity.valueOf("1.2 GeV")
returns an Energy instance.
csq - the character sequence.
QuantityFormat.current().parse(csq)
java.lang.IllegalArgumentException - if the specified character sequence
cannot be parsed.QuantityFormat
public static <Q extends Quantity> Q valueOf(double amount,
Unit<Q> unit)
Quantity.valueOf(30, NonSI.FOOT)returns a
Length instance.
amount - the estimated amount (± 1/2 LSB).unit - the amount's unit.
public static <Q extends Quantity> Q valueOf(double amount,
double error,
Unit<Q> unit)
Quantity.valueOf(20, 0.1, SI.KILO(SI.HERTZ))returns a
Frequency instance.
amount - the estimated amount (± error).error - the measurement error (absolute).unit - the amount's unit.
public static <Q extends Quantity> Q rangeOf(double minimum,
double maximum,
Unit<Q> unit)
minimum - the lower bound for the quantity amount.maximum - the upper bound of the quantity amount.unit - the bounds unit.
public double getAmount()
unit.
public Unit getUnit()
public final double getMinimum()
public final double getMaximum()
public final double getAbsoluteError()
estimated value
may differ from the true value (all stated in base units).
public final double getRelativeError()
public final <Q extends Quantity> Q to(Unit<Q> unit)
unit - the unit of the quantity being returned.
ConversionException - if the current model does not allows for
conversion to the specified unit.public final Quantity opposite()
-this.
public final Quantity plus(Quantity that)
throws ConversionException
that - the quantity to be added.
this + that.
ConversionException - if the current model does not allows for
these quantities to be added.
public final Quantity minus(Quantity that)
throws ConversionException
minus in class Number<Quantity>that - the quantity to be subtracted.
this - that.
ConversionException - if the current model does not allows for
these quantities to be subtracted.public final Quantity times(double factor)
factor - the multiplier.
this * factor.public final Quantity times(Quantity that)
that - the quantity multiplier.
this * that.public final Quantity reciprocal()
1 / this.public final Quantity divide(double divisor)
divisor - the divisor.
this / divisor.public final Quantity sqrt()
sqrt(this)public final Quantity root(int n)
n - the root's order (n >= 0).
java.lang.ArithmeticException - if n == 0.public final Quantity norm()
|this|.public final boolean isLargerThan(Quantity that)
that - the numeric to be compared with.
|this| > |that|public boolean equals(java.lang.Object obj)
Note: Unlike approxEquals(org.jscience.physics.quantities.Quantity), this method does not take into
account possible errors (e.g. numeric errors).
equals in class java.lang.Objectobj - the object to compare with.
true if this quantity and the specified object
represent the exact same quantity; false otherwise.public int hashCode()
hashCode in class java.lang.Objectequals(java.lang.Object)public boolean approxEquals(Quantity that)
that - the quantity to compare with.
this ≊ that.public int compareTo(Quantity that)
compareTo in interface java.lang.Comparable<Quantity>compareTo in class Number<Quantity>that - the quantity to be compared.
ConversionException - if the current model does not allows for
these quantities to be compared.Unit.isCompatible(org.jscience.physics.units.Unit)public Text toText()
toText in interface RealtimetoText in class RealtimeObjectQuantityFormatpublic final long longValue()
long.
longValue in class Number<Quantity>long.public final double doubleValue()
double.
doubleValue in class Number<Quantity>double.
|
JScience v2.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||