00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #ifndef _GENMatrix_H_
00046 #define _GENMatrix_H_
00047
00048 #ifdef GNUPRAGMA
00049 #pragma interface
00050 #endif
00051
00052 #include <vector>
00053 #include "CLHEP/config/CLHEP.h"
00054 #include "CLHEP/config/iostream.h"
00055
00056 class HepGenMatrix_row;
00057 class HepGenMatrix_row_const;
00058 class HepGenMatrix;
00059
00064 class HepGenMatrix {
00065
00066 public:
00067 virtual ~HepGenMatrix() {}
00068
00069
00070
00071 template <class T, size_t size> class Alloc
00072 {
00073
00074 public:
00075 typedef T value_type;
00076 typedef size_t size_type;
00077 typedef ptrdiff_t difference_type;
00078 typedef T* pointer;
00079 typedef const T* const_pointer;
00080 typedef T& reference;
00081 typedef const T& const_reference;
00082
00083 pointer address(reference r) const { return &r; }
00084 const_pointer address(const_reference r) const { return &r; }
00085 Alloc() throw() {}
00086 Alloc(const Alloc<T,size>&) throw() {}
00087 ~Alloc() throw() {}
00088 pointer allocate(size_type n ) { if( n <= size ) return pool; else return new T[n]; }
00089 void deallocate(pointer p, size_type n) { if (p == pool ) return; delete [] p; }
00090 void construct(pointer p, const T& val ) { new(p) T(val); }
00091 void destroy(pointer p) { p->~T(); }
00092 size_type max_size() const throw() { size_type c = (size_type)(-1) /sizeof(T); return (0 < c ? c : 1); }
00093 template<class O> struct rebind { typedef Alloc<O,size> other; };
00094
00095 private:
00096 T pool[size];
00097 };
00098
00099
00100 typedef std::vector<double,Alloc<double,25> >::iterator mIter;
00101 typedef std::vector<double,Alloc<double,25> >::const_iterator mcIter;
00102
00103 virtual int num_row() const = 0;
00104 virtual int num_col() const = 0;
00105
00106 virtual const double & operator()(int row, int col) const =0;
00107 virtual double & operator()(int row, int col) =0;
00108
00109
00110
00111 virtual void invert(int&) = 0;
00112
00113 class HepGenMatrix_row {
00114 public:
00115 inline HepGenMatrix_row(HepGenMatrix&,int);
00116 double & operator[](int);
00117 private:
00118 HepGenMatrix& _a;
00119 int _r;
00120 };
00121 class HepGenMatrix_row_const {
00122 public:
00123 inline HepGenMatrix_row_const (const HepGenMatrix&,int);
00124 const double & operator[](int) const;
00125 private:
00126 const HepGenMatrix& _a;
00127 int _r;
00128 };
00129
00130
00131 inline HepGenMatrix_row operator[] (int);
00132 inline const HepGenMatrix_row_const operator[] (int) const;
00133
00134
00135
00136
00137
00138 inline static void swap(int&,int&);
00139 inline static void swap(std::vector<double,Alloc<double,25> >&, std::vector<double,Alloc<double,25> >&);
00140
00141 virtual bool operator== ( const HepGenMatrix& ) const;
00142
00143
00144 static void error(const char *s);
00145
00146 protected:
00147
00148 virtual int num_size() const = 0;
00149 void delete_m(int size, double*);
00150 double* new_m(int size);
00151
00152 public:
00153 enum{size_max = 25};
00154
00155
00156
00157
00158
00159
00160
00161 private:
00162 void operator=(const HepGenMatrix &) {}
00163
00164
00165 friend class HepGenMatrix_row;
00166 friend class HepGenMatrix_row_const;
00167
00168 double data_array[size_max];
00169
00170 };
00171
00172 double norm(const HepGenMatrix &m);
00173 double norm1(const HepGenMatrix &m);
00174 double norm_infinity(const HepGenMatrix &m);
00175
00176
00177 #ifdef HEP_NO_INLINE_IN_DECLARATION
00178 #undef inline
00179 #endif
00180
00181 #ifdef HEP_SHORT_NAMES
00182 typedef HepGenMatrix GenMatrix;
00183 #endif
00184
00185 #ifndef HEP_DEBUG_INLINE
00186 #include "CLHEP/Matrix/GenMatrix.icc"
00187 #endif
00188
00189
00190 #endif