IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 22, 2006, 11:35:34 AM (20 years ago)
Author:
magnier
Message:

fixed compile errors from pmShutterCorrection stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmGrowthCurve.c

    r8815 r8886  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-09-15 09:49:01 $
     7 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-09-22 21:35:34 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1818#include <pslib.h>
    1919#include "pmGrowthCurve.h"
     20#include "psVectorBracket.h"
    2021
    2122static void pmGrowthCurveFree (pmGrowthCurve *growth)
     
    5758}
    5859
    59 // return the last entry below or first entry above key value
    60 int psVectorBracket (psVector *index, psF32 key, bool above)
    61 {
    62 
    63     int N;
    64     int Nlo = 0;
    65     int Nhi = index->n;
    66 
    67     if (above) {
    68         while (Nhi - Nlo > 10) {
    69             N = 0.5*(Nlo + Nhi);
    70             if (index->data.F32[N] > key) {
    71                 Nhi = N;
    72             } else {
    73                 Nlo = N - 1;
    74             }
    75         }
    76         // at this point, index[Nhi] > key >= index[Nlo]
    77         N = Nlo;
    78         while ((index->data.F32[N] <= key) && (N < Nhi)) {
    79             N++;
    80         }
    81         return (N);
    82     }
    83     while (Nhi - Nlo > 10) {
    84         N = 0.5*(Nlo + Nhi);
    85         if (index->data.F32[N] < key) {
    86             Nlo = N;
    87         } else {
    88             Nhi = N + 1;
    89         }
    90     }
    91     // at this point, index[Nhi] >= key > index[Nlo]
    92     N = Nhi;
    93     while ((index->data.F32[N] >= key) && (N > Nlo)) {
    94         N--;
    95     }
    96     return (N);
    97 }
    98 
    99 // search for the bins bounding key in index, interpolate the corresponding values
    100 psF32 psVectorInterpolate (psVector *index, psVector *value, psF32 key)
    101 {
    102 
    103     int n0 = 0;
    104     int n1 = 0;
    105 
    106     // extrapolate at ends
    107     if (key < index->data.F32[0]) {
    108         n0 = 0;
    109         n1 = 1;
    110     }
    111 
    112     // extrapolate at ends
    113     if (key > index->data.F32[index->n-1]) {
    114         n0 = index->n-2;
    115         n1 = index->n-1;
    116     }
    117 
    118     if (n1 == 0) {
    119         n0 = psVectorBracket (index, key, FALSE);
    120         n1 = n0 + 1;
    121     }
    122 
    123     if (n0 == index->n-1) {
    124         n1 = n0;
    125         n0 = n1 - 1;
    126     }
    127 
    128     float dy = value->data.F32[n1] - value->data.F32[n0];
    129     float dx = index->data.F32[n1] - index->data.F32[n0];
    130     float dX = key - index->data.F32[n0];
    131     float dY = dX * (dy/dx);
    132     float result = value->data.F32[n0] + dY;
    133     return result;
    134 }
    135 
Note: See TracChangeset for help on using the changeset viewer.