CMS 3D CMS Logo

L1MuGMTMatrix< T > Class Template Reference

Matrix. More...

#include <L1Trigger/GlobalMuonTrigger/src/L1MuGMTMatrix.h>

List of all members.

Public Member Functions

int colAny (int c) const
 is any element in column c > 0 ? return index or -1
void init (T v=0)
 initialize matrix
bool isMax (int r, int c) const
 is the element (r,c) the max. entry in its row and column?
bool isMin (int r, int c) const
 is the element (r,c) the min. entry in its row and column?
 L1MuGMTMatrix (const L1MuGMTMatrix< T > &)
 copy constructor
 L1MuGMTMatrix (int r, int c)
 constructor
L1MuGMTMatrixoperator *= (const T &s)
 scalar multiplication
const T & operator() (int r, int c) const
T & operator() (int r, int c)
L1MuGMTMatrixoperator+= (const T &s)
 scalar addition
L1MuGMTMatrixoperator+= (const L1MuGMTMatrix &m)
 matrix addition
L1MuGMTMatrixoperator= (const L1MuGMTMatrix &m)
 assignment operator
void print () const
 print matrix
int rowAny (int r) const
 is any element in row r > 0 ? return index or -1
void set (int r, int c, T v)
 set matrix element
virtual ~L1MuGMTMatrix ()
 destructor

Private Attributes

int c_size
T ** p
int r_size


Detailed Description

template<class T>
class L1MuGMTMatrix< T >

Matrix.

general matrix

Definition at line 49 of file L1MuGMTMatrix.h.


Constructor & Destructor Documentation

template<class T>
L1MuGMTMatrix< T >::L1MuGMTMatrix ( int  r,
int  c 
) [inline]

constructor

Definition at line 111 of file L1MuGMTMatrix.h.

References i, and L1MuGMTMatrix< T >::p.

00111                                             : r_size(r), c_size(c) {
00112 
00113    p = new T*[r];
00114 
00115    assert(p != 0);
00116 
00117    for (int i = 0; i < r; i++) {
00118      p[i] = new T[c];
00119      assert(p[i] != 0);
00120    }
00121 
00122 }

template<class T>
L1MuGMTMatrix< T >::L1MuGMTMatrix ( const L1MuGMTMatrix< T > &  mat  )  [inline]

copy constructor

Definition at line 128 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, i, j, L1MuGMTMatrix< T >::p, and L1MuGMTMatrix< T >::r_size.

00128                                                            : r_size(mat.r_size), c_size(mat.c_size) {
00129 
00130    p = new T*[r_size];
00131 
00132    assert(p != 0);
00133 
00134    for (int i = 0; i < r_size; i++) {
00135      p[i] = new T[c_size];
00136      assert(p[i] != 0);
00137      for (int j = 0; j < c_size; j++) p[i][j] = mat.p[i][j];
00138    }
00139 
00140 }

template<class T>
L1MuGMTMatrix< T >::~L1MuGMTMatrix (  )  [inline, virtual]

destructor

Definition at line 147 of file L1MuGMTMatrix.h.

References i, L1MuGMTMatrix< T >::p, and L1MuGMTMatrix< T >::r_size.

00147                                  {
00148 
00149    for (int i = 0; i < r_size; i++) {
00150      delete [] p[i];
00151    }
00152 
00153    delete [] p;
00154 
00155 }


Member Function Documentation

template<class T>
int L1MuGMTMatrix< T >::colAny ( int  c  )  const [inline]

is any element in column c > 0 ? return index or -1

Definition at line 328 of file L1MuGMTMatrix.h.

References i, and L1MuGMTMatrix< T >::r_size.

Referenced by L1MuGMTMerger::merge().

00328                                         {
00329 
00330   int stat = -1;
00331   for (int i = 0; i < r_size; i++) {
00332     if ( this->p[i][c] > 0 ) stat = i;
00333   }
00334  
00335   return stat;
00336  
00337 }

template<class T>
void L1MuGMTMatrix< T >::init ( v = 0  )  [inline]

initialize matrix

Definition at line 188 of file L1MuGMTMatrix.h.

References c, L1MuGMTMatrix< T >::c_size, L1MuGMTMatrix< T >::p, r, and L1MuGMTMatrix< T >::r_size.

Referenced by L1MuGMTMatcher::match(), and L1MuGMTMatcher::reset().

00188                                {
00189 
00190    for (int r = 0; r < r_size; r++) {
00191      for (int c = 0; c < c_size; c++) p[r][c] = v;
00192    }
00193 
00194 }

template<class T>
bool L1MuGMTMatrix< T >::isMax ( int  r,
int  c 
) const [inline]

is the element (r,c) the max. entry in its row and column?

Definition at line 282 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, i, j, max, L1MuGMTMatrix< T >::p, and L1MuGMTMatrix< T >::r_size.

Referenced by L1MuGMTMatcher::match().

00282                                                {
00283 
00284   bool max = true;
00285 
00286   for (int i = 0; i < c; i++) {
00287     max = max && ( this->p[r][c] > this->p[r][i]);
00288   }    
00289   for (int i = c+1; i < c_size; i++) {
00290     max = max && ( this->p[r][c] >= this->p[r][i]);
00291   }    
00292 
00293   for (int j = 0; j < r; j++) {
00294     max = max && ( this->p[r][c] > this->p[j][c]);
00295   }
00296   for (int j = r+1; j < r_size; j++) {
00297     max = max && ( this->p[r][c] >= this->p[j][c]);
00298   }
00299   
00300   return max;
00301   
00302 }

template<class T>
bool L1MuGMTMatrix< T >::isMin ( int  r,
int  c 
) const [inline]

is the element (r,c) the min. entry in its row and column?

Definition at line 309 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, i, j, min, L1MuGMTMatrix< T >::p, and L1MuGMTMatrix< T >::r_size.

00309                                                {
00310 
00311   bool min = true;
00312   for (int i = 0; i < c_size; i++) {
00313     min = min && ( this->p[r][c] <= this->p[r][i]);
00314   }    
00315   for (int j = 0; j < r_size; j++) {
00316     min = min && ( this->p[r][c] <= this->p[j][c]);
00317   }
00318   
00319   return min;
00320   
00321 } 

template<class T>
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator *= ( const T &  s  )  [inline]

scalar multiplication

Definition at line 267 of file L1MuGMTMatrix.h.

References c, L1MuGMTMatrix< T >::c_size, L1MuGMTMatrix< T >::p, r, and L1MuGMTMatrix< T >::r_size.

00267                                                          {
00268 
00269    for (int r = 0; r < r_size; r++) {
00270      for (int c = 0; c < c_size; c++) p[r][c] *= s;
00271    }
00272 
00273    return *this;
00274 
00275 }

template<class T>
const T & L1MuGMTMatrix< T >::operator() ( int  r,
int  c 
) const [inline]

Definition at line 175 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, and L1MuGMTMatrix< T >::p.

00175                                                         {
00176 
00177    assert( r >= 0 && r < r_size && c >= 0 && c < c_size );
00178 
00179    return p[r][c];
00180 
00181 }

template<class T>
T & L1MuGMTMatrix< T >::operator() ( int  r,
int  c 
) [inline]

Definition at line 162 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, and L1MuGMTMatrix< T >::p.

00162                                             {
00163 
00164    assert( r >= 0 && r < r_size && c >= 0 && c < c_size );
00165 
00166    return p[r][c];
00167 
00168 }

template<class T>
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator+= ( const T &  s  )  [inline]

scalar addition

Definition at line 252 of file L1MuGMTMatrix.h.

References c, L1MuGMTMatrix< T >::c_size, L1MuGMTMatrix< T >::p, r, and L1MuGMTMatrix< T >::r_size.

00252                                                          {
00253 
00254    for (int r = 0; r < r_size; r++) {
00255      for (int c = 0; c < c_size; c++) p[r][c] += s;
00256    }
00257 
00258    return *this;
00259 
00260 }

template<class T>
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator+= ( const L1MuGMTMatrix< T > &  m  )  [inline]

matrix addition

Definition at line 233 of file L1MuGMTMatrix.h.

References c, L1MuGMTMatrix< T >::c_size, L1MuGMTMatrix< T >::p, r, and L1MuGMTMatrix< T >::r_size.

00233                                                                      {
00234 
00235    assert(m.c_size == c_size && m.r_size == r_size);
00236 
00237    for (int r = 0; r < r_size; r++) {
00238      for (int c = 0; c < c_size; c++) {
00239        p[r][c] += m.p[r][c];
00240      }
00241    }
00242 
00243    return *this;
00244 
00245 }

template<class T>
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator= ( const L1MuGMTMatrix< T > &  m  )  [inline]

assignment operator

Definition at line 214 of file L1MuGMTMatrix.h.

References c, L1MuGMTMatrix< T >::c_size, L1MuGMTMatrix< T >::p, r, and L1MuGMTMatrix< T >::r_size.

00214                                                                     {
00215 
00216   if ( this != &m ) {
00217     assert(m.c_size == c_size && m.r_size == r_size);
00218 
00219     for (int r = 0; r < r_size; r++) {
00220       for (int c = 0; c < c_size; c++) p[r][c] = m.p[r][c];
00221     }
00222   }
00223 
00224   return (*this);
00225 
00226 }

template<class T>
void L1MuGMTMatrix< T >::print ( void   )  const [inline]

print matrix

Definition at line 360 of file L1MuGMTMatrix.h.

References c, L1MuGMTMatrix< T >::c_size, output(), L1MuGMTMatrix< T >::p, r, and L1MuGMTMatrix< T >::r_size.

Referenced by L1MuGMTMatcher::print().

00360                                    {
00361 
00362   for (int r = 0; r < r_size; r++) {
00363     std::stringstream output;
00364     for (int c = 0; c < c_size; c++) output << p[r][c] << "\t";
00365     edm::LogVerbatim("GMTMatrix_print") << output.str();
00366   }
00367   edm::LogVerbatim("GMTMatrix_print");
00368 
00369 }

template<class T>
int L1MuGMTMatrix< T >::rowAny ( int  r  )  const [inline]

is any element in row r > 0 ? return index or -1

Definition at line 344 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, and i.

Referenced by L1MuGMTMerger::merge().

00344                                         {
00345 
00346   int stat = -1;
00347   for (int i = 0; i < c_size; i++) {
00348     if ( this->p[r][i] > 0 ) stat = i;
00349   } 
00350 
00351   return stat;
00352 
00353 }

template<class T>
void L1MuGMTMatrix< T >::set ( int  r,
int  c,
v 
) [inline]

set matrix element

Definition at line 201 of file L1MuGMTMatrix.h.

References L1MuGMTMatrix< T >::c_size, and L1MuGMTMatrix< T >::p.

00201                                             {
00202 
00203    assert( r >= 0 && r < r_size && c >= 0 && c < c_size );
00204 
00205    p[r][c] = v;
00206 
00207 }


Member Data Documentation

template<class T>
int L1MuGMTMatrix< T >::c_size [private]

Definition at line 103 of file L1MuGMTMatrix.h.

Referenced by L1MuGMTMatrix< T >::init(), L1MuGMTMatrix< T >::isMax(), L1MuGMTMatrix< T >::isMin(), L1MuGMTMatrix< T >::L1MuGMTMatrix(), L1MuGMTMatrix< T >::operator *=(), L1MuGMTMatrix< T >::operator()(), L1MuGMTMatrix< T >::operator+=(), L1MuGMTMatrix< T >::operator=(), L1MuGMTMatrix< T >::print(), L1MuGMTMatrix< T >::rowAny(), and L1MuGMTMatrix< T >::set().

template<class T>
T** L1MuGMTMatrix< T >::p [private]

Definition at line 105 of file L1MuGMTMatrix.h.

Referenced by L1MuGMTMatrix< T >::init(), L1MuGMTMatrix< T >::isMax(), L1MuGMTMatrix< T >::isMin(), L1MuGMTMatrix< T >::L1MuGMTMatrix(), L1MuGMTMatrix< T >::operator *=(), L1MuGMTMatrix< T >::operator()(), L1MuGMTMatrix< T >::operator+=(), L1MuGMTMatrix< T >::operator=(), L1MuGMTMatrix< T >::print(), L1MuGMTMatrix< T >::set(), and L1MuGMTMatrix< T >::~L1MuGMTMatrix().

template<class T>
int L1MuGMTMatrix< T >::r_size [private]

Definition at line 103 of file L1MuGMTMatrix.h.

Referenced by L1MuGMTMatrix< T >::colAny(), L1MuGMTMatrix< T >::init(), L1MuGMTMatrix< T >::isMax(), L1MuGMTMatrix< T >::isMin(), L1MuGMTMatrix< T >::L1MuGMTMatrix(), L1MuGMTMatrix< T >::operator *=(), L1MuGMTMatrix< T >::operator+=(), L1MuGMTMatrix< T >::operator=(), L1MuGMTMatrix< T >::print(), and L1MuGMTMatrix< T >::~L1MuGMTMatrix().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:26:55 2009 for CMSSW by  doxygen 1.5.4