source: trunk/src/BisectionLocator.cpp@ 2729

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

New Development: No

JIRA Issue: Yes CAS-4770, CAS-4774

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

Updated STApplyCal to be able to specify interpolation method.
The method can be specified in time and frequency axes independently.
Possible options are nearest, linear (default), (natural) cubic spline,
and polynomial with arbitrary order.

File size: 1.1 KB
Line 
1//
2// C++ Implementation: BisectionLocator
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 "BisectionLocator.h"
15
16namespace asap {
17
18BisectionLocator::BisectionLocator(double *v, unsigned int n)
19 : Locator(v, n)
20{}
21
22BisectionLocator::~BisectionLocator()
23{}
24
25unsigned int BisectionLocator::locate(double x)
26{
27 if (n_ == 1)
28 return 0;
29 bool ascending = (x_[n_-1] >= x_[0]);
30 if (ascending) {
31 if (x <= x_[0])
32 return 0;
33 else if (x > x_[n_-1])
34 return n_;
35
36 unsigned int jl = 0;
37 unsigned int ju = n_;
38 unsigned int jm;
39 while (ju - jl > 1) {
40 jm = (ju + jl) >> 1;
41 if (x > x_[jm])
42 jl = jm;
43 else
44 ju = jm;
45 }
46 return ju;
47 }
48 else {
49 if (x >= x_[0])
50 return 0;
51 else if (x < x_[n_-1])
52 return n_;
53
54 unsigned int jl = 0;
55 unsigned int ju = n_;
56 unsigned int jm;
57 while (ju - jl > 1) {
58 jm = (ju + jl) >> 1;
59 if (x < x_[jm])
60 jl = jm;
61 else
62 ju = jm;
63 }
64 return ju;
65 }
66}
67
68}
Note: See TracBrowser for help on using the repository browser.