Last change
on this file since 2747 was 2733, checked in by Takeshi Nakazato, 12 years ago |
New Development: No
JIRA Issue: Yes CAS-4770
Ready for Test: Yes
Interface Changes: Yes/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...
Redefined Interpolator1D and derived classes as template class.
|
File size:
870 bytes
|
Line | |
---|
1 | //
|
---|
2 | // C++ Implementation: NearestInterpolator1D
|
---|
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 "NearestInterpolator1D.h"
|
---|
15 |
|
---|
16 | using namespace casa;
|
---|
17 |
|
---|
18 | namespace asap {
|
---|
19 |
|
---|
20 | template <class T, class U>
|
---|
21 | NearestInterpolator1D<T, U>::NearestInterpolator1D()
|
---|
22 | : Interpolator1D<T, U>()
|
---|
23 | {}
|
---|
24 |
|
---|
25 | template <class T, class U>
|
---|
26 | NearestInterpolator1D<T, U>::~NearestInterpolator1D()
|
---|
27 | {}
|
---|
28 |
|
---|
29 | template <class T, class U> U NearestInterpolator1D<T, U>::interpolate(T x)
|
---|
30 | {
|
---|
31 | assert(this->isready());
|
---|
32 | if (this->n_ == 1)
|
---|
33 | return this->y_[0];
|
---|
34 |
|
---|
35 | unsigned int i = this->locator_->locate(x);
|
---|
36 | if (i == 0) {
|
---|
37 | return this->y_[i];
|
---|
38 | }
|
---|
39 | else if (i == this->n_ || abs(x - this->x_[i]) > abs(x - this->x_[i-1])) {
|
---|
40 | i--;
|
---|
41 | }
|
---|
42 | return this->y_[i];
|
---|
43 | }
|
---|
44 |
|
---|
45 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.