////////////////////////////////////////////////////////////////////////// // // // TError // // // // Error matrix class // // // // Author: Marcel Kunze, RUB, Nov. 99 // // Copyright (C) 1999-2001, Ruhr-University Bochum. // // // ////////////////////////////////////////////////////////////////////////// #include #include //#include #include "RhoMath/TError.h" ClassImp(TError) #include using namespace std; const Double_t TError::chisqUndef = -1.; TError::TError(Int_t n, Double_t init) { TMatrixD::Allocate(n,n); for (int i1=0;i1>(std::istream& in, TError& mat) { // Peek at the next non-space character: char nextChar = ' '; while (isspace(nextChar)){ nextChar = in.get(); } in.putback(nextChar); if (EOF != nextChar){ if (!isdigit(nextChar)){ // Remove the "Bbr Covariance Matrix:" line: const int DUMMY_SIZE = 1000; char dummy[DUMMY_SIZE]; in.getline(dummy, DUMMY_SIZE); } // Read in the matrix: for (int row = 1; row <= mat.GetNrows(); ++row){ for (int col = 1; col <= mat.GetNcols(); ++col){ in >> mat(row, col); } } } return in; } TError& operator*(Double_t t, const TError& m1) { static TError mret(m1); mret.ResizeTo(m1); mret = m1; mret *= t; return mret; } TError& operator*(const TError& m1, Double_t t) { static TError mret(m1); mret.ResizeTo(m1); mret = m1; mret *= t; return mret; } /* TError operator/(Double_t t, const TError& m1) { TError mret = m1; mret /= t; return mret; } TError operator/(const TError& m1, Double_t t) { TError mret = m1; mret /= t; return mret; } */ TError& operator+(const TError& m1, const TError& m2) { static TError mret(m1); mret.ResizeTo(m1); mret = m1; mret += m2; return mret; } TError& operator-(const TError& m1, const TError& m2) { static TError mret(m1); mret.ResizeTo(m1); mret -= m2; return mret; } Double_t TError::Similarity(TVectorD &m1) { register Double_t mret = 0.0; TVectorD temp(m1); temp*=(*this); // If m1*(*this) has correct dimensions, then so will the m1.T multiplication. // So there is no need to check dimensions again. Double_t *a=&temp(0); Double_t *b=&m1(0); Double_t *e=a+m1.GetNrows(); for(;a