source: trunk/src/Interpolator1D.tcc@ 3112

Last change on this file since 3112 was 3106, checked in by Takeshi Nakazato, 8 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes/No

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


Check-in asap modifications from Jim regarding casacore namespace conversion.

File size: 1.9 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#include <casa/Utilities/Assert.h>
17
18#include "Interpolator1D.h"
19#include "Locator.h"
20#include "BisectionLocator.h"
21#include "HuntLocator.h"
22
23namespace asap {
24
25template <class T, class U> Interpolator1D<T, U>::Interpolator1D()
26 : order_(1),
27 n_(0),
28 x_(0),
29 y_(0),
30 locator_(0)
31{
32}
33
34template <class T, class U> Interpolator1D<T, U>::~Interpolator1D()
35{
36 if (locator_)
37 delete locator_;
38}
39
40template <class T, class U>
41void Interpolator1D<T, U>::setData(T *x, U *y, unsigned int n)
42{
43 x_ = x;
44 y_ = y;
45 n_ = n;
46 createLocator();
47 locator_->set(x, n);
48}
49
50template <class T, class U>
51void Interpolator1D<T, U>::setX(T *x, unsigned int n)
52{
53 //assert(n_ == 0 || n_ == n);
54 casacore::assert_<casacore::AipsError>(n_ == 0 || n_ == n, "length mismatch in data.");
55 x_ = x;
56 n_ = n;
57 createLocator();
58 locator_->set(x, n);
59}
60
61template <class T, class U>
62void Interpolator1D<T, U>::setY(U *y, unsigned int n)
63{
64 //assert(n_ == 0 || n_ == n);
65 casacore::assert_<casacore::AipsError>(n_ == 0 || n_ == n, "length mismatch in data.");
66 y_ = y;
67 n_ = n;
68}
69
70template <class T, class U> void Interpolator1D<T, U>::reset()
71{
72 n_ = 0;
73 x_ = 0;
74 y_ = 0;
75 if (locator_) {
76 delete locator_;
77 locator_ = 0;
78 }
79}
80
81template <class T, class U> bool Interpolator1D<T, U>::isready()
82{
83 return (n_ > 0 && x_ != 0 && y_ != 0);
84}
85
86template <class T, class U> unsigned int Interpolator1D<T, U>::locate(T x)
87{
88 return locator_->locate(x);
89}
90
91template <class T, class U> void Interpolator1D<T, U>::createLocator()
92{
93 if (!locator_) {
94 if (n_ > 1000)
95 locator_ = new HuntLocator<T>();
96 else
97 locator_ = new BisectionLocator<T>();
98 }
99}
100
101}
Note: See TracBrowser for help on using the repository browser.