library: libMatrix #include "TMatrixD.h"

# TMatrixD

class description - source file - inheritance tree (.pdf)

## class TMatrixD : public TMatrixDBase

| Inheritance Chart:
`TObject`
| <- | `TMatrixDBase`
| <- | `TMatrixD` |

        protected:

          virtual void Allocate(Int_t nrows, Int_t ncols, Int_t row_lwb = 0, Int_t col_lwb = 0, Int_t init = 0, Int_t nr_nonzeros = -1)
                  void AMultB(const TMatrixD& a, const TMatrixD& b, Int_t constr = 1)
                  void AMultB(const TMatrixD& a, const TMatrixDSym& b, Int_t constr = 1)
                  void AMultB(const TMatrixDSym& a, const TMatrixD& b, Int_t constr = 1)
                  void AMultB(const TMatrixDSym& a, const TMatrixDSym& b, Int_t constr = 1)
                  void AMultBt(const TMatrixD& a, const TMatrixD& b, Int_t constr = 1)
                  void AMultBt(const TMatrixD& a, const TMatrixDSym& b, Int_t constr = 1)
                  void AMultBt(const TMatrixDSym& a, const TMatrixD& b, Int_t constr = 1)
                  void AMultBt(const TMatrixDSym& a, const TMatrixDSym& b, Int_t constr = 1)
                  void AtMultB(const TMatrixD& a, const TMatrixD& b, Int_t constr = 1)
                  void AtMultB(const TMatrixD& a, const TMatrixDSym& b, Int_t constr = 1)
                  void AtMultB(const TMatrixDSym& a, const TMatrixD& b, Int_t constr = 1)
                  void AtMultB(const TMatrixDSym& a, const TMatrixDSym& b, Int_t constr = 1)
                  void Delete_m(Int_t size, Double_t*&)
                 Int_t Memcpy_m(Double_t* newp, const Double_t* oldp, Int_t copySize, Int_t newSize, Int_t oldSize)
             Double_t* New_m(Int_t size)

        public:

                                  TMatrixD()
                                  TMatrixD(Int_t nrows, Int_t ncols)
                                  TMatrixD(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb)
                                  TMatrixD(Int_t nrows, Int_t ncols, const Double_t* data, Option_t* option = "")
                                  TMatrixD(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, const Double_t* data, Option_t* option = "")
                                  TMatrixD(const TMatrixD& another)
                                  TMatrixD(const TMatrixF& another)
                                  TMatrixD(const TMatrixDSym& another)
                                  TMatrixD(const TMatrixDSparse& another)
                                  TMatrixD(TMatrixDBase::EMatrixCreatorsOp1 op, const TMatrixD& prototype)
                                  TMatrixD(const TMatrixD& a, TMatrixDBase::EMatrixCreatorsOp2 op, const TMatrixD& b)
                                  TMatrixD(const TMatrixD& a, TMatrixDBase::EMatrixCreatorsOp2 op, const TMatrixDSym& b)
                                  TMatrixD(const TMatrixDSym& a, TMatrixDBase::EMatrixCreatorsOp2 op, const TMatrixD& b)
                                  TMatrixD(const TMatrixDSym& a, TMatrixDBase::EMatrixCreatorsOp2 op, const TMatrixDSym& b)
                                  TMatrixD(const TMatrixDLazy& lazy_constructor)
                         TMatrixD GetSub(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Option_t* option = "S") const
                   const TMatrixD EigenVectors(TVectorD& eigenValues) const
                          virtual ~TMatrixD()
                   static TClass* Class()
                     virtual void Clear(Option_t* = "")
                 virtual Double_t Determinant() const
                     virtual void Determinant(Double_t& d1, Double_t& d2) const
             virtual const Int_t* GetColIndexArray() const
                   virtual Int_t* GetColIndexArray()
          virtual const Double_t* GetMatrixArray() const
                virtual Double_t* GetMatrixArray()
             virtual const Int_t* GetRowIndexArray() const
                   virtual Int_t* GetRowIndexArray()
            virtual TMatrixDBase& GetSub(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, TMatrixDBase& target, Option_t* option = "S") const
                        TMatrixD& Invert(Double_t* det = 0)
                        TMatrixD& InvertFast(Double_t* det = 0)
                  virtual TClass* IsA() const
                             void Mult(const TMatrixD& a, const TMatrixD& b)
                             void Mult(const TMatrixD& a, const TMatrixDSym& b)
                             void Mult(const TMatrixDSym& a, const TMatrixD& b)
                        TMatrixD& NormByColumn(const TVectorD& v, Option_t* option = "D")
                        TMatrixD& NormByRow(const TVectorD& v, Option_t* option = "D")
                 virtual Double_t operator()(Int_t rown, Int_t coln) const
                virtual Double_t& operator()(Int_t rown, Int_t coln)
                        TMatrixD& operator*=(Double_t val)
                        TMatrixD& operator*=(const TMatrixD& source)
                        TMatrixD& operator*=(const TMatrixDSym& source)
                        TMatrixD& operator*=(const TMatrixDDiag_const& diag)
                        TMatrixD& operator*=(const TMatrixDRow_const& row)
                        TMatrixD& operator*=(const TMatrixDColumn_const& col)
                        TMatrixD& operator+=(Double_t val)
                        TMatrixD& operator+=(const TMatrixD& source)
                        TMatrixD& operator+=(const TMatrixDSym& source)
                        TMatrixD& operator-=(Double_t val)
                        TMatrixD& operator-=(const TMatrixD& source)
                        TMatrixD& operator-=(const TMatrixDSym& source)
                        TMatrixD& operator/=(const TMatrixDDiag_const& diag)
                        TMatrixD& operator/=(const TMatrixDRow_const& row)
                        TMatrixD& operator/=(const TMatrixDColumn_const& col)
                        TMatrixD& operator=(const TMatrixD& source)
                        TMatrixD& operator=(const TMatrixF& source)
                        TMatrixD& operator=(const TMatrixDSym& source)
                        TMatrixD& operator=(const TMatrixDSparse& source)
                        TMatrixD& operator=(const TMatrixDLazy& source)
                        TMatrixD& operator=(Double_t val)
          const TMatrixDRow_const operator[](Int_t rown) const
                      TMatrixDRow operator[](Int_t rown)
                        TMatrixD& Rank1Update(const TVectorD& v, Double_t alpha = 1.0)
                        TMatrixD& Rank1Update(const TVectorD& v1, const TVectorD& v2, Double_t alpha = 1.0)
            virtual TMatrixDBase& ResizeTo(Int_t nrows, Int_t ncols, Int_t nr_nonzeros = -1)
            virtual TMatrixDBase& ResizeTo(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Int_t nr_nonzeros = -1)
                    TMatrixDBase& ResizeTo(const TMatrixD& m)
            virtual TMatrixDBase& SetColIndexArray(Int_t*)
            virtual TMatrixDBase& SetRowIndexArray(Int_t*)
            virtual TMatrixDBase& SetSub(Int_t row_lwb, Int_t col_lwb, const TMatrixDBase& source)
                     virtual void ShowMembers(TMemberInspector& insp, char* parent)
                     virtual void Streamer(TBuffer& b)
                             void StreamerNVirtual(TBuffer& b)
                        TMatrixD& T()
                        TMatrixD& Transpose(const TMatrixD& source)
                        TMatrixD& Use(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Double_t* data)
                        TMatrixD& Use(Int_t nrows, Int_t ncols, Double_t* data)
                        TMatrixD& Use(TMatrixD& a)

### Data Members

        protected:

           Double_t fDataStack[25]  ! data container
          Double_t* fElements       [fNelems] elements themselves

## Class Description

     TMatrixD

     Implementation of a general matrix in the linear algebra package

TMatrixD(Int_t no_rows,Int_t no_cols)

TMatrixD(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb)

TMatrixD(Int_t no_rows,Int_t no_cols,const Double_t *elements,Option_t *option)

     option="F": array elements contains the matrix stored column-wise
                 like in Fortran, so a[i,j] = elements[i+no_rows*j],
     else        it is supposed that array elements are stored row-wise
                 a[i,j] = elements[i*no_cols+j]

     array elements are copied

TMatrixD(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb, const Double_t *elements,Option_t *option)

     array elements are copied

TMatrixD(const TMatrixD &another) : TMatrixDBase(another)

TMatrixD(const TMatrixF &another)

TMatrixD(const TMatrixDSym &another)

TMatrixD(const TMatrixDSparse &another)

TMatrixD(EMatrixCreatorsOp1 op,const TMatrixD &prototype)

     Create a matrix applying a specific operation to the prototype.
     Example: TMatrixD a(10,12); ...; TMatrixD b(TMatrixDBase::kTransposed, a);
     Supported operations are: kZero, kUnit, kTransposed, kInverted and kAtA.

TMatrixD(const TMatrixD &a,EMatrixCreatorsOp2 op,const TMatrixD &b)

     Create a matrix applying a specific operation to two prototypes.
     Example: TMatrixD a(10,12), b(12,5); ...; TMatrixD c(a, TMatrixDBase::kMult, b);
     Supported operations are: kMult (a*b), kTransposeMult (a'*b), kInvMult (a^(-1)*b)

TMatrixD(const TMatrixD &a,EMatrixCreatorsOp2 op,const TMatrixDSym &b)

TMatrixD(const TMatrixDSym &a,EMatrixCreatorsOp2 op,const TMatrixD &b)

TMatrixD(const TMatrixDSym &a,EMatrixCreatorsOp2 op,const TMatrixDSym &b)

TMatrixD(const TMatrixDLazy &lazy_constructor)

void Delete_m(Int_t size,Double_t *&m)

     delete data pointer m, if it was assigned on the heap

Double_t* New_m(Int_t size)

     return data pointer . if requested size <= kSizeMax, assign pointer
     to the stack space

Int_t Memcpy_m(Double_t *newp,const Double_t *oldp,Int_t copySize, Int_t newSize,Int_t oldSize)

     copy copySize doubles from *oldp to *newp . However take care of the
     situation where both pointers are assigned to the same stack space

void Allocate(Int_t no_rows,Int_t no_cols,Int_t row_lwb,Int_t col_lwb, Int_t init,Int_t /*nr_nonzeros*/)

     Allocate new matrix. Arguments are number of rows, columns, row
     lowerbound (0 default) and column lowerbound (0 default).

void AMultB(const TMatrixD &a,const TMatrixD &b,Int_t constr)

     General matrix multiplication. Create a matrix C such that C = A * B.
     Note, matrix C is allocated for constr=1.

void AMultB(const TMatrixDSym &a,const TMatrixD &b,Int_t constr)

     Matrix multiplication, with A symmetric and B general.
     Create a matrix C such that C = A * B.
     Note, matrix C is allocated for constr=1.

void AMultB(const TMatrixD &a,const TMatrixDSym &b,Int_t constr)

     Matrix multiplication, with A general and B symmetric.
     Create a matrix C such that C = A * B.
     Note, matrix C is allocated for constr=1.

void AMultB(const TMatrixDSym &a,const TMatrixDSym &b,Int_t constr)

     Matrix multiplication, with A symmetric and B symmetric.
     (Actually copied for the moment routine for B general)
     Create a matrix C such that C = A * B.
     Note, matrix C is allocated for constr=1.

void AtMultB(const TMatrixD &a,const TMatrixD &b,Int_t constr)

     Create a matrix C such that C = A' * B. In other words,
     c[i,j] = SUM{ a[k,i] * b[k,j] }. Note, matrix C is allocated for constr=1.

void AtMultB(const TMatrixD &a,const TMatrixDSym &b,Int_t constr)

     Create a matrix C such that C = A' * B. In other words,
     c[i,j] = SUM{ a[k,i] * b[k,j] }. Note, matrix C is allocated for constr=1.

void AMultBt(const TMatrixD &a,const TMatrixD &b,Int_t constr)

     General matrix multiplication. Create a matrix C such that C = A * B^T.
     Note, matrix C is allocated for constr=1.

void AMultBt(const TMatrixDSym &a,const TMatrixD &b,Int_t constr)

     Matrix multiplication, with A symmetric and B general.
     Create a matrix C such that C = A * B^T.
     Note, matrix C is allocated for constr=1.

TMatrixD& Use(Int_t row_lwb,Int_t row_upb, Int_t col_lwb,Int_t col_upb,Double_t *data)

TMatrixDBase& GetSub(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb, TMatrixDBase &target,Option_t *option) const

     Get submatrix [row_lwb..row_upb][col_lwb..col_upb]; The indexing range of the
     returned matrix depends on the argument option:

     option == "S" : return [0..row_upb-row_lwb+1][0..col_upb-col_lwb+1] (default)
     else          : return [row_lwb..row_upb][col_lwb..col_upb]

TMatrixDBase& SetSub(Int_t row_lwb,Int_t col_lwb,const TMatrixDBase &source)

     Insert matrix source starting at [row_lwb][col_lwb], thereby overwriting the part
     [row_lwb..row_lwb+nrows_source][col_lwb..col_lwb+ncols_source];

TMatrixDBase& ResizeTo(Int_t nrows,Int_t ncols,Int_t /*nr_nonzeros*/)

     Set size of the matrix to nrows x ncols
     New dynamic elements are created, the overlapping part of the old ones are
     copied to the new structures, then the old elements are deleted.

TMatrixDBase& ResizeTo(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb, Int_t /*nr_nonzeros*/)

     Set size of the matrix to [row_lwb:row_upb] x [col_lwb:col_upb]
     New dynamic elemenst are created, the overlapping part of the old ones are
     copied to the new structures, then the old elements are deleted.

Double_t Determinant() const

void Determinant(Double_t &d1,Double_t &d2) const

TMatrixD& Invert(Double_t *det)

     Invert the matrix and calculate its determinant

TMatrixD& InvertFast(Double_t *det)

     Invert the matrix and calculate its determinant

TMatrixD& Transpose(const TMatrixD &source)

     Transpose a matrix.

TMatrixD& Rank1Update(const TVectorD &v,Double_t alpha)

     Perform a rank 1 operation on the matrix:
         A += alpha * v * v^T

TMatrixD& Rank1Update(const TVectorD &v1,const TVectorD &v2,Double_t alpha)

     Perform a rank 1 operation on the matrix:
         A += alpha * v1 * v2^T

TMatrixD& NormByColumn(const TVectorD &v,Option_t *option)

     Multiply/divide matrix columns by a vector:
     option:
     "D"   :  b(i,j) = a(i,j)/v(i)   i = 0,fNrows-1 (default)
     else  :  b(i,j) = a(i,j)*v(i)

TMatrixD& NormByRow(const TVectorD &v,Option_t *option)

     Multiply/divide matrix rows with a vector:
     option:
     "D"   :  b(i,j) = a(i,j)/v(j)   i = 0,fNcols-1 (default)
     else  :  b(i,j) = a(i,j)*v(j)

const TMatrixD EigenVectors(TVectorD &eigenValues) const

     Return a matrix containing the eigen-vectors ordered by descending values
     of Re^2+Im^2 of the complex eigen-values .
     If the matrix is asymmetric, only the real part of the eigen-values is
     returned . For full functionality use TMatrixDEigen .

void Streamer(TBuffer &R__b)

     Stream an object of class TMatrixD.

### Inline Functions

                               void ~TMatrixD()
                               void AtMultB(const TMatrixDSym& a, const TMatrixD& b, Int_t constr = 1)
                               void AtMultB(const TMatrixDSym& a, const TMatrixDSym& b, Int_t constr = 1)
                               void AMultBt(const TMatrixDSym& a, const TMatrixD& b, Int_t constr = 1)
                               void AMultBt(const TMatrixDSym& a, const TMatrixDSym& b, Int_t constr = 1)
                           TMatrixD TMatrixD(const TMatrixDLazy& lazy_constructor)
                    const Double_t* GetMatrixArray() const
                          Double_t* GetMatrixArray()
                       const Int_t* GetRowIndexArray() const
                             Int_t* GetRowIndexArray()
                       const Int_t* GetColIndexArray() const
                             Int_t* GetColIndexArray()
                      TMatrixDBase& SetRowIndexArray(Int_t*)
                      TMatrixDBase& SetColIndexArray(Int_t*)
                               void Clear(Option_t* = "")
                          TMatrixD& Use(Int_t nrows, Int_t ncols, Double_t* data)
                          TMatrixD& Use(TMatrixD& a)
                           TMatrixD GetSub(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Option_t* option = "S") const
                      TMatrixDBase& ResizeTo(const TMatrixD& m)
                          TMatrixD& T()
                               void Mult(const TMatrixD& a, const TMatrixD& b)
                               void Mult(const TMatrixD& a, const TMatrixDSym& b)
                               void Mult(const TMatrixDSym& a, const TMatrixD& b)
                           Double_t operator()(Int_t rown, Int_t coln) const
                          Double_t& operator()(Int_t rown, Int_t coln)
            const TMatrixDRow_const operator[](Int_t rown) const
                        TMatrixDRow operator[](Int_t rown)
                          TMatrixD& operator=(const TMatrixD& source)
                          TMatrixD& operator=(const TMatrixF& source)
                          TMatrixD& operator=(const TMatrixDSym& source)
                          TMatrixD& operator=(const TMatrixDSparse& source)
                          TMatrixD& operator=(const TMatrixDLazy& source)
                          TMatrixD& operator=(Double_t val)
                          TMatrixD& operator-=(Double_t val)
                          TMatrixD& operator+=(Double_t val)
                          TMatrixD& operator*=(Double_t val)
                          TMatrixD& operator+=(const TMatrixD& source)
                          TMatrixD& operator+=(const TMatrixDSym& source)
                          TMatrixD& operator-=(const TMatrixD& source)
                          TMatrixD& operator-=(const TMatrixDSym& source)
                          TMatrixD& operator*=(const TMatrixD& source)
                          TMatrixD& operator*=(const TMatrixDSym& source)
                          TMatrixD& operator*=(const TMatrixDDiag_const& diag)
                          TMatrixD& operator/=(const TMatrixDDiag_const& diag)
                          TMatrixD& operator*=(const TMatrixDRow_const& row)
                          TMatrixD& operator/=(const TMatrixDRow_const& row)
                          TMatrixD& operator*=(const TMatrixDColumn_const& col)
                          TMatrixD& operator/=(const TMatrixDColumn_const& col)
                            TClass* Class()
                            TClass* IsA() const
                               void ShowMembers(TMemberInspector& insp, char* parent)
                               void StreamerNVirtual(TBuffer& b)

Last update: root/matrix:$Name: $:$Id: TMatrixD.cxx,v 1.80 2005/04/05 12:47:11 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *