Board index » delphi » looking for a component or code to ....

looking for a component or code to ....


2005-04-06 10:24:32 PM
delphi39
Hi
The best way to explain what I need is through example:
Lets say we've mathematical equation: y=x^2/(x+5) and normally you put it in
a code, the variable 'x ' can be put it outside the code i.e. for user input
then the program gives you 'y' as an answer - simple. What I want is to give
possibility for user input of any equation as an example in EditBox without
interference in the code.
Anyone knows where I can get such a component or code which will do that??
I'll be grateful for any help, link on that subject.
Lukasz
 
 

Re:looking for a component or code to ....

In article <XXXX@XXXXX.COM>, Lt writes:
Quote

Lets say we've mathematical equation: y=x^2/(x+5) and normally you put it in
a code, the variable 'x ' can be put it outside the code i.e. for user input
then the program gives you 'y' as an answer - simple. What I want is to give
possibility for user input of any equation as an example in EditBox without
interference in the code.

Anyone knows where I can get such a component or code which will do that??
You need an expression parser and evaluator. Here are a couple of references,
some may even still work:
www.efg2.com/lab/library/Delphi/MathFunctions/Parsers.htm
www.econos.de/software/borland/index.html
members.xoom.com/jdtools/decam/index.htm
www.cs.uct.ac.za/courses/Course1/116/Tut0/help/evaluate.html
www.gemini2k.com/sparksoft
www.simes.clara.co.uk/delphi/expeval.htm
adcsoft.hypermart.net/products/rapideval/index.shtml
Peter Below (TeamB)
Use the newsgroup archives :
www.mers.com/searchsite.html
www.tamaracka.com/search.htm
groups.google.com
www.prolix.be
 

Re:looking for a component or code to ....

Quote
Lets say we've mathematical equation: y=x^2/(x+5) and normally you put it in
a code, the variable 'x ' can be put it outside the code i.e. for user input
then the program gives you 'y' as an answer - simple. What I want is to give
possibility for user input of any equation as an example in EditBox without
interference in the code.
If you need it to be as fast as possible (e.g. for pixel manipulation),
I can send you my expression parser. AFAIK it is the fastest one
available for Delphi (your expression is transformed to machine code at
runtime, it sometimes is even faster than Delphi compiled code). If it
doesn't have to be that fast, take a look a Peter's links, which might
lead you to more flexible components (mine offers no user defined
functions, only things like +, -, *, /, ^, sqr, sqrt, exp, ln, sin, cos,
round, floor, ceil...). If you are interested, let me know.
Jens
 

Re:looking for a component or code to ....

Hi, Jens
I was looking for such kind of expression parser. Could you please send it
to me as well?
My email address is (XXXX@XXXXX.COM)
Thanks
Bill
Jens Gruschel writes:
Quote
>Lets say we've mathematical equation: y=x^2/(x+5) and normally you
>put it in a code, the variable 'x ' can be put it outside the code
>i.e. for user input then the program gives you 'y' as an answer -
>simple. What I want is to give possibility for user input of any
>equation as an example in EditBox without interference in the code.

If you need it to be as fast as possible (e.g. for pixel
manipulation), I can send you my expression parser. AFAIK it is the
fastest one available for Delphi (your expression is transformed to
machine code at runtime, it sometimes is even faster than Delphi
compiled code). If it doesn't have to be that fast, take a look a
Peter's links, which might lead you to more flexible components (mine
offers no user defined functions, only things like +, -, *, /, ^,
sqr, sqrt, exp, ln, sin, cos, round, floor, ceil...). If you are
interested, let me know.

Jens
 

Re:looking for a component or code to ....

Jens Gruschel writes:
Quote

If you need it to be as fast as possible (e.g. for pixel manipulation),
I can send you my expression parser. AFAIK it is the fastest one
available for Delphi (your expression is transformed to machine code at
runtime, it sometimes is even faster than Delphi compiled code). If it
doesn't have to be that fast, take a look a Peter's links, which might
lead you to more flexible components (mine offers no user defined
functions, only things like +, -, *, /, ^, sqr, sqrt, exp, ln, sin, cos,
round, floor, ceil...). If you are interested, let me know.
I am also interested in taking a look at your component.
Is it possible for you to put this in the attachments newsgroup, so
others can get it as well.
--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia
 

Re:looking for a component or code to ....

Quote

If you need it to be as fast as possible (e.g. for pixel manipulation),
I can send you my expression parser. AFAIK it is the fastest one
available for Delphi (your expression is transformed to machine code at
runtime, it sometimes is even faster than Delphi compiled code). If it
doesn't have to be that fast, take a look a Peter's links, which might
lead you to more flexible components (mine offers no user defined
functions, only things like +, -, *, /, ^, sqr, sqrt, exp, ln, sin, cos,
round, floor, ceil...). If you are interested, let me know.
Yes, I would like to look at it as well. Please send me at: XXXX@XXXXX.COM
Thank you.
 

Re:looking for a component or code to ....

Quote
If you need it to be as fast as possible (e.g. for pixel manipulation),
I can send you my expression parser. AFAIK it is the fastest one
available for Delphi (your expression is transformed to machine code at
runtime, it sometimes is even faster than Delphi compiled code).
I have uploaded the package to
www.pegtop.net/delphi/files/pegtopmath.zip
There is no documentation yet, but a demo project included to the zip
file. The compiled exe of this demo can also be found at
www.pegtop.net/delphi/files/PegtopMathDemo.exe
(if you want to play around a bit before installing the component).
This isn't really a release version, since I tried to add user defined
functions lately, which is not finished yet. So there might be some code
not used yet. But it doesn't influence the functionality or speed.
Usage is simple: Assign you expression string to the Expression property
and define parameters with the Parameters property. The expresion is
parsed and compiled automatically the first time Eval is called (see
below) after assigning a new expression, or when you call the Compile
method (useful to catch parsing exceptions). There are different ways to
evaluate the expression (assuming you have defined 3 parameters x, y, z):
1) Result := MyFormula.Eval([3, 5, 2.3]);
// quite fast
2) MyFormula.SetArg('x', 3);
MyFormula.SetArg('y', 5);
MyFormula.SetArg('z', 2.3);
Result := MyFormula.Eval;
// not recommended since it is not very fast
3) MyFormula.SetArg(0, 3);
MyFormula.SetArg(1, 5);
MyFormula.SetArg(2, 2.3);
Result := MyFormula.Eval;
// fastest option, if you don't change all parameters
// at the same time (the inner loop only changes x).
Parameters is a simple TStringList, so you can also define them at
runtime by
MyFormula.Parameters.Clear;
MyFormula.Parameters.Add('x');
MyFormula.Parameters.Add('gravity');
You can take a look at the asm code of your formula with
MyFormula.CodeLines (also returns a string list).
Note that internally the calculation is made with highest precision (64
bit by default), but input and output always is of type Double.
The component has 3 properties that influence the FPU control word:
MathErrors, MathInfinity and MathPrecision. If you don't change them,
the calculation is made like you know it from Delphi (same precision,
same exceptions are raised like EDivByZero). You can change them, for
example if you don't want exceptions for division by zero (the result
might be an infinite value, you can use functions like IsInfiniteOrNaN
to check the result, as shown in the demo).
Jens
 

Re:looking for a component or code to ....

Quote
Note that internally the calculation is made with highest precision (64
bit by default), but input and output always is of type Double.
Stupid statement. Double has 64 bits. But Double uses 53 bit for the
mantiassa, while Extended (80 bit) uses 64 bit for the mantissa. So
internally the FPU uses the Extended type by default.
Jens
 

Re:looking for a component or code to ....

Quote
www.simes.clara.co.uk/delphi/expeval.htm
this link is a good one, it is free component works fine for me (that's what
I needed - simple), Properties and Methods are described as well.
 

Re:looking for a component or code to ....

Hi,
Test Delphi mathematical parsers (JclExprEval, StExpr 4.03, CalcExpress
2.1, Parser 10.1, etc.)
www.geocities.com/alexei_cioina/cioinaeval.html
Alexei.
LT writes:
Quote
Hi

The best way to explain what I need is through example:

Lets say we've mathematical equation: y=x^2/(x+5) and normally you
put it in
a code, the variable 'x ' can be put it outside the code i.e. for
user input
then the program gives you 'y' as an answer - simple. What I want is
to give
possibility for user input of any equation as an example in EditBox
without
interference in the code.

Anyone knows where I can get such a component or code which will do
that??

I'll be grateful for any help, link on that subject.

Lukasz