// Author: Krzysztof Danielowski, Kamil Kraszewski, Maciej Kruk, Jan Therhaag 

/**********************************************************************************
 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
 * Package: TMVA                                                                  *
 * Class  : MethodLD                                                              *
 * Web    : http://tmva.sourceforge.net                                           *
 *                                                                                *
 * Description:                                                                   *
 *      Linear Discriminant (Simple Linear Regression)                            *
 *                                                                                *
 * Authors (alphabetical):                                                        *
 *      Krzysztof Danielowski <danielow@cern.ch> - IFJ PAN & AGH, Poland          *
 *      Kamil Kraszewski      <kalq@cern.ch>     - IFJ PAN & UJ, Poland           *
 *      Maciej Kruk           <mkruk@cern.ch>    - IFJ PAN & AGH, Poland          *
 *      Peter Speckmayer      <peter.speckmayer@cern.ch>  - CERN, Switzerland     *
 *      Jan Therhaag          <therhaag@physik.uni-bonn.de> - Uni Bonn, Germany   *
 *                                                                                *
 * Copyright (c) 2008-2011:                                                       *
 *      CERN, Switzerland                                                         * 
 *      PAN, Poland                                                               * 
 *      U. of Bonn, Germany                                                       *
 *                                                                                *
 * Redistribution and use in source and binary forms, with or without             *
 * modification, are permitted according to the terms listed in LICENSE           *
 * (http://tmva.sourceforge.net/LICENSE)                                          *
 *                                                                                *
 **********************************************************************************/

#ifndef ROOT_TMVA_MethodLD
#define ROOT_TMVA_MethodLD

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// MethodLD                                                             //
//                                                                      //
// Linear Discriminant                                                  //
// Can compute multidimensional output for regression                   //
// (although it computes every dimension separately)                    //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include <vector>

#ifndef ROOT_TMVA_MethodBase
#include "TMVA/MethodBase.h"
#endif
#ifndef ROOT_TMatrixDfwd
#include "TMatrixDfwd.h"
#endif

namespace TMVA {

   class MethodLD : public MethodBase {

   public:
   
      // constructor
      MethodLD( const TString& jobName, 
                const TString& methodTitle, 
                DataSetInfo& dsi,
                const TString& theOption = "LD",
                TDirectory* theTargetDir = 0 );
      
      // constructor
      MethodLD( DataSetInfo& dsi, 
                const TString& theWeightFile, 
                TDirectory* theTargetDir = 0 );

      // destructor
      virtual ~MethodLD( void );

      Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
    
      // training method
      void Train( void );

      // calculate the MVA value
      Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );

      // calculate the Regression value
      virtual const std::vector<Float_t>& GetRegressionValues();

      using MethodBase::ReadWeightsFromStream;   

      void AddWeightsXMLTo      ( void* parent ) const;

      void ReadWeightsFromStream( std::istream & i );
      void ReadWeightsFromXML   ( void* wghtnode );

      const Ranking* CreateRanking();
      void DeclareOptions();
      void ProcessOptions();

   protected:

      void MakeClassSpecific( std::ostream&, const TString& ) const;
      void GetHelpMessage() const;

   private:

      Int_t fNRegOut; // size of the output
 
      TMatrixD *fSumMatx;              // Sum of coordinates product matrix 
      TMatrixD *fSumValMatx;           // Sum of values multiplied by coordinates
      TMatrixD *fCoeffMatx;            // Matrix of coefficients
      std::vector< std::vector<Double_t>* > *fLDCoeff; // LD coefficients

      // default initialisation called by all constructors
      void Init( void );

      // Initialization and allocation of matrices
      void InitMatrices( void );

      // Compute fSumMatx
      void GetSum( void );

      // Compute fSumValMatx
      void GetSumVal( void );

      // get LD coefficients
      void GetLDCoeff( void );
      
      // nice output
      void PrintCoefficients( void );

      ClassDef(MethodLD,0) //Linear discriminant analysis
         };
} // namespace TMVA

#endif // MethodLD_H
 MethodLD.h:1
 MethodLD.h:2
 MethodLD.h:3
 MethodLD.h:4
 MethodLD.h:5
 MethodLD.h:6
 MethodLD.h:7
 MethodLD.h:8
 MethodLD.h:9
 MethodLD.h:10
 MethodLD.h:11
 MethodLD.h:12
 MethodLD.h:13
 MethodLD.h:14
 MethodLD.h:15
 MethodLD.h:16
 MethodLD.h:17
 MethodLD.h:18
 MethodLD.h:19
 MethodLD.h:20
 MethodLD.h:21
 MethodLD.h:22
 MethodLD.h:23
 MethodLD.h:24
 MethodLD.h:25
 MethodLD.h:26
 MethodLD.h:27
 MethodLD.h:28
 MethodLD.h:29
 MethodLD.h:30
 MethodLD.h:31
 MethodLD.h:32
 MethodLD.h:33
 MethodLD.h:34
 MethodLD.h:35
 MethodLD.h:36
 MethodLD.h:37
 MethodLD.h:38
 MethodLD.h:39
 MethodLD.h:40
 MethodLD.h:41
 MethodLD.h:42
 MethodLD.h:43
 MethodLD.h:44
 MethodLD.h:45
 MethodLD.h:46
 MethodLD.h:47
 MethodLD.h:48
 MethodLD.h:49
 MethodLD.h:50
 MethodLD.h:51
 MethodLD.h:52
 MethodLD.h:53
 MethodLD.h:54
 MethodLD.h:55
 MethodLD.h:56
 MethodLD.h:57
 MethodLD.h:58
 MethodLD.h:59
 MethodLD.h:60
 MethodLD.h:61
 MethodLD.h:62
 MethodLD.h:63
 MethodLD.h:64
 MethodLD.h:65
 MethodLD.h:66
 MethodLD.h:67
 MethodLD.h:68
 MethodLD.h:69
 MethodLD.h:70
 MethodLD.h:71
 MethodLD.h:72
 MethodLD.h:73
 MethodLD.h:74
 MethodLD.h:75
 MethodLD.h:76
 MethodLD.h:77
 MethodLD.h:78
 MethodLD.h:79
 MethodLD.h:80
 MethodLD.h:81
 MethodLD.h:82
 MethodLD.h:83
 MethodLD.h:84
 MethodLD.h:85
 MethodLD.h:86
 MethodLD.h:87
 MethodLD.h:88
 MethodLD.h:89
 MethodLD.h:90
 MethodLD.h:91
 MethodLD.h:92
 MethodLD.h:93
 MethodLD.h:94
 MethodLD.h:95
 MethodLD.h:96
 MethodLD.h:97
 MethodLD.h:98
 MethodLD.h:99
 MethodLD.h:100
 MethodLD.h:101
 MethodLD.h:102
 MethodLD.h:103
 MethodLD.h:104
 MethodLD.h:105
 MethodLD.h:106
 MethodLD.h:107
 MethodLD.h:108
 MethodLD.h:109
 MethodLD.h:110
 MethodLD.h:111
 MethodLD.h:112
 MethodLD.h:113
 MethodLD.h:114
 MethodLD.h:115
 MethodLD.h:116
 MethodLD.h:117
 MethodLD.h:118
 MethodLD.h:119
 MethodLD.h:120
 MethodLD.h:121
 MethodLD.h:122
 MethodLD.h:123
 MethodLD.h:124
 MethodLD.h:125
 MethodLD.h:126
 MethodLD.h:127
 MethodLD.h:128
 MethodLD.h:129
 MethodLD.h:130
 MethodLD.h:131