From 42ccd76b21ed0c622f262ace78ad569fb56719eb Mon Sep 17 00:00:00 2001 From: Lorenzo Moneta <Lorenzo.Moneta@cern.ch> Date: Wed, 17 Mar 2010 10:30:26 +0000 Subject: [PATCH] fix a remaining issue found with Clang: - fix a wrong templated impelmentation of operator=(ForeignMatrix) - add copy constructor and assignment operator git-svn-id: http://root.cern.ch/svn/root/trunk@32632 27541ba8-7e3a-0410-8455-c3a389f83636 --- .../inc/Math/GenVector/LorentzRotation.h | 39 ++++++++++++++----- .../genvector/inc/Math/GenVector/Rotation3D.h | 12 ++---- math/genvector/test/coordinates3D.cxx | 6 ++- math/genvector/test/coordinates4D.cxx | 5 ++- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/math/genvector/inc/Math/GenVector/LorentzRotation.h b/math/genvector/inc/Math/GenVector/LorentzRotation.h index 1a7cc64b7de..b9dab83e321 100644 --- a/math/genvector/inc/Math/GenVector/LorentzRotation.h +++ b/math/genvector/inc/Math/GenVector/LorentzRotation.h @@ -78,15 +78,19 @@ public: template<class IT> LorentzRotation(IT begin, IT end) { SetComponents(begin,end); } + // The compiler-generated and dtor are OK but we have implementwd the copy-ctor and + // assignment operators since we have a template assignment + + /** + Copy constructor + */ + LorentzRotation( LorentzRotation const & r ) { + *this = r; + } + /** Construct from a pure boost */ - -//explicit LorentzRotation( Boost const & ) {} // TODO -//explicit LorentzRotation( BoostX const & ) {} // TODO -//explicit LorentzRotation( BoostY const & ) {} // TODO -//explicit LorentzRotation( BoostZ const & ) {} // TODO - explicit LorentzRotation( Boost const & b ) { b.GetLorentzRotation( fM+0 ); } explicit LorentzRotation( BoostX const & bx ) { bx.GetLorentzRotation( fM+0 ); } explicit LorentzRotation( BoostY const & by ) { by.GetLorentzRotation( fM+0 ); } @@ -125,8 +129,7 @@ public: const Foreign4Vector& v2, const Foreign4Vector& v3, const Foreign4Vector& v4 ) { SetComponents(v1, v2, v3, v4); } - - // The compiler-generated copy ctor, copy assignment, and dtor are OK. + /** Raw constructor from sixteen Scalar components (without any checking) @@ -142,6 +145,18 @@ public: tx, ty, tz, tt); } + /** + Assign from another LorentzRotation + */ + LorentzRotation & + operator=( LorentzRotation const & rhs ) { + SetComponents( rhs.fM[0], rhs.fM[1], rhs.fM[2], rhs.fM[3], + rhs.fM[4], rhs.fM[5], rhs.fM[6], rhs.fM[7], + rhs.fM[8], rhs.fM[9], rhs.fM[10], rhs.fM[11], + rhs.fM[12], rhs.fM[13], rhs.fM[14], rhs.fM[15] ); + return *this; + } + /** Assign from a pure boost */ @@ -180,7 +195,13 @@ public: */ template<class ForeignMatrix> LorentzRotation & - operator=(const ForeignMatrix & m) { SetComponents(m); return *this; } + operator=(const ForeignMatrix & m) { + SetComponents( m(0,0), m(0,1), m(0,2), m(0,3), + m(1,0), m(1,1), m(1,2), m(1,3), + m(2,0), m(2,1), m(2,2), m(2,3), + m(3,0), m(3,1), m(3,2), m(3,3) ); + return *this; + } /** Re-adjust components to eliminate small deviations from a perfect diff --git a/math/genvector/inc/Math/GenVector/Rotation3D.h b/math/genvector/inc/Math/GenVector/Rotation3D.h index 5eee64af497..d6594e01c6c 100644 --- a/math/genvector/inc/Math/GenVector/Rotation3D.h +++ b/math/genvector/inc/Math/GenVector/Rotation3D.h @@ -161,15 +161,9 @@ public: */ Rotation3D & operator=( Rotation3D const & rhs ) { - fM[0] = rhs.fM[0]; - fM[1] = rhs.fM[1]; - fM[2] = rhs.fM[2]; - fM[3] = rhs.fM[3]; - fM[4] = rhs.fM[4]; - fM[5] = rhs.fM[5]; - fM[6] = rhs.fM[6]; - fM[7] = rhs.fM[7]; - fM[8] = rhs.fM[8]; + SetComponents( rhs.fM[0], rhs.fM[1], rhs.fM[2], + rhs.fM[3], rhs.fM[4], rhs.fM[5], + rhs.fM[6], rhs.fM[7], rhs.fM[8] ); return *this; } diff --git a/math/genvector/test/coordinates3D.cxx b/math/genvector/test/coordinates3D.cxx index d823a627701..574a14db398 100644 --- a/math/genvector/test/coordinates3D.cxx +++ b/math/genvector/test/coordinates3D.cxx @@ -254,7 +254,7 @@ int test3D ( const DisplacementVector3D<C> & v, double ticks ) { -int main () { +int coordinates3D () { int ret = 0; ret |= test3D (XYZVector ( 0.0, 0.0, 0.0 ) ,2 ); @@ -303,3 +303,7 @@ int main () { return ret; } + +int main() { + return coordinates3D(); +} diff --git a/math/genvector/test/coordinates4D.cxx b/math/genvector/test/coordinates4D.cxx index be625e5529c..1d36f2baa23 100644 --- a/math/genvector/test/coordinates4D.cxx +++ b/math/genvector/test/coordinates4D.cxx @@ -213,7 +213,7 @@ int test4D ( const LorentzVector<C> & v, double ticks ) { } -int main () { +int coordinates4D () { int ret = 0; ret |= test4D (XYZTVector ( 0.0, 0.0, 0.0, 0.0 ) , 1 ); @@ -238,3 +238,6 @@ int main () { return ret; } +int main() { + return coordinates4D(); +} -- GitLab