Warning, file /include/root/TMatrixTBase.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TMatrixTBase
0013 #define ROOT_TMatrixTBase
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 #include "TError.h"
0069 #include "TObject.h"
0070 #include "TMathBase.h"
0071 #include "TMatrixFBasefwd.h"
0072 #include "TMatrixDBasefwd.h"
0073 #include "TVectorFfwd.h"
0074 #include "TVectorDfwd.h"
0075
0076 #include <limits>
0077
0078 template<class Element> class TVectorT;
0079 template<class Element> class TElementActionT;
0080 template<class Element> class TElementPosActionT;
0081
0082 R__EXTERN Int_t gMatrixCheck;
0083
0084 template<class Element> class TMatrixTBase : public TObject {
0085
0086 private:
0087 Element *GetElements();
0088
0089 protected:
0090 Int_t fNrows;
0091 Int_t fNcols;
0092 Int_t fRowLwb;
0093 Int_t fColLwb;
0094 Int_t fNelems;
0095 Int_t fNrowIndex;
0096
0097 Element fTol;
0098
0099
0100 Bool_t fIsOwner;
0101
0102 static void DoubleLexSort (Int_t n,Int_t *first,Int_t *second,Element *data);
0103 static void IndexedLexSort(Int_t n,Int_t *first,Int_t swapFirst,
0104 Int_t *second,Int_t swapSecond,Int_t *index);
0105
0106 enum {kSizeMax = 25};
0107 enum {kWorkMax = 100};
0108
0109 enum EMatrixStatusBits {
0110 kStatus = BIT(14)
0111 };
0112
0113 public:
0114
0115 TMatrixTBase():
0116 fNrows(0), fNcols(0), fRowLwb(0), fColLwb(0), fNelems(0), fNrowIndex(0),
0117 fTol(0), fIsOwner(kTRUE) { }
0118
0119 ~TMatrixTBase() override {}
0120
0121 inline Int_t GetRowLwb () const { return fRowLwb; }
0122 inline Int_t GetRowUpb () const { return fNrows+fRowLwb-1; }
0123 inline Int_t GetNrows () const { return fNrows; }
0124 inline Int_t GetColLwb () const { return fColLwb; }
0125 inline Int_t GetColUpb () const { return fNcols+fColLwb-1; }
0126 inline Int_t GetNcols () const { return fNcols; }
0127 inline Int_t GetNoElements () const { return fNelems; }
0128 inline Element GetTol () const { return fTol; }
0129
0130 virtual const Element *GetMatrixArray () const = 0;
0131 virtual Element *GetMatrixArray () = 0;
0132 virtual const Int_t *GetRowIndexArray() const = 0;
0133 virtual Int_t *GetRowIndexArray() = 0;
0134 virtual const Int_t *GetColIndexArray() const = 0;
0135 virtual Int_t *GetColIndexArray() = 0;
0136
0137 virtual TMatrixTBase<Element> &SetRowIndexArray(Int_t *data) = 0;
0138 virtual TMatrixTBase<Element> &SetColIndexArray(Int_t *data) = 0;
0139 virtual TMatrixTBase<Element> &SetMatrixArray (const Element *data,Option_t *option="");
0140 inline Element SetTol (Element tol);
0141
0142 void Clear (Option_t *option="") override = 0;
0143
0144 inline void Invalidate () { SetBit(kStatus); }
0145 inline void MakeValid () { ResetBit(kStatus); }
0146 inline Bool_t IsValid () const { return !TestBit(kStatus); }
0147 inline Bool_t IsOwner () const { return fIsOwner; }
0148 virtual Bool_t IsSymmetric() const;
0149
0150 virtual TMatrixTBase<Element> &GetSub(Int_t row_lwb,Int_t row_upb,Int_t col_lwb,Int_t col_upb,
0151 TMatrixTBase<Element> &target,Option_t *option="S") const = 0;
0152 virtual TMatrixTBase<Element> &SetSub(Int_t row_lwb,Int_t col_lwb,const TMatrixTBase<Element> &source) = 0;
0153
0154 virtual void GetMatrix2Array(Element *data,Option_t *option="") const;
0155 virtual TMatrixTBase<Element> &InsertRow (Int_t row,Int_t col,const Element *v,Int_t n = -1);
0156 virtual void ExtractRow (Int_t row,Int_t col, Element *v,Int_t n = -1) const;
0157
0158 virtual TMatrixTBase<Element> &Shift (Int_t row_shift,Int_t col_shift);
0159 virtual TMatrixTBase<Element> &ResizeTo (Int_t nrows,Int_t ncols,Int_t nr_nonzeros=-1) = 0;
0160 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;
0161
0162 virtual Double_t Determinant() const { AbstractMethod("Determinant()"); return 0.; }
0163 virtual void Determinant(Double_t &d1,Double_t &d2) const { AbstractMethod("Determinant()"); d1 = 0.; d2 = 0.; }
0164
0165 virtual TMatrixTBase<Element> &Zero ();
0166 virtual TMatrixTBase<Element> &Abs ();
0167 virtual TMatrixTBase<Element> &Sqr ();
0168 virtual TMatrixTBase<Element> &Sqrt ();
0169 virtual TMatrixTBase<Element> &UnitMatrix ();
0170
0171 virtual TMatrixTBase<Element> &NormByDiag (const TVectorT<Element> &v,Option_t *option="D");
0172
0173 virtual Element RowNorm () const;
0174 virtual Element ColNorm () const;
0175 virtual Element E2Norm () const;
0176 inline Element NormInf () const { return RowNorm(); }
0177 inline Element Norm1 () const { return ColNorm(); }
0178 virtual Int_t NonZeros () const;
0179 virtual Element Sum () const;
0180 virtual Element Min () const;
0181 virtual Element Max () const;
0182
0183 void Draw (Option_t *option="") override;
0184 void Print(Option_t *name ="") const override;
0185
0186 virtual Element operator()(Int_t rown,Int_t coln) const = 0;
0187 virtual Element &operator()(Int_t rown,Int_t coln) = 0;
0188
0189 Bool_t operator==(Element val) const;
0190 Bool_t operator!=(Element val) const;
0191 Bool_t operator< (Element val) const;
0192 Bool_t operator<=(Element val) const;
0193 Bool_t operator> (Element val) const;
0194 Bool_t operator>=(Element val) const;
0195
0196 virtual TMatrixTBase<Element> &Apply(const TElementActionT<Element> &action);
0197 virtual TMatrixTBase<Element> &Apply(const TElementPosActionT<Element> &action);
0198
0199 virtual TMatrixTBase<Element> &Randomize(Element alpha,Element beta,Double_t &seed);
0200
0201
0202 static Element & NaNValue();
0203
0204 ClassDefOverride(TMatrixTBase,5)
0205 };
0206
0207 #ifndef __CLING__
0208
0209
0210
0211
0212
0213
0214
0215 template <> TClass *TMatrixTBase<double>::Class();
0216 #endif
0217
0218
0219 template<class Element> Element TMatrixTBase<Element>::SetTol(Element newTol)
0220 {
0221 const Element oldTol = fTol;
0222 if (newTol >= 0.0)
0223 fTol = newTol;
0224 return oldTol;
0225 }
0226
0227 inline namespace TMatrixTAutoloadOps {
0228
0229 template<class Element> Bool_t operator== (const TMatrixTBase<Element> &m1,const TMatrixTBase<Element> &m2);
0230 template<class Element> Element E2Norm (const TMatrixTBase<Element> &m1,const TMatrixTBase<Element> &m2);
0231 template<class Element1,class Element2>
0232 Bool_t AreCompatible(const TMatrixTBase<Element1> &m1,const TMatrixTBase<Element2> &m2,Int_t verbose=0);
0233 template<class Element> void Compare (const TMatrixTBase<Element> &m1,const TMatrixTBase<Element> &m2);
0234
0235
0236
0237
0238 template<class Element> Bool_t VerifyMatrixValue (const TMatrixTBase<Element> &m,Element val,
0239 Int_t verbose,Element maxDevAllow);
0240 template<class Element> Bool_t VerifyMatrixValue (const TMatrixTBase<Element> &m,Element val,Int_t verbose)
0241 { return VerifyMatrixValue(m,val,verbose,Element(0.)); }
0242 template<class Element> Bool_t VerifyMatrixValue (const TMatrixTBase<Element> &m,Element val)
0243 { return VerifyMatrixValue(m,val,1,Element(0.)); }
0244 template<class Element> Bool_t VerifyMatrixIdentity(const TMatrixTBase<Element> &m1,const TMatrixTBase<Element> &m2,
0245 Int_t verbose,Element maxDevAllow);
0246 template<class Element> Bool_t VerifyMatrixIdentity(const TMatrixTBase<Element> &m1,const TMatrixTBase<Element> &m2,Int_t verbose)
0247 { return VerifyMatrixIdentity(m1,m2,verbose,Element(0.)); }
0248 template<class Element> Bool_t VerifyMatrixIdentity(const TMatrixTBase<Element> &m1,const TMatrixTBase<Element> &m2)
0249 { return VerifyMatrixIdentity(m1,m2,1,Element(0.)); }
0250
0251 }
0252 #endif