edu.isi.stella.utilities
Class DimNumber

java.lang.Object
  extended by edu.isi.stella.Stella_Object
      extended by edu.isi.stella.Quantity
          extended by edu.isi.stella.utilities.DimNumber

public class DimNumber
extends Quantity


Field Summary
 double magnitude
           
 Ratio pid
           
 java.lang.String preferredUnits
           
 
Constructor Summary
DimNumber()
           
 
Method Summary
 DimNumber absoluteValue()
          Computes abs(x)
static Stella_Object accessDimNumberSlotValue(DimNumber self, Symbol slotname, Stella_Object value, boolean setvalueP)
           
 DimNumber add(DimNumber y)
          Computes x + y
 Quantity coerceTo(Stella_Object y)
          Coerces y to be a compatible type with x.
static boolean compatibleUnitsP(DimNumber x, DimNumber y)
          Returns TRUE if the units of x and y are compatible.
static Cons degreesToDms(DimNumber d)
          Convert decimal degrees to a list of (Degree Minute Second) where Degree and Minute are integer-valued.
static TimeDuration dimToTimeDuration(DimNumber timeValue)
          Converts the dimensioned number timeValue to its equivalent value as a timeDuration object.
 DimNumber divide(DimNumber y)
          Computes x / y
 DimNumber exponentiate(int y)
          Computes x ^ y
 java.lang.String formatDimNumber(java.lang.String units, int decimals)
          Returns a string representation of x in units with decimals digits.
 Cons getBaseMeasures(java.lang.Object[] MV_returnarray)
          Returns cons of the base measures for the numerator and denominator of self.
 java.lang.String getBaseUnit()
          Returns the base units for the dim number.
 double getMagnitude(java.lang.String units)
          Returns the magnitude of the dim number in the given units.
 Measure getMeasure()
          Returns the measure for the dim number, if one is defined.
 java.lang.String getUnit()
          Returns the units for the dim number.
 boolean greaterEqualP(Stella_Object y)
          Computes x >= y
 boolean greaterP(Stella_Object y)
          Computes x > y
 int hashCode_()
          Return a hash code for self (can be negative).
static Cons hoursToHms(DimNumber d)
          Convert decimal hours to a list of (Hour Minute Second) where Hour and Minute are integer-valued.
 DimNumber invert()
          Computes 1 / x
 boolean lessEqualP(Stella_Object y)
          Computes x <= y
 boolean lessP(Stella_Object y)
          Computes x < y
static DimNumber makeDimNumber(double magnitude, java.lang.String units)
           
 DimNumber modulus(DimNumber y)
          Computes the modulus of x and y.
 DimNumber multiply(DimNumber y)
          Computes x * y
 DimNumber negate()
          Computes - x
static DimNumber newDimNumber(Ratio pid, double magnitude)
           
 boolean objectEqlP(Stella_Object y)
           
static DimNumber parseDimNumber(java.lang.String input)
           
 Surrogate primaryType()
          Returns the primary type of self.
 void printObject(java.io.PrintStream stream)
           
 int signum()
          Computes the signum of x: -1 if negative, 0 if zero, 1 if positive
 DimNumber squareRoot()
          Computes the positive square root of x, assuming the units are perfect squares
 DimNumber subtract(DimNumber y)
          Computes x - y
 
Methods inherited from class edu.isi.stella.Stella_Object
_, accessInContext, amPm, anchoredTypeSpecifierP, andOrNotTreeP, applyCoercionMethod, atomicExpressionP, bindToSurrogateP, booleanP, bootstrapIsaP, bquotify, cast, characterP, clTranslateAtomicTree, clTranslateATree, clTranslateBooleanTest, clTranslatePlainBooleanTest, clTranslateVerbatimBodySymbols, clYieldTypedExpressionTree, coerceATree, coerceEvaluatedTree, coerceMvTree, coerceToBoolean, coerceToModule, coerceToModuleName, coerceToSymbol, coerceToXmlElement, coercibleP, collectFeatureList, collectKeyValueList, commonLispSymbolP, computeExpressionType, cons, consify, consifyListsAndIterators, consP, consTreeMatchP, convertToLiteral, copyConsTree, cppArgumentIsStreamP, cppBinaryOperatorP, cppBlockP, cppMaybeOutputStatementWithParentheses, cppOperatorP, cppOutputAtomicExpression, cppOutputLiteral, cppOutputOneActualParameter, cppOutputStatement, cppOutputTypedEntity, cppPrognifyStatement, cppPrognP, cppStatementToList, cppStreamIsStandardOutputP, cpptrans, cppTranslateAtomicTree, cppTranslateATree, cppTranslatedArrayTypeP, csValueP, dateDivider, dateTimeDivider, day, dealWithAmPm, dealWithEra, dealWithNoonMidn, decrementReferenceCount, defaultOptionHandler, defineSystem, defmodule, deletedP, describe, describeObject, describeTersely, destructureMethodNameTree, deUglifyParseTree, either, eqlP, eqlToBooleanP, eqlToCharacterP, eqlToFloatP, eqlToIntegerP, eqlToStringP, equalConsTreesP, equalHashCode, equalP, era, estimatedEvaluationCost, evaluate, evaluateArgumentTree, evaluateAtomicTree, evaluateCommand, expandBquoteTree, filterModuleP, floatP, free, get, getObject, hashlist, hashMemoizedArguments, helpBquotify, helpClTranslateATree, helpCoerceATree, helpLptrans, helpPrintOutline, helpTransformBooleanProceduralExpression, helpWalkATree, homeModule, hour, idlOutputAtomicExpression, idlOutputLiteral, idlOutputStatement, idlTranslateAtomicTree, idlTranslateATree, illegalTreeP, implodePathname, incrementallyTranslate, incrementReferenceCount, inlineUnwrapBoolean, inlineWrapBoolean, inModule, integerP, isaP, javaBinaryOperatorP, javaBlockP, javaEndOfLineTokenP, javaHelpOutputPrintStream, javaMaybeOutputStatementWithParentheses, javaOperatorP, javaOutputLiteral, javaOutputStatement, javaPrognP, javaStreamIsStandardOutputP, javaSymbolCaseP, javaTranslateAtomicTree, javaTranslateATree, javaTranslateWithNativeWrapper, jptrans, keywordP, kvCons, legalTokenizerFromStateP, legalTokenizerStateP, legalTokenizerToStateP, literalEqlP, logLevelLE, lptrans, makeFileNameFromRelativePath, makeMemoizedValueEntry, makeMemoizedValueEntryn, matchConsTree, methodSlotP, minute, month, nameToString, nilP, noonMidn, numberWrapperToFloat, objectEqualP, objectHashCode, one, oneI, onlyIf, parametricTypeSpecifierP, parseArrayDimensionsSpec, parseTokenizerCharacterSpec, parseTokenizerStateModifiers, permanentCopy, permanentify, permanentifyForm, po, prettyPrintLiteral, primaryClass, printOutline, printStellaCode, printStellaDefinition, printUndefinedSuperClasses, proceduralExpressionP, ptrans, publicSlots, registerRecycledItem, runOptionHandlerP, safeEqualHashCode, safeHashCode, safePrimaryType, safeYieldTypeSpecifier, searchConsTreeP, searchConsTreeWithFilterP, searchForObject, secondp, sideEffectFreeExpressionP, simplifyBquoteTree, specialp, standardObjectP, stella_Increment, stellaClassP, stellaCollectionP, stellaNeedToCompileP, stellaNeedToTranslateP, stellaObjectP, stellify, storageSlotP, stringifyInModule, stringP, substituteConsTree, substituteOnce, surrogateP, surrogatify, sweep, symbolCaseP, symbolP, sysTree, targetLanguageType, taxonomyIsaP, timeDivider, timeMultiply, tokenizerIncludeSpecP, tokenizerToStateAlias, tokenizerToStateName, toString, traceIf, traceKeywordP, transientifyForm, transientObjectP, transientSymbolP, translateWalkedTree, treeSize, treeToTrees, trueOptionP, tryToEvaluate, typeP, typify, unmake, unregisterRecycledItem, updateInContext, valuesTreeP, variableExpressionP, verbatimStringP, verbatimTreeP, vetOptions, vrletExpressionP, walkAtomicTree, walkATree, walkCollectionTree, walkDontCallMeTree, walkedExpressionType, walkExpressionTree, walkMvExpressionTree, walkMvTree, walkStatement, walkTopLevelExpression, walkWithoutTypeTree, warnAboutUnknownSourceType, weekday, withinContext, withinModule, withinWorld, withStellaTokenizer, withSystemDefinition, withTokenizer, wrapperP, wrapWhereTest, xmlAttributeP, xmlCdataFormP, xmlCdataP, xmlDeclarationFormP, xmlDeclarationP, xmlDoctypeFormP, xmlElementFormP, xmlElementP, xmlnsAttributeP, xmlProcessingInstructionFormP, xmlProcessingInstructionP, xmlTagCase, year, yieldCondTest, yieldCondTestOrTests, yieldHardcodedCaseSymbolIdOrIds, yieldInCursorClausesForArgumentList, yieldInCursorClausesForGeneralCollection, yieldInCursorClausesForVector, yieldTypeSpecifier, zone, zoneMinute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pid

public Ratio pid

magnitude

public double magnitude

preferredUnits

public java.lang.String preferredUnits
Constructor Detail

DimNumber

public DimNumber()
Method Detail

parseDimNumber

public static DimNumber parseDimNumber(java.lang.String input)

makeDimNumber

public static DimNumber makeDimNumber(double magnitude,
                                      java.lang.String units)

newDimNumber

public static DimNumber newDimNumber(Ratio pid,
                                     double magnitude)

hoursToHms

public static Cons hoursToHms(DimNumber d)
Convert decimal hours to a list of (Hour Minute Second) where Hour and Minute are integer-valued.

Parameters:
d -
Returns:
Cons

degreesToDms

public static Cons degreesToDms(DimNumber d)
Convert decimal degrees to a list of (Degree Minute Second) where Degree and Minute are integer-valued.

Parameters:
d -
Returns:
Cons

dimToTimeDuration

public static TimeDuration dimToTimeDuration(DimNumber timeValue)
Converts the dimensioned number timeValue to its equivalent value as a timeDuration object. If timeValue is not of the appropriate units, an incompatibleUnitsException is thrown.

Parameters:
timeValue -
Returns:
TimeDuration

greaterP

public boolean greaterP(Stella_Object y)
Computes x > y

Overrides:
greaterP in class Quantity
Parameters:
y -
Returns:
boolean

greaterEqualP

public boolean greaterEqualP(Stella_Object y)
Computes x >= y

Overrides:
greaterEqualP in class Quantity
Parameters:
y -
Returns:
boolean

lessEqualP

public boolean lessEqualP(Stella_Object y)
Computes x <= y

Overrides:
lessEqualP in class Quantity
Parameters:
y -
Returns:
boolean

lessP

public boolean lessP(Stella_Object y)
Computes x < y

Overrides:
lessP in class Quantity
Parameters:
y -
Returns:
boolean

exponentiate

public DimNumber exponentiate(int y)
Computes x ^ y

Parameters:
y -
Returns:
DimNumber

squareRoot

public DimNumber squareRoot()
Computes the positive square root of x, assuming the units are perfect squares

Returns:
DimNumber

absoluteValue

public DimNumber absoluteValue()
Computes abs(x)

Returns:
DimNumber

invert

public DimNumber invert()
Computes 1 / x

Returns:
DimNumber

negate

public DimNumber negate()
Computes - x

Returns:
DimNumber

modulus

public DimNumber modulus(DimNumber y)
Computes the modulus of x and y. x and y must be compatible units, and the result has the preferred units of x.

Parameters:
y -
Returns:
DimNumber

divide

public DimNumber divide(DimNumber y)
Computes x / y

Parameters:
y -
Returns:
DimNumber

multiply

public DimNumber multiply(DimNumber y)
Computes x * y

Parameters:
y -
Returns:
DimNumber

subtract

public DimNumber subtract(DimNumber y)
Computes x - y

Parameters:
y -
Returns:
DimNumber

add

public DimNumber add(DimNumber y)
Computes x + y

Parameters:
y -
Returns:
DimNumber

signum

public int signum()
Computes the signum of x: -1 if negative, 0 if zero, 1 if positive

Returns:
int

hashCode_

public int hashCode_()
Description copied from class: Stella_Object
Return a hash code for self (can be negative). Two objects that are eqlP are guaranteed to generate the same hash code. Two objects that are not eqlP do not necessarily generate different hash codes.

Overrides:
hashCode_ in class Stella_Object
Returns:
int

objectEqlP

public boolean objectEqlP(Stella_Object y)
Overrides:
objectEqlP in class Stella_Object

compatibleUnitsP

public static boolean compatibleUnitsP(DimNumber x,
                                       DimNumber y)
Returns TRUE if the units of x and y are compatible.

Parameters:
x -
y -
Returns:
boolean

formatDimNumber

public java.lang.String formatDimNumber(java.lang.String units,
                                        int decimals)
Returns a string representation of x in units with decimals digits.

Parameters:
units -
decimals -
Returns:
String

getBaseMeasures

public Cons getBaseMeasures(java.lang.Object[] MV_returnarray)
Returns cons of the base measures for the numerator and denominator of self.

Parameters:
MV_returnarray -
Returns:
Cons

getMeasure

public Measure getMeasure()
Returns the measure for the dim number, if one is defined.

Returns:
Measure

getBaseUnit

public java.lang.String getBaseUnit()
Returns the base units for the dim number.

Returns:
String

getUnit

public java.lang.String getUnit()
Returns the units for the dim number. This will return the preferred output units if they exist, otherwise the base units. (see getBaseUnit)

Returns:
String

getMagnitude

public double getMagnitude(java.lang.String units)
Returns the magnitude of the dim number in the given units.

Parameters:
units -
Returns:
double

coerceTo

public Quantity coerceTo(Stella_Object y)
Coerces y to be a compatible type with x. If this isn't possible, an exception is thrown. The exception will be either INCOMPATIBLE-QUANTITY-EXCEPTION or INCOMPATIBLE-UNITS-EXCEPTION.

Overrides:
coerceTo in class Quantity
Parameters:
y -
Returns:
Quantity

printObject

public void printObject(java.io.PrintStream stream)
Overrides:
printObject in class Stella_Object

accessDimNumberSlotValue

public static Stella_Object accessDimNumberSlotValue(DimNumber self,
                                                     Symbol slotname,
                                                     Stella_Object value,
                                                     boolean setvalueP)

primaryType

public Surrogate primaryType()
Description copied from class: Stella_Object
Returns the primary type of self. Gets defined automatically for every non-abstract subclass of OBJECT.

Overrides:
primaryType in class Stella_Object
Returns:
Surrogate