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:
1007 bytes
|
Line | |
---|
1 | //
|
---|
2 | // C++ Implementation: HuntLocator
|
---|
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 "HuntLocator.h"
|
---|
15 |
|
---|
16 | namespace asap {
|
---|
17 |
|
---|
18 | HuntLocator::HuntLocator()
|
---|
19 | : Locator(),
|
---|
20 | prev_(0)
|
---|
21 | {}
|
---|
22 |
|
---|
23 | HuntLocator::HuntLocator(double *v, unsigned int n, bool copystorage)
|
---|
24 | : Locator(v, n, copystorage),
|
---|
25 | prev_(0)
|
---|
26 | {}
|
---|
27 |
|
---|
28 | HuntLocator::~HuntLocator()
|
---|
29 | {}
|
---|
30 |
|
---|
31 | unsigned int HuntLocator::locate(double x)
|
---|
32 | {
|
---|
33 | if (n_ == 1)
|
---|
34 | return 0;
|
---|
35 |
|
---|
36 | if (ascending_) {
|
---|
37 | if (x <= x_[0])
|
---|
38 | return 0;
|
---|
39 | else if (x > x_[n_-1])
|
---|
40 | return n_;
|
---|
41 | }
|
---|
42 | else {
|
---|
43 | if (x > x_[0])
|
---|
44 | return 0;
|
---|
45 | else if (x <= x_[n_-1])
|
---|
46 | return n_;
|
---|
47 | }
|
---|
48 |
|
---|
49 | unsigned int jl = 0;
|
---|
50 | unsigned int ju = n_;
|
---|
51 |
|
---|
52 | // hunt phase
|
---|
53 | if (prev_ > 0 && prev_ < n_) {
|
---|
54 | jl = prev_;
|
---|
55 | hunt(x, jl, ju);
|
---|
56 | }
|
---|
57 |
|
---|
58 | // final bisection phase
|
---|
59 | unsigned int j = bisection(x, jl, ju);
|
---|
60 | prev_ = (j > 0) ? j - 1 : 0;
|
---|
61 | return j;
|
---|
62 | }
|
---|
63 |
|
---|
64 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.