Thread: [Mathlib-commitlog] SF.net SVN: mathlib:[608] JMathLib/trunk/src/jmathlib/core/tokens/ VariableToke
Status: Beta
Brought to you by:
st_mueller
|
From: <st_...@us...> - 2009-01-04 08:48:40
|
Revision: 608
http://mathlib.svn.sourceforge.net/mathlib/?rev=608&view=rev
Author: st_mueller
Date: 2009-01-04 08:48:35 +0000 (Sun, 04 Jan 2009)
Log Message:
-----------
added the euler number "e"
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/tokens/VariableToken.java
Modified: JMathLib/trunk/src/jmathlib/core/tokens/VariableToken.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/tokens/VariableToken.java 2009-01-04 08:48:03 UTC (rev 607)
+++ JMathLib/trunk/src/jmathlib/core/tokens/VariableToken.java 2009-01-04 08:48:35 UTC (rev 608)
@@ -162,8 +162,11 @@
if (name.equals("eps"))
return new DoubleNumberToken(2.2204e-016);
+
+ if (name.equals("e"))
+ return new DoubleNumberToken(2.718281828459046);
+
-
ErrorLogger.debugLine("VariableToken: var " + name + " not found: check functions");
// If it is not a variable maybe it's a function or script-file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2009-01-05 15:08:34
|
Revision: 622
http://mathlib.svn.sourceforge.net/mathlib/?rev=622&view=rev
Author: st_mueller
Date: 2009-01-05 15:08:24 +0000 (Mon, 05 Jan 2009)
Log Message:
-----------
changed handling of global variables
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/tokens/VariableToken.java
Modified: JMathLib/trunk/src/jmathlib/core/tokens/VariableToken.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/tokens/VariableToken.java 2009-01-05 15:06:37 UTC (rev 621)
+++ JMathLib/trunk/src/jmathlib/core/tokens/VariableToken.java 2009-01-05 15:08:24 UTC (rev 622)
@@ -151,7 +151,7 @@
return ((MathLibObject)getVariable(name).getData()).getFieldData(fieldName);
//}
}
- else if( !getVariables().isVariable(name) )
+ else if( getVariable(name) == null )
{
// variable is not yet defined (e.g. user typed sin(a) and "a" is unknown)
// or it is a function
@@ -248,7 +248,7 @@
{
ErrorLogger.debugLine("Variable data = NULL");
- /* display the result of this variable in the user console*/
+ // display the result of this variable in the user console
if (isDisplayResult())
getInterpreter().displayText(name +" = []");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2009-01-25 21:01:14
|
Revision: 776
http://mathlib.svn.sourceforge.net/mathlib/?rev=776&view=rev
Author: st_mueller
Date: 2009-01-25 21:01:09 +0000 (Sun, 25 Jan 2009)
Log Message:
-----------
changed signature of evaluate(Token[] operands)
to
evaluate(Token[] operands, GlobalValues globals)
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/tokens/VariableToken.java
Modified: JMathLib/trunk/src/jmathlib/core/tokens/VariableToken.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/tokens/VariableToken.java 2009-01-25 21:00:19 UTC (rev 775)
+++ JMathLib/trunk/src/jmathlib/core/tokens/VariableToken.java 2009-01-25 21:01:09 UTC (rev 776)
@@ -25,8 +25,7 @@
/**Boolean indicator if limits are active */
private boolean limitSwitch = false;
- /** true if e.g. a{8}...
- * */
+ /** true if e.g. a{8}... */
private boolean cellB = false;
/**constructor containing the variables name
@@ -133,10 +132,11 @@
/**@return the value of the data held within the variable
if the variable has not been inisitalised then it returns the variable*/
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
ErrorLogger.debugLine("VariableToken: eval: " + name);
-
+ //ErrorLogger.debugLine("VariableToken: evalG: " + globals);
+
// Check if variable is defined (in object storage)
if(fieldName != null)
{
@@ -148,10 +148,10 @@
//else
//{
ErrorLogger.debugLine("VariableToken: " + name + "getting field " + fieldName);
- return ((MathLibObject)getVariable(name).getData()).getFieldData(fieldName);
+ return ((MathLibObject)globals.getVariable(name).getData()).getFieldData(fieldName);
//}
}
- else if( getVariable(name) == null )
+ else if( globals.getVariable(name) == null )
{
// variable is not yet defined (e.g. user typed sin(a) and "a" is unknown)
// or it is a function
@@ -172,7 +172,7 @@
// If it is not a variable maybe it's a function or script-file
FunctionToken function = new FunctionToken(name, limitTokens);
function.setOperands(new OperandToken[] {});
- OperandToken retValue = function.evaluate(null);
+ OperandToken retValue = function.evaluate(null, globals);
// if the "function" is really a script it won't return anything
if (function.isScript())
@@ -196,12 +196,12 @@
// variable is defined already/now
// get data of variable
- OperandToken variableData = getVariable(name).getData();
+ OperandToken variableData = globals.getVariable(name).getData();
// check if data is available
if(variableData != null)
{
- ErrorLogger.debugLine("Variable data = " + variableData.toString());
+ ErrorLogger.debugLine("VariableToken data = " + variableData.toString());
// clone data so that original values are not changed
variableData = ((OperandToken)variableData.clone());
@@ -219,7 +219,7 @@
//ErrorLogger.debugLine(i);
// clone limits functions/values to preserve for future evalutation
opTok[i+1] = ((OperandToken)limitTokens[i].clone());
- opTok[i+1] = opTok[i+1].evaluate(null);
+ opTok[i+1] = opTok[i+1].evaluate(null, globals);
if (opTok[i+1] != null)
ErrorLogger.debugLine("VariableToken: eval: toString("+i+") "+opTok[i+1].toString());
@@ -234,14 +234,14 @@
}
// create instance of external function SubMatix and compute submatrix
- result = subM.evaluate(opTok);
+ result = subM.evaluate(opTok, globals);
}
/* display the result of this variable in the user console*/
if (isDisplayResult())
- getInterpreter().displayText(name +" = "+ result.toString());
-
+ globals.getInterpreter().displayText(name +" = "+ result.toString(globals));
+
return result;
}
else
@@ -250,7 +250,7 @@
// display the result of this variable in the user console
if (isDisplayResult())
- getInterpreter().displayText(name +" = []");
+ globals.getInterpreter().displayText(name +" = []");
return null;
}
@@ -297,14 +297,14 @@
}
/**return the data of the variable*/
- public OperandToken getData()
+/* public OperandToken getData()
{
if(fieldName == null)
return getVariable(name).getData();
else
return ((MathLibObject)getVariable(name).getData()).getFieldData(fieldName);
}
-
+*/
public boolean equals(Object obj)
{
if(obj instanceof VariableToken)
@@ -319,7 +319,7 @@
/**Checks if this operand is a numeric value
@return true if this is a number, false if it's
an algebraic expression*/
- public boolean isNumeric()
+/* public boolean isNumeric()
{
boolean numeric = false;
OperandToken data = null;
@@ -330,6 +330,7 @@
return numeric;
}
+ */
/**
* check if variable is a struct
@@ -354,13 +355,13 @@
}
/**get the variable that this token references*/
- public Variable getVariable()
+ public Variable getVariable(GlobalValues globals)
{
if(fieldName == null)
- return getVariable(name);
+ return globals.getVariable(name);
- if(getVariable(name)!=null)
- return ((MathLibObject)getVariable(name).getData()).getFieldVariable(fieldName);
+ if(globals.getVariable(name)!=null)
+ return ((MathLibObject)globals.getVariable(name).getData()).getFieldVariable(fieldName);
return null;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|