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

make it work with gcc 2.95.2

parent 80e2e3ce
// -*- C++ -*-
// CLASSDOC OFF
// $Id: DiagMatrix.h,v 1.3.2.1 2004/08/25 18:37:41 pfeiffer Exp $
// $Id: DiagMatrix.h,v 1.3.2.2 2004/09/08 22:51:05 garren Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
......@@ -214,7 +214,11 @@ private:
friend HepMatrix operator*(const HepMatrix &m1, const HepDiagMatrix &m2);
friend HepVector operator*(const HepDiagMatrix &m1, const HepVector &m2);
#if defined __GNUC__ && (__GNUC__ < 3)
std::vector<double > m;
#else
std::vector<double,Alloc<double,25> > m;
#endif
int nrow;
#if defined(__sun) || !defined(__GNUG__)
//
......
// -*- C++ -*-
// CLASSDOC OFF
// $Id: GenMatrix.h,v 1.3.2.2 2004/09/02 09:49:38 pfeiffer Exp $
// $Id: GenMatrix.h,v 1.3.2.3 2004/09/08 22:51:05 garren Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
......@@ -70,7 +70,8 @@ public:
virtual ~HepGenMatrix() {}
#if defined __GNUC__ && (__GNUC__ < 3) // redefining Alloc does not work in gcc 2.95
#else // redefine Alloc for all other compilers
template <class T, size_t size> class Alloc
{
......@@ -98,10 +99,15 @@ public:
private:
T pool[size];
};
#endif
#if defined __GNUC__ && (__GNUC__ < 3)
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;
......@@ -139,7 +145,11 @@ public:
// ** Note that the indexing starts from [0][0]. **
inline static void swap(int&,int&);
#if defined __GNUC__ && (__GNUC__ < 3)
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)
......
// -*- C++ -*-
// $Id: GenMatrix.icc,v 1.2.2.1 2004/08/25 18:37:41 pfeiffer Exp $
// $Id: GenMatrix.icc,v 1.2.2.2 2004/09/08 22:51:05 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -41,9 +41,15 @@ namespace CLHEP {
// swap
//
inline void HepGenMatrix::swap(int &i,int &j) {int t=i;i=j;j=t;}
#if defined __GNUC__ && (__GNUC__ < 3)
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.2.1 2004/08/25 18:37:41 pfeiffer Exp $
// $Id: Matrix.h,v 1.3.2.2 2004/09/08 22:51:05 garren Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
......@@ -428,7 +428,11 @@ private:
int dfinv_matrix(int *ir);
// invert the matrix. See CERNLIB DFINV.
#if defined __GNUC__ && (__GNUC__ < 3)
std::vector<double > m;
#else
std::vector<double,Alloc<double,25> > m;
#endif
int nrow, ncol;
int size;
};
......
// -*- C++ -*-
// CLASSDOC OFF
// $Id: SymMatrix.h,v 1.3.2.1 2004/08/25 18:37:41 pfeiffer Exp $
// $Id: SymMatrix.h,v 1.3.2.2 2004/09/08 22:51:05 garren Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
......@@ -300,7 +300,11 @@ private:
friend HepSymMatrix vT_times_v(const HepVector &v);
// Returns v * v.T();
#if defined __GNUC__ && (__GNUC__ < 3)
std::vector<double > m;
#else
std::vector<double,Alloc<double,25> > m;
#endif
int nrow;
int size; // total number of elements
......
// -*- C++ -*-
// CLASSDOC OFF
// $Id: Vector.h,v 1.3.2.1 2004/08/25 18:37:41 pfeiffer Exp $
// $Id: Vector.h,v 1.3.2.2 2004/09/08 22:51:05 garren Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
......@@ -196,7 +196,11 @@ private:
friend HepSymMatrix vT_times_v(const HepVector &v);
friend HepVector qr_solve(HepMatrix *, const HepVector &);
#if defined __GNUC__ && (__GNUC__ < 3)
std::vector<double > m;
#else
std::vector<double,Alloc<double,25> > m;
#endif
int nrow;
};
......
// -*- C++ -*-
// $Id: DiagMatrix.cc,v 1.4.2.1 2004/08/25 18:37:41 pfeiffer Exp $
// $Id: DiagMatrix.cc,v 1.4.2.2 2004/09/08 22:50:24 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -100,12 +100,20 @@ const double HepDiagMatrix::zero = 0;
// Constructors. (Default constructors are inlined and in .icc file)
HepDiagMatrix::HepDiagMatrix(int p)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double>(p)), nrow(p)
#else
: m(std::vector<double,Alloc<double,25> >(p)), nrow(p)
#endif
{
}
HepDiagMatrix::HepDiagMatrix(int p, int init)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double>(p)), nrow(p)
#else
: m(std::vector<double,Alloc<double,25> >(p)), nrow(p)
#endif
{
switch(init)
{
......@@ -126,7 +134,11 @@ HepDiagMatrix::HepDiagMatrix(int p, int init)
}
HepDiagMatrix::HepDiagMatrix(int p, HepRandom &r)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(p)), nrow(p)
#else
: m(std::vector<double,Alloc<double,25> >(p)), nrow(p)
#endif
{
HepMatrix::mIter a = m.begin();
HepMatrix::mIter b = m.begin() + num_size();
......@@ -139,7 +151,11 @@ HepDiagMatrix::~HepDiagMatrix() {
}
HepDiagMatrix::HepDiagMatrix(const HepDiagMatrix &m1)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(m1.nrow)), nrow(m1.nrow)
#else
: m(std::vector<double,Alloc<double,25> >(m1.nrow)), nrow(m1.nrow)
#endif
{
m = m1.m;
}
......
// -*- C++ -*-
// $Id: Matrix.cc,v 1.4.2.1 2004/08/25 18:37:41 pfeiffer Exp $
// $Id: Matrix.cc,v 1.4.2.2 2004/09/08 22:50:24 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -93,13 +93,21 @@ namespace CLHEP {
// Constructors. (Default constructors are inlined and in .icc file)
HepMatrix::HepMatrix(int p,int q)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(p*q)), nrow(p), ncol(q)
#else
: m(std::vector<double,Alloc<double,25> >(p*q)), nrow(p), ncol(q)
#endif
{
size = nrow * ncol;
}
HepMatrix::HepMatrix(int p,int q,int init)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(p*q)), nrow(p), ncol(q)
#else
: m(std::vector<double,Alloc<double,25> >(p*q)), nrow(p), ncol(q)
#endif
{
size = nrow * ncol;
......@@ -127,7 +135,11 @@ HepMatrix::HepMatrix(int p,int q,int init)
}
HepMatrix::HepMatrix(int p,int q, HepRandom &r)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(p*q)), nrow(p), ncol(q)
#else
: m(std::vector<double,Alloc<double,25> >(p*q)), nrow(p), ncol(q)
#endif
{
size = nrow * ncol;
......@@ -142,14 +154,22 @@ HepMatrix::~HepMatrix() {
}
HepMatrix::HepMatrix(const HepMatrix &m1)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(m1.size)), nrow(m1.nrow), ncol(m1.ncol), size(m1.size)
#else
: m(std::vector<double,Alloc<double,25> >(m1.size)), nrow(m1.nrow), ncol(m1.ncol), size(m1.size)
#endif
{
m = m1.m;
}
HepMatrix::HepMatrix(const HepSymMatrix &m1)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(m1.nrow*m1.nrow)), nrow(m1.nrow), ncol(m1.nrow)
#else
: m(std::vector<double,Alloc<double,25> >(m1.nrow*m1.nrow)), nrow(m1.nrow), ncol(m1.nrow)
#endif
{
size = nrow * ncol;
......@@ -173,7 +193,11 @@ HepMatrix::HepMatrix(const HepSymMatrix &m1)
}
HepMatrix::HepMatrix(const HepDiagMatrix &m1)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(m1.nrow*m1.nrow)), nrow(m1.nrow), ncol(m1.nrow)
#else
: m(std::vector<double,Alloc<double,25> >(m1.nrow*m1.nrow)), nrow(m1.nrow), ncol(m1.nrow)
#endif
{
size = nrow * ncol;
......@@ -187,7 +211,11 @@ HepMatrix::HepMatrix(const HepDiagMatrix &m1)
}
HepMatrix::HepMatrix(const HepVector &m1)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(m1.nrow)), nrow(m1.nrow), ncol(1)
#else
: m(std::vector<double,Alloc<double,25> >(m1.nrow)), nrow(m1.nrow), ncol(1)
#endif
{
size = nrow;
......
// -*- C++ -*-
// $Id: SymMatrix.cc,v 1.3.2.1 2004/08/25 18:37:41 pfeiffer Exp $
// $Id: SymMatrix.cc,v 1.3.2.2 2004/09/08 22:50:24 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -89,14 +89,22 @@ namespace CLHEP {
// Constructors. (Default constructors are inlined and in .icc file)
HepSymMatrix::HepSymMatrix(int p)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(p*(p+1)/2)), nrow(p)
#else
: m(std::vector<double,Alloc<double,25> >(p*(p+1)/2)), nrow(p)
#endif
{
size = nrow * (nrow+1) / 2;
m.assign(size,0);
}
HepSymMatrix::HepSymMatrix(int p, int init)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(p*(p+1)/2)), nrow(p)
#else
: m(std::vector<double,Alloc<double,25> >(p*(p+1)/2)), nrow(p)
#endif
{
size = nrow * (nrow+1) / 2;
......@@ -121,7 +129,11 @@ HepSymMatrix::HepSymMatrix(int p, int init)
}
HepSymMatrix::HepSymMatrix(int p, HepRandom &r)
: m(std::vector<double,Alloc<double,25> >(p*(p+1)/2)), nrow(p)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(p*(p+1)/2)), nrow(p)
#else
: m(std::vector<double,Alloc<double,25> >(p*(p+1)/2)), nrow(p)
#endif
{
size = nrow * (nrow+1) / 2;
HepMatrix::mIter a = m.begin();
......@@ -136,13 +148,21 @@ HepSymMatrix::~HepSymMatrix() {
}
HepSymMatrix::HepSymMatrix(const HepSymMatrix &m1)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(m1.size)), nrow(m1.nrow), size(m1.size)
#else
: m(std::vector<double,Alloc<double,25> >(m1.size)), nrow(m1.nrow), size(m1.size)
#endif
{
m = m1.m;
}
HepSymMatrix::HepSymMatrix(const HepDiagMatrix &m1)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(m1.nrow*(m1.nrow+1)/2)), nrow(m1.nrow)
#else
: m(std::vector<double,Alloc<double,25> >(m1.nrow*(m1.nrow+1)/2)), nrow(m1.nrow)
#endif
{
size = nrow * (nrow+1) / 2;
......@@ -992,7 +1012,11 @@ void HepSymMatrix::invertBunchKaufman(int &ifail) {
static int * piv = new int[max_array];
// used to store details of exchanges
#if defined __GNUC__ && (__GNUC__ < 3)
std::vector<double >* xvec = new std::vector<double>(max_array);
#else
std::vector<double,Alloc<double,25> >* xvec = new std::vector<double,Alloc<double,25> >(max_array);
#endif
static mIter x = xvec->begin();
// helper storage, needs to have at least size nrow,
// which will be less than or equal 6 most of the time
......
// -*- C++ -*-
// $Id: Vector.cc,v 1.3.2.1 2004/08/25 18:37:41 pfeiffer Exp $
// $Id: Vector.cc,v 1.3.2.2 2004/09/08 22:50:24 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -86,12 +86,20 @@ namespace CLHEP {
// Constructors. (Default constructors are inlined and in .icc file)
HepVector::HepVector(int p)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(p)), nrow(p)
#else
: m(std::vector<double,Alloc<double,25> >(p)), nrow(p)
#endif
{
}
HepVector::HepVector(int p, int init)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(p)), nrow(p)
#else
: m(std::vector<double,Alloc<double,25> >(p)), nrow(p)
#endif
{
switch (init)
{
......@@ -112,7 +120,11 @@ HepVector::HepVector(int p, int init)
}
HepVector::HepVector(int p, HepRandom &r)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(p)), nrow(p)
#else
: m(std::vector<double,Alloc<double,25> >(p)), nrow(p)
#endif
{
HepGenMatrix::mIter a = m.begin();
HepGenMatrix::mIter b = m.begin() + nrow;
......@@ -127,7 +139,11 @@ HepVector::~HepVector() {
}
HepVector::HepVector(const HepVector &m1)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(m1.nrow)), nrow(m1.nrow)
#else
: m(std::vector<double,Alloc<double,25> >(m1.nrow)), nrow(m1.nrow)
#endif
{
m = m1.m;
}
......@@ -138,7 +154,11 @@ HepVector::HepVector(const HepVector &m1)
HepVector::HepVector(const HepMatrix &m1)
#if defined __GNUC__ && (__GNUC__ < 3)
: m(std::vector<double >(m1.nrow)), nrow(m1.nrow)
#else
: m(std::vector<double,Alloc<double,25> >(m1.nrow)), nrow(m1.nrow)
#endif
{
if (m1.num_col() != 1)
error("Vector::Vector(Matrix) : Matrix is not Nx1");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment