cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.3
A generic central exclusive processes event generator
Loading...
Searching...
No Matches

A \(n\times m\) matrix object. More...

#include <CepGen/Utils/Algebra.h>

+ Inheritance diagram for Matrix:

Public Types

typedef std::pair< size_t, size_t > Indices
 

Public Member Functions

 Matrix (size_t num_rows, size_t num_cols)
 Object constructor.
 
 Matrix (const std::initializer_list< Vector > &vecs)
 Object constructor (from vectors)
 
 Matrix (const Matrix &)
 Copy constructor.
 
Matrixoperator= (const Matrix &)
 Assignment operator.
 
 operator Vector () const
 Implicit conversion to vector.
 
size_t numColumns () const
 Number of (vertical) columns.
 
size_t numRows () const
 Number of (horizontal) rows.
 
bool operator== (const Matrix &) const
 Equality operator.
 
bool operator!= (const Matrix &oth) const
 Inequality operator.
 
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.
 
Matrixoperator*= (double)
 Multiplication by a scalar operator.
 
Matrixoperator*= (const Vector &)
 Multiplication by a vector operator.
 
Matrixoperator*= (const Matrix &)
 Multiplication by a matrix operator.
 
Matrixoperator/= (double)
 Division by a scalar operator.
 
Matrix operator- () const
 Unary inverse operator.
 
Matrixoperator+= (const Matrix &)
 Addition of another matrix.
 
Matrixoperator-= (const Matrix &)
 Subtraction of another matrix.
 
double & operator() (size_t, size_t)
 Component access operator.
 
double operator() (size_t, size_t) const
 Component retrieval operator.
 
Vector operator% (const Vector &) const
 Solving operator (from LU decomposition)
 
Indices imin () const
 Index (row, column) of the minimum matrix element.
 
Indices imax () const
 Index (row, column) of the maximum matrix element.
 
double min () const
 Minimum matrix element.
 
double max () const
 Maximum matrix element.
 
bool null () const
 Is the matrix uniformly null?
 
bool positive () const
 Is the matrix positive-defined?
 
bool negative () const
 Is the matrix negative-defined?
 
bool nonNegative () const
 Is the matrix non-negative-defined?
 
Matrixtruncate (double min=1.e-14)
 Truncate (specify minimum non-zero value) for all matrix components.
 
Matrixtranspose ()
 Transpose the matrix.
 
Matrix transposed () const
 Return a transposition of this matrix.
 
Matrixinvert ()
 Invert the matrix.
 
Matrix inverted () const
 Return the inverse of this matrix (LU decomposition)
 
VectorRef column (size_t)
 Return whole column of the matrix.
 
Vector column (size_t) const
 Return whole column of the matrix.
 
VectorRef row (size_t)
 Return whole row of the matrix.
 
Vector row (size_t) const
 Return whole row of the matrix.
 
VectorRef diagonal ()
 Return the diagonal components of the matrix.
 
Vector diagonal () const
 Return the diagonal components of the matrix.
 

Static Public Member Functions

static Matrix zero (size_t num_rows, size_t num_cols=0ull)
 Build a zero'ed matrix.
 
static Matrix uniform (size_t num_rows, size_t num_cols, double value=1.)
 Build a uniform matrix.
 
static Matrix identity (size_t)
 Build a (square) identity matrix.
 
static Matrix diagonal (const Vector &)
 Build a (square) diagonal matrix from its diagonal vector.
 

Friends

Matrix operator* (double, const Matrix &)
 Multiplication of a matrix by a scalar.
 
Matrix operator* (const Matrix &, double)
 Multiplication of a matrix by a scalar.
 
Vector operator* (const Matrix &, const Vector &)
 Multiplication of a matrix by a vector.
 
Matrix operator* (const Matrix &, const Matrix &)
 Multiplication of a matrix by another matrix.
 
Matrix operator/ (const Matrix &, double)
 Division of a matrix by a scalar.
 
Matrix operator+ (const Matrix &, const Matrix &)
 Addition of two matrices.
 
Matrix operator- (const Matrix &, const Matrix &)
 Subtraction of two matrices.
 
std::ostream & operator<< (std::ostream &, const Matrix &)
 Printout of matrix components.
 

Detailed Description

Definition at line 31 of file Algebra.h.

Member Typedef Documentation

◆ Indices

typedef std::pair<size_t, size_t> Indices

Definition at line 90 of file Algebra.h.

Constructor & Destructor Documentation

◆ Matrix() [1/3]

Matrix ( size_t  num_rows,
size_t  num_cols 
)
explicit
Parameters
[in]num_rowsnumber of (horizontal) rows for the matrix
[in]num_colsnumber of (vertical) columns for the matrix

Definition at line 30 of file Algebra.cpp.

◆ Matrix() [2/3]

Matrix ( const std::initializer_list< Vector > &  vecs)
Parameters
[in]vecsset of (vector) rows

Definition at line 32 of file Algebra.cpp.

◆ Matrix() [3/3]

Matrix ( const Matrix oth)

Definition at line 47 of file Algebra.cpp.

Member Function Documentation

◆ column() [1/2]

VectorRef column ( size_t  i)

Definition at line 225 of file Algebra.cpp.

◆ column() [2/2]

Vector column ( size_t  i) const

Definition at line 223 of file Algebra.cpp.

◆ diagonal() [1/3]

VectorRef diagonal ( )

Definition at line 233 of file Algebra.cpp.

◆ diagonal() [2/3]

Vector diagonal ( ) const

Definition at line 231 of file Algebra.cpp.

◆ diagonal() [3/3]

Matrix diagonal ( const Vector vec)
static

Definition at line 87 of file Algebra.cpp.

◆ identity()

Matrix identity ( size_t  n)
static

Definition at line 81 of file Algebra.cpp.

◆ imax()

Matrix::Indices imax ( ) const

Definition at line 168 of file Algebra.cpp.

◆ imin()

Matrix::Indices imin ( ) const

Definition at line 162 of file Algebra.cpp.

◆ invert()

Matrix & invert ( )

Definition at line 208 of file Algebra.cpp.

◆ inverted()

Matrix inverted ( ) const

Definition at line 221 of file Algebra.cpp.

◆ max()

double max ( ) const

Definition at line 176 of file Algebra.cpp.

◆ min()

double min ( ) const

Definition at line 174 of file Algebra.cpp.

◆ negative()

bool negative ( ) const

Definition at line 182 of file Algebra.cpp.

◆ nonNegative()

bool nonNegative ( ) const

Definition at line 184 of file Algebra.cpp.

◆ null()

bool null ( ) const

Definition at line 178 of file Algebra.cpp.

◆ numColumns()

size_t numColumns ( ) const

Definition at line 94 of file Algebra.cpp.

◆ numRows()

size_t numRows ( ) const

Definition at line 96 of file Algebra.cpp.

◆ operator Vector()

operator Vector ( ) const

Definition at line 59 of file Algebra.cpp.

◆ operator!=()

bool operator!= ( const Matrix oth) const

Definition at line 61 of file Algebra.h.

◆ operator%()

Vector operator% ( const Vector vec) const

Definition at line 136 of file Algebra.cpp.

◆ operator()() [1/2]

double & operator() ( size_t  ix,
size_t  iy 
)

Definition at line 148 of file Algebra.cpp.

◆ operator()() [2/2]

double operator() ( size_t  ix,
size_t  iy 
) const

Definition at line 155 of file Algebra.cpp.

◆ operator*=() [1/3]

Matrix & operator*= ( const Matrix mat)

Definition at line 117 of file Algebra.cpp.

◆ operator*=() [2/3]

Matrix & operator*= ( const Vector vec)

Definition at line 112 of file Algebra.cpp.

◆ operator*=() [3/3]

Matrix & operator*= ( double  val)

Definition at line 107 of file Algebra.cpp.

◆ operator+=()

Matrix & operator+= ( const Matrix oth)

Definition at line 126 of file Algebra.cpp.

◆ operator-()

Matrix operator- ( ) const

Definition at line 124 of file Algebra.cpp.

◆ operator-=()

Matrix & operator-= ( const Matrix oth)

Definition at line 131 of file Algebra.cpp.

◆ operator/=()

Matrix & operator/= ( double  val)

Definition at line 122 of file Algebra.cpp.

◆ operator=()

Matrix & operator= ( const Matrix oth)

Definition at line 52 of file Algebra.cpp.

◆ operator==()

bool operator== ( const Matrix oth) const

Definition at line 105 of file Algebra.cpp.

◆ positive()

bool positive ( ) const

Definition at line 180 of file Algebra.cpp.

◆ row() [1/2]

VectorRef row ( size_t  i)

Definition at line 229 of file Algebra.cpp.

◆ row() [2/2]

Vector row ( size_t  i) const

Definition at line 227 of file Algebra.cpp.

◆ subset()

Matrix subset ( size_t  min_y,
size_t  min_x,
size_t  max_y = 0ull,
size_t  max_x = 0ull 
) const
Parameters
[in]min_yfirst vertical index for the subset
[in]min_xfirst horizontal index for the subset
[in]max_ylast vertical index for the subset
[in]max_xlast horizontal index for the subset

Definition at line 98 of file Algebra.cpp.

◆ transpose()

Matrix & transpose ( )

Definition at line 196 of file Algebra.cpp.

◆ transposed()

Matrix transposed ( ) const

Definition at line 206 of file Algebra.cpp.

◆ truncate()

Matrix & truncate ( double  min = 1.e-14)

Definition at line 186 of file Algebra.cpp.

◆ uniform()

Matrix uniform ( size_t  num_rows,
size_t  num_cols,
double  value = 1. 
)
static
Parameters
[in]num_rowsnumber of (horizontal) rows for the matrix
[in]num_colsnumber of (vertical) columns for the matrix
[in]valueuniform value for all the matrix components

Definition at line 75 of file Algebra.cpp.

◆ zero()

Matrix zero ( size_t  num_rows,
size_t  num_cols = 0ull 
)
static
Parameters
[in]num_rowsnumber of (horizontal) rows for the matrix
[in]num_colsnumber of (vertical) columns for the matrix

Definition at line 67 of file Algebra.cpp.

Friends And Related Symbol Documentation

◆ operator* [1/4]

Matrix operator* ( const Matrix mat1,
const Matrix mat2 
)
friend

Definition at line 269 of file Algebra.cpp.

◆ operator* [2/4]

Vector operator* ( const Matrix mat,
const Vector vec 
)
friend

Definition at line 261 of file Algebra.cpp.

◆ operator* [3/4]

Matrix operator* ( const Matrix lhs,
double  val 
)
friend

Definition at line 255 of file Algebra.cpp.

◆ operator* [4/4]

Matrix operator* ( double  val,
const Matrix lhs 
)
friend

Definition at line 249 of file Algebra.cpp.

◆ operator+

Matrix operator+ ( const Matrix lhs,
const Matrix rhs 
)
friend

Definition at line 237 of file Algebra.cpp.

◆ operator-

Matrix operator- ( const Matrix lhs,
const Matrix rhs 
)
friend

Definition at line 243 of file Algebra.cpp.

◆ operator/

Matrix operator/ ( const Matrix lhs,
double  val 
)
friend

Definition at line 275 of file Algebra.cpp.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const Matrix mat 
)
friend

Definition at line 277 of file Algebra.cpp.