Last change
on this file since 2730 was
2730,
checked in by Takeshi Nakazato, 11 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.4 KB
|
Line | |
---|
1 | // |
---|
2 | // C++ Implementation: Interpolator1D |
---|
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 <casa/Arrays/Vector.h> |
---|
15 | #include <casa/Exceptions/Error.h> |
---|
16 | |
---|
17 | #include "Interpolator1D.h" |
---|
18 | #include "BisectionLocator.h" |
---|
19 | #include "HuntLocator.h" |
---|
20 | |
---|
21 | using namespace casa; |
---|
22 | |
---|
23 | namespace asap { |
---|
24 | |
---|
25 | Interpolator1D::Interpolator1D() |
---|
26 | : order_(1), |
---|
27 | n_(0), |
---|
28 | x_(0), |
---|
29 | y_(0), |
---|
30 | locator_(0) |
---|
31 | { |
---|
32 | } |
---|
33 | |
---|
34 | Interpolator1D::~Interpolator1D() |
---|
35 | { |
---|
36 | if (locator_) |
---|
37 | delete locator_; |
---|
38 | } |
---|
39 | |
---|
40 | void Interpolator1D::setData(double *x, float *y, unsigned int n) |
---|
41 | { |
---|
42 | x_ = x; |
---|
43 | y_ = y; |
---|
44 | n_ = n; |
---|
45 | createLocator(); |
---|
46 | locator_->set(x, n); |
---|
47 | } |
---|
48 | |
---|
49 | void Interpolator1D::setX(double *x, unsigned int n) |
---|
50 | { |
---|
51 | assert(n_ == 0 || n_ == n); |
---|
52 | x_ = x; |
---|
53 | n_ = n; |
---|
54 | createLocator(); |
---|
55 | locator_->set(x, n); |
---|
56 | } |
---|
57 | |
---|
58 | void Interpolator1D::setY(float *y, unsigned int n) |
---|
59 | { |
---|
60 | assert(n_ == 0 || n_ == n); |
---|
61 | y_ = y; |
---|
62 | n_ = n; |
---|
63 | } |
---|
64 | |
---|
65 | void Interpolator1D::reset() |
---|
66 | { |
---|
67 | n_ = 0; |
---|
68 | x_ = 0; |
---|
69 | y_ = 0; |
---|
70 | if (locator_) { |
---|
71 | delete locator_; |
---|
72 | locator_ = 0; |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | bool Interpolator1D::isready() |
---|
77 | { |
---|
78 | return (n_ > 0 && x_ != 0 && y_ != 0); |
---|
79 | } |
---|
80 | |
---|
81 | unsigned int Interpolator1D::locate(double x) |
---|
82 | { |
---|
83 | return locator_->locate(x); |
---|
84 | } |
---|
85 | |
---|
86 | void Interpolator1D::createLocator() |
---|
87 | { |
---|
88 | if (!locator_) { |
---|
89 | if (n_ > 1000) |
---|
90 | locator_ = new HuntLocator(); |
---|
91 | else |
---|
92 | locator_ = new BisectionLocator(); |
---|
93 | } |
---|
94 | } |
---|
95 | |
---|
96 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.