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

#include <VtNegMatrix.hh>

Inheritance diagram for MATRIX::VtNegMatrix:
Collaboration diagram for MATRIX::VtNegMatrix:

Public Member Functions

— Constructors —
 VtNegMatrix (const unsigned int row, const unsigned int col)
 
 VtNegMatrix (const VtNegMatrix &rhs)
 
 VtNegMatrix (const VtMatrix &rhs)
 
 ~VtNegMatrix ()
 
double operator() (unsigned int row, unsigned int col) const
 
double & operator() (const unsigned int row, const unsigned int col)
 
double nget (unsigned int row, unsigned int col) const
 
double & nget (unsigned int row, unsigned int col)
 
— Matrix operations —
const VtNegMatrix T (void) const
 return transposed matrix More...
 
const VtNegMatrixoperator+= (const double rhs)
 $\textbf{A} = (a_{\mu\nu} + \alpha)$ More...
 
const VtNegMatrixoperator-= (const double rhs)
 $\textbf{A} = (a_{\mu\nu} - \alpha)$ More...
 
const VtNegMatrixoperator*= (const double rhs)
 $\textbf{A} = (a_{\mu\nu} \cdot\alpha)$ More...
 
const VtNegMatrixoperator/= (const double rhs)
 $\textbf{A} = (a_{\mu\nu} / \alpha)$ More...
 
const VtNegMatrixoperator+= (const VtMatrix &rhs)
 
const VtNegMatrixoperator+= (const VtNegMatrix &rhs)
 
const VtNegMatrixoperator-= (const VtMatrix &rhs)
 
const VtNegMatrixoperator-= (const VtNegMatrix &rhs)
 
const VtMatrix operator+ (const VtMatrix &rhs) const
 
const VtMatrix operator+ (const VtNegMatrix &rhs) const
 
const VtMatrix operator- (const VtMatrix &rhs) const
 
const VtMatrix operator- (void) const
 
const VtMatrix operator* (const VtMatrix &rhs) const
 
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
 
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)
 
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

A class for negative matrices to optimize expressions like $C = -A * B$. For internal use only! @memo Negative matrix class

Constructor & Destructor Documentation

◆ VtNegMatrix() [1/3]

MATRIX::VtNegMatrix::VtNegMatrix ( const unsigned int  row,
const unsigned int  col 
)
35 :
36 VtMatrix(row,col) {}
VtMatrix(const unsigned int row, const unsigned int col)
Definition: VtMatrix.C:38

◆ VtNegMatrix() [2/3]

MATRIX::VtNegMatrix::VtNegMatrix ( const VtNegMatrix rhs)
38 :
39 VtMatrix(rhs) {}

◆ VtNegMatrix() [3/3]

MATRIX::VtNegMatrix::VtNegMatrix ( const VtMatrix rhs)
41 :
42 VtMatrix(rhs) {}

◆ ~VtNegMatrix()

MATRIX::VtNegMatrix::~VtNegMatrix ( )
inline
54{}

Member Function Documentation

◆ nget() [1/2]

double & MATRIX::VtNegMatrix::nget ( unsigned int  row,
unsigned int  col 
)
inline
62 {
63 return *(m + row*m_ncol + col);
64 }
double * m
Definition: VtMatrix.hh:171
unsigned int m_ncol
Definition: VtMatrix.hh:174

◆ nget() [2/2]

double MATRIX::VtNegMatrix::nget ( unsigned int  row,
unsigned int  col 
) const
inline
59 {
60 return -*(m + row*m_ncol + col);
61 }

◆ operator()() [1/2]

double & MATRIX::VtNegMatrix::operator() ( const unsigned int  row,
const unsigned int  col 
)
virtual

Reimplemented from MATRIX::VtMatrix.

49 {
50 // cout << "VtNegMatrix::operator() const called!" << endl;
51 return *(m + row*m_ncol + col);
52 }

◆ operator()() [2/2]

double MATRIX::VtNegMatrix::operator() ( unsigned int  row,
unsigned int  col 
) const
virtual

Reimplemented from MATRIX::VtMatrix.

44 {
45 // cout << "VtNegMatrix::operator() const called!" << endl;
46 return -*(m + row*m_ncol + col);
47 }

◆ operator*() [1/2]

const VtMatrix MATRIX::VtNegMatrix::operator* ( const VtMatrix rhs) const
182 {
183
184#ifndef VtFAST
185 assert(ncol() == rhs.nrow());
186#endif
187
188 const unsigned int lnrow = nrow();
189 const unsigned int rncol = rhs.ncol();
190 const unsigned int rnrow = rhs.nrow();
191
192 VtMatrix tmp(lnrow, rncol);
193
194 // the trick is that operator()(i,k) returns the
195 // negative!
196 for(unsigned int i=0; i<lnrow; ++i) {
197 for(unsigned int j=0; j<rncol; ++j) {
198 for(unsigned int k=0; k<rnrow; ++k) {
199 // tmp(i,j) += operator()(i,k) * rhs(k,j);
200 tmp.get(i,j) += nget(i,k) * rhs.get(k,j);
201 }
202 }
203 }
204
205 return tmp;
206 }
unsigned int ncol() const
no of columns $m$
Definition: VtMatrix.hh:63
unsigned int nrow() const
no of rows $n$
Definition: VtMatrix.hh:61
double nget(unsigned int row, unsigned int col) const
Definition: VtNegMatrix.hh:59

◆ operator*() [2/2]

const VtVector MATRIX::VtNegMatrix::operator* ( const VtVector rhs) const
211 {
212
213#ifndef VtFAST
214 assert(ncol() == rhs.nrow());
215#endif
216
217 VtVector tmp(nrow());
218
219 for(unsigned int i=0; i<nrow(); ++i) {
220 for(unsigned int j=0; j<ncol(); ++j) {
221 tmp[i] += operator()(i,j) * rhs[j];
222 }
223 }
224
225 return tmp;
226 }
double operator()(unsigned int row, unsigned int col) const
Definition: VtNegMatrix.C:44

◆ operator*=()

const VtNegMatrix & MATRIX::VtNegMatrix::operator*= ( const double  rhs)
virtual

$\textbf{A} = (a_{\mu\nu} \cdot\alpha)$

Reimplemented from MATRIX::VtMatrix.

109 {
111 return *this;
112 }
virtual const VtMatrix & operator*=(const double rhs)
$\textbf{A} = (a_{\mu\nu} \cdot\alpha)$
Definition: VtMatrix.C:200

◆ operator+() [1/2]

const VtMatrix MATRIX::VtNegMatrix::operator+ ( const VtMatrix rhs) const
125 {
126
127 return VtMatrix(rhs - *this);
128 }

◆ operator+() [2/2]

const VtMatrix MATRIX::VtNegMatrix::operator+ ( const VtNegMatrix rhs) const
133 {
134
135#ifndef VtFAST
136 assert(ncol() == rhs.ncol() && nrow() == rhs.nrow());
137#endif
138
139 VtMatrix tmp(rhs.nrow(),rhs.ncol());
140
141 for(unsigned int i=0; i<nrow(); ++i)
142 for(unsigned int j=0; j<ncol(); ++j)
143 tmp(i,j) = operator()(i,j) + rhs(i,j);
144
145 return tmp;
146 }

◆ operator+=() [1/3]

const VtNegMatrix & MATRIX::VtNegMatrix::operator+= ( const double  rhs)
virtual

$\textbf{A} = (a_{\mu\nu} + \alpha)$

Reimplemented from MATRIX::VtMatrix.

57 {
59 return *this;
60 }
virtual const VtMatrix & operator-=(const double rhs)
$\textbf{A} = (a_{\mu\nu} - \alpha)$
Definition: VtMatrix.C:179

◆ operator+=() [2/3]

const VtNegMatrix & MATRIX::VtNegMatrix::operator+= ( const VtMatrix rhs)
65 {
66 cout << "VtNegMatrix::operator+=(VtMatrix) called" << endl;
68 return *this;
69 }

◆ operator+=() [3/3]

const VtNegMatrix & MATRIX::VtNegMatrix::operator+= ( const VtNegMatrix rhs)
74 {
75 cout << "VtNegMatrix::operator+=(VtNegMatrix) called" << endl;
77 return *this;
78 }
virtual const VtMatrix & operator+=(const double rhs)
$\textbf{A} = (a_{\mu\nu} + \alpha)$
Definition: VtMatrix.C:158

◆ operator-() [1/2]

const VtMatrix MATRIX::VtNegMatrix::operator- ( const VtMatrix rhs) const
151 {
152
153#ifndef VtFAST
154 assert(ncol() == rhs.ncol() && nrow() == rhs.nrow());
155#endif
156
157 VtMatrix tmp(rhs.nrow(),rhs.ncol());
158
159 for(unsigned int i=0; i<nrow(); ++i)
160 for(unsigned int j=0; j<ncol(); ++j)
161 tmp(i,j) = operator()(i,j) - rhs(i,j);
162
163 return tmp;
164 }

◆ operator-() [2/2]

const VtMatrix MATRIX::VtNegMatrix::operator- ( void  ) const
170 {
171
172#ifndef VtDEBUG
173 cout << "VtNegMatrix::operator- (unary) called!" << endl;
174#endif
175
176 return VtMatrix(*this);
177 }

◆ operator-=() [1/3]

const VtNegMatrix & MATRIX::VtNegMatrix::operator-= ( const double  rhs)
virtual

$\textbf{A} = (a_{\mu\nu} - \alpha)$

Reimplemented from MATRIX::VtMatrix.

83 {
85 return *this;
86 }

◆ operator-=() [2/3]

const VtNegMatrix & MATRIX::VtNegMatrix::operator-= ( const VtMatrix rhs)
91 {
92 cout << "VtNegMatrix::operator-=(VtMatrix) called" << endl;
94 return *this;
95 }

◆ operator-=() [3/3]

const VtNegMatrix & MATRIX::VtNegMatrix::operator-= ( const VtNegMatrix rhs)
100 {
101 cout << "VtNegMatrix::operator-=(VtNegMatrix) called" << endl;
103 return *this;
104 }

◆ operator/=()

const VtNegMatrix & MATRIX::VtNegMatrix::operator/= ( const double  rhs)
virtual

$\textbf{A} = (a_{\mu\nu} / \alpha)$

Reimplemented from MATRIX::VtMatrix.

117 {
119 return *this;
120 }
virtual const VtMatrix & operator/=(const double rhs)
$\textbf{A} = (a_{\mu\nu} / \alpha)$
Definition: VtMatrix.C:208

◆ T()

const VtNegMatrix MATRIX::VtNegMatrix::T ( void  ) const

return transposed matrix

231 {
232 VtNegMatrix tmp(*this);
233 tmp.VtT();
234 return tmp;
235 }
VtNegMatrix(const unsigned int row, const unsigned int col)
Definition: VtNegMatrix.C:35

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