|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.webcompmath.functions.NumMinMaxParser
public class NumMinMaxParser
The NumMinMaxParser class makes it possible to use numerical minimums and maximums, such as numMin(xx,0,5,xx^2) in a Parser. The numerical min or max psedu-function has four parameters: (1) The variable, which must be an identifier and should be different than other variables registered with the parser; (2) The lower limit for the min/max, given as an expression (which can involve variables); (3) The upper limit for the min/max, given as an expression (which can involve variables); and (4) the expression over which to find the min or max. The expression in the fourth parameter can (and presumably will) use the variable (as well as other identifiers known to the parser).
The created psuedo function divides the interval into 1000 subintervals. It then checks the value of the derivative of the expression at the endpoints of each subinterval to see if a local minimum/maximum might be in the interval. If so, it hunts recursively for that local min/max, else it uses the min/max of the two subinterval endpoints. The function then returns the min/max of all 1000 subinterval min/max's.
To use numerical min with a Parser p, just say p.add(new NumMinMaxParser(NumMinParser.MIN)). It's unlikely that you will ever need to do anything else with NumMinMaxParsers. If you want to use a name other than "numMin" or "numMax", you can change the name after creating the NumMinMaxParser object but before adding it to a parser.
Nested Class Summary | |
---|---|
static class |
NumMinMaxParser.MinMaxType
The type of parser to create |
Constructor Summary | |
---|---|
NumMinMaxParser(NumMinMaxParser.MinMaxType t)
Constructor |
Method Summary | |
---|---|
void |
doParse(Parser parser,
ParserContext context)
When the name of this ParserExtension is encountered by a parser with which the extension is registered, the parser calls this routine to parse the subexpression. |
java.lang.String |
getName()
Get the name, which will be used in place of "numMin" or "numMax" in expressions. |
void |
setName(java.lang.String name)
Set the name, which will be used in place of "numMin" or "numMax" in expressions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NumMinMaxParser(NumMinMaxParser.MinMaxType t)
t
- the type, either MinMaxType.Min or MinMaxType.MaxMethod Detail |
---|
public void setName(java.lang.String name)
setName
in interface MathObject
name
- name of numerical min/maxpublic java.lang.String getName()
getName
in interface MathObject
public void doParse(Parser parser, ParserContext context)
doParse
in interface ParserExtension
parser
- parser to usecontext
- context to use
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |