source: branches/casa-release-4_3-test/src/Interpolator1D.tcc@ 3122

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