00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <iostream>
00028 #include <iomanip>
00029
00030 #ifndef ROOT_TMVA_PDEFoamVect
00031 #include "TMVA/PDEFoamVect.h"
00032 #endif
00033
00034 using namespace std;
00035
00036
00037
00038 ClassImp(TMVA::PDEFoamVect)
00039
00040
00041 TMVA::PDEFoamVect::PDEFoamVect()
00042 : TObject(),
00043 fDim(0),
00044 fCoords(0)
00045 {
00046
00047 }
00048
00049
00050 TMVA::PDEFoamVect::PDEFoamVect(Int_t n)
00051 : TObject(),
00052 fDim(n),
00053 fCoords(0)
00054 {
00055
00056
00057
00058 if (n>0) {
00059 fCoords = new Double_t[fDim];
00060 for (Int_t i=0; i<n; i++) *(fCoords+i)=0.0;
00061 }
00062 }
00063
00064
00065 TMVA::PDEFoamVect::PDEFoamVect(const PDEFoamVect &vect)
00066 : TObject(),
00067 fDim(vect.fDim),
00068 fCoords(vect.fCoords)
00069 {
00070
00071 Error( "PDEFoamVect", "COPY CONSTRUCTOR NOT IMPLEMENTED" );
00072 }
00073
00074
00075 TMVA::PDEFoamVect::~PDEFoamVect()
00076 {
00077
00078 delete [] fCoords;
00079 fCoords=0;
00080 }
00081
00082
00083
00084
00085
00086
00087 TMVA::PDEFoamVect& TMVA::PDEFoamVect::operator =(const PDEFoamVect& Vect)
00088 {
00089
00090
00091 if (&Vect == this) return *this;
00092 if( fDim != Vect.fDim )
00093 Error( "PDEFoamVect","operator=Dims. are different: %d and %d \n ",fDim,Vect.fDim);
00094 if( fDim != Vect.fDim ) {
00095 delete [] fCoords;
00096 fCoords = new Double_t[fDim];
00097 }
00098 fDim=Vect.fDim;
00099 for(Int_t i=0; i<fDim; i++)
00100 fCoords[i] = Vect.fCoords[i];
00101 return *this;
00102 }
00103
00104
00105 Double_t &TMVA::PDEFoamVect::operator[](Int_t n)
00106 {
00107
00108
00109
00110
00111
00112 if ((n<0) || (n>=fDim)) {
00113 Error( "PDEFoamVect","operator[], out of range \n");
00114 }
00115 return fCoords[n];
00116 }
00117
00118
00119 TMVA::PDEFoamVect& TMVA::PDEFoamVect::operator*=(const Double_t &x)
00120 {
00121
00122
00123 for(Int_t i=0;i<fDim;i++)
00124 fCoords[i] = fCoords[i]*x;
00125 return *this;
00126 }
00127
00128
00129 TMVA::PDEFoamVect& TMVA::PDEFoamVect::operator+=(const PDEFoamVect& Shift)
00130 {
00131
00132 if( fDim != Shift.fDim){
00133 Error( "PDEFoamVect","operator+, different dimensions= %d %d \n",fDim,Shift.fDim);
00134 }
00135 for(Int_t i=0;i<fDim;i++)
00136 fCoords[i] = fCoords[i]+Shift.fCoords[i];
00137 return *this;
00138 }
00139
00140
00141 TMVA::PDEFoamVect& TMVA::PDEFoamVect::operator-=(const PDEFoamVect& Shift)
00142 {
00143
00144 if( fDim != Shift.fDim) {
00145 Error( "PDEFoamVect","operator+, different dimensions= %d %d \n",fDim,Shift.fDim);
00146 }
00147 for(Int_t i=0;i<fDim;i++)
00148 fCoords[i] = fCoords[i]-Shift.fCoords[i];
00149 return *this;
00150 }
00151
00152
00153 TMVA::PDEFoamVect TMVA::PDEFoamVect::operator+(const PDEFoamVect &p2)
00154 {
00155
00156
00157 PDEFoamVect temp(fDim);
00158 temp = (*this);
00159 temp += p2;
00160 return temp;
00161 }
00162
00163
00164 TMVA::PDEFoamVect TMVA::PDEFoamVect::operator-(const PDEFoamVect &p2)
00165 {
00166
00167
00168 PDEFoamVect temp(fDim);
00169 temp = (*this);
00170 temp -= p2;
00171 return temp;
00172 }
00173
00174
00175 TMVA::PDEFoamVect& TMVA::PDEFoamVect::operator =(Double_t Vect[])
00176 {
00177
00178 for(Int_t i=0; i<fDim; i++)
00179 fCoords[i] = Vect[i];
00180 return *this;
00181 }
00182
00183
00184 TMVA::PDEFoamVect& TMVA::PDEFoamVect::operator =(Double_t x)
00185 {
00186
00187 if(fCoords != 0) {
00188 for(Int_t i=0; i<fDim; i++)
00189 fCoords[i] = x;
00190 }
00191 return *this;
00192 }
00193
00194
00195
00196
00197
00198
00199 void TMVA::PDEFoamVect::Print(Option_t *option) const
00200 {
00201 streamsize wid = cout.width();
00202
00203 if(!option) Error( "Print ", "No option set \n");
00204 cout << "(";
00205 for(Int_t i=0; i<fDim-1; i++)
00206 cout << std::setw(12) << *(fCoords+i) << ",";
00207 cout << std::setw(12) << *(fCoords+fDim-1);
00208 cout << ")";
00209 cout.width(wid);
00210 }