// @(#)root/hist:$Id$
// Author: Christian Holm Christensen    1/8/2000

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TPrincipal
#define ROOT_TPrincipal

#ifndef ROOT_TNamed
#include "TNamed.h"
#endif
#ifndef ROOT_TVectorD
#include "TVectorD.h"
#endif
#ifndef ROOT_TMatrixD
#include "TMatrixD.h"
#endif
#ifndef ROOT_TList
#include "TList.h"
#endif

class TPrincipal : public TNamed {

protected:
   Int_t       fNumberOfDataPoints;   // Number of data points
   Int_t       fNumberOfVariables;    // Number of variables

   TVectorD    fMeanValues;           // Mean value over all data points
   TVectorD    fSigmas;               // vector of sigmas
   TMatrixD    fCovarianceMatrix;     // Covariance matrix

   TMatrixD    fEigenVectors;         // Eigenvector matrix of trans
   TVectorD    fEigenValues;          // Eigenvalue vector of trans

   TVectorD    fOffDiagonal;          // elements of the tridiagonal

   TVectorD    fUserData;             // Vector of original data points

   Double_t    fTrace;                // Trace of covarience matrix

   TList      *fHistograms;           // List of histograms

   Bool_t      fIsNormalised;         // Normalize matrix?
   Bool_t      fStoreData;            // Should we store input data?

   TPrincipal(const TPrincipal&);
   TPrincipal& operator=(const TPrincipal&);

   void        MakeNormalised();
   void        MakeRealCode(const char *filename, const char *prefix, Option_t *option="");

public:
   TPrincipal();
   virtual ~TPrincipal();
   TPrincipal(Int_t nVariables, Option_t *opt="ND");

   virtual void       AddRow(const Double_t *x);
   virtual void       Browse(TBrowser *b);
   virtual void       Clear(Option_t *option="");
   const TMatrixD    *GetCovarianceMatrix() const {return &fCovarianceMatrix;}
   const TVectorD    *GetEigenValues() const      {return &fEigenValues;}
   const TMatrixD    *GetEigenVectors() const     {return &fEigenVectors;}
   TList             *GetHistograms() const {return fHistograms;}
   const TVectorD    *GetMeanValues() const       {return &fMeanValues;}
   const Double_t    *GetRow(Int_t row);
   const TVectorD    *GetSigmas() const           {return &fSigmas;}
   const TVectorD    *GetUserData() const         {return &fUserData;}
   Bool_t             IsFolder() const { return kTRUE;}
   virtual void       MakeCode(const char *filename ="pca", Option_t *option="");  // *MENU*
   virtual void       MakeHistograms(const char *name = "pca", Option_t *option="epsdx"); // *MENU*
   virtual void       MakeMethods(const char *classname = "PCA", Option_t *option=""); // *MENU*
   virtual void       MakePrincipals();            // *MENU*
   virtual void       P2X(const Double_t *p, Double_t *x, Int_t nTest);
   virtual void       Print(Option_t *opt="MSE") const;         // *MENU*
   virtual void       SumOfSquareResiduals(const Double_t *x, Double_t *s);
   void               Test(Option_t *option="");       // *MENU*
   virtual void       X2P(const Double_t *x, Double_t *p);

   ClassDef(TPrincipal,2) // Principal Components Analysis
}
;

#endif
 TPrincipal.h:1
 TPrincipal.h:2
 TPrincipal.h:3
 TPrincipal.h:4
 TPrincipal.h:5
 TPrincipal.h:6
 TPrincipal.h:7
 TPrincipal.h:8
 TPrincipal.h:9
 TPrincipal.h:10
 TPrincipal.h:11
 TPrincipal.h:12
 TPrincipal.h:13
 TPrincipal.h:14
 TPrincipal.h:15
 TPrincipal.h:16
 TPrincipal.h:17
 TPrincipal.h:18
 TPrincipal.h:19
 TPrincipal.h:20
 TPrincipal.h:21
 TPrincipal.h:22
 TPrincipal.h:23
 TPrincipal.h:24
 TPrincipal.h:25
 TPrincipal.h:26
 TPrincipal.h:27
 TPrincipal.h:28
 TPrincipal.h:29
 TPrincipal.h:30
 TPrincipal.h:31
 TPrincipal.h:32
 TPrincipal.h:33
 TPrincipal.h:34
 TPrincipal.h:35
 TPrincipal.h:36
 TPrincipal.h:37
 TPrincipal.h:38
 TPrincipal.h:39
 TPrincipal.h:40
 TPrincipal.h:41
 TPrincipal.h:42
 TPrincipal.h:43
 TPrincipal.h:44
 TPrincipal.h:45
 TPrincipal.h:46
 TPrincipal.h:47
 TPrincipal.h:48
 TPrincipal.h:49
 TPrincipal.h:50
 TPrincipal.h:51
 TPrincipal.h:52
 TPrincipal.h:53
 TPrincipal.h:54
 TPrincipal.h:55
 TPrincipal.h:56
 TPrincipal.h:57
 TPrincipal.h:58
 TPrincipal.h:59
 TPrincipal.h:60
 TPrincipal.h:61
 TPrincipal.h:62
 TPrincipal.h:63
 TPrincipal.h:64
 TPrincipal.h:65
 TPrincipal.h:66
 TPrincipal.h:67
 TPrincipal.h:68
 TPrincipal.h:69
 TPrincipal.h:70
 TPrincipal.h:71
 TPrincipal.h:72
 TPrincipal.h:73
 TPrincipal.h:74
 TPrincipal.h:75
 TPrincipal.h:76
 TPrincipal.h:77
 TPrincipal.h:78
 TPrincipal.h:79
 TPrincipal.h:80
 TPrincipal.h:81
 TPrincipal.h:82
 TPrincipal.h:83
 TPrincipal.h:84
 TPrincipal.h:85
 TPrincipal.h:86
 TPrincipal.h:87
 TPrincipal.h:88
 TPrincipal.h:89