FEDRA emulsion software from the OPERA Collaboration
MATRIX::VtSqMatrix Class Reference

#include <VtSqMatrix.hh>

Inheritance diagram for MATRIX::VtSqMatrix:
Collaboration diagram for MATRIX::VtSqMatrix:

Public Member Functions

— Constructors —
 VtSqMatrix (const int row)
 
 VtSqMatrix (const VtSqMatrix &rhs)
 
 VtSqMatrix (const VtMatrix &rhs)
 
virtual ~VtSqMatrix ()
 
— Matrix operations —
bool VtDinv (int dim=0)
 transform to inverse More...
 
const VtSqMatrix dinv (int dim=0) const
 return inverse More...
 
virtual double det () const
 return determinant More...
 
virtual const VtMatrix operator* (const VtMatrix &rhs)
 
const VtVector operator* (const VtVector &rhs) const
 
- Public Member Functions inherited from MATRIX::VtMatrix
 VtMatrix (const unsigned int row, const unsigned int col)
 
 VtMatrix (const VtMatrix &rhs)
 
virtual ~VtMatrix ()
 
unsigned int nrow () const
 no of rows $n$ More...
 
unsigned int ncol () const
 no of columns $m$ More...
 
int size () const
 $m\times n$ More...
 
VtMatrix_row operator[] (int row)
 
VtMatrix_row_const operator[] (int row) const
 
virtual double operator() (unsigned int row, unsigned int col) const
 
virtual double & operator() (const unsigned int row, const unsigned int col)
 
double get (unsigned int row, unsigned int col) const
 
double & get (unsigned int row, unsigned int col)
 
void VtT (void)
 transform into transpose matrix More...
 
const VtMatrix T (void) const
 return transpose More...
 
virtual void place_at (const VtMatrix &rhs, const unsigned int row, const unsigned int col)
 copy a smaller matrix at a certain place More...
 
virtual void place_at (const VtVector &rhs, const unsigned int row, const unsigned int col)
 copy a vector at a certain place More...
 
void copy (const VtMatrix &rhs)
 to be used if matrix dimensions are not equal More...
 
void clear (void)
 set matrix elements to 0 More...
 
const VtMatrixoperator= (const VtMatrix &rhs)
 $\textbf{A} = \textbf{B}$ More...
 
const VtMatrixoperator= (const VtNegMatrix &rhs)
 
virtual const VtMatrixoperator+= (const double rhs)
 $\textbf{A} = (a_{\mu\nu} + \alpha)$ More...
 
virtual const VtMatrixoperator-= (const double rhs)
 $\textbf{A} = (a_{\mu\nu} - \alpha)$ More...
 
virtual const VtMatrixoperator*= (const double rhs)
 $\textbf{A} = (a_{\mu\nu} \cdot\alpha)$ More...
 
virtual const VtMatrixoperator/= (const double rhs)
 $\textbf{A} = (a_{\mu\nu} / \alpha)$ More...
 
const VtMatrixoperator+= (const VtMatrix &rhs)
 $\textbf{A} = (a_{\mu\nu} + b_{\mu\nu})$ More...
 
const VtMatrixoperator-= (const VtMatrix &rhs)
 $\textbf{A} = (a_{\mu\nu} - b_{\mu\nu})$ More...
 
const VtMatrix operator+ (const VtMatrix &rhs) const
 $\textbf{A} + \textbf{B}$ More...
 
const VtMatrix operator+ (const VtNegMatrix &rhs) const
 
const VtMatrix operator- (const VtMatrix &rhs) const
 $\textbf{A} - \textbf{B}$ More...
 
const VtMatrix operator- (const VtNegMatrix &rhs) const
 
const VtNegMatrix operator- (void) const
 $-\textbf{A}$ More...
 
const VtMatrix operator* (const VtMatrix &rhs) const
 $\textbf{A}\cdot\textbf{B} = \sum_{\nu=1}^n a_{\mu\nu}b_{\nu\lambda}$ More...
 
const VtVector operator* (const VtVector &rhs) const
 $\textbf{A}\cdot\vec{v} = (\sum_{\nu=1}^n a_{\mu\nu}v_{\nu})$ More...
 
double * array () const
 return pointer to internal array More...
 
virtual void print (std::ostream &os) const
 

Additional Inherited Members

- Protected Attributes inherited from MATRIX::VtMatrix
double * m
 
double * work
 
unsigned int m_nrow
 
unsigned int m_ncol
 

Detailed Description

Class for quadratic matrices

Constructor & Destructor Documentation

◆ VtSqMatrix() [1/3]

MATRIX::VtSqMatrix::VtSqMatrix ( const int  row)
inline
54: VtMatrix(row,row) {}
VtMatrix(const unsigned int row, const unsigned int col)
Definition: VtMatrix.C:38

◆ VtSqMatrix() [2/3]

MATRIX::VtSqMatrix::VtSqMatrix ( const VtSqMatrix rhs)
inline
56: VtMatrix(rhs) {}

◆ VtSqMatrix() [3/3]

MATRIX::VtSqMatrix::VtSqMatrix ( const VtMatrix rhs)
inline
58 : VtMatrix(rhs) {
59#ifndef VtFAST
60 assert(rhs.ncol()==rhs.nrow());
61#endif
62 }

◆ ~VtSqMatrix()

MATRIX::VtSqMatrix::~VtSqMatrix ( )
virtual
446{}

Member Function Documentation

◆ det()

double MATRIX::VtSqMatrix::det ( void  ) const
virtual

return determinant

Reimplemented in MATRIX::VtSymMatrix.

451 {
452
453 int ifail, jfail;
454 int n = nrow();
455 double det;
456
457 memcpy( work, m, size() * sizeof(double) );
458 double *work2 = new double[n];
459
460 Dfact1(&n, work, &n, work2, &ifail, &det, &jfail);
461 if(jfail != 0) {
462 det = 0;
463#ifdef VtDEBUG
464 cout << "VtMatrix::det() error: Determinant computation failed!" << endl;
465#endif
466 }
467
468 delete[] work2;
469
470 return det;
471 }
void Dfact1(int *n, double *a, int *idim, double *ir, int *ifail, double *det, int *jfail)
Definition: VtSqMatrix.C:224
double * m
Definition: VtMatrix.hh:171
int size() const
$m\times n$
Definition: VtMatrix.hh:65
double * work
Definition: VtMatrix.hh:172
unsigned int nrow() const
no of rows $n$
Definition: VtMatrix.hh:61
virtual double det() const
return determinant
Definition: VtSqMatrix.C:451

◆ dinv()

const VtSqMatrix MATRIX::VtSqMatrix::dinv ( int  dim = 0) const

return inverse

477 {
478 VtSqMatrix tmp(*this);
479 tmp.VtDinv(dim);
480 return tmp;
481 }
VtSqMatrix(const int row)
Definition: VtSqMatrix.hh:54

◆ operator*() [1/2]

const VtMatrix MATRIX::VtSqMatrix::operator* ( const VtMatrix rhs)
virtual
521 {
522 return VtMatrix::operator*(rhs);
523 }
const VtMatrix operator*(const VtMatrix &rhs) const
$\textbf{A}\cdot\textbf{B} = \sum_{\nu=1}^n a_{\mu\nu}b_{\nu\lambda}$
Definition: VtMatrix.C:283

◆ operator*() [2/2]

const VtVector MATRIX::VtSqMatrix::operator* ( const VtVector rhs) const
528 {
529 return VtMatrix::operator*(rhs);
530 }

◆ VtDinv()

bool MATRIX::VtSqMatrix::VtDinv ( int  dim = 0)

transform to inverse

486 {
487 bool valid = false;
488
489 if(dim == 0) dim = nrow();
490#ifndef VtFAST
491 else {
492 assert(dim <= static_cast<int>(nrow()));
493 }
494#endif
495
496 const size_t msize = size() * sizeof(double);
497
498 memcpy( work, m, msize );
499
500 int ifail = 0;
501 double *work2 = new double[dim];
502 Dinv1(&dim, work, &dim, work2, &ifail);
503 delete[] work2;
504
505 if(ifail != -1) {
506 memcpy( m, work, msize );
507 valid = true;
508 }
509#ifdef VtDEBUG
510 else {
511 cout << "VtMatrix::dinv() error: Matrix inversion failed!!!" << endl;
512 }
513#endif
514
515 return valid;
516 }
void Dinv1(int *n, double *a, int *idim, double *ir, int *ifail)
Definition: VtSqMatrix.C:321

The documentation for this class was generated from the following files: