CMS 3D CMS Logo

Public Member Functions | Private Attributes

L1MuGMTMatrix< T > Class Template Reference

#include <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
Toperator() (int r, int c)
const Toperator() (int r, int c) const
L1MuGMTMatrixoperator*= (const T &s)
 scalar multiplication
L1MuGMTMatrixoperator+= (const L1MuGMTMatrix &m)
 matrix addition
L1MuGMTMatrixoperator+= (const T &s)
 scalar 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 
)

constructor

Definition at line 111 of file L1MuGMTMatrix.h.

References trackerHits::c, i, L1MuGMTMatrix< T >::p, and csvReporter::r.

                                            : r_size(r), c_size(c) {

   p = new T*[r];

   assert(p != 0);

   for (int i = 0; i < r; i++) {
     p[i] = new T[c];
     assert(p[i] != 0);
   }

}
template<class T>
L1MuGMTMatrix< T >::L1MuGMTMatrix ( const L1MuGMTMatrix< T > &  mat)

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.

                                                           : r_size(mat.r_size), c_size(mat.c_size) {

   p = new T*[r_size];

   assert(p != 0);

   for (int i = 0; i < r_size; i++) {
     p[i] = new T[c_size];
     assert(p[i] != 0);
     for (int j = 0; j < c_size; j++) p[i][j] = mat.p[i][j];
   }

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

destructor

Definition at line 147 of file L1MuGMTMatrix.h.

References i, and AlCaHLTBitMon_ParallelJobs::p.

                                 {

   for (int i = 0; i < r_size; i++) {
     delete [] p[i];
   }

   delete [] p;

}

Member Function Documentation

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

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

Definition at line 328 of file L1MuGMTMatrix.h.

References i, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by L1MuGMTCancelOutUnit::decide(), and L1MuGMTMerger::merge().

                                        {

  int stat = -1;
  for (int i = 0; i < r_size; i++) {
    if ( this->p[i][c] > 0 ) stat = i;
  }
 
  return stat;
 
}
template<class T>
void L1MuGMTMatrix< T >::init ( T  v = 0)
template<class T >
bool L1MuGMTMatrix< T >::isMax ( int  r,
int  c 
) const

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

Definition at line 282 of file L1MuGMTMatrix.h.

References trackerHits::c, i, j, max(), AlCaHLTBitMon_ParallelJobs::p, and csvReporter::r.

Referenced by L1MuGMTMatcher::match().

                                               {

  bool max = true;

  for (int i = 0; i < c; i++) {
    max = max && ( this->p[r][c] > this->p[r][i]);
  }    
  for (int i = c+1; i < c_size; i++) {
    max = max && ( this->p[r][c] >= this->p[r][i]);
  }    

  for (int j = 0; j < r; j++) {
    max = max && ( this->p[r][c] > this->p[j][c]);
  }
  for (int j = r+1; j < r_size; j++) {
    max = max && ( this->p[r][c] >= this->p[j][c]);
  }
  
  return max;
  
}
template<class T >
bool L1MuGMTMatrix< T >::isMin ( int  r,
int  c 
) const

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

Definition at line 309 of file L1MuGMTMatrix.h.

References trackerHits::c, i, j, min, AlCaHLTBitMon_ParallelJobs::p, and csvReporter::r.

                                               {

  bool min = true;
  for (int i = 0; i < c_size; i++) {
    min = min && ( this->p[r][c] <= this->p[r][i]);
  }    
  for (int j = 0; j < r_size; j++) {
    min = min && ( this->p[r][c] <= this->p[j][c]);
  }
  
  return min;
  
} 
template<class T >
const T & L1MuGMTMatrix< T >::operator() ( int  r,
int  c 
) const

Definition at line 175 of file L1MuGMTMatrix.h.

References trackerHits::c, AlCaHLTBitMon_ParallelJobs::p, and csvReporter::r.

                                                        {

   assert( r >= 0 && r < r_size && c >= 0 && c < c_size );

   return p[r][c];

}
template<class T >
T & L1MuGMTMatrix< T >::operator() ( int  r,
int  c 
)

Definition at line 162 of file L1MuGMTMatrix.h.

References trackerHits::c, AlCaHLTBitMon_ParallelJobs::p, and csvReporter::r.

                                            {

   assert( r >= 0 && r < r_size && c >= 0 && c < c_size );

   return p[r][c];

}
template<class T>
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator*= ( const T s)

scalar multiplication

Definition at line 267 of file L1MuGMTMatrix.h.

References trackerHits::c, AlCaHLTBitMon_ParallelJobs::p, and csvReporter::r.

                                                         {

   for (int r = 0; r < r_size; r++) {
     for (int c = 0; c < c_size; c++) p[r][c] *= s;
   }

   return *this;

}
template<class T>
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator+= ( const T s)

scalar addition

Definition at line 252 of file L1MuGMTMatrix.h.

References trackerHits::c, AlCaHLTBitMon_ParallelJobs::p, and csvReporter::r.

                                                         {

   for (int r = 0; r < r_size; r++) {
     for (int c = 0; c < c_size; c++) p[r][c] += s;
   }

   return *this;

}
template<class T >
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator+= ( const L1MuGMTMatrix< T > &  m)

matrix addition

Definition at line 233 of file L1MuGMTMatrix.h.

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

                                                                     {

   assert(m.c_size == c_size && m.r_size == r_size);

   for (int r = 0; r < r_size; r++) {
     for (int c = 0; c < c_size; c++) {
       p[r][c] += m.p[r][c];
     }
   }

   return *this;

}
template<class T >
L1MuGMTMatrix< T > & L1MuGMTMatrix< T >::operator= ( const L1MuGMTMatrix< T > &  m)

assignment operator

Definition at line 214 of file L1MuGMTMatrix.h.

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

                                                                    {

  if ( this != &m ) {
    assert(m.c_size == c_size && m.r_size == r_size);

    for (int r = 0; r < r_size; r++) {
      for (int c = 0; c < c_size; c++) p[r][c] = m.p[r][c];
    }
  }

  return (*this);

}
template<class T >
void L1MuGMTMatrix< T >::print ( void  ) const

print matrix

Definition at line 360 of file L1MuGMTMatrix.h.

References trackerHits::c, convertSQLitetoXML_cfg::output, AlCaHLTBitMon_ParallelJobs::p, and csvReporter::r.

Referenced by L1MuGMTMatcher::print().

                                   {

  for (int r = 0; r < r_size; r++) {
    std::stringstream output;
    for (int c = 0; c < c_size; c++) output << p[r][c] << "\t";
    edm::LogVerbatim("GMTMatrix_print") << output.str();
  }
  edm::LogVerbatim("GMTMatrix_print");

}
template<class T >
int L1MuGMTMatrix< T >::rowAny ( int  r) const

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

Definition at line 344 of file L1MuGMTMatrix.h.

References i, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by L1MuGMTCancelOutUnit::decide(), and L1MuGMTMerger::merge().

                                        {

  int stat = -1;
  for (int i = 0; i < c_size; i++) {
    if ( this->p[r][i] > 0 ) stat = i;
  } 

  return stat;

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

set matrix element

Definition at line 201 of file L1MuGMTMatrix.h.

References trackerHits::c, AlCaHLTBitMon_ParallelJobs::p, csvReporter::r, and v.

Referenced by L1MuGMTPSB::getCalo().

                                            {

   assert( r >= 0 && r < r_size && c >= 0 && c < c_size );

   p[r][c] = v;

}

Member Data Documentation

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