Changeset 2730 for trunk/src/Locator.h


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/Locator.h

    r2727 r2730  
    2121class Locator {
    2222public:
    23   Locator() {;}
    24   Locator(double *v, unsigned int n);
    25   void set(double *v, unsigned int n);
     23  // Default constructor.
     24  Locator();
     25 
     26  // Construct with data.
     27  // @param[in] v pointer to input data.
     28  // @param[in] n length of the data.
     29  // @param[in] copystorage whether allocate internal memory or not.
     30  // @see set()
     31  Locator(double *v, unsigned int n, bool copystorage=true);
    2632
     33  // Set data. The data must be sorted in either ascending or descending
     34  // order, and must not have any duplicate elements.
     35  // @param[in] v pointer to input data.
     36  // @param[in] n length of the data.
     37  // @param[in] copystorage whether allocate internal memory or not.
     38  //
     39  // Setting copystorage=false is bit faster since it directly points
     40  // to the input array instead to allocate memory and copy input array.
     41  // However, you have to be careful to set copystorage to false since
     42  // it will take a risk to allow to edit the data to be searched from
     43  // outside the class.
     44  void set(double *v, unsigned int n, bool copystorage=true);
     45
     46  // Destructor.
    2747  virtual ~Locator();
    2848
    29   // return right hand side index of location
    30   // (return j+1 if x[j] < x <= x[j+1])
    31   // return value 0 or x.nelements() indicates out of range
     49  // Return right hand side index of location.
     50  // @param[in] x input value to be located.
     51  // @return location as an index j.
     52  //
     53  // Returned index j satisfies x_[j-1] < x <= x_[j] for ascending
     54  // case while x_[j-1] > x >= x_[j] for descending case.
     55  // Returned value 0 or x.nelements() indicates out of range.
    3256  virtual unsigned int locate(double x) = 0;
    3357
    3458protected:
     59  // Bisection search.
     60  // @param[in] x input value to be located.
     61  // @param[in] left the leftmost index to search.
     62  // @param[in] right the rightmost index to search.
     63  unsigned int bisection(double x, unsigned int left, unsigned int right);
     64 
     65  // Hunt algorithm
     66  // @param[in] x input value to be located.
     67  // @param[in,out] left input: the starting point for hunt.
     68  //                     output: the left index of hunted region.
     69  // @param[out] right the right index of hunted region.
     70  void hunt(double x, unsigned int &left, unsigned int &right);
     71
     72  // Pointer to the data.
    3573  double *x_;
     74
     75  // Length of the data.
    3676  unsigned int n_;
     77
     78  // Is data ascending or descending?
     79  bool ascending_;
     80
     81  // Is internal storage allocated?
     82  bool copy_;
    3783};
    3884
Note: See TracChangeset for help on using the changeset viewer.