Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TDecompBase.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/matrix:$Id$
0002 // Authors: Fons Rademakers, Eddy Offermann   Dec 2003
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TDecompBase
0013 #define ROOT_TDecompBase
0014 
0015 ///////////////////////////////////////////////////////////////////////////
0016 //                                                                       //
0017 // Decomposition Base class                                              //
0018 //                                                                       //
0019 // This class forms the base for all the decompositions methods in the   //
0020 // linear algebra package .                                              //
0021 //                                                                       //
0022 ///////////////////////////////////////////////////////////////////////////
0023 
0024 #include "Rtypes.h"
0025 
0026 #include "TMatrixD.h"
0027 #include "TMatrixDUtils.h"
0028 #include "TObject.h"
0029 #include "TVectorD.h"
0030 
0031 #include <limits>
0032 
0033 class TDecompBase : public TObject
0034 {
0035 protected :
0036    Double_t fTol;       // sqrt(epsilon); epsilon is smallest number number so that  1+epsilon > 1
0037    Double_t fDet1;      // determinant mantissa
0038    Double_t fDet2;      // determinant exponent for powers of 2
0039    Double_t fCondition; // matrix condition number
0040    Int_t    fRowLwb;    // Row    lower bound of decomposed matrix
0041    Int_t    fColLwb;    // Column lower bound of decomposed matrix
0042 
0043    void          ResetStatus() { for (Int_t i = 14; i < 22; i++) ResetBit(BIT(i)); }
0044    Int_t         Hager      (Double_t& est,Int_t iter=5);
0045    static  void  DiagProd   (const TVectorD &diag,Double_t tol,Double_t &d1,Double_t &d2);
0046 
0047    virtual const TMatrixDBase &GetDecompMatrix() const = 0;
0048 
0049    enum EMatrixDecompStat {
0050       kInit       = BIT(14),
0051       kPatternSet = BIT(15),
0052       kValuesSet  = BIT(16),
0053       kMatrixSet  = BIT(17),
0054       kDecomposed = BIT(18),
0055       kDetermined = BIT(19),
0056       kCondition  = BIT(20),
0057       kSingular   = BIT(21)
0058    };
0059 
0060    enum {kWorkMax = 100}; // size of work array's in several routines
0061 
0062 public :
0063    TDecompBase();
0064    TDecompBase(const TDecompBase &another);
0065    ~TDecompBase() override {};
0066 
0067    inline  Double_t GetTol       () const { return fTol; }
0068    inline  Double_t GetDet1      () const { return fDet1; }
0069    inline  Double_t GetDet2      () const { return fDet2; }
0070    inline  Double_t GetCondition () const { return fCondition; }
0071    virtual Int_t    GetNrows     () const = 0;
0072    virtual Int_t    GetNcols     () const = 0;
0073    Int_t            GetRowLwb    () const { return fRowLwb; }
0074    Int_t            GetColLwb    () const { return fColLwb; }
0075    inline Double_t  SetTol       (Double_t tol);
0076 
0077    virtual Double_t Condition  ();
0078    virtual void     Det        (Double_t &d1,Double_t &d2);
0079    virtual Bool_t   Decompose  ()                             = 0;
0080    virtual Bool_t   Solve      (      TVectorD &b)            = 0;
0081    virtual TVectorD Solve      (const TVectorD& b,Bool_t &ok) = 0;
0082    virtual Bool_t   Solve      (      TMatrixDColumn& b)      = 0;
0083    virtual Bool_t   TransSolve (      TVectorD &b)            = 0;
0084    virtual TVectorD TransSolve (const TVectorD &b,Bool_t &ok) = 0;
0085    virtual Bool_t   TransSolve (      TMatrixDColumn& b)      = 0;
0086 
0087    virtual Bool_t   MultiSolve (TMatrixD &B);
0088 
0089    void Print(Option_t *opt="") const override;
0090 
0091    TDecompBase &operator= (const TDecompBase &source);
0092 
0093    ClassDefOverride(TDecompBase,2) // Matrix Decomposition Base
0094 };
0095 
0096 Double_t TDecompBase::SetTol(Double_t newTol)
0097 {
0098    const Double_t oldTol = fTol;
0099    if (newTol >= 0.0)
0100       fTol = newTol;
0101    return oldTol;
0102 }
0103 
0104 Bool_t DefHouseHolder  (const TVectorD &vc,Int_t     lp,Int_t     l,Double_t &up,Double_t &b,Double_t tol=0.0);
0105 void   ApplyHouseHolder(const TVectorD &vc,Double_t  up,Double_t  b,Int_t     lp,Int_t     l,TMatrixDRow &cr);
0106 void   ApplyHouseHolder(const TVectorD &vc,Double_t  up,Double_t  b,Int_t     lp,Int_t     l,TMatrixDColumn &cc);
0107 void   ApplyHouseHolder(const TVectorD &vc,Double_t  up,Double_t  b,Int_t     lp,Int_t     l,TVectorD &cv);
0108 void   DefGivens       (      Double_t  v1,Double_t  v2,Double_t &c,Double_t &s);
0109 void   DefAplGivens    (      Double_t &v1,Double_t &v2,Double_t &c,Double_t &s);
0110 void   ApplyGivens     (      Double_t &z1,Double_t &z2,Double_t  c,Double_t  s);
0111 
0112 #endif