CMS 3D CMS Logo

LASvector2D.cc

Go to the documentation of this file.
00001 
00009 #include "FWCore/Utilities/interface/Exception.h"
00010 
00011 #include "Alignment/LaserAlignment/interface/LASvector2D.h"
00012 
00013 template<class Element>
00014 LASvector2D<Element> LASvector2D<Element>::operator*(const LASvector<Element> & multiplicator) const
00015 {
00016   if ((*this)[0].size() != multiplicator.size())
00017     throw cms::Exception("SizeMisMatch","Size of matrix and multiplicator (vector) do not match!") << this[0].size() 
00018       << " does not match the size of the multiplicator " << multiplicator.size() << std::endl;
00019   LASvector2D<Element> result = (*this);
00020   for( unsigned int i = 0; i < result.size(); ++i )
00021   {
00022     for( unsigned int j = 0; j < result[0].size(); ++j )
00023     {
00024       result[i][j] *= multiplicator[j];
00025     }
00026   }
00027   return result;
00028 }
00029 
00030 template<class Element>
00031 LASvector2D<Element> LASvector2D<Element>::operator*(Element multiplicator) const 
00032 {
00033   LASvector2D<Element> result = (*this);
00034   for( unsigned int i = 0; i < result.size(); ++i )
00035   {
00036     for( unsigned int j = 0; j < result[0].size(); ++j )
00037     {
00038       result[i][j] *= multiplicator;
00039     }
00040   }
00041   return result;
00042 }
00043 
00044 template<class Element>
00045 LASvector2D<Element> LASvector2D<Element>::operator/(Element factor) const
00046 {
00047   if (factor == 0)
00048     throw cms::Exception("DivisionByZero","Division by zero is not allowed!!!");
00049     
00050   LASvector2D<Element> result = (*this);
00051   for( unsigned int i = 0; i < result.size(); ++i )
00052   {
00053     for( unsigned int j = 0; j < result[0].size(); ++j )
00054     {
00055       result[i][j] /= factor;
00056     }
00057   }
00058   return result;
00059 }
00060 
00061 
00062 template<class Element>
00063 LASvector<Element> LASvector2D<Element>::sumC()
00064 {
00065   LASvector<Element> result((*this).size());
00066   for( unsigned int i = 0; i < (*this).size(); ++i )
00067   {
00068     for( unsigned int j = 0; j < (*this)[i].size(); ++j )
00069     {
00070       result[i] += (*this)[i][j];
00071     }
00072   }
00073   return result;
00074 }
00075 
00076 template<class Element>
00077 LASvector<Element> LASvector2D<Element>::sumR()
00078 {
00079   LASvector<Element> result((*this)[0].size());
00080   for( unsigned int i = 0; i < (*this)[0].size(); ++i )
00081   {
00082     for( unsigned int j = 0; j < (*this).size(); ++j )
00083     {
00084       result[i] += (*this)[i][j];
00085     }
00086   }
00087   return result;
00088 }
00089 
00090 template<class Element>
00091 Element LASvector2D<Element>::sum()
00092 {
00093   Element result = 0;
00094   for( unsigned int i = 0; i < (*this).size(); ++i )
00095   {
00096     for( unsigned int j = 0; j < (*this)[i].size(); ++j )
00097     {
00098       result += (*this)[i][j];
00099     }
00100   }
00101   return result;
00102 }
00103 
00104 template<class Element>
00105 void LASvector2D<Element>::transpose(const LASvector2D<Element> & source)
00106 {
00107   for( unsigned int i = 0; i < source.size(); ++i )
00108   {
00109     for( unsigned int j = 0; j < source[i].size(); ++j )
00110     {
00111       (*this)[j][i] = source[i][j];
00112     }
00113   }
00114 }
00115 
00116 template LASvector2D<double>::LASvector2D(size_t nrows=0, size_t ncolumns=0, const double init=0);
00117 template LASvector<double> LASvector2D<double>::sumC();
00118 template LASvector<double> LASvector2D<double>::sumR();
00119 template double LASvector2D<double>::sum();
00120 template void LASvector2D<double>::transpose(const LASvector2D<double> & source);
00121 template LASvector2D<double> LASvector2D<double>::operator*(const LASvector<double> & multiplicator) const;
00122 template LASvector2D<double> LASvector2D<double>::operator*(double multiplicator) const;
00123 template LASvector2D<double> LASvector2D<double>::operator/(double factor) const;

Generated on Tue Jun 9 17:24:09 2009 for CMSSW by  doxygen 1.5.4