Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:38

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_TDecompQRH
0013 #define ROOT_TDecompQRH
0014 
0015 ///////////////////////////////////////////////////////////////////////////
0016 //                                                                       //
0017 // QR Decomposition class                                                //
0018 //                                                                       //
0019 ///////////////////////////////////////////////////////////////////////////
0020 
0021 #include "TDecompBase.h"
0022 
0023 #include "Rtypes.h"
0024 
0025 class TDecompQRH : public TDecompBase
0026 {
0027 protected :
0028 
0029    //  A = fQ fR H (m x n) matrix
0030    TMatrixD fQ;  // (m x n) - orthogonal matrix
0031    TMatrixD fR;  // (n x n) - upper triangular matrix
0032    TVectorD fUp; // (n) - vector with Householder up's
0033    TVectorD fW;  // (n) - vector with Householder beta's
0034 
0035    static Bool_t QRH(TMatrixD &q,TVectorD &diagR,TVectorD &up,TVectorD &w,Double_t tol);
0036 
0037    const TMatrixDBase &GetDecompMatrix() const override { return fR; }
0038 
0039 public :
0040 
0041    enum {kWorkMax = 100}; // size of work array
0042 
0043    TDecompQRH() {}
0044    TDecompQRH(Int_t nrows,Int_t ncols);
0045    TDecompQRH(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb);
0046    TDecompQRH(const TMatrixD &m,Double_t tol = 0.0); // be careful for slicing in operator=
0047    TDecompQRH(const TDecompQRH &another);
0048    ~TDecompQRH() override {}
0049 
0050          Int_t     GetNrows () const override { return fQ.GetNrows(); }
0051          Int_t     GetNcols () const override { return fQ.GetNcols(); }
0052    virtual const TMatrixD &GetQ     ()       { if ( !TestBit(kDecomposed) ) Decompose();
0053                                                return fQ; }
0054    virtual const TMatrixD &GetR     ()       { if ( !TestBit(kDecomposed) ) Decompose();
0055                                                return fR; }
0056    virtual const TVectorD &GetUp    ()       { if ( !TestBit(kDecomposed) ) Decompose();
0057                                                return fUp; }
0058    virtual const TVectorD &GetW     ()       { if ( !TestBit(kDecomposed) ) Decompose();
0059                                                return fW; }
0060 
0061    TMatrixD GetOrthogonalMatrix() const;
0062    const TMatrixD &GetTriangularMatrix() const { return fR; }
0063 
0064    virtual       void      SetMatrix(const TMatrixD &a);
0065 
0066    Bool_t   Decompose  () override;
0067    Bool_t   Solve      (      TVectorD &b) override;
0068    TVectorD Solve      (const TVectorD& b,Bool_t &ok) override { TVectorD x = b; ok = Solve(x); return x; }
0069    Bool_t   Solve      (      TMatrixDColumn &b) override;
0070    Bool_t   TransSolve (      TVectorD &b) override;
0071    TVectorD TransSolve (const TVectorD& b,Bool_t &ok) override { TVectorD x = b; ok = TransSolve(x); return x; }
0072    Bool_t   TransSolve (      TMatrixDColumn &b) override;
0073    void     Det        (Double_t &d1,Double_t &d2) override;
0074 
0075            Bool_t   Invert     (TMatrixD &inv);
0076            TMatrixD Invert     (Bool_t &status);
0077            TMatrixD Invert     () { Bool_t status; return Invert(status); }
0078 
0079    void Print(Option_t *opt ="") const override; // *MENU*
0080 
0081    TDecompQRH &operator= (const TDecompQRH &source);
0082 
0083    ClassDefOverride(TDecompQRH,1) // Matrix Decompositition QRH
0084 };
0085 
0086 #endif