QwAnalysis
|
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <boost/version.hpp>
#include <boost/numeric/ublas/config.hpp>
#include <boost/numeric/ublas/storage.hpp>
#include <boost/numeric/ublas/functional.hpp>
#include <boost/numeric/ublas/operation.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/triangular.hpp>
#include <boost/numeric/ublas/lu.hpp>
#include <boost/numeric/ublas/io.hpp>
Go to the source code of this file.
Functions | |
double | UNorm (const double *A, int n, const int m) |
Calculates the least upper bound norm. More... | |
double * | M_Cholesky (double *B, double *q, const int n) |
Calculates the Cholesky decomposition of the positive-definite matrix B. More... | |
double * | M_InvertPos (double *B, const int n) |
Calculates a*A + b*B, where both A and B are rows of length n. More... | |
double * | M_Invert (double *Ap, double *Bp, const int n) |
Matrix inversion of Ap will be stored in Bp. More... | |
void | RowMult (const double a, double *A, const double b, const double *B, const int n) |
Calculates a*A + b*B, where both A and B are rows of length n, returns as A. More... | |
double * | M_A_times_b (double *y, const double *A, const int n, const int m, const double *b) |
Calculates y[n] = A[n,m] * b[m], with dimensions indicated. More... | |
double * | M_Zero (double *A, const int n) |
Creates zero matrix A. More... | |
double * | M_Unit (double *A, const int n) |
Creates unit matrix A. More... | |
void | M_Print (const double *A, const int n) |
Print matrix A of dimension [n,n] to cout. More... | |
void | M_Print (const double *A, const double *B, const int n) |
Print matrices A and B of dimension [n,n] to cout. More... | |
double * | V_Zero (double *v, const int n) |
double * | V_Unit (double *v, const int n, int k) |
void | V_Print (const double *v, const int n) |
void | V_Print (const double *v, const double *w, const int n) |
template<class T > | |
boost::numeric::ublas::matrix< T > | invert (boost::numeric::ublas::matrix< T > &input) |
boost::numeric::ublas::matrix<T> invert | ( | boost::numeric::ublas::matrix< T > & | input | ) |
The following code inverts the matrix input using LU-decomposition with backsubstitution of unit vectors.
References: Numerical Recipies in C, 2nd ed., by Press, Teukolsky, Vetterling & Flannery. http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?LU_Matrix_Inversion
Note: This function is relatively slow (around 230 usec on my laptop for a 4 x 4 matrix, compared to less than 10 usec using the functions above), but on a total processing time per event of 0.1 sec this does not make any difference and greatly improves maintainability. If profiling reveals that this matrix inversion is a bottle neck, we should move back to the optimized functions.
Definition at line 71 of file matrix.h.
double * M_A_times_b | ( | double * | y, |
const double * | A, | ||
const int | n, | ||
const int | m, | ||
const double * | b | ||
) |
Calculates y[n] = A[n,m] * b[m], with dimensions indicated.
Definition at line 443 of file matrix.cc.
References Qw::m.
Referenced by QwTrackingTreeCombine::r2_PartialTrackFit().
double * M_Cholesky | ( | double * | B, |
double * | q, | ||
const int | n | ||
) |
Calculates the Cholesky decomposition of the positive-definite matrix B.
Definition at line 76 of file matrix.cc.
References DBL_EPSILON, Qw::min, and UNorm().
Referenced by M_InvertPos().
double * M_Invert | ( | double * | Ap, |
double * | Bp, | ||
const int | n | ||
) |
Matrix inversion of Ap will be stored in Bp.
Definition at line 240 of file matrix.cc.
References M_Unit(), and RowMult().
Referenced by QwTrackingTreeCombine::r2_PartialTrackFit().
double * M_InvertPos | ( | double * | B, |
const int | n | ||
) |
Calculates a*A + b*B, where both A and B are rows of length n.
Definition at line 376 of file matrix.cc.
References M_Cholesky().
void M_Print | ( | const double * | A, |
const int | n | ||
) |
Print matrix A of dimension [n,n] to cout.
void M_Print | ( | const double * | A, |
const double * | B, | ||
const int | n | ||
) |
double * M_Unit | ( | double * | A, |
const int | n | ||
) |
Creates unit matrix A.
Definition at line 199 of file matrix.cc.
Referenced by M_Invert().
double * M_Zero | ( | double * | A, |
const int | n | ||
) |
void RowMult | ( | const double | a, |
double * | A, | ||
const double | b, | ||
const double * | B, | ||
const int | n | ||
) |
Calculates a*A + b*B, where both A and B are rows of length n, returns as A.
Definition at line 130 of file matrix.cc.
Referenced by M_Invert().
double UNorm | ( | const double * | A, |
int | n, | ||
const int | m | ||
) |
Calculates the least upper bound norm.
Definition at line 51 of file matrix.cc.
References Qw::m.
Referenced by M_Cholesky().
void V_Print | ( | const double * | v, |
const int | n | ||
) |
void V_Print | ( | const double * | v, |
const double * | w, | ||
const int | n | ||
) |
double* V_Unit | ( | double * | v, |
const int | n, | ||
int | k | ||
) |