Commit 5fb4788a authored by Leif Lonnblad's avatar Leif Lonnblad
Browse files

This commit was manufactured by cvs2svn to create branch

'CLHEP_2_000_branch'.
parent e3b3f417
Makefile.in
configure
aclocal.m4
autom4te.cache
install-sh
missing
mkinstalldirs
This diff is collapsed.
Makefile.in
configure
aclocal.m4
autom4te.cache
config.h.in
CLHEP-@PACKAGE@-@VERSION@ CLHEP-@PACKAGE@-@VERSION@
// -*- C++ -*-
// $Id: Evaluator.h,v 1.1.1.1 2003/07/15 20:15:05 garren Exp $
// ---------------------------------------------------------------------------
#ifndef HEP_EVALUATOR_H
#define HEP_EVALUATOR_H
namespace HepTool {
/**
* Evaluator of arithmetic expressions with an extendable dictionary.
* Example:
* @code
* #include "CLHEP/Evaluator/Evaluator.h"
* HepTool::Evaluator eval;
* eval.setStdMath();
* double res = eval.evaluate("sin(30*degree)");
* if (eval.status() != HepTool::Evaluator::OK) eval.print_error();
* @endcode
*
* @author Evgeni Chernyaev <Evgueni.Tcherniaev@cern.ch>
* @ingroup evaluator
*/
class Evaluator {
public:
/**
* List of possible statuses.
* Status of the last operation can be obtained with status().
* In case if status() is an ERROR the corresponding error message
* can be printed with print_error().
*
* @see status
* @see error_position
* @see print_error
*/
enum {
OK, /**< Everything OK */
WARNING_EXISTING_VARIABLE, /**< Redefinition of existing variable */
WARNING_EXISTING_FUNCTION, /**< Redefinition of existing function */
WARNING_BLANK_STRING, /**< Empty input string */
ERROR_NOT_A_NAME, /**< Not allowed sysmbol in the name of variable or function */
ERROR_SYNTAX_ERROR, /**< Systax error */
ERROR_UNPAIRED_PARENTHESIS, /**< Unpaired parenthesis */
ERROR_UNEXPECTED_SYMBOL, /**< Unexpected sysbol */
ERROR_UNKNOWN_VARIABLE, /**< Non-existing variable */
ERROR_UNKNOWN_FUNCTION, /**< Non-existing function */
ERROR_EMPTY_PARAMETER, /**< Function call has empty parameter */
ERROR_CALCULATION_ERROR /**< Error during calculation */
};
/**
* Constructor.
*/
Evaluator();
/**
* Destructor.
*/
~Evaluator();
/**
* Evaluates the arithmetic expression given as character string.
* The expression may consist of numbers, variables and functions
* separated by arithmetic (+, - , /, *, ^, **) and logical
* operators (==, !=, >, >=, <, <=, &&, ||).
*
* @param expression input expression.
* @return result of the evaluation.
* @see status
* @see error_position
* @see print_error
*/
double evaluate(const char * expression);
/**
* Returns status of the last operation with the evaluator.
*/
int status() const;
/**
* Returns position in the input string where the problem occured.
*/
int error_position() const;
/**
* Prints error message if status() is an ERROR.
*/
void print_error() const;
/**
* Adds to the dictionary a variable with given value.
* If a variable with such a name already exist in the dictionary,
* then status will be set to WARNING_EXISTING_VARIABLE.
*
* @param name name of the variable.
* @param value value assigned to the variable.
*/
void setVariable(const char * name, double value);
/**
* Adds to the dictionary a variable with an arithmetic expression
* assigned to it.
* If a variable with such a name already exist in the dictionary,
* then status will be set to WARNING_EXISTING_VARIABLE.
*
* @param name name of the variable.
* @param expression arithmetic expression.
*/
void setVariable(const char * name, const char * expression);
/**
* Adds to the dictionary a function without parameters.
* If such a function already exist in the dictionary,
* then status will be set to WARNING_EXISTING_FUNCTION.
*
* @param name function name.
* @param fun pointer to the real function in the user code.
*/
void setFunction(const char * name, double (*fun)());
/**
* Adds to the dictionary a function with one parameter.
* If such a function already exist in the dictionary,
* then status will be set to WARNING_EXISTING_FUNCTION.
*
* @param name function name.
* @param fun pointer to the real function in the user code.
*/
void setFunction(const char * name, double (*fun)(double));
/**
* Adds to the dictionary a function with two parameters.
* If such a function already exist in the dictionary,
* then status will be set to WARNING_EXISTING_FUNCTION.
*
* @param name function name.
* @param fun pointer to the real function in the user code.
*/
void setFunction(const char * name, double (*fun)(double,double));
/**
* Adds to the dictionary a function with three parameters.
* If such a function already exist in the dictionary,
* then status will be set to WARNING_EXISTING_FUNCTION.
*
* @param name function name.
* @param fun pointer to the real function in the user code.
*/
void setFunction(const char * name, double (*fun)(double,double,double));
/**
* Adds to the dictionary a function with four parameters.
* If such a function already exist in the dictionary,
* then status will be set to WARNING_EXISTING_FUNCTION.
*
* @param name function name.
* @param fun pointer to the real function in the user code.
*/
void setFunction(const char * name,
double (*fun)(double,double,double,double));
/**
* Adds to the dictionary a function with five parameters.
* If such a function already exist in the dictionary,
* then status will be set to WARNING_EXISTING_FUNCTION.
*
* @param name function name.
* @param fun pointer to the real function in the user code.
*/
void setFunction(const char * name,
double (*fun)(double,double,double,double,double));
/**
* Finds the variable in the dictionary.
*
* @param name name of the variable.
* @return true if such a variable exists, false otherwise.
*/
bool findVariable(const char * name) const;
/**
* Finds the function in the dictionary.
*
* @param name name of the function to be unset.
* @param npar number of parameters of the function.
* @return true if such a function exists, false otherwise.
*/
bool findFunction(const char * name, int npar) const;
/**
* Removes the variable from the dictionary.
*
* @param name name of the variable.
*/
void removeVariable(const char * name);
/**
* Removes the function from the dictionary.
*
* @param name name of the function to be unset.
* @param npar number of parameters of the function.
*/
void removeFunction(const char * name, int npar);
/**
* Clear all settings.
*/
void clear();
/**
* Sets standard mathematical functions and constants.
*/
void setStdMath();
/**
* Sets system of units. Default is the SI system of units.
* To set the CGS (Centimeter-Gram-Second) system of units
* one should call:
* setSystemOfUnits(100., 1000., 1.0, 1.0, 1.0, 1.0, 1.0);
*
* To set system of units accepted in the GEANT4 simulation toolkit
* one should call:
* @code
* setSystemOfUnits(1.e+3, 1./1.60217733e-25, 1.e+9, 1./1.60217733e-10,
* 1.0, 1.0, 1.0);
* @endcode
*
* The basic units in GEANT4 are:
* @code
* millimeter (millimeter = 1.)
* nanosecond (nanosecond = 1.)
* Mega electron Volt (MeV = 1.)
* positron charge (eplus = 1.)
* degree Kelvin (kelvin = 1.)
* the amount of substance (mole = 1.)
* luminous intensity (candela = 1.)
* radian (radian = 1.)
* steradian (steradian = 1.)
* @endcode
*/
void setSystemOfUnits(double meter = 1.0,
double kilogram = 1.0,
double second = 1.0,
double ampere = 1.0,
double kelvin = 1.0,
double mole = 1.0,
double candela = 1.0);
private:
void * p; // private data
Evaluator(const Evaluator &); // copy constructor is not allowed
Evaluator & operator=(const Evaluator &); // assignment is not allowed
};
} // namespace HepTool
#endif /* HEP_EVALUATOR_H */
## Process this file with automake to produce Makefile.in
includedir = $(prefix)/include/CLHEP
pkginclude_HEADERS = \
Evaluator.h \
defs.h
# Identify generated file(s) to be removed when 'make clean' is requested:
CLEANFILES = defs.h
#-------------------------------------------------------------
# installing from a source code tar ball
#-------------------------------------------------------------
Unwind the source code tar ball in some relevant directory.
Autoconf and automake will aready have been run.
Determine where the files will be installed.
Create a build directory that is NOT in the source code directory tree.
cd <build_directory>
<source_code_direcotry>/configure --prefix=<install_dir>
(Note that files will be installed under /usr/local if you do not
specify a prefix.)
make
(Build temporary copies of libraries and executables.)
make check
(Run the tests.)
make install
(Copy libraries, headers, executables, etc. to relevant
subdirectories under <install_dir>.)
#-------------------------------------------------------------
# building from cvs
#-------------------------------------------------------------
You will need current versions of automake, autoconf, and libtool.
See building autotools below.
cvs co CLHEP/package OR cvs co package
cd [CLHEP/]package
bootstrap
Now continue with directions as if you unpacked a source code tarball.
#-------------------------------------------------------------
# building autotools
#-------------------------------------------------------------
If you do not have at least autoconf 2.57 and automake 1.6, you will
need to build autoconf, automake, and libtool. On some platforms,
you may also need to build m4 and texinfo.
Download the relevant tarballs from gnu.org.
Untar them in a common source code tree.
Decide whether you want to install them in /usr/local or your own
install directory. If you use your own install directory, use
--prefix=<install_dir>
with configure.
For each autotool package:
<source_code_dir>/configure [--prefix=<install_dir>]
make
make install
Make sure that <install_dir>/bin is at the front of your path.
#-------------------------------------------------------------
## Process this file with automake to produce Makefile.in
includedir = $(prefix)/include/CLHEP
# put . first so that CLHEP directory is built before anything else
SUBDIRS = Evaluator . src test
all-local: $(top_builddir)/CLHEP
# create temporary CLHEP header tree
# search for header directories in the following order:
# 1. $(top_srcdir)/..
# 2. $(CLHEPSOURCE_DIR)/CLHEP
# 3. $(CLHEP_DIR)/CLHEP
#
# abs_ => absolute path
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
$(top_builddir)/CLHEP:
mkdir $(top_builddir)/CLHEP;
cd $(abs_top_builddir); list=`ls $(abs_top_srcdir)/..`; \
for pkg in $$list; do \
if test -d $(abs_top_srcdir)/../"$$pkg"/"$$pkg"; then \
(cd $(abs_top_builddir)/CLHEP; mkdir $$pkg; cd $$pkg; \
hdrs=`ls $(abs_top_srcdir)/../$$pkg/$$pkg`; \
for hdr in $$hdrs; do $(LN_S) $(abs_top_srcdir)/../$$pkg/$$pkg/$$hdr $$hdr; done; \
if test -f $(abs_top_builddir)/../"$$pkg"/"$$pkg"/defs.h; then $(LN_S) $(abs_top_builddir)/../$$pkg/$$pkg/defs.h defs.h; fi; \
if test -f $(abs_top_builddir)/"$$pkg"/defs.h && test ! -e defs.h ; then $(LN_S) $(abs_top_builddir)/$$pkg/defs.h defs.h; fi); \
fi; done
cd $(abs_top_builddir); \
if test -n "$(CLHEPSOURCE_DIR)" && test -d $(CLHEPSOURCE_DIR)/CLHEP; then \
(list=`ls $(CLHEPSOURCE_DIR)/CLHEP`; \
for pkg in $$list; do cd $(abs_top_builddir)/CLHEP; \
if test -d $(CLHEPSOURCE_DIR)/CLHEP/"$$pkg"/"$$pkg" && test ! -d "$$pkg"; then \
(mkdir $$pkg; cd $$pkg; \
hdrs=`ls $(CLHEPSOURCE_DIR)/CLHEP/$$pkg/$$pkg`; \
for hdr in $$hdrs; do $(LN_S) $(CLHEPSOURCE_DIR)/CLHEP/$$pkg/$$pkg/$$hdr $$hdr; done); \
fi; done); fi
cd $(abs_top_builddir); \
if test -n "$(CLHEP_DIR)" && test -d $(CLHEP_DIR)/CLHEP; then \
(list=`ls $(CLHEP_DIR)/CLHEP`; \
for pkg in $$list; do cd $(abs_top_builddir)/CLHEP; \
if test -d $(CLHEP_DIR)/CLHEP/"$$pkg"/"$$pkg" && test ! -d "$$pkg"; then \
(mkdir $$pkg; cd $$pkg; \
hdrs=`ls $(CLHEP_DIR)/CLHEP/$$pkg/$$pkg`; \
for hdr in $$hdrs; do $(LN_S) $(CLHEP_DIR)/CLHEP/$$pkg/$$pkg/$$hdr $$hdr; done); \
fi; done); fi
docs:
cd doc; $(MAKE) $(AM_MAKEFLAGS)
install-docs:
cd doc; $(MAKE) $(AM_MAKEFLAGS) install-docs
# extra clean rule
clean-local:
rm -rf $(top_builddir)/CLHEP
config.sub
config.guess
depcomp
install-sh
missing
mkinstalldirs
This diff is collapsed.
#! /bin/sh
# run autotool commands
set -x
aclocal -I autotools
autoheader
automake --add-missing --copy
autoconf
# ready to make a source code distribution tarball
# ======================================================================
# This is the Evaluator configuration input file
# Process this file with autoconf to produce a configure script.
# ======================================================================
# ----------------------------------------------------------------------
# Identify the package and initialize the autotools:
# ----------------------------------------------------------------------
AC_PREREQ(2.57)
AC_INIT(CLHEP Evaluator, 1.9.0.0, CLHEP@cern.ch, Evaluator)
AC_CONFIG_AUX_DIR(autotools)
AC_CANONICAL_TARGET
AC_CONFIG_SRCDIR([src/Evaluator.cc])
AM_INIT_AUTOMAKE(1.6 foreign)
AC_PROG_LIBTOOL
AC_PROG_INSTALL
AC_PROG_LN_S
# ----------------------------------------------------------------------
# Identify the files that 'configure' is to produce:
# ----------------------------------------------------------------------
# Header containing #defines:
AM_CONFIG_HEADER([Evaluator/defs.h])
# Makefiles:
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([Evaluator/Makefile])
AC_CONFIG_FILES([src/Makefile])
AC_CONFIG_FILES([test/Makefile])
AC_CONFIG_FILES([Evaluator-deps])
# Test driver program/script:
AC_CONFIG_FILES([test/testEvaluator.sh], [chmod +x test/testEvaluator.sh])
# ----------------------------------------------------------------------
# Capture post-install information:
# ----------------------------------------------------------------------
Evaluator_CPPFLAGS="-I$includedir"
Evaluator_LDFLAGS="-L$libdir"
Evaluator_LIBS="-lCLHEP-$PACKAGE-$VERSION"
AC_SUBST(Evaluator_CPPFLAGS)
AC_SUBST(Evaluator_LIBS)
AC_SUBST(Evaluator_LDFLAGS)
# ----------------------------------------------------------------------
# Supply boilerplate for Evaluator/defs.h source header:
# ----------------------------------------------------------------------
AH_TOP([#ifndef EVALUATOR_DEFS_H
#define EVALUATOR_DEFS_H])
## the undefs are converted by configure
AH_VERBATIM([PACKAGE],[/* Name of package */
#ifndef PACKAGE
#undef PACKAGE
#endif])
AH_VERBATIM([PACKAGE_BUGREPORT],[/* Define to the address where bug reports for this package should be sent. */
#ifndef PACKAGE_BUGREPORT
#undef PACKAGE_BUGREPORT
#endif])
AH_VERBATIM([PACKAGE_NAME],[/* Define to the full name of this package. */
#ifndef PACKAGE_NAME
#undef PACKAGE_NAME
#endif])
AH_VERBATIM([PACKAGE_STRING],[/* Define to the full name and version of this package. */
#ifndef PACKAGE_STRING
#undef PACKAGE_STRING
#endif])
AH_VERBATIM([PACKAGE_TARNAME],[/* Define to the one symbol short name of this package. */
#ifndef PACKAGE_TARNAME
#undef PACKAGE_TARNAME
#endif])
AH_VERBATIM([PACKAGE_VERSION],[/* Define to the version of this package. */
#ifndef PACKAGE_VERSION
#undef PACKAGE_VERSION
#endif])
AH_VERBATIM([VERSION],[/* Version number of package */
#ifndef VERSION
#undef VERSION
#endif])
## backwards compatibility
AH_VERBATIM([ENABLE_BACKWARDS_COMPATIBILITY],[/* backwards compatibility will be enabled ONLY in CLHEP 1.9 */
#ifndef ENABLE_BACKWARDS_COMPATIBILITY
#define ENABLE_BACKWARDS_COMPATIBILITY
#endif])
AH_BOTTOM([#endif // EVALUATOR_DEFS_H])
# ----------------------------------------------------------------------
# Account for any user configuration options:
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# Check for needed programs:
# ----------------------------------------------------------------------
# Locate a C++ compiler:
AC_PROG_CXX(g++ c++ aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC gpp)
# Use it hereinafter:
AC_LANG(C++)
# Ensure we've found a preprocessor:
AC_REQUIRE_CPP
# worry about compiler flags
case "$target" in
*-*-win32*)
case "$CXX" in
cl) CXXFLAGS="-DWIN32 -O -GX -GR -MD";;
g++) CXXFLAGS="-O";;
c++) CXXFLAGS="-O";;
*) echo UNEXPECTED CHOICE OF C++ COMPILER: $CXX
esac;;
*-*-cygwin*)
case "$CXX" in
cl) CXXFLAGS="-DWIN32 -O -GX -GR -MD";;
g++) CXXFLAGS="-O -ansi -pedantic -Wall";;
c++) CXXFLAGS="-O -ansi -pedantic -Wall";;
*) echo UNEXPECTED CHOICE OF C++ COMPILER: $CXX
esac;;
*-*-solaris*)
case "$CXX" in
CC) CXXFLAGS="-O -mt";;
g++) CXXFLAGS="-O -ansi -pedantic -Wall";;
c++) CXXFLAGS="-O -ansi -pedantic -Wall";;
*) echo UNEXPECTED CHOICE OF C++ COMPILER: $CXX
esac;;
*-*-linux*)
case "$CXX" in
g++) CXXFLAGS="-O -ansi -pedantic -Wall -D_GNU_SOURCE";;
c++) CXXFLAGS="-O -ansi -pedantic -Wall -D_GNU_SOURCE";;
*) echo UNEXPECTED CHOICE OF C++ COMPILER: $CXX
esac;;
alpha*-dec-osf*)
case "$CXX" in
cxx) CXXFLAGS="-O -std strict_ansi -timplicit_local";;
g++) CXXFLAGS="-O -ansi -pedantic -Wall";;
c++) CXXFLAGS="-O -ansi -pedantic -Wall";;
*) echo UNEXPECTED CHOICE OF C++ COMPILER: $CXX
esac;;
*-*-hpux*)
case "$CXX" in
aCC) CXXFLAGS="-O -Aa +DAportable +Onolimit";;
CC) CXXFLAGS="+O3 +DAportable +a1 -z -pta +Onolimit";;
g++) CXXFLAGS="-O -ansi -pedantic -Wall";;
c++) CXXFLAGS="-O -ansi -pedantic -Wall";;
*) echo UNEXPECTED CHOICE OF C++ COMPILER: $CXX
esac;;
*-*-aix*)
case "$CXX" in
xlC) CXXFLAGS="-O3 -qtwolink -+";;
g++) CXXFLAGS="-O -ansi -pedantic -Wall";;
c++) CXXFLAGS="-O -ansi -pedantic -Wall";;
*) echo UNEXPECTED CHOICE OF C++ COMPILER: $CXX
esac;;
*-*-irix*)
case "$CXX" in
CC) CXXFLAGS="-O -OPT:Olimit=0 -pta";;
g++) CXXFLAGS="-O -ansi -pedantic -Wall";;
c++) CXXFLAGS="-O -ansi -pedantic -Wall";;
*) echo UNEXPECTED CHOICE OF C++ COMPILER: $CXX
esac;;
powerpc-apple-darwin*)
case "$CXX" in
g++) CXXFLAGS="-O -ansi -pedantic -Wall";;
c++) CXXFLAGS="-O -ansi -pedantic -Wall";;
*) echo UNEXPECTED CHOICE OF C++ COMPILER: $CXX
esac;;
esac
# ----------------------------------------------------------------------
# Set system-dependent options:
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# Check for needed libraries:
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# Check for needed header files:
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------