#include <NCSpectrumInterpolator.h>
Inheritance diagram for NC::SpectrumInterpolatorSimple:

Protected Member Functions | |
| virtual TMatrixD | FindCoeffs (const std::vector< std::vector< double > > &xs, const std::vector< double > &x) const |
| Do the bulk of the work. | |
|
||||||||||||
|
Do the bulk of the work.
Implements NC::ISpectrumInterpolator. Definition at line 421 of file NCSpectrumInterpolator.cxx. 00422 {
00423 // const unsigned int D = x.size(); // dimensionality of the space
00424
00425 // Ideally these should match, but the case where the reference
00426 // points are in more dimensions than the input should still work.
00427 assert(xs[0].size() <= x.size());
00428 const unsigned int D = TMath::Min(x.size(), xs[0].size());
00429
00430 const unsigned int N = xs.size(); // number of input points
00431
00432 TMatrixD ret(1, N);
00433
00434 for(unsigned int n = 0; n < N; ++n){ // for every point
00435 double weight = 1;
00436 for(unsigned int d = 0; d < D; ++d){ // for every dimension
00437 const bool ltOneSigma = x[d] > -1 && x[d] < +1;
00438
00439 if(ltOneSigma){
00440 const double dist = fabs(xs[n][d]-x[d]);
00441 if(dist > 1)
00442 weight = 0;
00443 else
00444 weight *= (1-dist);
00445 }
00446 else{
00447 const bool sign = xs[n][d]/x[d] >= 0; // right sign
00448
00449 if(sign){
00450 if(fabs(xs[n][d]) < 1)
00451 weight *= 1-fabs(x[d]);
00452 else
00453 weight *= fabs(x[d]);
00454 }
00455 else weight = 0;
00456 }
00457 } // end for d
00458 ret(0, n) = weight;
00459 } // end for n
00460
00461 // cout << x << " -> " << ret << endl;
00462
00463 double norm = 0;
00464 for(unsigned int n = 0; n < N; ++n) norm += ret(0, n);
00465 assert(fabs(norm - 1) < 1e-3);
00466
00467
00468 return ret;
00469 }
|
1.3.9.1