Last change
on this file since 2730 was 2730, checked in by Takeshi Nakazato, 12 years ago |
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 size:
1.3 KB
|
Rev | Line | |
---|
[2727] | 1 | //
|
---|
| 2 | // C++ Implementation: BufferedBisectionLocator
|
---|
| 3 | //
|
---|
| 4 | // Description:
|
---|
| 5 | //
|
---|
| 6 | //
|
---|
| 7 | // Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp>, (C) 2012
|
---|
| 8 | //
|
---|
| 9 | // Copyright: See COPYING file that comes with this distribution
|
---|
| 10 | //
|
---|
| 11 | //
|
---|
| 12 | #include <assert.h>
|
---|
| 13 |
|
---|
| 14 | #include "BufferedBisectionLocator.h"
|
---|
| 15 |
|
---|
| 16 | namespace asap {
|
---|
[2730] | 17 | BufferedBisectionLocator::BufferedBisectionLocator()
|
---|
| 18 | : Locator(),
|
---|
| 19 | prev_(0)
|
---|
| 20 | {}
|
---|
[2727] | 21 |
|
---|
[2730] | 22 | BufferedBisectionLocator::BufferedBisectionLocator(double *v, unsigned int n,
|
---|
| 23 | bool copystorage)
|
---|
| 24 | : Locator(v, n, copystorage),
|
---|
[2727] | 25 | prev_(0)
|
---|
| 26 | {}
|
---|
| 27 |
|
---|
| 28 | BufferedBisectionLocator::~BufferedBisectionLocator()
|
---|
| 29 | {}
|
---|
| 30 |
|
---|
| 31 | unsigned int BufferedBisectionLocator::locate(double x)
|
---|
| 32 | {
|
---|
| 33 | if (n_ == 1)
|
---|
| 34 | return 0;
|
---|
[2730] | 35 |
|
---|
| 36 | unsigned int jl = 0;
|
---|
| 37 | unsigned int ju = n_;
|
---|
| 38 | if (ascending_) {
|
---|
| 39 | // ascending order
|
---|
[2727] | 40 | if (x <= x_[0])
|
---|
| 41 | return 0;
|
---|
| 42 | else if (x > x_[n_-1])
|
---|
| 43 | return n_;
|
---|
| 44 |
|
---|
| 45 | if (x < x_[prev_]) {
|
---|
[2730] | 46 | ju = bisection(x, jl, prev_);
|
---|
[2727] | 47 | }
|
---|
[2730] | 48 | else {
|
---|
| 49 | ju = bisection(x, prev_, ju);
|
---|
| 50 | }
|
---|
[2727] | 51 |
|
---|
| 52 | }
|
---|
| 53 | else {
|
---|
[2730] | 54 | // descending order
|
---|
[2727] | 55 | if (x >= x_[0])
|
---|
| 56 | return 0;
|
---|
| 57 | else if (x < x_[n_-1])
|
---|
| 58 | return n_;
|
---|
| 59 |
|
---|
| 60 | if (x > x_[prev_]) {
|
---|
[2730] | 61 | ju = bisection(x, jl, prev_);
|
---|
[2727] | 62 | }
|
---|
[2730] | 63 | else {
|
---|
| 64 | ju = bisection(x, prev_, ju);
|
---|
[2727] | 65 | }
|
---|
| 66 | }
|
---|
[2730] | 67 |
|
---|
| 68 | prev_ = (ju > 0) ? ju - 1 : 0;
|
---|
| 69 | return ju;
|
---|
[2727] | 70 | }
|
---|
| 71 |
|
---|
| 72 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.