Ignore:
Timestamp:
01/16/13 16:00:28 (11 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-4770

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Rewrite implementations for locator and interpolator.
Documentation (doxygen format) is added to header files.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/BufferedBisectionLocator.cpp

    r2727 r2730  
    1515
    1616namespace asap {
     17BufferedBisectionLocator::BufferedBisectionLocator()
     18  : Locator(),
     19    prev_(0)
     20{}
    1721
    18 BufferedBisectionLocator::BufferedBisectionLocator(double *v, unsigned int n)
    19   : Locator(v, n),
     22BufferedBisectionLocator::BufferedBisectionLocator(double *v, unsigned int n,
     23                                                   bool copystorage)
     24  : Locator(v, n, copystorage),
    2025    prev_(0)
    2126{}
     
    2833  if (n_ == 1)
    2934    return 0;
    30   bool ascending = (x_[n_-1] >= x_[0]);
    31   if (ascending) {
     35
     36  unsigned int jl = 0;
     37  unsigned int ju = n_;
     38  if (ascending_) {
     39    // ascending order
    3240    if (x <= x_[0])
    3341      return 0;
     
    3543      return n_;
    3644
    37     unsigned int jl = 0;
    38     unsigned int ju = n_;
    39     unsigned int jm;
     45    if (x < x_[prev_]) {
     46      ju = bisection(x, jl, prev_);
     47    }
     48    else {
     49      ju = bisection(x, prev_, ju);
     50    }
    4051
    41     if (x < x_[prev_]) {
    42       ju = prev_;
    43       prev_ = 0;
    44     }
    45     else
    46       jl = prev_;
    47 
    48     while (ju - jl > 1) {
    49       jm = (ju + jl) >> 1;
    50       if (x > x_[jm])
    51         jl = jm;
    52       else
    53         ju = jm;
    54     }
    55     prev_ = jl;
    56     return ju;
    5752  }
    5853  else {
     54    // descending order
    5955    if (x >= x_[0])
    6056      return 0;
     
    6258      return n_;
    6359
    64     unsigned int jl = 0;
    65     unsigned int ju = n_;
    66     unsigned int jm;
     60    if (x > x_[prev_]) {
     61      ju = bisection(x, jl, prev_);
     62    }
     63    else {
     64      ju = bisection(x, prev_, ju);
     65    }
     66  }
    6767
    68     if (x > x_[prev_]) {
    69       ju = prev_;
    70       prev_ = 0;
    71     }
    72     else
    73       jl = prev_;
    74 
    75     while (ju - jl > 1) {
    76       jm = (ju + jl) >> 1;
    77       if (x < x_[jm])
    78         jl = jm;
    79       else
    80         ju = jm;
    81     }
    82     prev_ = jl;
    83     return ju;
    84   }
     68  prev_ = (ju > 0) ? ju - 1 : 0;
     69  return ju;   
    8570}
    8671
Note: See TracChangeset for help on using the changeset viewer.