Add new package which allows anonymous lambda functions to be defined in expressions x=>x^2
.
The package adds higher order like map
and fold
which take lambda functions
as arguments. It also adds a range operator [1..10]
for easily specifying a range of numbers.
POperator
equalsPNode()
and compareTo()
methods,
less critical as most expressions are represented as Polynomials and not POperators.
equals()
method to AbstractPNode
so it is consistent with compareTo()
.
Add hashCode()
methods for all subtypes.
MrpEval
when using expressions with more than
128 calls to binary functions which have non-scaler arguments.
Now support up to 32767 separate vector arguments and 32767 separate matrix arguments.
RationalDivisionPrintRule
which fixes bug with printing expressions with rational constants.
MrpeEval.setVarVal(ref,double[])
can set scaler variable to arrays of length 1.
Compare.process(Node node, Node children[])
now uses
the children[]
array rather than node.jjtGetChild()
.
This prevented any symbolic operations being applied before comparison.
DimensionVisitor
incorrectly calculated dimensions like id(2,3)
where the output dimensions depend on constant arguments.
Dimensions
class reworked to support vectors with 0 and 1 elements.
Now a vector with 1 element is distinguished from a Scaler. The constant ONE
and the method valueOf(int)
are deprecated. The constant
SCALER, EMPTY_VECTOR, ONE_ELEMENT_VECTOR should be used instead, and the methods
valueOfVecOrScaler(int)
and valueOfVec(int)
remove ambiguity.
The method valueOf(Dimensions,int)
was buggy and is now fixed. String representation changed to distinguish scalers from vectors.
The DoubleVector
and GenericVector
classes no allow zero length vectors.
The MatrixList
class turns empty lists into zero length vectors.
MrpeEval
now has facilities to make it easier to use in multiple
threads. The getLightWeightInstance()
returns a new instance which can
be safely used for evaluation in multiple threads. This has copies of internal
data so the evaluate(MrpCommandList)
can be used with
a given command list.
Instances created in this way lose information about Jep variable.
Variable values
can be accessed using the getVarValue(MrpVarRef ref)
and the various setVarValue(MrpVarRef ref, double d)
methods.
But method using Jep Variable
, i.e.
updateFromJepVariables()
, updateToJepVariables
getVariable(MrpVarRef ref)
getVarRef(String name)
getVarRef(Variable var)
, do not work.
The instance also lose information about the matrix factory used to convert
vector and matrix results. So the methods convertToVector(MrpRes res)
convertToMatrix(MrpRes res)
and convertResult(MrpRes res)
don't work. But you can use the MrpRes.copyToVec(VectorI)
,
MrpRes.copyToMat(MatrixI)
and other methods of MrpRes
.
A second method getLightWeightInstance(Jep jep)
uses the Variable and MatrixFactory information from the new Jep instance. So the above
methods are safe to use.
The RpEval
class has similar methods. With and instance created
using getLightWeightInstance()
variable values can be accessed
using getVarValue(int ref)
and setVarValue(int ref, double val)
.
When using getLightWeightInstance(Jep jep)
references can be found using
int getVarRef(Variable var)
int getVarRef(String name)
.
Add a chargeFunctionName(String oldname, String newname)
method to AbstractEval
allowing alternative names for built in functions.
Add a String toString(RpCommandList coms1)
to RpEval
to print a more detailed
version of a command list.
The RpEval
, MrpEval
, RpCommandList
, MrpCommandList
and related classes are all Serializable.
General
OperatorTable
and FunctionTable
classes to mirror Jep 4.0 release with
shallowCopy()
methods.
com.singularsys.extensions.xjep
Xjep.recursiveGetVarsInEquation()
to return a sorted list rather than a set.
Order will be in evaluation order.
TreeUtils
class treats Integers and Complex numbers representing real integer values
like double values with integer results. This allows correct simplification of expressions like x^(Complex(1,0))
.
Preprocess
PFMC which causes the preprocessor to be run during evaluation.
Eval
PFMC which evaluates is argument during preprocessing.
XAssign.process()
when the UseEquation
flag is not set
or the left hand side is a LValueI
.
DirtyFunction
interface for PFMC's which should not
be cleaned when all arguments are constants. Add new
DirtyRandom
and DirtyThreadSafeRandom
PFMC's which implement the
interface. Modify ExpressionCleaner
to respect interface.
XFunctionTable
which uses the DirtyRandom
PFMC.
com.singularsys.extensions.matrix
GenericMatrix.equals(Object)
, which failed for two different matrices with equal elements. Now uses Arrays.deepEquals()
MatrixComponents
.
MatrixFunctionTable
.
DimensionVisitor
:
visit(XVariable var)
calculates the dimensions of a variable specified by an equation,
getDimensions(Variable var)
and getDimensions(Node node)
find dimensions
of existing objects which have already been calculated, and
calcVariableDimensionsByValue(Variable var)
calculates its dimensions using its value.
MatrixFactoryI
now has a default method VectorI zeroVec(Dimensions dim)
to create a vector of a given size.
MatrixFactory
and MatrixField
classes now all return this
from the getLightWeightInstance()
method.s
MatrixI, vectorI
are not Serializable.
com.singularsys.extensions.matrixdiff
MDjep
.
DDimensionVisitor
to work with variables with equations and some edge cases.
com.singularsys.extensions.fastmatrix
MrpEval
has new constructor MrpEval(Jep jep)
which use a MatrixI factory taken from a Jep component.
MrpEval
has methods getLightWeightInstance(Jep newjep)
which creates a thread safe
copy using supplied Jep context.
MrpeEval.setVarVal(ref,double[])
can set scaler variable to arrays of length 1.
MrpeEval.evaluate()
now throws an EvaluationException
if the a PFMC called throws an Exception.
MrpRes
and subclasses have a toFlatternedArray()
method which always returns a one dimensional array.
MrpRes
methods
copyToVec(VectorI vec)
and copyToMat(MatrixI res)
now return the supplied VectorI
or MatrixI
respectively.
MrpCommandList
has a new MrpCommand getCommand(int i)
method.
fastmatrix
package.com.singularsys.extensions.fastreal
RpEval
and RpCommandList
can both be serialised.
updateFromJepVariables()
methods to set variable values from the Jep instance.
com.singularsys.extensions.statistical
MatrixFunctionI
so work with the Matrix package.
ElementMinMax
Mode
add handling of cases where mode is not defined, returning NaN by default.
com.singularsys.extensions.djep
DJep
has new methods replacePartialDerivativeByExpressions(Node)
,
differentiate(DVariable var,String... names)
.
com.singularsys.extensions.rewrite
RewriteVisitor
to transform constant and variable nodes. Creates new interfaces ConstantRuleI
and VariableRuleI
for rules which perform these actions.
SmallNumberRule
a constant rule which replaces small number with 0.0, useful for cleaning nodes.
VariableShifter
which replaces a variable "x" by a shifted version e.g. "x+5"
com.singularsys.extensions.polynomial
SymbolicEquals
PFMC.
Compare
PFMC.
PNodeI
are serializable.
DirtyFunction
interface.
Major re-release to match the Jep 3.5 release.
All packages moved to the
com.singularsys.extensions
and reworked to use the Jep 3 framework.
com.singularsys.extensions.field
com.singularsys.extensions.matrix
com.singularsys.extensions.mathml
com.singularsys.extensions.structure
org.lsmp.djep.rpe
renamed to
com.singularsys.extensions.fastreal
org.lsmp.djep.mrpe
renamed to
com.singularsys.extensions.fastmatrix
org.lsmp.djep.sjep
renamed to
com.singularsys.extensions.polynomials
groupJep
replaced by Field package com.singularsys.extensions.field
matrixJep
and vectorJep
replaced by Matrix package com.singularsys.extensions.matrix
3x+x^2+4x+x^2
is transformed to 7x+2x^2
. Full
expansion of polynomials is also available so (1+x)^3
it transformed
to 1+3x+3x^2+x^3
. No major changes were made for the release.
This is the third release of the package, released 28/Feb/04. I'm really just rushing this out as some people have been asking for documentation which is included here. Still more documentation to come. Also the code is still in a fairly mutable state and I still expect to move some things around so don't expect the the API to be stable. Hopefully it will just be the inner workings which change the main interface for users is nearly fixed. The most important changes in this package are
if(stack.size()!=2) throw new ParseException("Multiply: should have two children its got "+stack.size());