Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
DataFormats
Math
interface
MatRepSparse.h
Go to the documentation of this file.
1
#ifndef MatRepSparse_H
2
#define MatRepSparse_H
3
#include<type_traits>
4
#include<algorithm>
5
10
template
<
typename
T,
unsigned
int
D1,
unsigned
int
D2,
unsigned
int
S,
typename
F=
int
(*)(
int
)>
11
class
MatRepSparse
{
12
13
public
:
14
MatRepSparse
(){}
15
template
<
typename
FI>
16
explicit
MatRepSparse
(FI fi) :
f
(fi) { }
17
18
typedef
T
value_type
;
19
20
static
T
&
sink
() {
21
static
T
t
=0;
// this should throw...
22
return
t
;
23
}
24
25
static
T
const
&
csink
() {
26
static
const
T
t
=0;
27
return
t
;
28
}
29
30
31
inline
T
const
&
operator()
(
unsigned
int
i
,
unsigned
int
j
)
const
{
32
int
k
=
f
(i*
D2
+j);
33
return
k<0 ?
csink
() :
fArray
[
k
];
34
}
35
36
inline
T
&
operator()
(
unsigned
int
i
,
unsigned
int
j
) {
37
int
k
=
f
(i*
D2
+j);
38
return
k<0 ?
sink
() :
fArray
[
k
];
39
}
40
41
inline
T
&
operator[]
(
unsigned
int
i
) {
42
int
k
=
f
(i);
43
return
k<0 ?
sink
() :
fArray
[
k
];
44
}
45
46
inline
T
const
&
operator[]
(
unsigned
int
i
)
const
{
47
int
k
=
f
(i);
48
return
k<0 ?
csink
() :
fArray
[
k
];
49
}
50
51
inline
T
apply
(
unsigned
int
i
)
const
{
52
int
k
=
f
(i);
53
return
k<0 ? 0 :
fArray
[
k
];
54
}
55
56
inline
T
*
Array
() {
return
fArray
; }
57
58
inline
const
T
*
Array
()
const
{
return
fArray
; }
59
63
template
<
class
R>
64
inline
MatRepSparse
&
operator=
(
const
R
&) {
65
static_assert(std::is_same<
R
,
MatRepSparse<T,D1,D2,S,F>
>::
value
,
66
"Cannot_assign_general_to_sparse_matrix_representation"
);
67
return
*
this
;
68
}
69
70
inline
MatRepSparse
&
operator=
(
const
MatRepSparse
& rhs) {
71
for
(
unsigned
int
i
=0;
i
<
kSize
; ++
i
)
fArray
[
i
] = rhs.
Array
()[
i
];
72
return
*
this
;
73
}
74
78
template
<
class
R>
79
inline
MatRepSparse
&
operator+=
(
const
R
&) {
80
static_assert(std::is_same<
R
,
MatRepSparse<T,D1,D2,S,F>
>::
value
,
81
"Cannot_add_general_to_sparse_matrix_representation"
);
82
return
*
this
;
83
}
84
inline
MatRepSparse
&
operator+=
(
const
MatRepSparse
& rhs) {
85
for
(
unsigned
int
i
=0;
i
<
kSize
; ++
i
)
fArray
[
i
] += rhs.
Array
()[
i
];
86
return
*
this
;
87
}
88
92
template
<
class
R>
93
inline
MatRepSparse
&
operator-=
(
const
R
&) {
94
static_assert(std::is_same<
R
,
MatRepSparse<T,D1,D2,S,F>
>::
value
,
95
"Cannot_substract_general_to_sparse_matrix_representation"
);
96
return
*
this
;
97
}
98
99
inline
MatRepSparse
&
operator-=
(
const
MatRepSparse
& rhs) {
100
for
(
unsigned
int
i
=0;
i
<
kSize
; ++
i
)
fArray
[
i
] -= rhs.
Array
()[
i
];
101
return
*
this
;
102
}
103
template
<
class
R>
104
inline
bool
operator==
(
const
R
& rhs)
const
{
105
bool
rc =
true
;
106
for
(
unsigned
int
i
=0;
i
<
D1
*
D2
; ++
i
) {
107
rc = rc && (
operator[]
(
i
) == rhs[
i
]);
108
}
109
return
rc;
110
}
111
112
enum
{
114
kRows
=
D1
,
116
kCols
=
D1
,
118
kSize
=
S
119
};
120
121
122
public
:
123
T
fArray
[
kSize
]={0};
124
F
f
;
125
};
126
127
#endif //
funct::D2
Divides< B, C > D2
Definition:
Factorize.h:145
MatRepSparse::MatRepSparse
MatRepSparse()
Definition:
MatRepSparse.h:14
i
int i
Definition:
DBlmapReader.cc:9
MatRepSparse::Array
T * Array()
Definition:
MatRepSparse.h:56
MatRepSparse::kSize
return no of elements: rows*columns
Definition:
MatRepSparse.h:118
MatRepSparse::operator==
bool operator==(const R &rhs) const
Definition:
MatRepSparse.h:104
relativeConstraints.value
tuple value
Definition:
relativeConstraints.py:54
MatRepSparse::operator=
MatRepSparse & operator=(const R &)
Definition:
MatRepSparse.h:64
MatRepSparse::Array
const T * Array() const
Definition:
MatRepSparse.h:58
MatRepSparse::operator=
MatRepSparse & operator=(const MatRepSparse &rhs)
Definition:
MatRepSparse.h:70
MatRepSparse::operator()
T const & operator()(unsigned int i, unsigned int j) const
Definition:
MatRepSparse.h:31
MatRepSparse::value_type
T value_type
Definition:
MatRepSparse.h:18
MatRepSparse::kRows
return no. of matrix rows
Definition:
MatRepSparse.h:114
edmStreamStallGrapher.t
tuple t
Definition:
edmStreamStallGrapher.py:108
dttmaxenums::R
Definition:
DTTMax.h:28
funct::D1
Divides< A, C > D1
Definition:
Factorize.h:144
MatRepSparse::operator-=
MatRepSparse & operator-=(const R &)
Definition:
MatRepSparse.h:93
MatRepSparse::sink
static T & sink()
Definition:
MatRepSparse.h:20
j
int j
Definition:
DBlmapReader.cc:9
MatRepSparse::kCols
return no. of matrix columns
Definition:
MatRepSparse.h:116
MatRepSparse::f
F f
Definition:
MatRepSparse.h:124
MatRepSparse::csink
static T const & csink()
Definition:
MatRepSparse.h:25
S
double S(const TLorentzVector &, const TLorentzVector &)
Definition:
Particle.cc:99
MatRepSparse
Definition:
MatRepSparse.h:11
MatRepSparse::operator[]
T & operator[](unsigned int i)
Definition:
MatRepSparse.h:41
MatRepSparse::operator+=
MatRepSparse & operator+=(const R &)
Definition:
MatRepSparse.h:79
MatRepSparse::operator[]
T const & operator[](unsigned int i) const
Definition:
MatRepSparse.h:46
MatRepSparse::operator+=
MatRepSparse & operator+=(const MatRepSparse &rhs)
Definition:
MatRepSparse.h:84
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition:
blowfish.cc:281
relval_steps.k
list k
Definition:
relval_steps.py:1523
MatRepSparse::fArray
T fArray[kSize]
Definition:
MatRepSparse.h:123
T
long double T
Definition:
Basic3DVectorLD.h:57
MatRepSparse::MatRepSparse
MatRepSparse(FI fi)
Definition:
MatRepSparse.h:16
MatRepSparse::apply
T apply(unsigned int i) const
Definition:
MatRepSparse.h:51
MatRepSparse::operator()
T & operator()(unsigned int i, unsigned int j)
Definition:
MatRepSparse.h:36
MatRepSparse::operator-=
MatRepSparse & operator-=(const MatRepSparse &rhs)
Definition:
MatRepSparse.h:99
Generated for CMSSW Reference Manual by
1.8.5