// -*- mode: c++ -*-
// 
// File pca.C generated by TPrincipal::MakeCode
// on Tue Dec 16 12:46:45 2008
// ROOT version 5.21/07
//
// This file contains the functions 
//
//    void  X2P(Double_t *x, Double_t *p); 
//    void  P2X(Double_t *p, Double_t *x, Int_t nTest);
//
// The first for transforming original data x in 
// pattern space, to principal components p in 
// feature space. The second function is for the
// inverse transformation, but using only nTest
// of the principal components in the expansion
// 
// See TPrincipal class documentation for more information 
// 
#ifndef __CINT__
#include <Rtypes.h> // needed for Double_t etc
#endif

//
// Static data variables
//
static Int_t    gNVariables = 10;

// Assignment of eigenvector matrix.
// Elements are stored row-wise, that is
//    M[i][j] = e[i * nVariables + j] 
// where i and j are zero-based
static Double_t gEigenVectors[] = {
  0.105952,
  -0.0412338,
  -0.163932,
  0.506955,
  -0.293327,
  -0.45912,
  0.611921,
  0.0417098,
  0.124369,
  -0.121286,
  0.299103,
  0.114816,
  -0.423035,
  0.173049,
  0.129852,
  -0.264772,
  -0.58561,
  0.118711,
  0.35397,
  -0.345193,
  0.196631,
  0.182178,
  0.334538,
  0.0979602,
  -0.695575,
  0.431875,
  -0.124202,
  0.0811669,
  0.242022,
  -0.236021,
  0.0946521,
  0.0513485,
  0.107011,
  0.552681,
  0.561861,
  0.539862,
  0.180077,
  0.041718,
  0.124394,
  -0.121309,
  0.294184,
  0.179444,
  0.157981,
  -0.594249,
  0.257622,
  -0.0673251,
  0.421439,
  0.117814,
  0.351295,
  -0.342585,
  0.135669,
  -0.895902,
  -0.0723783,
  -0.0912176,
  -0.0511243,
  0.155245,
  0.0072091,
  -0.0686794,
  0.36119,
  0.0587528,
  0.0393664,
  -0.129504,
  0.791462,
  0.188712,
  0.167449,
  -0.456201,
  -0.235961,
  -0.142627,
  0.0747034,
  -0.0435387,
  0.501306,
  -0.134663,
  0.0961035,
  0.0147716,
  0.015782,
  -0.0347285,
  -0.0292305,
  0.724996,
  -0.379729,
  0.221314,
  0.503961,
  -0.111486,
  -0.060855,
  -0.0228244,
  -0.0175214,
  0.0561781,
  0.0175518,
  -0.534241,
  -0.552628,
  -0.367135,
  0.4898,
  0.259068,
  -0.0353844,
  0.0139158,
  0.00266293,
  -0.00485772,
  0.0160046,
  -0.354777,
  0.275952,
  0.69945};

// Assignment to eigen value vector. Zero-based.
static Double_t gEigenValues[] = {
  0.385122,
  0.110703,
  0.103572,
  0.101548,
  0.100795,
  0.0996221,
  0.0986388,
  5.97928e-16,
  2.52544e-16,
  5.65803e-16
};

// Assignment to mean value vector. Zero-based.
static Double_t gMeanValues[] = {
  5.0082,
  7.9976,
  1.96735,
  5.0162,
  8.0087,
  2.01253,
  4.99247,
  35.0031,
  30.0106,
  27.9981
};

// Assignment to sigma value vector. Zero-based.
static Double_t gSigmaValues[] = {
  1.00507,
  2.86056,
  1.95587,
  1.00527,
  2.83895,
  1.97263,
  1.01426,
  5.15563,
  5.04925,
  4.64883
};

// 
// The function   void X2P(Double_t *x, Double_t *p)
// 
void X2P(Double_t *x, Double_t *p) {
  for (Int_t i = 0; i < gNVariables; i++) {
    p[i] = 0;
    for (Int_t j = 0; j < gNVariables; j++)
      p[i] += (x[j] - gMeanValues[j]) 
        * gEigenVectors[j *  gNVariables + i] / gSigmaValues[j];

  }
}

// 
// The function   void P2X(Double_t *p, Double_t *x, Int_t nTest)
// 
void P2X(Double_t *p, Double_t *x, Int_t nTest) {
  for (Int_t i = 0; i < gNVariables; i++) {
    x[i] = gMeanValues[i];
    for (Int_t j = 0; j < nTest; j++)
      x[i] += p[j] * gSigmaValues[i] 
        * gEigenVectors[i *  gNVariables + j];
  }
}

// EOF for pca.C

Last change: Wed Dec 17 10:56:16 2008
Last generated: 2008-12-17 10:56

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.