cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
Algebra.h
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2020-2024 Laurent Forthomme
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef CepGen_Utils_Algebra_h
20
#define CepGen_Utils_Algebra_h
21
22
#include <gsl/gsl_matrix_double.h>
23
24
#include <initializer_list>
25
#include <memory>
26
27
namespace
cepgen
{
28
class
Vector;
29
class
VectorRef;
31
class
Matrix
{
32
public
:
36
explicit
Matrix
(
size_t
num_rows,
size_t
num_cols);
39
Matrix
(
const
std::initializer_list<Vector>& vecs);
40
41
Matrix
(
const
Matrix
&);
42
Matrix
&
operator=
(
const
Matrix
&);
43
operator
Vector
()
const
;
44
48
static
Matrix
zero
(
size_t
num_rows,
size_t
num_cols = 0ull);
53
static
Matrix
uniform
(
size_t
num_rows,
size_t
num_cols,
double
value = 1.);
54
static
Matrix
identity
(
size_t
);
55
static
Matrix
diagonal
(
const
Vector
&);
56
57
size_t
numColumns
()
const
;
58
size_t
numRows
()
const
;
59
60
bool
operator==
(
const
Matrix
&)
const
;
61
inline
bool
operator!=
(
const
Matrix
& oth)
const
{
return
!(
operator==
(oth)); }
62
68
Matrix
subset
(
size_t
min_y,
size_t
min_x,
size_t
max_y = 0ull,
size_t
max_x = 0ull)
const
;
69
70
Matrix
&
operator*=
(
double
);
71
Matrix
&
operator*=
(
const
Vector
&);
72
Matrix
&
operator*=
(
const
Matrix
&);
73
Matrix
&
operator/=
(
double
);
74
Matrix
operator-
()
const
;
75
Matrix
&
operator+=
(
const
Matrix
&);
76
Matrix
&
operator-=
(
const
Matrix
&);
77
double
&
operator()
(
size_t
,
size_t
);
78
double
operator()
(
size_t
,
size_t
)
const
;
79
80
Vector
operator%
(
const
Vector
&)
const
;
81
82
friend
Matrix
operator*
(
double
,
const
Matrix
&);
83
friend
Matrix
operator*
(
const
Matrix
&,
double
);
84
friend
Vector
operator*
(
const
Matrix
&,
const
Vector
&);
85
friend
Matrix
operator*
(
const
Matrix
&,
const
Matrix
&);
86
friend
Matrix
operator/
(
const
Matrix
&,
double
);
87
friend
Matrix
operator+
(
const
Matrix
&,
const
Matrix
&);
88
friend
Matrix
operator-
(
const
Matrix
&,
const
Matrix
&);
89
90
typedef
std::pair<size_t, size_t>
Indices
;
91
Indices
imin
()
const
;
92
Indices
imax
()
const
;
93
94
double
min
()
const
;
95
double
max
()
const
;
96
97
bool
null
()
const
;
98
bool
positive
()
const
;
99
bool
negative
()
const
;
100
bool
nonNegative
()
const
;
101
102
friend
std::ostream&
operator<<
(std::ostream&,
const
Matrix
&);
103
104
Matrix
&
truncate
(
double
min
= 1.e-14);
105
106
Matrix
&
transpose
();
107
Matrix
transposed
()
const
;
108
Matrix
&
invert
();
109
Matrix
inverted
()
const
;
110
111
VectorRef
column
(
size_t
);
112
Vector
column
(
size_t
)
const
;
113
VectorRef
row
(
size_t
);
114
Vector
row
(
size_t
)
const
;
115
VectorRef
diagonal
();
116
Vector
diagonal
()
const
;
117
118
private
:
119
std::unique_ptr<gsl_matrix, void (*)(gsl_matrix*)> gsl_mat_;
120
};
121
122
class
VectorRef
:
public
gsl_vector_view {
123
public
:
124
VectorRef
(
const
gsl_vector_view&);
125
126
VectorRef
&
operator=
(
const
Vector
&);
127
operator
Vector
()
const
;
128
bool
operator==
(
const
Vector
&)
const
;
129
inline
bool
operator!=
(
const
Vector
& vec)
const
{
return
!
operator==
(vec); }
130
double
&
operator()
(
size_t
);
131
double
operator()
(
size_t
)
const
;
132
friend
std::ostream&
operator<<
(std::ostream&,
const
VectorRef
&);
133
134
private
:
135
friend
class
Vector
;
136
};
137
139
class
Vector
:
public
Matrix
{
140
public
:
144
explicit
Vector
(
size_t
num_coord,
double
def = 0.);
145
Vector
(
const
std::initializer_list<double>&);
146
Vector
(
const
VectorRef
&);
147
Vector
(
const
gsl_vector_const_view&);
148
149
size_t
size
()
const
;
150
154
Vector
subset
(
size_t
min
,
size_t
max
= 0ull)
const
;
155
156
double
&
operator()
(
size_t
);
157
double
operator()
(
size_t
)
const
;
158
double
dot
(
const
Vector
&)
const
;
159
Vector
cross
(
const
Vector
&)
const
;
160
161
friend
std::ostream&
operator<<
(std::ostream&,
const
Vector
&);
162
};
163
}
// namespace cepgen
164
165
#endif
cepgen::Matrix
A matrix object.
Definition
Algebra.h:31
cepgen::Matrix::operator-=
Matrix & operator-=(const Matrix &)
Subtraction of another matrix.
Definition
Algebra.cpp:131
cepgen::Matrix::nonNegative
bool nonNegative() const
Is the matrix non-negative-defined?
Definition
Algebra.cpp:184
cepgen::Matrix::imax
Indices imax() const
Index (row, column) of the maximum matrix element.
Definition
Algebra.cpp:168
cepgen::Matrix::operator-
Matrix operator-() const
Unary inverse operator.
Definition
Algebra.cpp:124
cepgen::Matrix::operator%
Vector operator%(const Vector &) const
Solving operator (from LU decomposition)
Definition
Algebra.cpp:136
cepgen::Matrix::inverted
Matrix inverted() const
Return the inverse of this matrix (LU decomposition)
Definition
Algebra.cpp:221
cepgen::Matrix::imin
Indices imin() const
Index (row, column) of the minimum matrix element.
Definition
Algebra.cpp:162
cepgen::Matrix::operator*
friend Matrix operator*(double, const Matrix &)
Multiplication of a matrix by a scalar.
Definition
Algebra.cpp:249
cepgen::Matrix::column
VectorRef column(size_t)
Return whole column of the matrix.
Definition
Algebra.cpp:225
cepgen::Matrix::transposed
Matrix transposed() const
Return a transposition of this matrix.
Definition
Algebra.cpp:206
cepgen::Matrix::operator*=
Matrix & operator*=(double)
Multiplication by a scalar operator.
Definition
Algebra.cpp:107
cepgen::Matrix::null
bool null() const
Is the matrix uniformly null?
Definition
Algebra.cpp:178
cepgen::Matrix::Indices
std::pair< size_t, size_t > Indices
Definition
Algebra.h:90
cepgen::Matrix::operator+=
Matrix & operator+=(const Matrix &)
Addition of another matrix.
Definition
Algebra.cpp:126
cepgen::Matrix::subset
Matrix subset(size_t min_y, size_t min_x, size_t max_y=0ull, size_t max_x=0ull) const
Extract a subset of the matrix as a new object.
Definition
Algebra.cpp:98
cepgen::Matrix::operator+
friend Matrix operator+(const Matrix &, const Matrix &)
Addition of two matrices.
Definition
Algebra.cpp:237
cepgen::Matrix::min
double min() const
Minimum matrix element.
Definition
Algebra.cpp:174
cepgen::Matrix::zero
static Matrix zero(size_t num_rows, size_t num_cols=0ull)
Build a zero'ed matrix.
Definition
Algebra.cpp:67
cepgen::Matrix::operator/=
Matrix & operator/=(double)
Division by a scalar operator.
Definition
Algebra.cpp:122
cepgen::Matrix::truncate
Matrix & truncate(double min=1.e-14)
Truncate (specify minimum non-zero value) for all matrix components.
Definition
Algebra.cpp:186
cepgen::Matrix::negative
bool negative() const
Is the matrix negative-defined?
Definition
Algebra.cpp:182
cepgen::Matrix::uniform
static Matrix uniform(size_t num_rows, size_t num_cols, double value=1.)
Build a uniform matrix.
Definition
Algebra.cpp:75
cepgen::Matrix::operator!=
bool operator!=(const Matrix &oth) const
Inequality operator.
Definition
Algebra.h:61
cepgen::Matrix::identity
static Matrix identity(size_t)
Build a (square) identity matrix.
Definition
Algebra.cpp:81
cepgen::Matrix::operator=
Matrix & operator=(const Matrix &)
Assignment operator.
Definition
Algebra.cpp:52
cepgen::Matrix::transpose
Matrix & transpose()
Transpose the matrix.
Definition
Algebra.cpp:196
cepgen::Matrix::positive
bool positive() const
Is the matrix positive-defined?
Definition
Algebra.cpp:180
cepgen::Matrix::max
double max() const
Maximum matrix element.
Definition
Algebra.cpp:176
cepgen::Matrix::operator==
bool operator==(const Matrix &) const
Equality operator.
Definition
Algebra.cpp:105
cepgen::Matrix::row
VectorRef row(size_t)
Return whole row of the matrix.
Definition
Algebra.cpp:229
cepgen::Matrix::operator<<
friend std::ostream & operator<<(std::ostream &, const Matrix &)
Printout of matrix components.
Definition
Algebra.cpp:277
cepgen::Matrix::invert
Matrix & invert()
Invert the matrix.
Definition
Algebra.cpp:208
cepgen::Matrix::numColumns
size_t numColumns() const
Number of (vertical) columns.
Definition
Algebra.cpp:94
cepgen::Matrix::operator()
double & operator()(size_t, size_t)
Component access operator.
Definition
Algebra.cpp:148
cepgen::Matrix::numRows
size_t numRows() const
Number of (horizontal) rows.
Definition
Algebra.cpp:96
cepgen::Matrix::diagonal
VectorRef diagonal()
Return the diagonal components of the matrix.
Definition
Algebra.cpp:233
cepgen::Matrix::operator/
friend Matrix operator/(const Matrix &, double)
Division of a matrix by a scalar.
Definition
Algebra.cpp:275
cepgen::VectorRef
Definition
Algebra.h:122
cepgen::VectorRef::operator==
bool operator==(const Vector &) const
Equality with a vector operator.
Definition
Algebra.cpp:297
cepgen::VectorRef::operator=
VectorRef & operator=(const Vector &)
Assignment operator.
Definition
Algebra.cpp:289
cepgen::VectorRef::operator()
double & operator()(size_t)
Component access operator.
Definition
Algebra.cpp:299
cepgen::VectorRef::operator<<
friend std::ostream & operator<<(std::ostream &, const VectorRef &)
Printout operator.
Definition
Algebra.cpp:303
cepgen::VectorRef::Vector
friend class Vector
Definition
Algebra.h:135
cepgen::VectorRef::operator!=
bool operator!=(const Vector &vec) const
Inequality with a vector operator.
Definition
Algebra.h:129
cepgen::Vector
Specialisation of a matrix.
Definition
Algebra.h:139
cepgen::Vector::subset
Vector subset(size_t min, size_t max=0ull) const
Extract a subset of the vector.
Definition
Algebra.cpp:327
cepgen::Vector::size
size_t size() const
Vector multiplicity (number of lines)
Definition
Algebra.cpp:325
cepgen::Vector::dot
double dot(const Vector &) const
Scalar product of two vectors.
Definition
Algebra.cpp:333
cepgen::Vector::operator()
double & operator()(size_t)
Component access operator.
Definition
Algebra.cpp:329
cepgen::Vector::operator<<
friend std::ostream & operator<<(std::ostream &, const Vector &)
Printout of vector components.
Definition
Algebra.cpp:357
cepgen::Vector::cross
Vector cross(const Vector &) const
Vector product of two vectors.
Definition
Algebra.cpp:345
cepgen
Common namespace for this Monte Carlo generator.
Definition
CommandLineHandler.cpp:36
CepGen
Utils
Algebra.h
Generated on Mon Jul 29 2024 for CepGen by
1.9.7