com.rubecula.math
Class Mill
java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
java.util.Vector
java.util.Stack
com.rubecula.jquantity.Mill
com.rubecula.math.Mill
- All Implemented Interfaces:
- Auditable, java.lang.Cloneable, java.util.Collection, Identifiable, java.util.List, Lookupable, MillInterface, java.util.RandomAccess, java.io.Serializable
- public class Mill
- extends Mill
This class extends the JQuantity Mill to be useful for general mathematical
functions.
In particular, it has a set of macros which are indexed by a set of operations and which can
be used to implement more complex mathematics than the base class.
- Since:
- V_0_2
- Version:
- $Revision: 1.12 $
- Author:
- Robin Hillyard
- See Also:
,
Serialized Form
Nested classes inherited from class java.util.AbstractList |
|
Field Summary |
private StringMap |
_Macros
This is the table of macro definitions, that is to say non-native
operations which are enabled using compounds of other operations. |
private AlphabeticalMap |
_Operations
This is the table of operations supported by this mill (in addition to
base class). |
private static java.lang.String |
K_LOG10_E
|
private static java.lang.String |
OP_COS
|
private static java.lang.String |
OP_COSH
|
private static java.lang.String |
OP_COT
|
private static java.lang.String |
OP_COTH
|
private static java.lang.String |
OP_CSC
|
private static java.lang.String |
OP_CSCH
|
private static java.lang.String |
OP_LOG10
|
private static java.lang.String |
OP_SEC
|
private static java.lang.String |
OP_SECH
|
private static java.lang.String |
OP_SIN
|
private static java.lang.String |
OP_SINH
|
private static java.lang.String |
OP_TAN
|
private static java.lang.String |
OP_TANH
|
Fields inherited from class com.rubecula.jquantity.Mill |
CONSTANTS, K__1, K_0, K_1, K_10, K_2, K_3, K_E, K_MEM, K_PI, OP_2ATAN, OP_AUDIT, OP_CHS, OP_COPY, OP_DIFFERENCE, OP_E, OP_EXP, OP_INV, OP_LOG, OP_NOOP, OP_PI, OP_POWER, OP_PRODUCT, OP_QUOTIENT, OP_SUM, OP_SWAP, OP_TANHALF |
Fields inherited from class java.util.Stack |
|
Fields inherited from class java.util.Vector |
capacityIncrement, elementCount, elementData |
Fields inherited from class java.util.AbstractList |
modCount |
Constructor Summary |
Mill(java.lang.String name)
|
Method Summary |
void |
addConstants(Lookupable table)
MUTATING method to add a table of constants.
|
void |
addMacro(java.lang.String name,
Macro expansion)
|
private void |
addMacro(java.lang.String name,
java.lang.String[] operations)
|
private void |
addMacro(java.lang.String name,
java.lang.String first,
java.lang.String second)
|
AlphabeticalMap |
getOperations()
Method to get a map which represents the supported functions of this
Mill. |
private void |
initOperations()
|
private void |
loadMacros()
|
static void |
main(java.lang.String[] args)
Main method for testing this class. |
void |
operate(Macro operator)
|
void |
operate(java.lang.String operator)
Mutating method to apply the operation operator to the stack.
|
Methods inherited from class com.rubecula.jquantity.Mill |
addConstant, audit, audit, audit, getAdy, getIdentifier, getKeys, getValue, help, lookupOperator, push, setValue |
Methods inherited from class java.util.Stack |
empty, peek, pop, push, search |
Methods inherited from class java.util.Vector |
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize |
Methods inherited from class java.util.AbstractList |
iterator, listIterator, listIterator |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
iterator, listIterator, listIterator |
_Operations
private AlphabeticalMap _Operations
- This is the table of operations supported by this mill (in addition to
base class). Keys are abbreviated operators; Entries are formal
definitions.
_Macros
private final StringMap _Macros
- This is the table of macro definitions, that is to say non-native
operations which are enabled using compounds of other operations.
OP_SIN
private static final java.lang.String OP_SIN
- See Also:
- Constant Field Values
OP_COS
private static final java.lang.String OP_COS
- See Also:
- Constant Field Values
OP_TAN
private static final java.lang.String OP_TAN
- See Also:
- Constant Field Values
OP_COT
private static final java.lang.String OP_COT
- See Also:
- Constant Field Values
OP_SEC
private static final java.lang.String OP_SEC
- See Also:
- Constant Field Values
OP_CSC
private static final java.lang.String OP_CSC
- See Also:
- Constant Field Values
OP_COSH
private static final java.lang.String OP_COSH
- See Also:
- Constant Field Values
OP_SINH
private static final java.lang.String OP_SINH
- See Also:
- Constant Field Values
OP_TANH
private static final java.lang.String OP_TANH
- See Also:
- Constant Field Values
OP_SECH
private static final java.lang.String OP_SECH
- See Also:
- Constant Field Values
OP_CSCH
private static final java.lang.String OP_CSCH
- See Also:
- Constant Field Values
OP_COTH
private static final java.lang.String OP_COTH
- See Also:
- Constant Field Values
OP_LOG10
private static final java.lang.String OP_LOG10
- See Also:
- Constant Field Values
K_LOG10_E
private static final java.lang.String K_LOG10_E
- See Also:
- Constant Field Values
Mill
public Mill(java.lang.String name)
addConstants
public void addConstants(Lookupable table)
- MUTATING method to add a table of constants.
All entries in the table are Presentables.
If an entry proves to be a Macro then it is added as a Macro.
- Specified by:
addConstants
in interface MillInterface
- Overrides:
addConstants
in class Mill
- Parameters:
table
- the set of constants to be added.
operate
public void operate(java.lang.String operator)
throws java.util.EmptyStackException,
MillException
Mutating method to apply the operation operator to the stack.
The number of items required on the stack prior to the operation and the
number of items left on the stack afterwards depends upon the operation.
- Specified by:
operate
in interface MillInterface
- Overrides:
operate
in class Mill
- Parameters:
operator
- the name for the operation. For the operators supported by
the superclass, see
Mill.operate(String)
. The
following operators are additionally supported by this Mill:
- cos
- Pop the stack and push its cosine.
- sin
- Pop the stack and push its sine.
- tan
- Pop the stack and push its tangent.
- cot
- Pop the stack and push its cotangent.
- sec
- Pop the stack and push its secant.
- csc
- Pop the stack and push its cosecant.
- cosh
- Pop the stack and push its hyperbolic cosine.
- sinh
- Pop the stack and push its hyperbolic sine.
- tanh
- Pop the stack and push its hyperbolic tangent.
- sech
- Pop the stack and push its hyperbolic secant.
- csch
- Pop the stack and push its hyperbolic cosecant.
- coth
- Pop the stack and push its hyperbolic cotangent.
- log10
- Pop the stack and push its Napierian logarithm (log to
base 10).
- Throws:
java.util.EmptyStackException
MillException
operate
public void operate(Macro operator)
throws java.util.EmptyStackException,
MillException
- Throws:
java.util.EmptyStackException
MillException
addMacro
public void addMacro(java.lang.String name,
Macro expansion)
throws MillException
- Throws:
MillException
addMacro
private void addMacro(java.lang.String name,
java.lang.String first,
java.lang.String second)
throws MillException
- Throws:
MillException
addMacro
private void addMacro(java.lang.String name,
java.lang.String[] operations)
throws MillException
- Throws:
MillException
getOperations
public AlphabeticalMap getOperations()
- Method to get a map which represents the supported functions of this
Mill. The keys are the operators (typically abbreviations, all lower
case) and the entries are the full mathematical function names (all
lower case).
- Specified by:
getOperations
in interface MillInterface
- Overrides:
getOperations
in class Mill
- Returns:
- a map of the abbreviation-function mappings for the supported
operations of this mill.
loadMacros
private void loadMacros()
initOperations
private void initOperations()
main
public static void main(java.lang.String[] args)
- Description copied from class:
Mill
- Main method for testing this class.