Permalink
Browse files

; is no longer necessary after last statement

C++ API updated in EngineAPI.hh.
include directory contains headers for API
lib directory contains static library
update documentation and tests with respect to ; no longer required after last statement
  • Loading branch information...
tcaduser committed Feb 17, 2013
1 parent 997e2f8 commit 395b607035bf750b01148f97763719b2c26526e2
Showing with 262 additions and 269 deletions.
  1. +1 −0 CMakeLists.txt
  2. BIN doc/symdiff.pdf
  3. +11 −11 examples/arrhenius.py
  4. +1 −1 examples/deftest.py
  5. +2 −2 examples/modellist1.py
  6. +19 −19 examples/models1.py
  7. +2 −2 examples/ordered.py
  8. +1 −1 examples/parsetest.py
  9. +3 −3 examples/remove1.py
  10. +3 −3 examples/subexpression1.py
  11. +2 −2 examples/table.py
  12. +6 −6 examples/undefined1.py
  13. +3 −3 examples/utf8.py
  14. +3 −3 goldenresults/unix/parsetest_py.out
  15. +3 −3 goldenresults/unix/parsetest_tcl.out
  16. +0 −3 src/engine/Add.cc
  17. +12 −0 src/engine/CMakeLists.txt
  18. +0 −1 src/engine/Constant.cc
  19. +25 −7 src/engine/Context.cc
  20. +10 −1 src/engine/Context.hh
  21. +52 −0 src/engine/EngineAPI.cc
  22. +18 −0 src/engine/EngineAPI.hh
  23. +0 −11 src/engine/EquationFunctions.cc
  24. +0 −1 src/engine/EquationObject.cc
  25. +1 −1 src/engine/EquationObject.hh
  26. +0 −2 src/engine/Exponent.cc
  27. +0 −1 src/engine/IfElse.cc
  28. +0 −1 src/engine/Log.cc
  29. +0 −1 src/engine/Pow.cc
  30. +0 −20 src/engine/Product.cc
  31. +1 −19 src/engine/UserFunc.cc
  32. +0 −1 src/engine/Variable.cc
  33. +0 −50 src/engine/dsAssert.hh
  34. +8 −12 src/engine/mcModel.cc
  35. +4 −2 src/engine/mcParser.y
  36. +0 −10 src/engine/mcTest.cc
  37. +5 −1 src/engine/parseexpr.cc
  38. +2 −1 src/engine/parseexpr.hh
  39. +12 −12 testing/arrhenius_tcl.tcl
  40. +16 −16 testing/parsetest_tcl.tcl
  41. +1 −1 testing/symdiff1.tcl
  42. +17 −17 testing/symdiff2.tcl
  43. +8 −8 testing/symdiff3.tcl
  44. +6 −6 testing/symdiff4.tcl
  45. +2 −2 testing/table.tcl
  46. +2 −2 testing/units.tcl
View
@@ -15,6 +15,7 @@ ADD_DEFINITIONS(-Wall -DTCL_THREADS -DUSE_TCL_STUBS)
set(PROJECT_BIN_DIR ${PROJECT_SOURCE_DIR}/bin)
set(PROJECT_SCRIPTS_DIR ${PROJECT_SOURCE_DIR}/scripts)
set(PROJECT_LIBRARY_DIR ${PROJECT_SOURCE_DIR}/lib)
set(PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
#SET(CMAKE_SKIP_BUILD_RPATH TRUE)
View
Binary file not shown.
View
@@ -2,18 +2,18 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
symdiff('define_model(arrhenius, simplify(Cf * pow(T, Etar) * exp(-Ea/T)));')
symdiff('define_model(KC1 , simplify(A3 * R * T * exp((A1 * (-pow(T,(-1)) + pow(A2,(-1))) * pow(R,(-1))))));')
symdiff('define_model(kb_model , simplify(arrhenius / KC1));')
symdiff('declare_model(fprod);')
symdiff('define_model(arrhenius, simplify(Cf * pow(T, Etar) * exp(-Ea/T)))')
symdiff('define_model(KC1 , simplify(A3 * R * T * exp((A1 * (-pow(T,(-1)) + pow(A2,(-1))) * pow(R,(-1))))))')
symdiff('define_model(kb_model , simplify(arrhenius / KC1))')
symdiff('declare_model(fprod)')
symdiff('define_model(rprod , simplify(H * CN * AR));')
symdiff('define_model(omega_dot_H , simplify((vr_H - vf_H) * (arrhenius * fprod - kb_model * rprod)));')
symdiff('diff(omega_dot_H, T);')
symdiff('diff(omega_dot_H, H);')
symdiff('diff(omega_dot_H, HCN);')
symdiff('diff(omega_dot_H, AR);')
symdiff('diff(omega_dot_H, CN);')
symdiff('define_model(rprod , simplify(H * CN * AR))')
symdiff('define_model(omega_dot_H , simplify((vr_H - vf_H) * (arrhenius * fprod - kb_model * rprod)))')
symdiff('diff(omega_dot_H, T)')
symdiff('diff(omega_dot_H, H)')
symdiff('diff(omega_dot_H, HCN)')
symdiff('diff(omega_dot_H, AR)')
symdiff('diff(omega_dot_H, CN)')
subexpression()
remove_zeros()
View
@@ -45,4 +45,4 @@
]
for i in commands:
print symdiff(i + ';')
print symdiff(i)
View
@@ -2,8 +2,8 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
symdiff('declare_model(x);')
symdiff('declare_model(y);')
symdiff('declare_model(x)')
symdiff('declare_model(y)')
l = model_list();
for i in l:
print('%s' % i)
View
@@ -2,40 +2,40 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
print symdiff('declare_model(x);')
print symdiff('define_model(y, a*x);')
print symdiff('diff(y, x);')
print symdiff('clear_model(x);')
print symdiff('declare_model(x)')
print symdiff('define_model(y, a*x)')
print symdiff('diff(y, x)')
print symdiff('clear_model(x)')
print ordered_list('y')
print symdiff('declare_model(x);')
print symdiff('declare_model(x)')
print ordered_list('y')
print symdiff('define_model(x,y);')
print symdiff('define_model(x,y)')
# catch cycles
try:
print ordered_list('y')
except SymdiffError as x:
print x
for i in model_list():
print i + ' ' + symdiff('model_value(%s);' % i)
symdiff('clear_model(%s);' % i)
print i + ' ' + symdiff('model_value(%s)' % i)
symdiff('clear_model(%s)' % i)
print
print symdiff('declare_model(x);')
print symdiff('define_model(y,x^2);')
print symdiff('diff(y,x);')
print symdiff('clear_model(y);')
print symdiff('model_value(y__x);')
print symdiff('diff(model_value(y__x),z);')
print symdiff('declare_model(x)')
print symdiff('define_model(y,x^2)')
print symdiff('diff(y,x)')
print symdiff('clear_model(y)')
print symdiff('model_value(y__x)')
print symdiff('diff(model_value(y__x),z)')
for i in model_list():
print i + ' ' + symdiff('model_value(%s);' % i)
print i + ' ' + symdiff('model_value(%s)' % i)
print
symdiff('clear_model(x);')
symdiff('clear_model(x__z);')
symdiff('clear_model(x)')
symdiff('clear_model(x__z)')
for i in model_list():
print i + ' ' + symdiff('model_value(%s);' % i)
symdiff('clear_model(%s);' % i)
print i + ' ' + symdiff('model_value(%s)' % i)
symdiff('clear_model(%s)' % i)
View
@@ -2,8 +2,8 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
symdiff('define_model(b, a);')
symdiff('define_model(d, b * c);')
symdiff('define_model(b, a)')
symdiff('define_model(d, b * c)')
mylist = ordered_list('d');
for i in mylist:
print('%s' % i)
View
@@ -6,7 +6,7 @@ def maptest(arg):
print
print arg;
try:
out = symdiff(arg + ';')
out = symdiff(arg)
except SymdiffError as x:
out = x
print out
View
@@ -2,7 +2,7 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
symdiff('define_model(x, 0);')
symdiff('define_model(y, x + z);')
symdiff('define_model(x, 0)')
symdiff('define_model(y, x + z)')
remove_zeros()
print('%s' % symdiff('model_value(y);'))
print('%s' % symdiff('model_value(y)'))
@@ -2,9 +2,9 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
symdiff('define_model(x, y * z);')
symdiff('define_model(z, y * z);')
symdiff('define_model(x, y * z)')
symdiff('define_model(z, y * z)')
subexpression()
l = model_list()
for i in l:
print("%s, %s" % (i, symdiff('model_value(%s);' % i)))
print("%s, %s" % (i, symdiff('model_value(%s)' % i)))
View
@@ -2,6 +2,6 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
symdiff('declare_model(x);')
for i, v in enumerate(symdiff_table('a*x + b*c;')):
symdiff('declare_model(x)')
for i, v in enumerate(symdiff_table('a*x + b*c')):
print '%s %s' % (i, v)
View
@@ -2,9 +2,9 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
symdiff('declare_model(y);')
symdiff('define_model(x, 3 * y + z);')
symdiff('diff(x, z);')
print('%s' % symdiff('model_value(x);'))
print('%s' % symdiff('model_value(x__z);'))
print('%s' % symdiff('model_value(y__z);'))
symdiff('declare_model(y)')
symdiff('define_model(x, 3 * y + z)')
symdiff('diff(x, z)')
print('%s' % symdiff('model_value(x)'))
print('%s' % symdiff('model_value(x__z)'))
print('%s' % symdiff('model_value(y__z)'))
View
@@ -3,8 +3,8 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
alpha = "α"
alpha = 'α'
print alpha
x = symdiff("%s;" % alpha);
x = symdiff("diff(%s^2, %s);" % (alpha, alpha));
x = symdiff('%s' % alpha);
x = symdiff('diff(%s^2, %s)' % (alpha, alpha));
print x
@@ -121,7 +121,7 @@ a++-+a
a+*+a
While calling symdiff interpreter
While evaluating expression "a+*+a;"
While evaluating expression "a+*+a"
syntax error
@@ -226,12 +226,12 @@ simplify(-8*a*x^2 -3*b*c^2)
simplify(x,y)
While calling symdiff interpreter
While evaluating expression "simplify(x,y);"
While evaluating expression "simplify(x,y)"
Function "simplify" expects 1 argument and you provided 2: "x", "y"
subst(y)
While calling symdiff interpreter
While evaluating expression "subst(y);"
While evaluating expression "subst(y)"
Function "subst" expects 3 arguments and you provided 1: "y"
@@ -121,7 +121,7 @@ a++-+a
a+*+a
While calling symdiff interpreter
While evaluating expression "a+*+a;"
While evaluating expression "a+*+a"
syntax error
@@ -226,12 +226,12 @@ simplify(-8*a*x^2 -3*b*c^2)
simplify(x,y)
While calling symdiff interpreter
While evaluating expression "simplify(x,y);"
While evaluating expression "simplify(x,y)"
Function "simplify" expects 1 argument and you provided 2: "x", "y"
subst(y)
While calling symdiff interpreter
While evaluating expression "subst(y);"
While evaluating expression "subst(y)"
Function "subst" expects 3 arguments and you provided 1: "y"
View
@@ -17,7 +17,6 @@ limitations under the License.
#include "Add.hh"
#include "Utility.hh"
#include "Functions.hh"
#include "dsAssert.hh"
#include <sstream>
namespace Eqo {
@@ -268,7 +267,6 @@ EqObjPtr Add::CombineAdd(std::vector<EqObjPtr> y)
EqObjPtr Add::clone()
{
const size_t len = values.size();
dsAssert(len != 0, "UNEXPECTED");
std::vector<EqObjPtr> tmp(len);
for (size_t i = 0; i < len; ++i)
{
@@ -326,7 +324,6 @@ EqObjPtr Add::getUnsignedValue()
EqObjPtr Add::expand()
{
const size_t len = values.size();
dsAssert(len != 0, "UNEXPECTED");
std::vector<EqObjPtr> tmp(len);
for (size_t i = 0; i < len; ++i)
{
View
@@ -38,6 +38,7 @@ INCLUDE_DIRECTORIES (
)
ADD_LIBRARY(symdiff SHARED ${CXX_SRCS} ${MC_SRCS})
ADD_LIBRARY(symdiff_static STATIC ${CXX_SRCS} ${MC_SRCS})
IF (WIN32)
@@ -67,6 +68,17 @@ ADD_CUSTOM_COMMAND(TARGET symdiff
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_LIBRARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${SYMDIFF_NAME} ${PROJECT_LIBRARY_DIR}/.
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_INCLUDE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/import.hh ${PROJECT_INCLUDE_DIR}/.
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/dsmemory.hh ${PROJECT_INCLUDE_DIR}/.
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/EngineAPI.hh ${PROJECT_INCLUDE_DIR}/.
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/parseexpr.hh ${PROJECT_INCLUDE_DIR}/.
)
GET_TARGET_PROPERTY(SYMDIFF_STATIC_NAME symdiff_static LOCATION)
ADD_CUSTOM_COMMAND(TARGET symdiff_static
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_LIBRARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${SYMDIFF_STATIC_NAME} ${PROJECT_LIBRARY_DIR}/.
)
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET_TARGET_PROPERTIES(symdiff PROPERTIES INSTALL_RPATH "\$ORIGIN/")
View
@@ -15,7 +15,6 @@ limitations under the License.
***/
#include "Constant.hh"
#include "Functions.hh"
#include "dsAssert.hh"
#include <sstream>
#include <iomanip>
#include <cmath>
View
@@ -47,13 +47,20 @@ void Context::SetModelListCallBack(inModelListCallback_ptr foo)
*/
bool Context::IsInModelList(const std::string &str)
{
ModelMap_t::iterator it, end=context_data_.model_list_.end();
for (it=context_data_.model_list_.begin(); it != end; ++it)
{
if ((*it).first == str)
return true;
}
return false;
if (context_data_.callback_func_ptr_)
{
return context_data_.callback_func_ptr_(str);
}
else
{
ModelMap_t::iterator it, end=context_data_.model_list_.end();
for (it=context_data_.model_list_.begin(); it != end; ++it)
{
if ((*it).first == str)
return true;
}
}
return false;
}
/*
@@ -95,3 +102,14 @@ void Context::DefineModel(const std::string &s, Eqo::EqObjPtr e)
GetModelMap()[s] = e;
}
Eqo::EqObjPtr Context::EvaluateModelDerivative(Eqo::EqObjPtr x, Eqo::EqObjPtr y)
{
return context_data_.model_derivative_rule_ptr_(x, y);
}
void Context::SetDerivativeRule(modelDerivativeRule_ptr x)
{
context_data_.model_derivative_rule_ptr_ = x;
}
View
@@ -29,17 +29,24 @@ typedef std::tr1::shared_ptr<EquationObject> EqObjPtr;
typedef std::map<std::string, Eqo::EqObjPtr > ModelMap_t;
typedef bool (*inModelListCallback_ptr)(const std::string &);
typedef Eqo::EqObjPtr (*modelDerivativeRule_ptr)(Eqo::EqObjPtr, Eqo::EqObjPtr);
namespace Eqo
{
extern Eqo::EqObjPtr DLL_PUBLIC default_derivative_rule(Eqo::EqObjPtr, Eqo::EqObjPtr);
}
//// Be able to store rules in the future.
class ContextData {
public:
ContextData() : callback_func_ptr_(NULL)
ContextData() : callback_func_ptr_(NULL), model_derivative_rule_ptr_(Eqo::default_derivative_rule)
{
}
ModelMap_t model_list_;
inModelListCallback_ptr callback_func_ptr_;
modelDerivativeRule_ptr model_derivative_rule_ptr_;
private:
// ContextData();
// ~ContextData();
@@ -51,9 +58,11 @@ class DLL_PUBLIC Context {
public:
static Context &GetInstance();
Eqo::EqObjPtr EvaluateModelDerivative(Eqo::EqObjPtr, Eqo::EqObjPtr);
Eqo::EqObjPtr FindInModelList(const std::string &);
bool IsInModelList(const std::string &);
void SetModelListCallBack(inModelListCallback_ptr);
void SetDerivativeRule(modelDerivativeRule_ptr);
ModelMap_t &GetModelMap();
void ClearModel(const std::string &);
Oops, something went wrong.

0 comments on commit 395b607

Please sign in to comment.