CMS 3D CMS Logo

LASvector.cc

Go to the documentation of this file.
00001 
00009 #include "Alignment/LaserAlignment/interface/LASvector.h"
00010 #include "FWCore/Utilities/interface/Exception.h"
00011 
00012 #include <math.h>
00013 
00014 template<class Element>
00015 LASvector<Element> LASvector<Element>::operator+(const LASvector<Element> & source) const
00016 {
00017   // check if size matches, else throw exception
00018   if (this->size() != source.size())
00019     throw cms::Exception("SizeMisMatch","Size of vectors do not match!") << this->size() 
00020       << " does not match the size of the multiplicator " << source.size() << std::endl;
00021 
00022   LASvector<Element> result(*this);
00023   for( unsigned int i = 0; i < result.size(); ++i )
00024   {
00025     result[i] += source[i];
00026   }  
00027   return result;
00028 }
00029 
00030 template<class Element>
00031 LASvector<Element> LASvector<Element>::operator+(Element source) const
00032 {
00033   LASvector<Element> result(*this);
00034   for( unsigned int i = 0; i < result.size(); ++i )
00035   {
00036     result[i] += source;
00037   }  
00038   return result;
00039 }
00040 
00041 template<class Element>
00042 LASvector<Element> LASvector<Element>::operator-(const LASvector<Element> & source) const
00043 {
00044   // check if size matches, else throw exception
00045   if (this->size() != source.size())
00046     throw cms::Exception("SizeMisMatch","Size of vectors do not match!") << this->size() 
00047       << " does not match the size of the multiplicator " << source.size() << std::endl;
00048 
00049   LASvector<Element> result(*this);
00050   for( unsigned int i = 0; i < result.size(); ++i )
00051   {
00052     result[i] -= source[i];
00053   }  
00054   return result;
00055 }
00056 
00057 template<class Element>
00058 LASvector<Element> LASvector<Element>::operator-(Element source) const
00059 {
00060   LASvector<Element> result(*this);
00061   for( unsigned int i = 0; i < result.size(); ++i )
00062   {
00063     result[i] -= source;
00064   }  
00065   return result;
00066 }
00067 
00068 template<class Element>
00069 LASvector<Element> LASvector<Element>::operator*(const LASvector<Element> &source) const
00070 {
00071   // check if size matches, else throw exception
00072   if (this->size() != source.size())
00073     throw cms::Exception("SizeMisMatch","Size of vectors do not match!") << this->size() 
00074       << " does not match the size of the multiplicator " << source.size() << std::endl;
00075         
00076   LASvector<Element> result(*this);
00077   for( unsigned int i = 0; i < result.size(); ++i )
00078   {
00079     result[i]*=source[i];
00080   }
00081   return result;
00082 }
00083 
00084 template<class Element>
00085 LASvector<Element> LASvector<Element>::operator*(Element multiplicator) const
00086 {
00087   LASvector<Element> result(*this);
00088   for( unsigned int i = 0; i < result.size(); ++i )
00089   {
00090     result[i] *= multiplicator;
00091   }
00092   return result;
00093 }
00094 
00095 template<class Element>
00096 LASvector<Element> LASvector<Element>::operator/(Element factor) const
00097 {
00098   if (factor == 0)
00099     throw cms::Exception("DivisionByZero","Division by zero is not allowed!!!");
00100     
00101   LASvector<Element> result = (*this);
00102   for( unsigned int i = 0; i < result.size(); ++i )
00103   {
00104       result[i] /= factor;
00105   }
00106   return result;
00107 }
00108 
00109 template<class Element>
00110 void LASvector<Element>::operator-=(Element subtractor)
00111 {
00112   for( unsigned int i = 0; i < (*this).size(); ++i )
00113   {
00114     (*this)[i] -= subtractor;
00115   }
00116 }
00117 
00118 template<class Element>
00119 void LASvector<Element>::sine(const LASvector<Element> &source)
00120 {
00121   LASvector<Element> result;
00122   for( unsigned int i = 0; i < source.size(); ++i )
00123   {
00124     (*this)[i] = sin(source[i]);
00125   }
00126 }
00127 
00128 template<class Element>
00129 void LASvector<Element>::cosine(const LASvector<Element> &source)
00130 {
00131   for( unsigned int i = 0; i < source.size(); ++i )
00132   {
00133     (*this)[i] = cos(source[i]);
00134   }
00135 }
00136 
00137 template<class Element>
00138 Element LASvector<Element>::sum()
00139 {
00140   Element result = 0;
00141   for( unsigned int i = 0; i < (*this).size(); ++i )
00142   {
00143     result += (*this)[i];
00144   }
00145   return result;
00146 }
00147 
00148 template LASvector<double>::LASvector(size_t size=0, const double init=0);
00149 template LASvector<double> LASvector<double>::operator+(const LASvector<double> & source) const;
00150 template LASvector<double> LASvector<double>::operator+(double source) const;
00151 template LASvector<double> LASvector<double>::operator-(const LASvector<double> & source) const;
00152 template LASvector<double> LASvector<double>::operator-(double source) const;
00153 template LASvector<double> LASvector<double>::operator*(const LASvector<double> &source) const;
00154 template LASvector<double> LASvector<double>::operator*(double mulitplicator) const;
00155 template LASvector<double> LASvector<double>::operator/(double factor) const;
00156 template void LASvector<double>::operator-=(double subtractor);
00157 template void LASvector<double>::sine(const LASvector<double> & source);
00158 template void LASvector<double>::cosine(const LASvector<double> & source);
00159 template double LASvector<double>::sum();
00160 
00161 // template LASvector<LASvector<double> >::LASvector(size_t size=0, const LASvector<double>(size_t size=0, const double init=0));

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