Changeset 8524 for trunk/MagicSoft/Mars/mextralgo
- Timestamp:
- 05/17/07 12:19:59 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.h
r8522 r8524 119 119 inline void EvalDerivEq0(const Int_t i, Float_t &rc1, Float_t &rc2) const 120 120 { 121 /* --- ORIGINAL CODE --- 121 122 Double_t sumder = fDer2[i]+fDer2[i+1]; 122 123 Double_t difder = fDer2[i]-fDer2[i+1]; … … 125 126 Double_t sqt2 = difder*(fVal[i+1]-fVal[i]); 126 127 Double_t sqt3 = sqrt(3*sqt1 + 3*sqt2); 127 Double_t denom = 3*(fDer2[i+1]-fDer2[i]);128 Double_t denom = -3*(fDer2[i+1]-fDer2[i]); 128 129 129 130 rc1 = -(3*fDer2[i] + sqt3)/denom; 130 131 rc2 = -(3*fDer2[i] - sqt3)/denom; 132 */ 133 134 Double_t sumder = fDer2[i]+fDer2[i+1]; 135 Double_t difder = fDer2[i]-fDer2[i+1]; 136 137 Double_t sqt1 = sumder*sumder - fDer2[i]*fDer2[i+1]; 138 Double_t sqt2 = difder*(fVal[i+1]-fVal[i]); 139 Double_t sqt3 = sqt1+sqt2<0 ? 0 : sqrt((sqt1 + sqt2)/3); 140 141 rc1 = -(fDer2[i] + sqt3)/difder; 142 rc2 = -(fDer2[i] - sqt3)/difder; 131 143 } 132 144 … … 134 146 inline Double_t EvalPrimitive(Int_t i, Float_t x) const 135 147 { 136 /* TO BE CHECKED! 148 Align(i, x); 149 137 150 if (x==0) 138 return 0;151 return -fDer2[i]/4; 139 152 140 153 if (x==1) 141 return (fVal[i+1]+fVal[i])/2 - fDer2[i+1]/4; 142 */ 143 Align(i, x); 154 return (fVal[i+1] + fVal[i])/2 - fDer2[i+1]/4 - fDer2[i]/2; 144 155 145 156 const Double_t x2 = x*x; … … 149 160 150 161 return x2*fVal[i+1]/2 + (x4/2-x2)*fDer2[i+1]/2 + (x-x2/2)*fVal[i] + (x2/2-x-x14/4)*fDer2[i]; 162 151 163 } 152 164 … … 167 179 // Calculate the intgeral of the Eval-function in 168 180 // bin i from a=[0;1[ to b=[0;1[ 169 inline Double_t EvalInteg(Int_t i, Float_t a =0, Float_t b=1) const181 inline Double_t EvalInteg(Int_t i, Float_t a, Float_t b) const 170 182 { 171 183 return EvalPrimitive(i, b)-EvalPrimitive(i, a); 184 } 185 186 // Identical to EvalInteg(i, 0, 1) but much faster 187 // Be carefull: NO RANGECHECK! 188 inline Double_t EvalInteg(Int_t i) const 189 { 190 return (fVal[i+1] + fVal[i])/2 - (fDer2[i+1] + fDer2[i])/4; 191 } 192 193 // Identical to sum EvalInteg(i, 0, 1) for i=0 to i<b but much faster 194 // Be carefull: NO RANGECHECK! 195 inline Double_t EvalInteg(Int_t a, Int_t b) const 196 { 197 /* 198 Double_t sum = 0; 199 for (int i=a; i<b; i++) 200 sum += EvalInteg(i); 201 202 return sum; 203 */ 204 Double_t sum=0; 205 for (const Float_t *ptr=fDer2+a+1; ptr<fDer2+b; ptr++) 206 sum -= *ptr; 207 208 sum -= (fDer2[a]+fDer2[b])/2; 209 210 sum /= 2; 211 212 for (const Float_t *ptr=fVal+a+1; ptr<fVal+b; ptr++) 213 sum += *ptr; 214 215 sum += (fVal[a]+fVal[b])/2; 216 217 return sum; 172 218 } 173 219 … … 175 221 inline Double_t EvalInteg(Float_t x0, Float_t x1) const 176 222 { 223 // RANGE CHECK MISSING! 224 177 225 const Int_t min = TMath::CeilNint(x0); 178 226 const Int_t max = TMath::FloorNint(x1); … … 183 231 184 232 // Sum complete intervals 185 Double_t sum = 0; 186 for (int i=min; i<max; i++) 187 sum += EvalInteg(i); 233 Double_t sum = EvalInteg(min, max); 188 234 189 235 // Sum the incomplete intervals at the beginning and end
Note:
See TracChangeset
for help on using the changeset viewer.