Re: Matheval (was: Dos32Lib, Win32Lib)

new topic     » topic index » view thread      » older message » newer message

On 2000-06-01 EUPHORIA at LISTSERV.MUOHIO.EDU said:

 EU>>    To the author of Matheval ,

 EU>>     You may of encountered a file I posted somewhile ago
 EU>>   called parr1.txt, detailing one approach to constructing a
 EU>>parser.      This has a fair few advantages over other ways of
 EU>>evaluating equations    or expressions. One of the disadvantages
 EU>>is the necessity of making at    least two disk accesses , the
 EU>parser of d.cuny circumvents this ; however
 EU>>   as you discovered in one implementation of eval.e ; there were
 EU>difficulties. Are you looking
 EU>>   towards an alternative or merging of these two approaches ,
 EU>this is something I was considering >   for awhile and mentioned to
 EU>d.cuny. He was reticent about that approach.
 EU>>     This doesn't mean that there's no other way of constructing a
 EU>workable parser with
 EU>>   at least some of the attributes desired , i.e minimal use of
 EU>>the disk,    ease of configuration ; rapidity of evaluation.


 EU>I did take a look at your file, and that's a very interesting
 EU>approach, but I don't think it's really suited to what I was
 EU>looking to do.

   This was really a second option for me to , I had originally just been
  thinking in terms of calculator type functionality , as i still do,
  then I thought , 'what if i use some more of the resources available
  through the o/s' ; dos in this instance , and let the interpreter ;
  ex.exe do all the work.
   This approach isn't unique to euphoria , any interpreter that provides
  system() calls and error checking ; through a file like ex.err might
  conceivably be used.
   Redirection , through dos , might further improve upon this concept.

 eu>First, my goal was to allow 'normal' mathematical
 EU>notation, as far as possible to be used exclusively, rather than
 EU>hard coding the math into a Euphoria program. I'd say that the
 EU>version on the contributions page is a rough draft.

    By 'normal' are you referring to document style notation as is found
  in professional style math packages , some of these give you the ability
  to enter programming code too ; though usually C/C++ code.
    In some ways the math is 'hard coded' into euphoria . The include file
  that contains the expression being evaluated can be exported or edited
  quite readily , through the use of a standard text editor.
   Modules might be added , dynamically , to the basic configuration to
  perform certain tasks ; like statistics.
    What is generated , is a syntax corrected sequence , suitable for use
  within euphoria ; further evaluation might then occur using something
  like the evaluator that you had in the rough draft. Though this appears
  to be a little slow for some applications. This sequence might be
  amenable to symbolic manipulation.

   The rough draft was what I found myself evaluating , I'd like to see
  something that is without the hiccups , perhaps in shrouded form ; if
  you wish to protect your code.

 EU>There are several quirks about the parser and naming conventions
 EU>(eg, can't have a var begin with the same characters as an existing
 EU>function), but it seems to work fast enough.  You would only need
 EU>to parse an expression once, and then you'd have the expression in
 EU>matheval format, able to pass it directly to the evaluation
 EU>routines.

    Are right brackets automatically appended now , or are these seen
  as being unnecessary clutter.
   I'm a little unfamiliar with recursion , hence my tendency to bury my
  head in the sand , a bit more familarity might put me at ease with
  this approach.

 EU>I really haven't worked on the parser lately, since it works.  I've
 EU>been focusing on the meat of the code, and I've been putting off
 EU>fixing the other 'inconveniences' for later.  I think that it is
 EU>fairly easy to reconfigure. To add a function to the parsing, you
 EU>basically need to add it to the list of functions, insert it
 EU>wherever it needs to go withing the precedence table, and write the
 EU>code to 'collapse the token' (as I put it).  These tend to be no
 EU>more than 5 or 6 lines of code, most of which is simply concerned
 EU>with the number of arguments required for the function.

    F(x1,x2,x3,....,xn) =  type functions are readily available with my
  approach , is this true of yours also ?

   If you can also evaluate these and with only a few more lines of code
  I'm definitely interested in reviewing your approach.

    By collapsing the token I assume you mean making a corresponding
  sequence , to the equation , that can be more quickly evaluated ; within
  a loop ;  perhaps even an assembly language loop. To date I haven't
  bothered with this possibility as once the function has been defined ,
  within the editable include file I can generate an output sequence of
  values from an input sequence of values in the usual manner with just
  a few lines of euphoria code.

 EU>In the development of the parser, I'd looked at David Cuny's (and a
 EU>couple of others' libs that were posted), but they didn't seem to
 EU>have the right sort of functionality that I needed, so the parsing
 EU>routines are pretty much all mine.

   Hence , understandably , your reluctance to be overly public with your
  code. These are my feelings also , hence my posting parr1.txt that tells
  you how to ; without giving any detail. With the type of convoluted code
  you might be involved with I'd be even more reluctant to post. Parsers ,
  especially small functional ones can appear to be real mind benders.
   Some of the literature surrounding these , as you're probably aware ,
  is pretty daunting until you break through some unknown barrier of
  comprehension. To some extent I managed this , though not at the basic
  level of understanding I'd prefer.

 EU>One reason I don't want to hard code anything is that I'm
 EU>interested in being able to manipulate the expressions
 EU>symbolically--factor, integrate, diferentiate, trig identities, etc.
 EU>I can't see how you would be able to do that using your model,
 EU>since you're not really parsing the expression, but equivalent
 EU>Euphoria code.

  The sequence that contains the, syntax corrected , expression
 might be manipulated symbolically , I haven't really looked into this , as
 potentially , this involves more complexity than attempting to parse the
 sequence using the basic concepts. There might be a way to circumvent this,
 note that Euphoria [ or any other ] interpreter tends to minimize the
 components of an expression and tests for a certain amount of equivalence.

   Anyway , I should get some text , if I don't have an unexpected brainwave
  first .

  hint:
         Associative sequences.

 EU>I don't think that you've ever mentioned what your application was.
 EU>I'd be interested to see it if you've made progress.

   I posted the concept in parr1.txt , after I'd written software that
  worked ;  rather than the other way around.

   I tend to have some difficulty with my DOS based browser , hence the
  software doesn't appear on any of the euphoria contribution sites .
   As  this type of software might not exist , except for the features
  available through euphoria , I don't mind discussing this at all ,
  probably I should make all of the code available . A bit of scrutiny
  from more competent software developers, than I, might lead off into
  new directions.
   I suppose I could send , in plain text format , the code to this list
  server ; I think it's about 120k . I shall do this only if requested.

   The software that exists , presently , evaluates an expression of
  the form f(x) = sin(x*pi) + sinh(x) , or similar  , where  -1 <= x <= 1;
  then graphs the resultant (x,y) values in 800x600, 256 color resolution.
   An error message is generated , if your equation/expression has a fault
  with the syntax. This is also a rough draft , some expressions can't
  be graphed because f(x) returns an undefined value ; these exceptions
  can be handled through software in a general way or at the level of
  the basic functions,I just haven't written this code yet.

    I wanted reliable software that was , small in size , my own , that
   I might send to others ; that evaluated large expressions , graphed
   these and perhaps did things like integration.

   I found that running my present version from RAMDRIVE the two , or so ,
  disk accesses are hardly noticable.






Net-Tamer V 1.11 - Test Drive

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu