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/HuntLocator.cpp

    r2727 r2730  
    1616namespace asap {
    1717
    18 HuntLocator::HuntLocator(double *v, unsigned int n)
    19   : Locator(v, n),
     18HuntLocator::HuntLocator()
     19  : Locator(),
     20    prev_(0)
     21{}
     22
     23HuntLocator::HuntLocator(double *v, unsigned int n, 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  if (ascending_) {
    3237    if (x <= x_[0])
    3338      return 0;
     
    4449  unsigned int jl = 0;
    4550  unsigned int ju = n_;
     51
     52  // hunt phase
    4653  if (prev_ > 0 && prev_ < n_) {
    47     // do hunt
    4854    jl = prev_;
    49     unsigned int inc = 1;
    50     if ((x >= x_[jl]) == ascending) {
    51       // hunt up
    52       if (jl >= n_ - 1)
    53         return jl;
    54       ju = jl + inc;
    55       while ((x >= x_[ju]) == ascending) {
    56         jl = ju;
    57         inc <<= 1;
    58         ju = jl + inc;
    59         if (ju > n_ - 1) {
    60           ju = n_;
    61           break;
    62         }
    63       }
    64     }
    65     else {
    66       // hunt down
    67       if (jl == 0)
    68         return jl;
    69       ju = jl;
    70       jl -= inc;
    71       while ((x < x_[jl]) == ascending) {
    72         ju = jl;
    73         inc <<= 1;
    74         if (inc >= ju) {
    75           jl = 0;
    76           break;
    77         }
    78         else
    79           jl = ju - inc;
    80       }
    81     }
     55    hunt(x, jl, ju);
    8256  }
    8357
    8458  // final bisection phase
    85   unsigned int jm;
    86   if (ascending) {
    87     while (ju - jl > 1) {
    88       jm = (ju + jl) >> 1;
    89       if (x > x_[jm])
    90         jl = jm;
    91       else
    92         ju = jm;
    93     }
    94   }
    95   else {
    96     while (ju - jl > 1) {
    97       jm = (ju + jl) >> 1;
    98       if (x < x_[jm])
    99         jl = jm;
    100       else
    101         ju = jm;
    102     }
    103   }
    104   prev_ = jl;
    105   return ju;
     59  unsigned int j = bisection(x, jl, ju);
     60  prev_ = (j > 0) ? j - 1 : 0;
     61  return j;
    10662}
    10763
Note: See TracChangeset for help on using the changeset viewer.