Changeset 2730 for trunk/src/BisectionLocator.cpp
- Timestamp:
- 01/16/13 16:00:28 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/BisectionLocator.cpp
r2727 r2730 15 15 16 16 namespace asap { 17 BisectionLocator::BisectionLocator() 18 : Locator() 19 { 20 } 17 21 18 BisectionLocator::BisectionLocator(double *v, unsigned int n) 19 : Locator(v, n) 22 23 BisectionLocator::BisectionLocator(double *v, unsigned int n, bool copystorage) 24 : Locator(v, n, copystorage) 20 25 {} 21 26 … … 27 32 if (n_ == 1) 28 33 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 34 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 } 35 return bisection(x, 0, n_); 66 36 } 67 37
Note: See TracChangeset
for help on using the changeset viewer.