Commit 5e3fc250 authored by Joseph Boudreau's avatar Joseph Boudreau
Browse files

First commit of CLHEP Fields: this contains transformation fields

parent 43b81639
CLHEP-@PACKAGE@-@VERSION@ CLHEP-@PACKAGE@-@VERSION@
CLHEP-@PACKAGE@-@VERSION@ CLHEP-GenericFunctions-@VERSION@
CLHEP-@PACKAGE@-@VERSION@ CLHEP-Geometry-@VERSION@
## Process this file with automake to produce Makefile.in
includedir = $(prefix)/include/CLHEP
pkginclude_HEADERS = \
XF.h \
defs.h
# Identify generated file(s) to be removed when 'make clean' is requested:
CLEANFILES = defs.h
//---------------XF::Function (transformation field)--------------------//
// //
// XF::Function, class of function objects which evaluate to a //
// evaluate to a HepTransform, and a class XF::Pow which can be //
// used to exponentiate any transform. The transformations fields //
// can be multiplied together or multiplied with a fixed global //
// transformation. These can be used to build arbitrary //
// HepTransform3D-valued-fields which are very compact. Chief //
// application so far is in geometry modelling where it is a //
// powerful technique for parameterization. //
// //
// Example: //
// //
// // Define some constants: //
// int N; //
// double c1, c2, r, z; //
// //
// // Construct a simple linear function of a variable i: //
// //
// Variable i; //
// //
// GENFUNCTION g = c1+c2*i; //
// //
// // Create a transfunction //
// //
// TRANSFUNCTION xf = Pow(HepRotateZ3D(1),g)* //
// HepTranslateX3D(r)* //
// HepTranslateZ3D(z); //
// //
// // Evaluation of TRANSFUNCTION //
// //
// HepTransform3D x = xf(33.2); //
// //
// //
// ... //
// Similar techniques may be used to create a transformation field of //
// more than one variable. //
// //
// //
//----------------------------------------------------------------------//
#ifndef TransformFunction_h
#define TransformFunction_h 1
#include "CLHEP/GenericFunctions/AbsFunction.hh"
#include "CLHEP/GenericFunctions/Argument.hh"
#include "CLHEP/Geometry/Transform3D.h"
//-----------------------------------------------------------------------//
// Exact return type of arithmentic operations. To the user, the return //
// type is TRANSFUNCTION, or const XF::Function &. //
//-----------------------------------------------------------------------//
namespace XF
{
class Product;
class PreMult;
class PostMult;
class Pow;
class Function
{
public:
// Default Constructor
Function ();
// Destructor
virtual ~ Function ();
// Function value: N-dimensional functions must override these:
virtual unsigned int dimensionality () const; //returns 1;
// Function value
virtual HepTransform3D operator () (double argument) const = 0;
virtual HepTransform3D operator () (const Genfun::
Argument & argument) const =
0;
// Every function must override this:
virtual Function *clone () const = 0;
// Copy constructor
Function (const Function & right);
private:
// Assignment operator
const Function & operator = (const Function & right);
};
class Pow:public Function
{
public:
Pow (const HepTransform3D &, Genfun::GENFUNCTION f);
virtual ~ Pow ();
virtual HepTransform3D operator () (double argument) const;
virtual HepTransform3D operator () (const Genfun::
Argument & argument) const;
// Every function must override this:
Pow *clone () const;
// Copy constructor:
Pow (const Pow & right);
private:
// Assignment operator
const Pow & operator = (const Pow & right);
const HepTransform3D xf;
const Genfun::AbsFunction * function;
};
Product operator * (const Function & op1, const Function & op2);
PreMult operator * (const HepTransform3D & xf, const Function & op2);
PostMult operator * (const Function & op2, const HepTransform3D & xf);
// Internally used class:: Product:
class Product:public Function
{
public:
Product (const Function * arg1, const Function * arg2);
virtual ~ Product ();
virtual unsigned int dimensionality () const;
virtual HepTransform3D operator () (double argument) const;
virtual HepTransform3D operator () (const Genfun::
Argument & argument) const;
// Every function must override this:
virtual Product *clone () const;
// Copy constructor:
Product (const Product & right);
private:
const Function *_arg1;
const Function *_arg2;
};
// Internally used class:: PreMult :
class PreMult:public Function
{
public:
PreMult (const HepTransform3D & arg1, const Function * arg2);
virtual ~ PreMult ();
virtual unsigned int dimensionality () const;
virtual HepTransform3D operator () (double argument) const;
virtual HepTransform3D operator () (const Genfun::
Argument & argument) const;
// Every function must override this:
virtual PreMult *clone () const;
// Copy constructor:
PreMult (const PreMult & right);
private:
const HepTransform3D _arg1;
const Function *_arg2;
};
// Internally used class:: PostMult :
class PostMult:public Function
{
public:
PostMult (const Function * arg1, const HepTransform3D & arg2);
virtual ~ PostMult ();
virtual unsigned int dimensionality () const;
virtual HepTransform3D operator () (double argument) const;
virtual HepTransform3D operator () (const Genfun::
Argument & argument) const;
// Every function must override this:
virtual PostMult *clone () const;
// Copy constructor:
PostMult (const PostMult & right);
private:
const Function *_arg1;
const HepTransform3D _arg2;
};
typedef const Function & TRANSFUNCTION;
}
#endif
#-------------------------------------------------------------
# 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 = Fields . 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
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 Fields 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 Fields, 2.0.0.0, CLHEP@cern.ch, Fields)
AC_CONFIG_AUX_DIR(autotools)
AC_CANONICAL_TARGET
AC_CONFIG_SRCDIR([src/XF.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([Fields/defs.h])
# Makefiles:
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([Fields/Makefile])
AC_CONFIG_FILES([src/Makefile])
AC_CONFIG_FILES([test/Makefile])
AC_CONFIG_FILES([Fields-deps])
# Test driver program/script:
AC_CONFIG_FILES([test/testXF.sh], [chmod +x test/testXF.sh])
# ----------------------------------------------------------------------
# Capture post-install information:
# ----------------------------------------------------------------------
Fields_CPPFLAGS="-I$includedir"
Fields_LDFLAGS="-L$libdir"
Fields_LIBS="-lCLHEP-$PACKAGE-$VERSION -lCLHEP-Geometry-$VERSION -lCLHEP-GenericFunctions-$VERSION"
AC_SUBST(Fields_CPPFLAGS)
AC_SUBST(Fields_LIBS)
AC_SUBST(Fields_LDFLAGS)
# ----------------------------------------------------------------------
# Supply boilerplate for Fields/defs.h source header:
# ----------------------------------------------------------------------
AH_TOP([#ifndef FIELDS_DEFS_H
#define FIELDS_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])
AH_BOTTOM([#endif // FIELDS_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:
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# Check for needed typedefs, structures, and compiler characteristics:
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# Check for needed library functions:
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# Finish up:
# ----------------------------------------------------------------------
AC_OUTPUT
# ======================================================================
## Process this file with automake to produce Makefile.in
INCLUDES = -I$(top_builddir)
lib_LTLIBRARIES = libCLHEP-Fields-@VERSION@.la
libCLHEP_Fields_@VERSION@_la_SOURCES = \
XF.cc
#include "CLHEP/Fields/XF.h"
#include <assert.h>
#include <iostream>
namespace XF
{
//------------------------------------------------------------------//
// //
// Implementation of Function //
// //
//------------------------------------------------------------------//
Function::Function ()
{
}
Function::~Function ()
{
}
Product operator * (const Function & a, const Function & b)
{
return Product (&a, &b);
}
PreMult operator * (const HepTransform3D & xf, const Function & b)
{
return PreMult (xf, &b);
}