source: trunk/src/NearestInterpolator1D.cpp@ 2727

Last change on this file since 2727 was 2720, checked in by Takeshi Nakazato, 12 years ago

New Development: Yes

JIRA Issue: Yes CAS-4770 and its sub-tickets

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...

First version of applycal for single dish calibration.
Added new classes for the operation (STApplyCal, Calibrator, PSAlmaCalibrator,
Locator, BisectionLocator, Interpolator1D, NearestInterpolator1D).
Also, modified existing classes to fit with implementation of applycal.


File size: 783 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 <casa/Arrays/Vector.h>
15#include <casa/Exceptions/Error.h>
16
17#include "NearestInterpolator1D.h"
18
19using namespace casa;
20
21namespace asap {
22
23NearestInterpolator1D::NearestInterpolator1D()
24 : Interpolator1D()
25{}
26
27NearestInterpolator1D::~NearestInterpolator1D()
28{}
29
30float NearestInterpolator1D::interpolate(double x)
31{
32 assert(isready());
33 if (n_ == 1)
34 return y_[0];
35
36 unsigned int i = locator_->locate(x);
37 if (i == 0) {
38 return y_[i];
39 }
40 else if (i == n_ || abs(x - x_[i]) > abs(x - x_[i-1])) {
41 i--;
42 }
43 return y_[i];
44}
45
46}
Note: See TracBrowser for help on using the repository browser.