Commit 14887833 authored by Lynn Garren's avatar Lynn Garren
Browse files

remove unnecessary copy and disable allocator

merging configure changes
parent 99c32ea6
Fri Sep 24 2004 Lynn Garren <garren@fnal.gov>
* Matrix: remove unnecessary copy and disable allocator
==============================
23.07.04 Release CLHEP-2.0.1.0
==============================
==============================
11.05.04 Release CLHEP-2.0.0.2
==============================
......
#-------------------------------------------------------------
# platform specific issues
#-------------------------------------------------------------
Support for shared libraries with CC 5.4 on Solaris requires libtool 1.9b
or later. This also implies the use of autoconf 2.59 or later and
automake 1.9.1 or later. If you bootstrap, you will probably have to build
these yourself. See "building autotools" below.
The new libtool no longer properly supports shared libraries for gcc 2.95.2.
If you build CLHEP with gcc 2.95.2, you must configure --disable-shared.
#-------------------------------------------------------------
# installing from a source code tar ball
#-------------------------------------------------------------
......@@ -65,11 +77,13 @@ 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
If you do not have at least autoconf 2.59 and automake 1.9.1, 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.
Download the relevant tarballs from gnu.org
(http://www.gnu.org/software/autoconf/, http://www.gnu.org/software/automake/,
and http://www.gnu.org/software/libtool/)
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
......
......@@ -4,6 +4,10 @@ includedir = $(prefix)/include/CLHEP
# put . first so that CLHEP directory is built before anything else
SUBDIRS = Matrix . src test
# list all subdirectories - for distribution and cleaning
DIST_SUBDIRS = Matrix . src test
bin_SCRIPTS = Matrix-config
all-local: $(top_builddir)/CLHEP
......
#! /bin/sh
# @configure_input@
prefix=@prefix@
exec_prefix=@exec_prefix@
includedir=@includedir@
usage()
{
cat <<EOF
Usage: Matrix-config [OPTION]
Known values for OPTION are:
--prefix show installation prefix
--cxx print compilation command
--cppflags print pre-processor flags
--cxxflags print C++ compiler flags
--ldflags print linker flags
--libs print libraries to link against
--help display this help and exit
--version output version information
EOF
exit $1
}
if test $# -eq 0; then
usage 1
fi
while test $# -gt 0; do
case "$1" in
-*=*)
optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
;;
*)
optarg=
;;
esac
case "$1" in
--prefix=*)
prefix="$optarg"
;;
--prefix)
echo "$prefix"
;;
--version)
echo @PACKAGE@ @VERSION@
exit 0
;;
--help)
usage 0
;;
--cxx)
echo "CXX: " @CXX@
echo "CC: " @CC@
echo "CPP: " @CPP@
echo "CXXCPP: " @CXXCPP@
;;
--cppflags)
echo @CPPFLAGS@ @Matrix_CPPFLAGS@
;;
--cxxflags)
echo @AM_CXXFLAGS@ @CXXFLAGS@
;;
--ldflags)
echo @LDFLAGS@ @Matrix_LDFLAGS@
;;
--libs)
echo @LIBS@ @Matrix_LIBS@ -lm
;;
*)
usage
exit 1
;;
esac
shift
done
exit 0
// -*- C++ -*-
// CLASSDOC OFF
// $Id: DiagMatrix.h,v 1.3 2003/10/23 21:29:50 garren Exp $
// $Id: DiagMatrix.h,v 1.3.4.1 2004/09/24 21:28:13 garren Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
......@@ -51,6 +51,8 @@
#pragma interface
#endif
#include <vector>
#include "CLHEP/Matrix/defs.h"
#include "CLHEP/Matrix/GenMatrix.h"
......@@ -212,7 +214,11 @@ private:
friend HepMatrix operator*(const HepMatrix &m1, const HepDiagMatrix &m2);
friend HepVector operator*(const HepDiagMatrix &m1, const HepVector &m2);
double *m;
#ifdef DISABLE_ALLOC
std::vector<double > m;
#else
std::vector<double,Alloc<double,25> > m;
#endif
int nrow;
#if defined(__sun) || !defined(__GNUG__)
//
......
// -*- C++ -*-
// $Id: DiagMatrix.icc,v 1.2 2003/07/18 05:31:48 garren Exp $
// $Id: DiagMatrix.icc,v 1.2.4.1 2004/09/24 21:28:13 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -55,7 +55,7 @@ inline double & HepDiagMatrix::fast(int row,int col)
if (row != col)
error("Index error in HepDiagMatrix::fast(i,j): i != j");
return *(m+(col-1));
return *(m.begin()+(col-1));
}
inline const double & HepDiagMatrix::fast(int row,int col) const
......@@ -65,7 +65,7 @@ inline const double & HepDiagMatrix::fast(int row,int col) const
error("Range error in HepDiagMatrix::fast()");
#endif
if (row == col) {
return *(m+(col-1));
return *(m.begin()+(col-1));
} else {
#if defined(__sun) || !defined(__GNUG__)
//
......
// -*- C++ -*-
// CLASSDOC OFF
// $Id: GenMatrix.h,v 1.3 2003/10/23 21:29:50 garren Exp $
// $Id: GenMatrix.h,v 1.3.4.1 2004/09/24 21:28:13 garren Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
......@@ -49,6 +49,8 @@
#pragma interface
#endif
#include <vector>
#include <iostream>
#include "CLHEP/Matrix/defs.h"
......@@ -63,10 +65,50 @@ class HepGenMatrix;
* @ingroup matrix
*/
class HepGenMatrix {
public:
virtual ~HepGenMatrix() {}
#ifdef DISABLE_ALLOC // disable this non-compliant allocator
#else
template <class T, size_t size> class Alloc
{
public:
typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
pointer address(reference r) const { return &r; }
const_pointer address(const_reference r) const { return &r; }
Alloc() throw() {}
Alloc(const Alloc<T,size>&) throw() {}
~Alloc() throw() {}
pointer allocate(size_type n, const void* hint=0 ) { if( n <= size ) return pool; else return new T[n]; }
void deallocate(pointer p, size_type n) { if (p == pool ) return; delete [] p; }
void construct(pointer p, const T& val ) { new(p) T(val); }
void destroy(pointer p) { p->~T(); }
size_type max_size() const throw() { size_type c = (size_type)(-1) /sizeof(T); return (0 < c ? c : 1); }
template<class O> struct rebind { typedef Alloc<O,size> other; };
private:
T pool[size];
};
#endif
#ifdef DISABLE_ALLOC
typedef std::vector<double >::iterator mIter;
typedef std::vector<double >::const_iterator mcIter;
#else
typedef std::vector<double,Alloc<double,25> >::iterator mIter;
typedef std::vector<double,Alloc<double,25> >::const_iterator mcIter;
#endif
virtual int num_row() const = 0;
virtual int num_col() const = 0;
......@@ -103,7 +145,11 @@ public:
// ** Note that the indexing starts from [0][0]. **
inline static void swap(int&,int&);
inline static void swap(double *&, double *&);
#ifdef DISABLE_ALLOC
inline static void swap(std::vector<double >&, std::vector<double >&);
#else
inline static void swap(std::vector<double,Alloc<double,25> >&, std::vector<double,Alloc<double,25> >&);
#endif
virtual bool operator== ( const HepGenMatrix& ) const;
// equality operator for matrices (BaBar)
......@@ -131,8 +177,8 @@ private:
friend class HepGenMatrix_row;
friend class HepGenMatrix_row_const;
double data_array[size_max];
//-ap: removed this as it is taken over by the std::vector<double>
//-ap double data_array[size_max];
};
double norm(const HepGenMatrix &m);
......
// -*- C++ -*-
// $Id: GenMatrix.icc,v 1.2 2003/07/18 05:31:48 garren Exp $
// $Id: GenMatrix.icc,v 1.2.4.1 2004/09/24 21:28:13 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -41,7 +41,15 @@ namespace CLHEP {
// swap
//
inline void HepGenMatrix::swap(int &i,int &j) {int t=i;i=j;j=t;}
inline void HepGenMatrix::swap(double * &i,double * &j) {double * t=i;i=j;j=t;}
#ifdef DISABLE_ALLOC
inline void HepGenMatrix::swap(std::vector<double >& i, std::vector<double >& j) {
std::vector<double > t=i;i=j;j=t;
}
#else
inline void HepGenMatrix::swap(std::vector<double,Alloc<double,25> >& i, std::vector<double,Alloc<double,25> >& j) {
std::vector<double,Alloc<double,25> > t=i;i=j;j=t;
}
#endif
//
// operator [] (I cannot make it virtual because return types are different.)
......
// -*- C++ -*-
// CLASSDOC OFF
// $Id: Matrix.h,v 1.3 2003/10/23 21:29:50 garren Exp $
// $Id: Matrix.h,v 1.3.4.1 2004/09/24 21:28:13 garren Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
......@@ -228,6 +228,8 @@
#pragma interface
#endif
#include <vector>
#include "CLHEP/Matrix/defs.h"
#include "CLHEP/Matrix/GenMatrix.h"
......@@ -426,7 +428,11 @@ private:
int dfinv_matrix(int *ir);
// invert the matrix. See CERNLIB DFINV.
double *m;
#ifdef DISABLE_ALLOC
std::vector<double > m;
#else
std::vector<double,Alloc<double,25> > m;
#endif
int nrow, ncol;
int size;
};
......
// -*- C++ -*-
// $Id: Matrix.icc,v 1.2 2003/07/18 05:31:48 garren Exp $
// $Id: Matrix.icc,v 1.2.4.1 2004/09/24 21:28:13 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -56,7 +56,7 @@ inline double & HepMatrix::operator()(int row, int col)
if(row<1 || row>num_row() || col<1 || col>num_col())
error("Range error in HepMatrix::operator()");
#endif
return *(m+(row-1)*ncol+col-1);
return *(m.begin()+(row-1)*ncol+col-1);
}
inline const double & HepMatrix::operator()(int row, int col) const
......@@ -65,7 +65,7 @@ inline const double & HepMatrix::operator()(int row, int col) const
if(row<1 || row>num_row() || col<1 || col>num_col())
error("Range error in HepMatrix::operator()");
#endif
return *(m+(row-1)*ncol+col-1);
return *(m.begin()+(row-1)*ncol+col-1);
}
inline HepMatrix::HepMatrix_row HepMatrix::operator[] (int r)
......@@ -95,7 +95,7 @@ inline double &HepMatrix::HepMatrix_row::operator[](int c) {
if (_r<0 || _r>=_a.num_row() || c<0 || c>=_a.num_col())
HepGenMatrix::error("Range error in HepMatrix::operator[][]");
#endif
return *(_a.m+_r*_a.ncol+c);
return *(_a.m.begin()+_r*_a.ncol+c);
}
inline const double &HepMatrix::HepMatrix_row_const::operator[](int c) const
......@@ -104,7 +104,7 @@ inline const double &HepMatrix::HepMatrix_row_const::operator[](int c) const
if (_r<0 || _r>=_a.num_row() || c<0 || c>=_a.num_col())
HepGenMatrix::error("Range error in HepMatrix::operator[][]");
#endif
return *(_a.m+_r*_a.ncol+c);
return *(_a.m.begin()+_r*_a.ncol+c);
}
inline HepMatrix::HepMatrix_row::HepMatrix_row(HepMatrix&a,int r)
......@@ -122,12 +122,14 @@ inline HepMatrix::HepMatrix_row_const::HepMatrix_row_const
// This function swaps two Matrices without doing a full copy.
inline void swap(HepMatrix &m1,HepMatrix &m2) {
HepGenMatrix::swap(m1.m,m2.m);
/*** commented
HepGenMatrix::swap(m1.nrow,m2.nrow);
HepGenMatrix::swap(m1.ncol,m2.ncol);
HepGenMatrix::swap(m1.size,m2.size);
*/
}
inline HepMatrix HepMatrix::inverse(int &ierr) const
/*-ap inline */ HepMatrix HepMatrix::inverse(int &ierr) const
#ifdef HEP_GNU_OPTIMIZED_RETURN
return mTmp(*this);
{
......
// -*- C++ -*-
// CLASSDOC OFF
// $Id: SymMatrix.h,v 1.3 2003/10/23 21:29:50 garren Exp $
// $Id: SymMatrix.h,v 1.3.4.1 2004/09/24 21:28:13 garren Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
......@@ -109,6 +109,8 @@
#pragma interface
#endif
#include <vector>
#include "CLHEP/Matrix/defs.h"
#include "CLHEP/Matrix/GenMatrix.h"
......@@ -298,7 +300,11 @@ private:
friend HepSymMatrix vT_times_v(const HepVector &v);
// Returns v * v.T();
double *m;
#ifdef DISABLE_ALLOC
std::vector<double > m;
#else
std::vector<double,Alloc<double,25> > m;
#endif
int nrow;
int size; // total number of elements
......
// -*- C++ -*-
// $Id: SymMatrix.icc,v 1.2 2003/07/18 05:31:48 garren Exp $
// $Id: SymMatrix.icc,v 1.2.4.1 2004/09/24 21:28:13 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -55,7 +55,7 @@ inline double & HepSymMatrix::fast(int row,int col)
if(row<1||row>num_row() || col<1||col>num_col())
error("Range error in HepSymMatrix::fast()");
#endif
return *(m+(row*(row-1))/2+(col-1));
return *(m.begin()+(row*(row-1))/2+(col-1));
}
inline const double & HepSymMatrix::fast(int row,int col) const
{
......@@ -63,7 +63,7 @@ inline const double & HepSymMatrix::fast(int row,int col) const
if(row<1||row>num_row() || col<1||col>num_col())
error("Range error in HepSymMatrix::fast()");
#endif
return *(m+(row*(row-1))/2+(col-1));
return *(m.begin()+(row*(row-1))/2+(col-1));
}
inline double & HepSymMatrix::operator()(int row, int col)
......@@ -105,9 +105,9 @@ inline double &HepSymMatrix::HepSymMatrix_row::operator[](int c)
error("Range error in HepSymMatrix::operator[][]");
#endif
if (_r >= c ) {
return *(_a.m + (_r+1)*_r/2 + c);
return *(_a.m.begin() + (_r+1)*_r/2 + c);
} else {
return *(_a.m + (c+1)*c/2 + _r);
return *(_a.m.begin() + (c+1)*c/2 + _r);
}
}
......@@ -119,9 +119,9 @@ HepSymMatrix::HepSymMatrix_row_const::operator[](int c) const
error("Range error in HepSymMatrix::operator[][]");
#endif
if (_r >= c ) {
return *(_a.m + (_r+1)*_r/2 + c);
return *(_a.m.begin() + (_r+1)*_r/2 + c);
} else {
return *(_a.m + (c+1)*c/2 + _r);
return *(_a.m.begin() + (c+1)*c/2 + _r);
}
}
......
// -*- C++ -*-
// CLASSDOC OFF
// $Id: Vector.h,v 1.3 2003/10/23 21:29:50 garren Exp $
// $Id: Vector.h,v 1.3.4.1 2004/09/24 21:28:13 garren Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
......@@ -196,7 +196,11 @@ private:
friend HepSymMatrix vT_times_v(const HepVector &v);
friend HepVector qr_solve(HepMatrix *, const HepVector &);
double *m;
#ifdef DISABLE_ALLOC
std::vector<double > m;
#else
std::vector<double,Alloc<double,25> > m;
#endif
int nrow;
};
......
// -*- C++ -*-
// $Id: Vector.icc,v 1.3 2003/07/18 05:31:48 garren Exp $
// $Id: Vector.icc,v 1.3.4.1 2004/09/24 21:28:13 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -64,7 +64,7 @@ inline double & HepVector::operator()(int row)
error("Range error in HepVector::operator()");
#endif
return *(m+row-1);
return *(m.begin()+row-1);
}
inline const double & HepVector::operator()(int row) const
{
......@@ -73,7 +73,7 @@ inline const double & HepVector::operator()(int row) const
error("Range error in HepVector::operator()");
#endif
return *(m+row-1);
return *(m.begin()+row-1);
}
inline double & HepVector::operator[](int row)
{
......@@ -82,7 +82,7 @@ inline double & HepVector::operator[](int row)
error("Range error in HepVector::operator[]");
#endif
return *(m+row);
return *(m.begin()+row);
}
inline const double & HepVector::operator[](int row) const
{
......@@ -91,7 +91,7 @@ inline const double & HepVector::operator[](int row) const
error("Range error in HepVector::operator[]");
#endif
return *(m+row);
return *(m.begin()+row);
}
#ifdef MATRIX_BOUND_CHECK
......@@ -104,7 +104,7 @@ inline double & HepVector::operator()(int row, int)
{
#endif
return *(m+(row-1));
return *(m.begin()+(row-1));
}
#ifdef MATRIX_BOUND_CHECK
......@@ -117,7 +117,7 @@ inline const double & HepVector::operator()(int row, int) const
{
#endif
return *(m+(row-1));
return *(m.begin()+(row-1));
}
} // namespace CLHEP
......
This diff is collapsed.
#! /bin/sh
# run autotool commands
set -x
# cleanup should not be necessary
# however, in some cases strange results are found if you do not start clean
rm -rf autom4te.cache
rm -f aclocal.m4
rm -f Makefile.in */Makefile.in */defs.h.in
rm -f autotools/config* autotools/depcomp autotools/install-sh autotools/m*
rm -f configure config.*
# run autotool commands
aclocal -I autotools
autoheader
automake --add-missing --copy
......
......@@ -8,12 +8,12 @@
# Identify the package and initialize the autotools:
# ----------------------------------------------------------------------
AC_PREREQ(2.57)
AC_PREREQ(2.59)
AC_INIT(CLHEP Matrix, 2.0.1.1, CLHEP@cern.ch, Matrix)
AC_CONFIG_AUX_DIR(autotools)
AC_CANONICAL_TARGET
AC_CONFIG_SRCDIR([src/DiagMatrix.cc])
AM_INIT_AUTOMAKE(1.6 foreign)
AM_INIT_AUTOMAKE(1.9 foreign)
AC_PROG_LIBTOOL
AC_PROG_LN_S
AC_PROG_INSTALL
......@@ -34,6 +34,9 @@ AC_CONFIG_FILES([test/Makefile])
AC_CONFIG_FILES([Matrix-deps])
AC_CONFIG_FILES([Matrix/copy-header.pl], [chmod +x Matrix/copy-header.pl])
# Configuration inquiry program/script:
AC_CONFIG_FILES([Matrix-config], [chmod +x Matrix-config])
# Test driver program/script:
AC_CONFIG_FILES([test/testMatrix.sh], [chmod +x test/testMatrix.sh])
AC_CONFIG_FILES([test/testInversion.sh], [chmod +x test/testInversion.sh])
......@@ -50,9 +53,6 @@ AC_SUBST(Matrix_CPPFLAGS)
AC_SUBST(Matrix_LIBS)
AC_SUBST(Matrix_LDFLAGS)
AC_SUBST(COPY_P)
AC_SUBST(DIFF_Q)
# ----------------------------------------------------------------------
# Supply boilerplate for Matrix/defs.h source header:
# ----------------------------------------------------------------------
......@@ -90,6 +90,12 @@ AH_VERBATIM([VERSION],[/* Version number of package */
#undef VERSION
#endif])
## disable allocator until it is fixed
AH_VERBATIM([DISABLE_ALLOC],[/* disable non-compliant allocator */
#ifndef DISABLE_ALLOC
#define DISABLE_ALLOC
#endif])
AH_BOTTOM([#endif // MATRIX_DEFS_H])
......@@ -111,72 +117,63 @@ AC_LANG(C++)
# Ensure we've found a preprocessor:
AC_REQUIRE_CPP
# worry about compiler flags
# copy and diff
case "$target" in
*-*-win32*)
case "$CXX" in
cl) CXXFLAGS="-DWIN32 -O -GX -GR -MD";COPY_P="copy -p";DIFF_Q="diff -q -b";;
g++) CXXFLAGS="-O";COPY_P="copy -p";DIFF_Q="diff -q -b";;
c++) CXXFLAGS="-O";COPY_P="copy -p";DIFF_Q="diff -q -b";;
*) echo UNEXPECTED CHOICE OF C++ COMPILER: $CXX
esac;;
COPY_P="copy -p";DIFF_Q="diff -q -b"
;;
*-*-cygwin*)
case "$CXX" in
cl) CXXFLAGS="-DWIN32 -O -GX -GR -MD";COPY_P="cp -p";DIFF_Q="diff -q -b";;
g++) CXXFLAGS="-O -ansi -pedantic -Wall";COPY_P="cp -p";DIFF_Q="diff -q -b";;
c++) CXXFLAGS="-O -ansi -pedantic -Wall";COPY_P="cp -p";DIFF_Q="diff -q -b";;
*) echo UNEXPECTED CHOICE OF C++ COMPILER: $CXX