Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:20:04

0001 
0002 /***********************************************************************
0003 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
0004 *                                                                      *
0005 * This file is part of EvtGen.                                         *
0006 *                                                                      *
0007 * EvtGen is free software: you can redistribute it and/or modify       *
0008 * it under the terms of the GNU General Public License as published by *
0009 * the Free Software Foundation, either version 3 of the License, or    *
0010 * (at your option) any later version.                                  *
0011 *                                                                      *
0012 * EvtGen is distributed in the hope that it will be useful,            *
0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
0015 * GNU General Public License for more details.                         *
0016 *                                                                      *
0017 * You should have received a copy of the GNU General Public License    *
0018 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
0019 ***********************************************************************/
0020 
0021 #ifndef EVTTENSOR3C_HH
0022 #define EVTTENSOR3C_HH
0023 
0024 #include "EvtGenBase/EvtComplex.hh"
0025 
0026 #include <iostream>
0027 
0028 class EvtVector3C;
0029 class EvtVector3R;
0030 
0031 class EvtTensor3C;
0032 
0033 namespace EvtGenFunctions {
0034     EvtTensor3C eps( const EvtVector3R& v );
0035     EvtTensor3C rotateEuler( const EvtTensor3C& v, double phi, double theta,
0036                              double ksi );
0037     EvtTensor3C directProd( const EvtVector3C& c1, const EvtVector3C& c2 );
0038     EvtTensor3C directProd( const EvtVector3C& c1, const EvtVector3R& c2 );
0039     EvtTensor3C directProd( const EvtVector3R& c1, const EvtVector3R& c2 );
0040 }    // namespace EvtGenFunctions
0041 
0042 class EvtTensor3C final {
0043     friend EvtTensor3C operator*( const EvtComplex& c, const EvtTensor3C& t2 );
0044     friend EvtTensor3C operator*( const double d, const EvtTensor3C& t2 );
0045     friend EvtTensor3C operator*( const EvtTensor3C& t2, const EvtComplex& c );
0046     friend EvtTensor3C operator*( const EvtTensor3C& t2, const double d );
0047     friend EvtTensor3C operator+( const EvtTensor3C& t1, const EvtTensor3C& t2 );
0048     friend EvtTensor3C operator-( const EvtTensor3C& t1, const EvtTensor3C& t2 );
0049     friend EvtTensor3C EvtGenFunctions::directProd( const EvtVector3C& c1,
0050                                                     const EvtVector3C& c2 );
0051     friend EvtTensor3C EvtGenFunctions::directProd( const EvtVector3C& c1,
0052                                                     const EvtVector3R& c2 );
0053     friend EvtTensor3C EvtGenFunctions::directProd( const EvtVector3R& c1,
0054                                                     const EvtVector3R& c2 );
0055     friend EvtTensor3C conj( const EvtTensor3C& t2 );
0056     //Contract the second index of two tensors result(i,j) = t1(i,k)t2(j,k)
0057     friend EvtTensor3C cont22( const EvtTensor3C& t1, const EvtTensor3C& t2 );
0058     //Contract the first index of two tensors result(i,j) = t1(k,i)t2(k,j)
0059     friend EvtTensor3C cont11( const EvtTensor3C& t1, const EvtTensor3C& t2 );
0060     //Contract the last index of eps_{ijk} with w
0061     friend EvtTensor3C EvtGenFunctions::eps( const EvtVector3R& v );
0062     friend std::ostream& operator<<( std::ostream& c, const EvtTensor3C& v );
0063 
0064   public:
0065     EvtTensor3C();
0066     EvtTensor3C( const EvtTensor3C& t1 );
0067     EvtTensor3C( double d11, double d22, double d33 );
0068     EvtTensor3C& operator=( const EvtTensor3C& t1 );
0069     inline void set( int i, int j, const EvtComplex& c );
0070     inline const EvtComplex& get( int i, int j ) const;
0071     inline EvtComplex trace() const;
0072     static const EvtTensor3C& id();
0073     void zero();
0074     void applyRotateEuler( double phi, double theta, double ksi );
0075 
0076     EvtTensor3C operator+=( const EvtTensor3C& t2 );
0077     EvtTensor3C operator-=( const EvtTensor3C& t2 );
0078     EvtTensor3C operator*=( const double d );
0079     EvtTensor3C operator*=( const EvtComplex& c );
0080     EvtTensor3C conj() const;
0081     EvtVector3C cont1( const EvtVector3C& v ) const;
0082     EvtVector3C cont2( const EvtVector3C& v ) const;
0083     EvtVector3C cont1( const EvtVector3R& v ) const;
0084     EvtVector3C cont2( const EvtVector3R& v ) const;
0085 
0086   private:
0087     EvtComplex t[3][3];
0088 };
0089 
0090 inline EvtTensor3C operator*( const EvtComplex& c, const EvtTensor3C& t2 )
0091 {
0092     return EvtTensor3C( t2 ) *= c;
0093 }
0094 
0095 inline EvtTensor3C operator*( const double d, const EvtTensor3C& t2 )
0096 {
0097     return EvtTensor3C( t2 ) *= d;
0098 }
0099 
0100 inline EvtTensor3C operator*( const EvtTensor3C& t2, const EvtComplex& c )
0101 {
0102     return EvtTensor3C( t2 ) *= c;
0103 }
0104 
0105 inline EvtTensor3C operator*( const EvtTensor3C& t2, const double d )
0106 {
0107     return EvtTensor3C( t2 ) *= d;
0108 }
0109 
0110 inline EvtTensor3C operator+( const EvtTensor3C& t1, const EvtTensor3C& t2 )
0111 {
0112     return EvtTensor3C( t1 ) += t2;
0113 }
0114 
0115 inline EvtTensor3C operator-( const EvtTensor3C& t1, const EvtTensor3C& t2 )
0116 {
0117     return EvtTensor3C( t1 ) -= t2;
0118 }
0119 
0120 inline void EvtTensor3C::set( int i, int j, const EvtComplex& c )
0121 {
0122     t[i][j] = c;
0123 }
0124 
0125 inline const EvtComplex& EvtTensor3C::get( int i, int j ) const
0126 {
0127     return t[i][j];
0128 }
0129 
0130 inline EvtComplex EvtTensor3C::trace() const
0131 {
0132     return t[0][0] + t[1][1] + t[2][2];
0133 }
0134 
0135 #endif