source: trunk/src/LinearInterpolator1D.tcc@ 2937

Last change on this file since 2937 was 2756, 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: test_sdcal2

Put in Release Notes: No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Replace assert with casa::assert_ to avoid aborting casapy session.


File size: 1.1 KB
RevLine 
[2733]1//
2// C++ Implementation: LinearInterpolator1D
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
[2756]14#include <casa/Exceptions/Error.h>
15#include <casa/Utilities/Assert.h>
16
[2733]17#include "LinearInterpolator1D.h"
18
19namespace asap {
20
21template <class T, class U>
22LinearInterpolator1D<T, U>::LinearInterpolator1D()
23 : Interpolator1D<T, U>()
24{}
25
26template <class T, class U>
27LinearInterpolator1D<T, U>::~LinearInterpolator1D()
28{}
29
30template <class T, class U> U LinearInterpolator1D<T, U>::interpolate(T x)
31{
[2756]32 //assert(this->isready());
33 assert_<AipsError>(this->isready(),"object is not ready to process.");
[2733]34 if (this->n_ == 1)
35 return this->y_[0];
36
37 unsigned int i = this->locator_->locate(x);
38
39 // do not perform extrapolation
40 if (i == 0) {
41 return this->y_[i];
42 }
43 else if (i == this->n_) {
44 return this->y_[i-1];
45 }
46
47 // linear interpolation
48 U y = this->y_[i-1] + (this->y_[i] - this->y_[i-1]) * (x - this->x_[i-1])
49 / (this->x_[i] - this->x_[i-1]);
50 return y;
51}
52
53}
Note: See TracBrowser for help on using the repository browser.