Changeset 8927
- Timestamp:
- Sep 24, 2006, 3:06:51 PM (20 years ago)
- Location:
- trunk/psModules/src/objects
- Files:
-
- 2 edited
-
psVectorBracket.c (modified) (2 diffs)
-
psVectorBracket.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/psVectorBracket.c
r8885 r8927 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $8 * @date $Date: 2006-09-2 2 21:35:10$7 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-09-25 01:06:51 $ 9 9 * 10 10 * Copyright 2006 Institute for Astronomy, University of Hawaii … … 59 59 } 60 60 61 // return the last entry below or first entry above key value (reverse sorted input) 62 int psVectorBracketDescend (psVector *index, psF32 key, bool above) 63 { 64 65 int N; 66 int Nhi = 0; 67 int Nlo = index->n; 68 69 if (above) { 70 while (Nlo - Nhi > 10) { 71 N = 0.5*(Nhi + Nlo); 72 if (index->data.F32[N] < key) { 73 Nlo = N; 74 } else { 75 Nhi = N - 1; 76 } 77 } 78 // at this point, index[Nhi] >= key > index[Nlo] 79 N = Nhi; 80 while ((index->data.F32[N] >= key) && (N < Nlo)) { 81 N++; 82 } 83 return (N); 84 } 85 while (Nlo - Nhi > 10) { 86 N = 0.5*(Nhi + Nlo); 87 if (index->data.F32[N] > key) { 88 Nhi = N; 89 } else { 90 Nlo = N + 1; 91 } 92 } 93 // at this point, index[Nhi] > key >= index[Nlo] 94 N = Nlo; 95 while ((index->data.F32[N] <= key) && (N > Nhi)) { 96 N--; 97 } 98 return (N); 99 } 100 61 101 // search for the bins bounding key in index, interpolate the corresponding values 62 102 psF32 psVectorInterpolate (psVector *index, psVector *value, psF32 key) -
trunk/psModules/src/objects/psVectorBracket.h
r8885 r8927 4 4 5 5 int psVectorBracket (psVector *index, psF32 key, bool above); 6 int psVectorBracketDescend (psVector *index, psF32 key, bool above); 6 7 psF32 psVectorInterpolate (psVector *index, psVector *value, psF32 key); 7 8
Note:
See TracChangeset
for help on using the changeset viewer.
