CMS 3D CMS Logo

Migration.h
Go to the documentation of this file.
1 #ifndef _CLEHP_2_SMATRIX_MIGRATION_H_
2 #define _CLEHP_2_SMATRIX_MIGRATION_H_
3 
5 
6 #include "CLHEP/Matrix/Matrix.h"
7 #include "CLHEP/Matrix/Vector.h"
8 #include "CLHEP/Matrix/SymMatrix.h"
9 
10 #include <cstring>
11 #include <cassert>
12 
13 /*
14 template <unsigned int N1, unsigned int N2>
15  ROOT::Math::SMatrix<double,N1,N2,ROOT::Math::RepStd<double,N1,N2> > clhep2smatrix(const CLHEP::HepMatrix &mt) {
16  typedef ROOT::Math::SMatrix<double,N1,N2,ROOT::Math::RepStd<double,N1,N2> > RM;
17  RM rm;
18  memcpy(rm.Array(), &matmt(1,1), (N1*N2)*sizeof(double));
19  return rm;
20  }
21 template <unsigned int N1>
22  ROOT::Math::SMatrix<double,N1,N1,ROOT::Math::RepSym<double,N1> > clhep2smatrix(const CLHEP::HepSymMatrix &mt) {
23  typedef ROOT::Math::SMatrix<double,N1,N1,ROOT::Math::RepSym<double,N1> > RM;
24  RM rm;
25  memcpy(rm.Array(), &matmt(1,1), (D1*D2)*sizeof(double));
26  return rm;
27  }
28 */
29 
30 template <unsigned int N1, unsigned int N2>
31 ROOT::Math::SMatrix<double, N1, N2, typename ROOT::Math::MatRepStd<double, N1, N2> > asSMatrix(
32  const CLHEP::HepMatrix &m) {
33  typedef typename ROOT::Math::MatRepStd<double, N1, N2> REP;
34  assert(m.num_row() == N1);
35  assert(m.num_col() == N2);
36  return ROOT::Math::SMatrix<double, N1, N2, REP>(&m(1, 1), REP::kSize);
37 }
38 
39 template <unsigned int N1>
40 ROOT::Math::SMatrix<double, N1, N1, typename ROOT::Math::MatRepSym<double, N1> > asSMatrix(
41  const CLHEP::HepSymMatrix &m) {
42  typedef typename ROOT::Math::MatRepSym<double, N1> REP;
43  assert(m.num_row() == N1);
44  return ROOT::Math::SMatrix<double, N1, N1, REP>(&m(1, 1), REP::kSize);
45 }
46 
47 template <unsigned int N1>
48 ROOT::Math::SVector<double, N1> asSVector(const CLHEP::HepVector &m) {
49  return ROOT::Math::SVector<double, N1>(&m[0], N1);
50 }
51 
52 template <unsigned int N>
53 CLHEP::HepVector asHepVector(const ROOT::Math::SVector<double, N> &v) {
54  CLHEP::HepVector hv(N);
55  memcpy(&hv[0], &v[0], N * sizeof(double));
56  return hv;
57 }
58 
59 template <unsigned int N1, unsigned int N2>
60 CLHEP::HepMatrix asHepMatrix(
61  const ROOT::Math::SMatrix<double, N1, N2, typename ROOT::Math::MatRepStd<double, N1, N2> > &rm) {
62  CLHEP::HepMatrix am(N1, N2);
63  memcpy(&am(1, 1), rm.Array(), N1 * N2 * sizeof(double));
64  return am;
65 }
66 
67 template <unsigned int N1>
68 CLHEP::HepSymMatrix asHepMatrix(
69  const ROOT::Math::SMatrix<double, N1, N1, typename ROOT::Math::MatRepSym<double, N1> > &rm) {
70  CLHEP::HepSymMatrix am(N1);
71  memcpy(&am(1, 1), rm.Array(), (N1 * (N1 + 1)) / 2 * sizeof(double));
72  return am;
73 }
74 
75 #endif
cms::cuda::assert
assert(be >=bs)
findQualityFiles.v
v
Definition: findQualityFiles.py:179
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
N
#define N
Definition: blowfish.cc:9
asSVector
ROOT::Math::SVector< double, N1 > asSVector(const CLHEP::HepVector &m)
Definition: Migration.h:48
submit.rm
rm
Definition: submit.py:77
asSMatrix
ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > asSMatrix(const CLHEP::HepMatrix &m)
Definition: Migration.h:31
asHepVector
CLHEP::HepVector asHepVector(const ROOT::Math::SVector< double, N > &v)
Definition: Migration.h:53
asHepMatrix
CLHEP::HepMatrix asHepMatrix(const ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > &rm)
Definition: Migration.h:60
AlgebraicROOTObjects.h