Draft: Math_Expression

From: Date: Mon, 29 May 2006 14:46:16 +0000
Subject: Draft: Math_Expression
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-42666@lists.php.net to get a copy of this message
Hello, I started a draft for a Math_Expression package [1]. ----->8------ Description ----->8------ This package is ment to unify mathematical expressions' representation. The goal is to provide an easy way to have internal representations of mathematical objects, so any specific math package could be focused on the operations, leaving the parsing/output process to Math_Expression. The work process would be: "input string" -> (parsing) Math_Expression -> Math_Package1 -> Math_Package2 -> (evaluating) Math_Expression -> "output string" instead of the old-style: "input string" -> (parsing) -> Math_Package1 -> (evaluating) -> "intermediary result" -> (parsing) -> Math_Package2 -> (evaluating) -> "output string" The Math_Expression job would be to represent mathematical object linearly stored in string into PHP Objects, so the other packages can work on these objects only. By mathematical object I mean every operators or structure a mathematical expression could use. The package starts from scratch and define some basic structures: - Real numbers - Parenthesis and some elementary operators: - + - - - * - / - ^ (power) With that basis, Math_Expression is already capable of parsing&evaluating every simple math expressions like "2*3/4 + (5^(1+(4*2))-2)" This package is really extensible. As a proof of concept, I implemented a representation of vectors, and two basic operations, <vector> * or / <real>. For example, "{2+1,2,4}" is the string representation of a vector. Giving "{2+1,2,4}*3" to Math_Expression and evaluating it will return an object which could be transformed to the string "{9,6,12}". The code is not already fully commented etc... But I think it's ok for a draft. Every files are located here: http://www.colder.ch/repository/php/Math_Expression/ <http://www.colder.ch/repository/php/Math_Expression/%3Cbr> Comments about the design and/or implementation would be appreciated. Thanks in advance. -----8<------ End of Description -----8<------ Thanks in advance for your comments! [1] http://pear.php.net/pepr/pepr-proposal-show.php?id=401 -- Etienne Kneuss http://www.colder.ch/ colder@php.net

« previous php.pear.dev (#42666) next »