edu.isi.stella.utilities
Class Ratio

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

public class Ratio
extends Quantity


Field Summary
 int denominator
           
 int numerator
           
 
Constructor Summary
Ratio()
           
 
Method Summary
static Stella_Object accessRatioSlotValue(Ratio self, Symbol slotname, Stella_Object value, boolean setvalueP)
           
 Ratio add(Ratio y)
           
 Quantity coerceTo(Stella_Object y)
          Coerces y to be a compatible type with x.
static Cons computeMeasuresForPrimeId(Ratio pid, java.lang.Object[] MV_returnarray)
          Returns two CONSes of Measure objects for the prime ID pid
static java.lang.String computeUnitsForPrimeId(Ratio pid)
           
 Ratio divide(Ratio y)
           
 Ratio exponentiate(int y)
           
 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).
 Ratio invert()
           
 boolean lessEqualP(Stella_Object y)
          Computes x <= y
 boolean lessP(Stella_Object y)
          Computes x < y
static Ratio makeRatio(int num, int denom)
           
 Ratio multiply(Ratio y)
           
 Ratio negate()
           
static Ratio newRatio(int numerator, int denominator)
           
 boolean objectEqlP(Stella_Object y)
           
 Surrogate primaryType()
          Returns the primary type of self.
 void printObject(java.io.PrintStream stream)
           
 Ratio subtract(Ratio 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

numerator

public int numerator

denominator

public int denominator
Constructor Detail

Ratio

public Ratio()
Method Detail

makeRatio

public static Ratio makeRatio(int num,
                              int denom)

newRatio

public static Ratio newRatio(int numerator,
                             int denominator)

computeUnitsForPrimeId

public static java.lang.String computeUnitsForPrimeId(Ratio pid)

computeMeasuresForPrimeId

public static Cons computeMeasuresForPrimeId(Ratio pid,
                                             java.lang.Object[] MV_returnarray)
Returns two CONSes of Measure objects for the prime ID pid

Parameters:
pid -
MV_returnarray -
Returns:
Cons

exponentiate

public Ratio exponentiate(int y)

invert

public Ratio invert()

negate

public Ratio negate()

divide

public Ratio divide(Ratio y)

multiply

public Ratio multiply(Ratio y)

subtract

public Ratio subtract(Ratio y)

add

public Ratio add(Ratio y)

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

objectEqlP

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

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

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

printObject

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

accessRatioSlotValue

public static Stella_Object accessRatioSlotValue(Ratio 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