ROOTPWA
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
src
TCMatrix.h
Go to the documentation of this file.
1
2
//
3
// Copyright 2009 Sebastian Neubert
4
//
5
// This file is part of rootpwa
6
//
7
// rootpwa is free software: you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation, either version 3 of the License, or
10
// (at your option) any later version.
11
//
12
// rootpwa is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
16
//
17
// You should have received a copy of the GNU General Public License
18
// along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
19
//
21
// a matrix with complex elements
22
23
24
#ifndef TCMATRIX_HH
25
#define TCMATRIX_HH
26
27
#include <complex>
28
29
#include "TObject.h"
30
#include "TComplex.h"
31
#include "TMatrixD.h"
32
33
34
class
TCMatrix
:
public
TObject {
35
36
public
:
37
38
TCMatrix
(){}
39
TCMatrix
(TMatrixD re, TMatrixD im):
_re
(re),
_im
(im){}
40
TCMatrix
(
const
int
i
,
const
int
j);
41
~TCMatrix
(){};
42
43
void
ResizeTo
(
const
int
i
,
const
int
j) {
_re
.ResizeTo(i,j);
_im
.ResizeTo(i,j); }
44
void
set
(
const
int
i
,
const
int
j,
const
std::complex<double>& c);
45
void
set
(
const
int
i
,
const
int
j,
const
TComplex& c);
46
TComplex
get
(
const
int
i
,
const
int
j)
const
{
return
TComplex(
_re
[
i
][j],
_im
[
i
][j]); }
47
TComplex
operator()
(
const
int
i
,
const
int
j)
const
{
return
this->
get
(
i
, j); }
48
int
nrows
()
const
{
return
_re
.GetNrows(); }
49
int
ncols
()
const
{
return
_re
.GetNcols(); }
50
virtual
void
Print
(
const
Option_t* =
""
)
const
{
_re
.Print();
_im
.Print(); }
51
52
TCMatrix
t
()
const
;
// return transpose matrix
53
TCMatrix
dagger
()
const
;
// return adjoint matrix
54
55
friend
TCMatrix
operator*
(
const
TCMatrix
& c1,
const
TCMatrix
& c2);
56
friend
TCMatrix
operator-
(
const
TCMatrix
& c1,
const
TCMatrix
& c2);
57
friend
TCMatrix
operator+
(
const
TCMatrix
& c1,
const
TCMatrix
& c2);
58
59
private
:
60
61
TMatrixD
_re
;
62
TMatrixD
_im
;
63
64
65
public
:
66
67
ClassDef
(
TCMatrix
,2);
68
69
};
70
71
72
inline
73
std::ostream&
74
operator <<
(std::ostream& out,
75
const
TCMatrix
&
A
)
76
{
77
for
(
int
row = 0; row < A.
nrows
(); ++row) {
78
out <<
"row "
<< row <<
" = ("
;
79
for
(
int
col = 0; col < A.
ncols
(); ++col) {
80
out <<
A
(row, col);
81
if
(col < A.ncols() - 1)
82
out <<
", "
;
83
}
84
if
(row < A.
nrows
() - 1)
85
out <<
"), "
<< std::endl;
86
else
87
out <<
")"
;
88
}
89
return
out;
90
}
91
92
93
#endif // TCMATRIX_HH
Generated by
1.8.1.2