Logo ROOT   6.10/09
Reference Guide
List of all members | Public Member Functions | Static Public Member Functions | Protected Types | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
TMatrixTBase< Element > Class Template Referenceabstract

template<class Element>
class TMatrixTBase< Element >

Linear Algebra Package.

Linear Algebra Package

The present package implements all the basic algorithms dealing with vectors, matrices, matrix columns, rows, diagonals, etc. In addition eigen-Vector analysis and several matrix decomposition have been added (LU,QRH,Cholesky,Bunch-Kaufman and SVD) . The decompositions are used in matrix inversion, equation solving.

For a dense matrix, elements are arranged in memory in a ROW-wise fashion . For (n x m) matrices where n*m <=kSizeMax (=25 currently) storage space is available on the stack, thus avoiding expensive allocation/deallocation of heap space . However, this introduces of course kSizeMax overhead for each matrix object . If this is an issue recompile with a new appropriate value (>=0) for kSizeMax

Sparse matrices are also stored in row-wise fashion but additional row/column information is stored, see TMatrixTSparse source for additional details .

Another way to assign and store matrix data is through Use see for instance stressLinear.cxx file .

Unless otherwise specified, matrix and vector indices always start with 0, spanning up to the specified limit-1. However, there are constructors to which one can specify aribtrary lower and upper bounds, e.g. TMatrixD m(1,10,1,5) defines a matrix that ranges from 1..10, 1..5 (a(1,1)..a(10,5)).

The present package provides all facilities to completely AVOID returning matrices. Use "TMatrixD A(TMatrixD::kTransposed,B);" and other fancy constructors as much as possible. If one really needs to return a matrix, return a TMatrixTLazy object instead. The conversion is completely transparent to the end user, e.g. "TMatrixT m = THaarMatrixT(5);" and is efficient.

Since TMatrixT et al. are fully integrated in ROOT, they of course can be stored in a ROOT database.

For usage examples see $ROOTSYS/test/stressLinear.cxx

Acknowledgements

  1. Oleg E. Kiselyov First implementations were based on the his code . We have diverged quite a bit since then but the ideas/code for lazy matrix and "nested function" are 100% his . You can see him and his code in action at http://okmij.org/ftp
  2. Chris R. Birchenhall, We adapted his idea of the implementation for the decomposition classes instead of our messy installation of matrix inversion His installation of matrix condition number, using an iterative scheme using the Hage algorithm is worth looking at ! Chris has a nice writeup (matdoc.ps) on his matrix classes at ftp://ftp.mcc.ac.uk/pub/matclass/
  3. Mark Fischler and Steven Haywood of CLHEP They did the slave labor of spelling out all sub-determinants for Cramer inversion of (4x4),(5x5) and (6x6) matrices The stack storage for small matrices was also taken from them
  4. Roldan Pozo of TNT (http://math.nist.gov/tnt/) He converted the EISPACK routines for the eigen-vector analysis to C++ . We started with his implementation
  5. Siegmund Brandt (http://siux00.physik.uni-siegen.de/~brandt/datan We adapted his (very-well) documented SVD routines

How to efficiently use this package

1. Never return complex objects (matrices or vectors)

Danger: For example, when the following snippet:

TMatrixD foo(int n)
{
TMatrixD foom(n,n); fill_in(foom); return foom;
}
TMatrixD m = foo(5);

runs, it constructs matrix foo:foom, copies it onto stack as a return value and destroys foo:foom. Return value (a matrix) from foo() is then copied over to m (via a copy constructor), and the return value is destroyed. So, the matrix constructor is called 3 times and the destructor 2 times. For big matrices, the cost of multiple constructing/copying/destroying of objects may be very large. Some optimized compilers can cut down on 1 copying/destroying, but still it leaves at least two calls to the constructor. Note, TMatrixDLazy (see below) can construct TMatrixD m "inplace", with only a single call to the constructor.

#### 2. Use "two-address instructions"

"void TMatrixD::operator += (const TMatrixD &B);"

as much as possible. That is, to add two matrices, it's much more efficient to write

A += B;

than

TMatrixD C = A + B;

(if both operand should be preserved, TMatrixD C = A; C += B; is still better).

#### 3. Use glorified constructors when returning of an object seems inevitable:

"TMatrixD A(TMatrixD::kTransposed,B);"
"TMatrixD C(A,TMatrixD::kTransposeMult,B);"

like in the following snippet (from $ROOTSYS/test/vmatrix.cxx) that verifies that for an orthogonal matrix T, T'T = TT' = E.

TMatrixD hht(haar,TMatrixD::kMult,haar_t);
TMatrixD hht1 = haar; hht1 *= haar_t;

4. Accessing row/col/diagonal of a matrix without much fuss

(and without moving a lot of stuff around):

TMatrixD m(n,n); TVectorD v(n); TMatrixDDiag(m) += 4;
v = TMatrixDRow(m,0);
TMatrixDColumn m1(m,1); m1(2) = 3; // the same as m(2,1)=3;

Note, constructing of, say, TMatrixDDiag does not involve any copying of any elements of the source matrix.

5. It's possible (and encouraged) to use "nested" functions

For example, creating of a Hilbert matrix can be done as follows:

void foo(const TMatrixD &m)
{
struct MakeHilbert : public TElementPosActionD {
void Operation(Double_t &element)
{ element = 1./(fI+fJ-1); }
};
m1.Apply(MakeHilbert());
}

of course, using a special method THilbertMatrixD() is still more optimal, but not by a whole lot. And that's right, class MakeHilbert is declared within a function and local to that function. It means one can define another MakeHilbert class (within another function or outside of any function, that is, in the global scope), and it still will be OK. Note, this currently is not yet supported by the interpreter CINT.

Another example is applying of a simple function to each matrix element:

void foo(TMatrixD &m,TMatrixD &m1)
{
typedef double (*dfunc_t)(double);
class ApplyFunction : public TElementActionD {
dfunc_t fFunc;
void Operation(Double_t &element)
{ element=fFunc(element); }
public:
ApplyFunction(dfunc_t func):fFunc(func) {}
};
ApplyFunction x(TMath::Sin);
m.Apply(x);
}

Validation code $ROOTSYS/test/vmatrix.cxx and vvector.cxx contain a few more examples of that kind.

6. Lazy matrices:

instead of returning an object return a "recipe" how to make it. The full matrix would be rolled out only when and where it's needed:

THaarMatrixD() is a class, not a simple function. However similar this looks to a returning of an object (see note #1 above), it's dramatically different. THaarMatrixD() constructs a TMatrixDLazy, an object of just a few bytes long. A special "TMatrixD(const TMatrixDLazy &recipe)" constructor follows the recipe and makes the matrix haar() right in place. No matrix element is moved whatsoever!

Definition at line 25 of file TMatrixDBasefwd.h.

Public Member Functions

 TMatrixTBase ()
 
virtual ~TMatrixTBase ()
 
virtual TMatrixTBase< Element > & Abs ()
 Take an absolute value of a matrix, i.e. apply Abs() to each element. More...
 
virtual TMatrixTBase< Element > & Apply (const TElementActionT< Element > &action)
 Apply action to each matrix element. More...
 
virtual TMatrixTBase< Element > & Apply (const TElementPosActionT< Element > &action)
 Apply action to each element of the matrix. More...
 
template<>
TClassClass ()
 
virtual void Clear (Option_t *option="")=0
 
virtual Element ColNorm () const
 Column matrix norm, MAX{ SUM{ |M(i,j)|, over i}, over j}. More...
 
virtual Double_t Determinant () const
 
virtual void Determinant (Double_t &d1, Double_t &d2) const
 
void Draw (Option_t *option="")
 Draw this matrix The histogram is named "TMatrixT" by default and no title. More...
 
virtual Element E2Norm () const
 Square of the Euclidian norm, SUM{ m(i,j)^2 }. More...
 
virtual void ExtractRow (Int_t row, Int_t col, Element *v, Int_t n=-1) const
 Store in array v, n matrix elements of row rown starting at column coln. More...
 
virtual const Int_tGetColIndexArray () const =0
 
virtual Int_tGetColIndexArray ()=0
 
Int_t GetColLwb () const
 
Int_t GetColUpb () const
 
virtual void GetMatrix2Array (Element *data, Option_t *option="") const
 Copy matrix data to array . More...
 
virtual const Element * GetMatrixArray () const =0
 
virtual Element * GetMatrixArray ()=0
 
Int_t GetNcols () const
 
Int_t GetNoElements () const
 
Int_t GetNrows () const
 
virtual const Int_tGetRowIndexArray () const =0
 
virtual Int_tGetRowIndexArray ()=0
 
Int_t GetRowLwb () const
 
Int_t GetRowUpb () const
 
virtual TMatrixTBase< Element > & GetSub (Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, TMatrixTBase< Element > &target, Option_t *option="S") const =0
 
Element GetTol () const
 
virtual TMatrixTBase< Element > & InsertRow (Int_t row, Int_t col, const Element *v, Int_t n=-1)
 Copy n elements from array v to row rown starting at column coln. More...
 
void Invalidate ()
 
Bool_t IsOwner () const
 
virtual Bool_t IsSymmetric () const
 Check whether matrix is symmetric. More...
 
Bool_t IsValid () const
 
void MakeValid ()
 
virtual Element Max () const
 return maximum vector element value More...
 
virtual Element Min () const
 return minimum matrix element value More...
 
virtual Int_t NonZeros () const
 Compute the number of elements != 0.0. More...
 
Element Norm1 () const
 
virtual TMatrixTBase< Element > & NormByDiag (const TVectorT< Element > &v, Option_t *option="D")
 option: More...
 
Element NormInf () const
 
Bool_t operator!= (Element val) const
 Are all matrix elements not equal to val? More...
 
virtual Element operator() (Int_t rown, Int_t coln) const =0
 
virtual Element & operator() (Int_t rown, Int_t coln)=0
 
Bool_t operator< (Element val) const
 Are all matrix elements < val? More...
 
Bool_t operator<= (Element val) const
 Are all matrix elements <= val? More...
 
Bool_t operator== (Element val) const
 Are all matrix elements equal to val? More...
 
Bool_t operator> (Element val) const
 Are all matrix elements > val? More...
 
Bool_t operator>= (Element val) const
 Are all matrix elements >= val? More...
 
void Print (Option_t *name="") const
 Print the matrix as a table of elements. More...
 
virtual TMatrixTBase< Element > & Randomize (Element alpha, Element beta, Double_t &seed)
 Randomize matrix element values. More...
 
virtual TMatrixTBase< Element > & ResizeTo (Int_t nrows, Int_t ncols, Int_t nr_nonzeros=-1)=0
 
virtual TMatrixTBase< Element > & ResizeTo (Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Int_t nr_nonzeros=-1)=0
 
virtual Element RowNorm () const
 Row matrix norm, MAX{ SUM{ |M(i,j)|, over j}, over i}. More...
 
virtual TMatrixTBase< Element > & SetColIndexArray (Int_t *data)=0
 
virtual TMatrixTBase< Element > & SetMatrixArray (const Element *data, Option_t *option="")
 Copy array data to matrix . More...
 
virtual TMatrixTBase< Element > & SetRowIndexArray (Int_t *data)=0
 
virtual TMatrixTBase< Element > & SetSub (Int_t row_lwb, Int_t col_lwb, const TMatrixTBase< Element > &source)=0
 
Element SetTol (Element tol)
 
virtual TMatrixTBase< Element > & Shift (Int_t row_shift, Int_t col_shift)
 Shift the row index by adding row_shift and the column index by adding col_shift, respectively. More...
 
virtual TMatrixTBase< Element > & Sqr ()
 Square each element of the matrix. More...
 
virtual TMatrixTBase< Element > & Sqrt ()
 Take square root of all elements. More...
 
virtual Element Sum () const
 Compute sum of elements. More...
 
virtual TMatrixTBase< Element > & UnitMatrix ()
 Make a unit matrix (matrix need not be a square one). More...
 
virtual TMatrixTBase< Element > & Zero ()
 Set matrix elements to zero. More...
 
- Public Member Functions inherited from TObject
 TObject ()
 TObject constructor. More...
 
 TObject (const TObject &object)
 TObject copy ctor. More...
 
virtual ~TObject ()
 TObject destructor. More...
 
void AbstractMethod (const char *method) const
 Use this method to implement an "abstract" method that you don't want to leave purely abstract. More...
 
virtual void AppendPad (Option_t *option="")
 Append graphics object to current pad. More...
 
virtual void Browse (TBrowser *b)
 Browse object. May be overridden for another default action. More...
 
virtual const char * ClassName () const
 Returns name of class to which the object belongs. More...
 
virtual TObjectClone (const char *newname="") const
 Make a clone of an object using the Streamer facility. More...
 
virtual Int_t Compare (const TObject *obj) const
 Compare abstract method. More...
 
virtual void Copy (TObject &object) const
 Copy this to obj. More...
 
virtual void Delete (Option_t *option="")
 Delete this object. More...
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 Computes distance from point (px,py) to the object. More...
 
virtual void DrawClass () const
 Draw class inheritance tree of the class to which this object belongs. More...
 
virtual TObjectDrawClone (Option_t *option="") const
 Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad). More...
 
virtual void Dump () const
 Dump contents of object on stdout. More...
 
virtual void Error (const char *method, const char *msgfmt,...) const
 Issue error message. More...
 
virtual void Execute (const char *method, const char *params, Int_t *error=0)
 Execute method on this object with the given parameter string, e.g. More...
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=0)
 Execute method on this object with parameters stored in the TObjArray. More...
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 Execute action corresponding to an event at (px,py). More...
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 Issue fatal error message. More...
 
virtual TObjectFindObject (const char *name) const
 Must be redefined in derived classes. More...
 
virtual TObjectFindObject (const TObject *obj) const
 Must be redefined in derived classes. More...
 
virtual Option_tGetDrawOption () const
 Get option used by the graphics system to draw this object. More...
 
virtual const char * GetIconName () const
 Returns mime type name of object. More...
 
virtual const char * GetName () const
 Returns name of object. More...
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 Returns string containing info about the object at position (px,py). More...
 
virtual Option_tGetOption () const
 
virtual const char * GetTitle () const
 Returns title of object. More...
 
virtual UInt_t GetUniqueID () const
 Return the unique object id. More...
 
virtual Bool_t HandleTimer (TTimer *timer)
 Execute action in response of a timer timing out. More...
 
virtual ULong_t Hash () const
 Return hash value for this object. More...
 
virtual void Info (const char *method, const char *msgfmt,...) const
 Issue info message. More...
 
virtual Bool_t InheritsFrom (const char *classname) const
 Returns kTRUE if object inherits from class "classname". More...
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 Returns kTRUE if object inherits from TClass cl. More...
 
virtual void Inspect () const
 Dump contents of this object in a graphics canvas. More...
 
void InvertBit (UInt_t f)
 
virtual Bool_t IsEqual (const TObject *obj) const
 Default equal comparison (objects are equal if they have the same address in memory). More...
 
virtual Bool_t IsFolder () const
 Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). More...
 
Bool_t IsOnHeap () const
 
virtual Bool_t IsSortable () const
 
Bool_t IsZombie () const
 
virtual void ls (Option_t *option="") const
 The ls function lists the contents of a class on stdout. More...
 
void MayNotUse (const char *method) const
 Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary). More...
 
virtual Bool_t Notify ()
 This method must be overridden to handle object notification. More...
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 Use this method to declare a method obsolete. More...
 
void operator delete (void *ptr)
 Operator delete. More...
 
void operator delete[] (void *ptr)
 Operator delete []. More...
 
voidoperator new (size_t sz)
 
voidoperator new (size_t sz, void *vp)
 
voidoperator new[] (size_t sz)
 
voidoperator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 TObject assignment operator. More...
 
virtual void Paint (Option_t *option="")
 This method must be overridden if a class wants to paint itself. More...
 
virtual void Pop ()
 Pop on object drawn in a pad to the top of the display list. More...
 
virtual Int_t Read (const char *name)
 Read contents of object with specified name from the current directory. More...
 
virtual void RecursiveRemove (TObject *obj)
 Recursively remove this object from a list. More...
 
void ResetBit (UInt_t f)
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 Save this object in the file specified by filename. More...
 
virtual void SavePrimitive (std::ostream &out, Option_t *option="")
 Save a primitive as a C++ statement(s) on output stream "out". More...
 
void SetBit (UInt_t f, Bool_t set)
 Set or unset the user status bits as specified in f. More...
 
void SetBit (UInt_t f)
 
virtual void SetDrawOption (Option_t *option="")
 Set drawing option for object. More...
 
virtual void SetUniqueID (UInt_t uid)
 Set the unique object id. More...
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 Issue system error message. More...
 
Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
virtual void UseCurrentStyle ()
 Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked. More...
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 Issue warning message. More...
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0)
 Write this object to the current directory. More...
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const
 Write this object to the current directory. More...
 

Static Public Member Functions

static Element & NaNValue ()
 
- Static Public Member Functions inherited from TObject
static Long_t GetDtorOnly ()
 Return destructor only flag. More...
 
static Bool_t GetObjectStat ()
 Get status of object stat flag. More...
 
static void SetDtorOnly (void *obj)
 Set destructor only flag. More...
 
static void SetObjectStat (Bool_t stat)
 Turn on/off tracking of objects in the TObjectTable. More...
 

Protected Types

enum  { kSizeMax = 25 }
 
enum  { kWorkMax = 100 }
 
enum  EMatrixStatusBits { kStatus = BIT(14) }
 

Static Protected Member Functions

static void DoubleLexSort (Int_t n, Int_t *first, Int_t *second, Element *data)
 default kTRUE, when Use array kFALSE More...
 
static void IndexedLexSort (Int_t n, Int_t *first, Int_t swapFirst, Int_t *second, Int_t swapSecond, Int_t *index)
 Lexical sort on array data using indices first and second. More...
 

Protected Attributes

Int_t fColLwb
 
Bool_t fIsOwner
 
Int_t fNcols
 
Int_t fNelems
 
Int_t fNrowIndex
 
Int_t fNrows
 
Int_t fRowLwb
 
Element fTol
 

Private Member Functions

Element * GetElements ()
 

Additional Inherited Members

- Public Types inherited from TObject
enum  { kIsOnHeap = 0x01000000, kNotDeleted = 0x02000000, kZombie = 0x04000000, kBitMask = 0x00ffffff }
 
enum  { kSingleKey = BIT(0), kOverwrite = BIT(1), kWriteDelete = BIT(2) }
 
enum  EStatusBits {
  kCanDelete = BIT(0), kMustCleanup = BIT(3), kObjInCanvas = BIT(3), kIsReferenced = BIT(4),
  kHasUUID = BIT(5), kCannotPick = BIT(6), kNoContextMenu = BIT(8), kInvalidObject = BIT(13)
}
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 Interface to ErrorHandler (protected). More...
 
void MakeZombie ()
 

#include <TMatrixDBasefwd.h>

Inheritance diagram for TMatrixTBase< Element >:
[legend]

Member Enumeration Documentation

◆ anonymous enum

template<class Element>
anonymous enum
protected
Enumerator
kSizeMax 

Definition at line 105 of file TMatrixTBase.h.

◆ anonymous enum

template<class Element>
anonymous enum
protected
Enumerator
kWorkMax 

Definition at line 106 of file TMatrixTBase.h.

◆ EMatrixStatusBits

template<class Element>
enum TMatrixTBase::EMatrixStatusBits
protected
Enumerator
kStatus 

Definition at line 108 of file TMatrixTBase.h.

Constructor & Destructor Documentation

◆ TMatrixTBase()

template<class Element>
TMatrixTBase< Element >::TMatrixTBase ( )
inline

Definition at line 114 of file TMatrixTBase.h.

◆ ~TMatrixTBase()

template<class Element>
virtual TMatrixTBase< Element >::~TMatrixTBase ( )
inlinevirtual

Definition at line 118 of file TMatrixTBase.h.

Member Function Documentation

◆ Abs()

template<class Element >
TMatrixTBase< Element > & TMatrixTBase< Element >::Abs ( )
virtual

Take an absolute value of a matrix, i.e. apply Abs() to each element.

Definition at line 559 of file TMatrixTBase.cxx.

◆ Apply() [1/2]

template<class Element >
TMatrixTBase< Element > & TMatrixTBase< Element >::Apply ( const TElementActionT< Element > &  action)
virtual

Apply action to each matrix element.

Reimplemented in TMatrixTSym< Element >.

Definition at line 997 of file TMatrixTBase.cxx.

◆ Apply() [2/2]

template<class Element >
TMatrixTBase< Element > & TMatrixTBase< Element >::Apply ( const TElementPosActionT< Element > &  action)
virtual

Apply action to each element of the matrix.

To action the location of the current element is passed.

Reimplemented in TMatrixTSym< Element >.

Definition at line 1014 of file TMatrixTBase.cxx.

◆ Class()

template<>
TClass * TMatrixTBase< double >::Class ( )

◆ Clear()

template<class Element>
virtual void TMatrixTBase< Element >::Clear ( Option_t option = "")
pure virtual

◆ ColNorm()

template<class Element >
Element TMatrixTBase< Element >::ColNorm ( ) const
virtual

Column matrix norm, MAX{ SUM{ |M(i,j)|, over i}, over j}.

The norm is induced by the 1 vector norm.

Reimplemented in TMatrixTSparse< Element >, and TMatrixTSparse< Double_t >.

Definition at line 713 of file TMatrixTBase.cxx.

◆ Determinant() [1/2]

template<class Element>
virtual Double_t TMatrixTBase< Element >::Determinant ( ) const
inlinevirtual

◆ Determinant() [2/2]

template<class Element>
virtual void TMatrixTBase< Element >::Determinant ( Double_t d1,
Double_t d2 
) const
inlinevirtual

◆ DoubleLexSort()

template<class Element >
void TMatrixTBase< Element >::DoubleLexSort ( Int_t  n,
Int_t first,
Int_t second,
Element *  data 
)
staticprotected

default kTRUE, when Use array kFALSE

Lexical sort on array data using indices first and second.

Definition at line 238 of file TMatrixTBase.cxx.

◆ Draw()

template<class Element >
void TMatrixTBase< Element >::Draw ( Option_t option = "")
virtual

Draw this matrix The histogram is named "TMatrixT" by default and no title.

Reimplemented from TObject.

Definition at line 819 of file TMatrixTBase.cxx.

◆ E2Norm()

template<class Element >
Element TMatrixTBase< Element >::E2Norm ( ) const
virtual

Square of the Euclidian norm, SUM{ m(i,j)^2 }.

Definition at line 740 of file TMatrixTBase.cxx.

◆ ExtractRow()

template<class Element >
void TMatrixTBase< Element >::ExtractRow ( Int_t  row,
Int_t  col,
Element *  v,
Int_t  n = -1 
) const
virtual

Store in array v, n matrix elements of row rown starting at column coln.

Reimplemented in TMatrixTSparse< Element >.

Definition at line 501 of file TMatrixTBase.cxx.

◆ GetColIndexArray() [1/2]

template<class Element>
virtual const Int_t* TMatrixTBase< Element >::GetColIndexArray ( ) const
pure virtual

◆ GetColIndexArray() [2/2]

template<class Element>
virtual Int_t* TMatrixTBase< Element >::GetColIndexArray ( )
pure virtual

◆ GetColLwb()

template<class Element>
Int_t TMatrixTBase< Element >::GetColLwb ( ) const
inline

Definition at line 123 of file TMatrixTBase.h.

◆ GetColUpb()

template<class Element>
Int_t TMatrixTBase< Element >::GetColUpb ( ) const
inline

Definition at line 124 of file TMatrixTBase.h.

◆ GetElements()

template<class Element>
Element* TMatrixTBase< Element >::GetElements ( )
private

◆ GetMatrix2Array()

template<class Element >
void TMatrixTBase< Element >::GetMatrix2Array ( Element *  data,
Option_t option = "" 
) const
virtual

Copy matrix data to array .

It is assumed that array is of size >= fNelems (=)))) fNrows*fNcols option indicates how the data is stored in the array: option =

  • 'F' : column major (Fortran) array[i+j*fNrows] = m[i][j]
  • else : row major (C) array[i*fNcols+j] = m[i][j] (default)

Reimplemented in TMatrixTSparse< Element >.

Definition at line 441 of file TMatrixTBase.cxx.

◆ GetMatrixArray() [1/2]

template<class Element>
virtual const Element* TMatrixTBase< Element >::GetMatrixArray ( ) const
pure virtual

◆ GetMatrixArray() [2/2]

template<class Element>
virtual Element* TMatrixTBase< Element >::GetMatrixArray ( )
pure virtual

◆ GetNcols()

template<class Element>
Int_t TMatrixTBase< Element >::GetNcols ( ) const
inline

Definition at line 125 of file TMatrixTBase.h.

◆ GetNoElements()

template<class Element>
Int_t TMatrixTBase< Element >::GetNoElements ( ) const
inline

Definition at line 126 of file TMatrixTBase.h.

◆ GetNrows()

template<class Element>
Int_t TMatrixTBase< Element >::GetNrows ( ) const
inline

Definition at line 122 of file TMatrixTBase.h.

◆ GetRowIndexArray() [1/2]

template<class Element>
virtual const Int_t* TMatrixTBase< Element >::GetRowIndexArray ( ) const
pure virtual

◆ GetRowIndexArray() [2/2]

template<class Element>
virtual Int_t* TMatrixTBase< Element >::GetRowIndexArray ( )
pure virtual

◆ GetRowLwb()

template<class Element>
Int_t TMatrixTBase< Element >::GetRowLwb ( ) const
inline

Definition at line 120 of file TMatrixTBase.h.

◆ GetRowUpb()

template<class Element>
Int_t TMatrixTBase< Element >::GetRowUpb ( ) const
inline

Definition at line 121 of file TMatrixTBase.h.

◆ GetSub()

template<class Element>
virtual TMatrixTBase<Element>& TMatrixTBase< Element >::GetSub ( Int_t  row_lwb,
Int_t  row_upb,
Int_t  col_lwb,
Int_t  col_upb,
TMatrixTBase< Element > &  target,
Option_t option = "S" 
) const
pure virtual

◆ GetTol()

template<class Element>
Element TMatrixTBase< Element >::GetTol ( ) const
inline

Definition at line 127 of file TMatrixTBase.h.

◆ IndexedLexSort()

template<class Element >
void TMatrixTBase< Element >::IndexedLexSort ( Int_t  n,
Int_t first,
Int_t  swapFirst,
Int_t second,
Int_t  swapSecond,
Int_t index 
)
staticprotected

Lexical sort on array data using indices first and second.

Definition at line 277 of file TMatrixTBase.cxx.

◆ InsertRow()

template<class Element >
TMatrixTBase< Element > & TMatrixTBase< Element >::InsertRow ( Int_t  row,
Int_t  col,
const Element *  v,
Int_t  n = -1 
)
virtual

Copy n elements from array v to row rown starting at column coln.

Reimplemented in TMatrixTSparse< Element >.

Definition at line 467 of file TMatrixTBase.cxx.

◆ Invalidate()

template<class Element>
void TMatrixTBase< Element >::Invalidate ( )
inline

Definition at line 143 of file TMatrixTBase.h.

◆ IsOwner()

template<class Element>
Bool_t TMatrixTBase< Element >::IsOwner ( ) const
inline

Definition at line 146 of file TMatrixTBase.h.

◆ IsSymmetric()

template<class Element >
Bool_t TMatrixTBase< Element >::IsSymmetric ( ) const
virtual

Check whether matrix is symmetric.

Reimplemented in TMatrixTSparse< Element >, TMatrixTSparse< Double_t >, TMatrixTSym< Element >, and TMatrixTSym< Double_t >.

Definition at line 412 of file TMatrixTBase.cxx.

◆ IsValid()

template<class Element>
Bool_t TMatrixTBase< Element >::IsValid ( ) const
inline

Definition at line 145 of file TMatrixTBase.h.

◆ MakeValid()

template<class Element>
void TMatrixTBase< Element >::MakeValid ( )
inline

Definition at line 144 of file TMatrixTBase.h.

◆ Max()

template<class Element >
Element TMatrixTBase< Element >::Max ( ) const
virtual

return maximum vector element value

Definition at line 805 of file TMatrixTBase.cxx.

◆ Min()

template<class Element >
Element TMatrixTBase< Element >::Min ( ) const
virtual

return minimum matrix element value

Definition at line 792 of file TMatrixTBase.cxx.

◆ NaNValue()

template<class Element >
Element & TMatrixTBase< Element >::NaNValue ( )
static

Definition at line 1282 of file TMatrixTBase.cxx.

◆ NonZeros()

template<class Element >
Int_t TMatrixTBase< Element >::NonZeros ( ) const
virtual

Compute the number of elements != 0.0.

Reimplemented in TMatrixTSparse< Element >, and TMatrixTSparse< Double_t >.

Definition at line 758 of file TMatrixTBase.cxx.

◆ Norm1()

template<class Element>
Element TMatrixTBase< Element >::Norm1 ( ) const
inline

Definition at line 176 of file TMatrixTBase.h.

◆ NormByDiag()

template<class Element >
TMatrixTBase< Element > & TMatrixTBase< Element >::NormByDiag ( const TVectorT< Element > &  v,
Option_t option = "D" 
)
virtual

option:

  • "D" : b(i,j) = a(i,j)/sqrt(abs*(v(i)*v(j))) (default)
  • else : b(i,j) = a(i,j)*sqrt(abs*(v(i)*v(j))) (default)

Reimplemented in TMatrixTSparse< Element >.

Definition at line 632 of file TMatrixTBase.cxx.

◆ NormInf()

template<class Element>
Element TMatrixTBase< Element >::NormInf ( ) const
inline

Definition at line 175 of file TMatrixTBase.h.

◆ operator!=()

template<class Element >
Bool_t TMatrixTBase< Element >::operator!= ( Element  val) const

Are all matrix elements not equal to val?

Definition at line 909 of file TMatrixTBase.cxx.

◆ operator()() [1/2]

template<class Element>
virtual Element TMatrixTBase< Element >::operator() ( Int_t  rown,
Int_t  coln 
) const
pure virtual

◆ operator()() [2/2]

template<class Element>
virtual Element& TMatrixTBase< Element >::operator() ( Int_t  rown,
Int_t  coln 
)
pure virtual

◆ operator<()

template<class Element >
Bool_t TMatrixTBase< Element >::operator< ( Element  val) const

Are all matrix elements < val?

Definition at line 929 of file TMatrixTBase.cxx.

◆ operator<=()

template<class Element >
Bool_t TMatrixTBase< Element >::operator<= ( Element  val) const

Are all matrix elements <= val?

Definition at line 946 of file TMatrixTBase.cxx.

◆ operator==()

template<class Element >
Bool_t TMatrixTBase< Element >::operator== ( Element  val) const

Are all matrix elements equal to val?

Definition at line 889 of file TMatrixTBase.cxx.

◆ operator>()

template<class Element >
Bool_t TMatrixTBase< Element >::operator> ( Element  val) const

Are all matrix elements > val?

Definition at line 963 of file TMatrixTBase.cxx.

◆ operator>=()

template<class Element >
Bool_t TMatrixTBase< Element >::operator>= ( Element  val) const

Are all matrix elements >= val?

Definition at line 980 of file TMatrixTBase.cxx.

◆ Print()

template<class Element >
void TMatrixTBase< Element >::Print ( Option_t option = "") const
virtual

Print the matrix as a table of elements.

By default the format "%11.4g" is used to print one element. One can specify an alternative format with eg option ="f= %6.2f "

Reimplemented from TObject.

Definition at line 832 of file TMatrixTBase.cxx.

◆ Randomize()

template<class Element >
TMatrixTBase< Element > & TMatrixTBase< Element >::Randomize ( Element  alpha,
Element  beta,
Double_t seed 
)
virtual

Randomize matrix element values.

Reimplemented in TMatrixTSparse< Element >, and TMatrixTSym< Element >.

Definition at line 1032 of file TMatrixTBase.cxx.

◆ ResizeTo() [1/2]

template<class Element>
virtual TMatrixTBase<Element>& TMatrixTBase< Element >::ResizeTo ( Int_t  nrows,
Int_t  ncols,
Int_t  nr_nonzeros = -1 
)
pure virtual

◆ ResizeTo() [2/2]

template<class Element>
virtual TMatrixTBase<Element>& TMatrixTBase< Element >::ResizeTo ( Int_t  row_lwb,
Int_t  row_upb,
Int_t  col_lwb,
Int_t  col_upb,
Int_t  nr_nonzeros = -1 
)
pure virtual

◆ RowNorm()

template<class Element >
Element TMatrixTBase< Element >::RowNorm ( ) const
virtual

Row matrix norm, MAX{ SUM{ |M(i,j)|, over j}, over i}.

The norm is induced by the infinity vector norm.

Reimplemented in TMatrixTSparse< Element >, and TMatrixTSparse< Double_t >.

Definition at line 686 of file TMatrixTBase.cxx.

◆ SetColIndexArray()

template<class Element>
virtual TMatrixTBase<Element>& TMatrixTBase< Element >::SetColIndexArray ( Int_t data)
pure virtual

◆ SetMatrixArray()

template<class Element >
TMatrixTBase< Element > & TMatrixTBase< Element >::SetMatrixArray ( const Element *  data,
Option_t option = "" 
)
virtual

Copy array data to matrix .

It is assumed that array is of size >= fNelems (=)))) fNrows*fNcols option indicates how the data is stored in the array: option =

  • 'F' : column major (Fortran) m[i][j] = array[i+j*fNrows]
  • else : row major (C) m[i][j] = array[i*fNcols+j] (default)

Reimplemented in TMatrixTSym< Element >, and TMatrixTSparse< Element >.

Definition at line 384 of file TMatrixTBase.cxx.

◆ SetRowIndexArray()

template<class Element>
virtual TMatrixTBase<Element>& TMatrixTBase< Element >::SetRowIndexArray ( Int_t data)
pure virtual

◆ SetSub()

template<class Element>
virtual TMatrixTBase<Element>& TMatrixTBase< Element >::SetSub ( Int_t  row_lwb,
Int_t  col_lwb,
const TMatrixTBase< Element > &  source 
)
pure virtual

◆ SetTol()

template<class Element >
Element TMatrixTBase< Element >::SetTol ( Element  tol)
inline

Definition at line 218 of file TMatrixTBase.h.

◆ Shift()

template<class Element >
TMatrixTBase< Element > & TMatrixTBase< Element >::Shift ( Int_t  row_shift,
Int_t  col_shift 
)
virtual

Shift the row index by adding row_shift and the column index by adding col_shift, respectively.

So [rowLwb..rowUpb][colLwb..colUpb] becomes [rowLwb+row_shift..rowUpb+row_shift][colLwb+col_shift..colUpb+col_shift]

Reimplemented in TMatrixTSym< Element >, and TMatrixTSym< Double_t >.

Definition at line 535 of file TMatrixTBase.cxx.

◆ Sqr()

template<class Element >
TMatrixTBase< Element > & TMatrixTBase< Element >::Sqr ( )
virtual

Square each element of the matrix.

Definition at line 577 of file TMatrixTBase.cxx.

◆ Sqrt()

template<class Element >
TMatrixTBase< Element > & TMatrixTBase< Element >::Sqrt ( )
virtual

Take square root of all elements.

Definition at line 595 of file TMatrixTBase.cxx.

◆ Sum()

template<class Element >
Element TMatrixTBase< Element >::Sum ( ) const
virtual

Compute sum of elements.

Definition at line 775 of file TMatrixTBase.cxx.

◆ UnitMatrix()

template<class Element >
TMatrixTBase< Element > & TMatrixTBase< Element >::UnitMatrix ( )
virtual

Make a unit matrix (matrix need not be a square one).

Reimplemented in TMatrixTSparse< Element >, and TMatrixTSparse< Double_t >.

Definition at line 613 of file TMatrixTBase.cxx.

◆ Zero()

template<class Element >
TMatrixTBase< Element > & TMatrixTBase< Element >::Zero ( )
virtual

Set matrix elements to zero.

Reimplemented in TMatrixTSparse< Element >, and TMatrixTSparse< Double_t >.

Definition at line 547 of file TMatrixTBase.cxx.

Member Data Documentation

◆ fColLwb

template<class Element>
Int_t TMatrixTBase< Element >::fColLwb
protected

Definition at line 92 of file TMatrixTBase.h.

◆ fIsOwner

template<class Element>
Bool_t TMatrixTBase< Element >::fIsOwner
protected

Definition at line 99 of file TMatrixTBase.h.

◆ fNcols

template<class Element>
Int_t TMatrixTBase< Element >::fNcols
protected

Definition at line 90 of file TMatrixTBase.h.

◆ fNelems

template<class Element>
Int_t TMatrixTBase< Element >::fNelems
protected

Definition at line 93 of file TMatrixTBase.h.

◆ fNrowIndex

template<class Element>
Int_t TMatrixTBase< Element >::fNrowIndex
protected

Definition at line 94 of file TMatrixTBase.h.

◆ fNrows

template<class Element>
Int_t TMatrixTBase< Element >::fNrows
protected

Definition at line 89 of file TMatrixTBase.h.

◆ fRowLwb

template<class Element>
Int_t TMatrixTBase< Element >::fRowLwb
protected

Definition at line 91 of file TMatrixTBase.h.

◆ fTol

template<class Element>
Element TMatrixTBase< Element >::fTol
protected

Definition at line 96 of file TMatrixTBase.h.


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