qupid 0.2
Quasi-Signal Generation Model for Pixelized Detector
Loading...
Searching...
No Matches
QPMatrix.hpp
1#ifndef __QPMATRIX__
2#define __QPMATRIX__ 1
3
4#include <string>
5#include <vector>
6#include "QPVector.hpp"
7
16 public:
18 QPMatrix();
22 QPMatrix(const int n);
23 // QPMatrix(const int m, const int n); //Arb matrix of n x m, zero matrix
27 QPMatrix(const int m, const int n);
34 QPMatrix(const int m, const int n, const int npassed, ...);
43 QPMatrix(const QPMatrix& other);
48 QPMatrix(QPVector& vec, int ncomp);
49
54
56 ~QPMatrix();
63 double Det();
68 double Trace();
75 QPMatrix SubMatrix(const int i, const int j);
81 double Cofactor(const int i, const int j);
92 double At(int i);
98 double At(int i, int j);
104 double& operator[](int i);
108 double& operator()(int i);
117 double& operator()(int i, int j);
120 bool IsInside(int i);
124 bool IsInside(int i, int j);
127 bool IsSameShape(QPMatrix & other);
130 bool IsTransShape(QPMatrix & other);
135 std::string Print(bool quite=false);
136
139 friend QPMatrix operator*(QPMatrix , double );
142 friend QPMatrix operator*(double , QPMatrix );
150 friend QPMatrix operator+(QPMatrix & , QPMatrix & );
154 friend QPMatrix operator-(QPMatrix & , QPMatrix & );
155
159 inline QPMatrix& operator*=(const double& other); //Scaling
160
161
162 protected:
165 void Freeing();
166
167 private:
168 void Init();
169 double * fElement;
170 int fM=1;
171 int fN=1;
172
173 double nval=-1;
174};
175
176QPMatrix operator*(QPMatrix , double );
177QPMatrix operator*(double , QPMatrix );
178QPMatrix operator*(QPMatrix , QPMatrix );
179QPMatrix operator+(QPMatrix & , QPMatrix & );
180QPMatrix operator-(QPMatrix & , QPMatrix & );
181
182inline QPMatrix& QPMatrix::operator*=(const double& other){
183 for(int i=0; i<fM*fN; i++){
184 fElement[i] *= other;
185 }
186 return (*this);
187}
188
189#endif
Dense m×n matrix of double with hand-rolled linear algebra.
Definition QPMatrix.hpp:15
QPMatrix Transpose()
Definition QPMatrix.cpp:227
friend QPMatrix operator-(QPMatrix &, QPMatrix &)
Element-wise difference.
Definition QPMatrix.cpp:287
bool IsTransShape(QPMatrix &other)
Definition QPMatrix.cpp:117
friend QPMatrix operator+(QPMatrix &, QPMatrix &)
Element-wise sum.
Definition QPMatrix.cpp:270
~QPMatrix()
Frees the element storage.
Definition QPMatrix.cpp:66
friend QPMatrix operator*(QPMatrix, double)
Scaled copy.
Definition QPMatrix.cpp:238
QPMatrix Inverse()
Inverse by the adjugate formula .
Definition QPMatrix.cpp:200
bool IsInside(int i)
Definition QPMatrix.cpp:84
std::string Print(bool quite=false)
Formats the matrix as tab-separated rows.
Definition QPMatrix.cpp:304
double Trace()
Sum of the diagonal elements up to min(m, n).
Definition QPMatrix.cpp:167
QPMatrix & operator*=(const double &other)
Multiply every element in place.
Definition QPMatrix.hpp:182
double Cofactor(const int i, const int j)
Cofactor where is the minor.
Definition QPMatrix.cpp:192
QPMatrix & operator=(const QPMatrix &)
Deep copy assignment; reallocates the storage.
Definition QPMatrix.cpp:52
double At(int i)
Value of linear element i of the row-major storage.
Definition QPMatrix.cpp:96
QPMatrix()
Null matrix: 0×0, no storage.
Definition QPMatrix.cpp:10
QPMatrix SubMatrix(const int i, const int j)
Minor matrix: this matrix with row i and column j removed.
Definition QPMatrix.cpp:177
bool IsSameShape(QPMatrix &other)
Definition QPMatrix.cpp:112
QPMatrix(QPVector &vec)
Column vector from a QPVector.
double & operator[](int i)
Reference to linear element i of the row-major storage.
Definition QPMatrix.cpp:122
void Freeing()
Releases the element storage.
Definition QPMatrix.cpp:77
double Det()
Determinant by recursive Laplace expansion along the first row.
Definition QPMatrix.cpp:146
double & operator()(int i)
Same as operator[].
Definition QPMatrix.cpp:130
3-component double vector with hand-rolled operations.
Definition QPVector.hpp:13