5 #include "Rstrstream.h"
11 #if ROOT_VERSION_CODE < 331013
17 #define __VA_LIST__(name) \
19 va_start(args,va_(name)); \
20 for (Int_t num=0; num<fN; num++) { \
21 if (! num) fArray[0] = name; \
22 else fArray[num] = (Double_t) va_arg(args, Double_t); \
31 enum ETRMatrixType {kUndefined, kVector, kRectangular, kSemiPosDefinedSymMatrix, kDiagonalMatrix};
32 enum ETRMatrixCreatorsOp { kZero, kUnit, kTransposed, kInverted, kInvertedPosDef, kInvertedA,
34 kAxB, kAxBT, kATxB, kATxBT,
36 kSxA, kAxS, kSxAT, kATxS,
38 kAxSxAT, kATxSxA, kRxSxR
40 TRArray(Int_t N=0): TArrayD(N), fValid(kTRUE), fIsNotOwn(kFALSE) {}
43 TRArray(Int_t N,Double_t a0, ...);
45 TRArray(Int_t N,
const Double_t *Array): TArrayD(N,Array), fValid(kTRUE), fIsNotOwn(kFALSE) {}
46 TRArray(Int_t N,
const Float_t *Array);
47 TRArray(
const TRArray &A,
const Double_t fA,
TRArray &B,
const Double_t fB): TArrayD(0), fValid(kTRUE), fIsNotOwn(kFALSE) {
48 Int_t N = A.GetSize(); assert (N == B.GetSize()); Set(N);
49 TCL::vlinco(A.GetArray(),fA,B.GetArray(),fB,fArray,N);
51 TRArray(Int_t N,
const Char_t *s);
52 virtual ~
TRArray() {
if (fIsNotOwn) fArray = 0;}
53 virtual Int_t GetNrows()
const {
return GetSize();}
54 virtual Int_t GetNcols()
const {
return 1;}
55 virtual ETRMatrixType GetMatrixType()
const {
return kUndefined;}
56 virtual Bool_t IsValid()
const {
return fValid;}
57 virtual Double_t Mag2()
const;
58 virtual Double_t Mag()
const {
return TMath::Sqrt(Mag2());}
59 virtual void SetValid(Bool_t Valid=kTRUE) {fValid = Valid;}
61 void Set(Int_t n,
const Double_t *array);
62 void Set(Int_t n,
const Float_t *array);
63 void AdoptA(Int_t n, Double_t *arr);
64 void reset() {Reset();}
66 virtual Double_t &operator()(Int_t i) {
return operator[](i);}
67 virtual Double_t operator()(Int_t i)
const {
return operator[](i);}
69 for (
int i=0; i<target.fN; i++) target.fArray[i] -= scalar;
return target;}
71 for (
int i=0; i<target.fN; i++) target.fArray[i] += scalar;
return target;
73 friend Double_t operator*(
const TRArray &target,
const TRArray &source) {
74 assert(target.fN == source.GetSize());
76 const Double_t *sArray = source.GetArray();
77 for (
int i=0; i<target.fN; i++) sum += target.fArray[i]*sArray[i];
return sum;
80 for (
int i=0; i<target.fN; i++) target.fArray[i] *= scalar;
return target;
83 for (
int i=0; i<target.fN; i++) target.fArray[i] /= scalar;
return target;
86 assert(target.fN == A.GetSize());
87 const Double_t *fA = A.GetArray();
88 for (
int i=0; i<target.fN; i++) target.fArray[i] -= fA[i];
92 assert(target.fN == A.GetSize());
93 const Double_t *fA = A.GetArray();
94 for (
int i=0; i<target.fN; i++) target.fArray[i] += fA[i];
98 friend Bool_t operator==(
TRArray &target, Double_t scalar) {
99 for (
int i=0; i<target.fN; i++)
if (target.fArray[i] != scalar)
return kFALSE;
103 if (target.fN != A.GetSize())
return kFALSE;
104 const Double_t *fB = A.GetArray();
105 for (
int i=0; i<target.fN; i++)
if (target.fArray[i] != fB[i])
return kFALSE;
return kTRUE;
110 Bool_t Verify(
const TRArray &A,
const Double_t zeru=5.e-7, Int_t Level=1)
const;
111 virtual void Print(Option_t *opt=
"")
const;
120 std::ostream& operator<<(std::ostream& s,
const TRArray &target);
121 std::istream & operator>>(std::istream &s,
TRArray &target);