IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 10, 2004, 1:05:49 PM (22 years ago)
Author:
gusciora
Message:

Added full type support for vector bin dissect.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psSpline.c

    r2324 r2327  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.60 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-11-10 22:43:48 $
     9 *  @version $Revision: 1.61 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-11-10 23:05:49 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    18871887XXX: name since we don't take psVectors as input.
    18881888 *****************************************************************************/
     1889/*
    18891890static psS32 vectorBinDisectF32(float *bins,
    18901891                                psS32 numBins,
     
    18941895    psS32 max;
    18951896    psS32 mid;
    1896 
     1897 
    18971898    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
    18981899            "---- Calling vectorBinDisectF32(%f)\n", x);
    1899 
     1900 
    19001901    if (x < bins[0]) {
    19011902        psLogMsg(__func__, PS_LOG_WARN,
     
    19041905        return(-2);
    19051906    }
    1906 
     1907 
    19071908    if (x > bins[numBins-1]) {
    19081909        psLogMsg(__func__, PS_LOG_WARN,
     
    19111912        return(-1);
    19121913    }
    1913 
     1914 
    19141915    min = 0;
    19151916    max = numBins-2;
    19161917    mid = ((max+1)-min)/2;
    1917 
     1918 
    19181919    while (min != max) {
    19191920        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
    19201921                "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
    19211922                min, mid, max, x, bins[mid]);
    1922 
     1923 
    19231924        if (x == bins[mid]) {
    19241925            psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
     
    19321933        mid = ((max+1)+min)/2;
    19331934    }
    1934 
     1935 
    19351936    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectF32", 4,
    19361937            "---- Exiting vectorBinDisectF32(): bin %d\n", min);
    19371938    return(min);
    19381939}
    1939 
     1940*/
    19401941/*****************************************************************************
    19411942vectorBinDisectS32(): integer version of above.
    19421943 *****************************************************************************/
     1944/*
    19431945static psS32 vectorBinDisectS32(psS32 *bins,
    19441946                                psS32 numBins,
     
    19481950    psS32 max;
    19491951    psS32 mid;
    1950 
     1952 
    19511953    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
    19521954            "---- Calling vectorBinDisectS32(%f)\n", x);
    1953 
     1955 
    19541956    if ((x < bins[0]) ||
    19551957            (x > bins[numBins-1])) {
     
    19591961        return(-1);
    19601962    }
    1961 
     1963 
    19621964    min = 0;
    19631965    max = numBins-2;
    19641966    mid = ((max+1)-min)/2;
    1965 
     1967 
    19661968    while (min != max) {
    19671969        psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
    19681970                "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n",
    19691971                min, mid, max, x, bins[mid]);
    1970 
     1972 
    19711973        if (x == bins[mid]) {
    19721974            psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
     
    19801982        mid = ((max+1)+min)/2;
    19811983    }
    1982 
     1984 
    19831985    psTrace(".psLib.dataManip.psFunctions.vectorBinDisectS32", 4,
    19841986            "---- Exiting vectorBinDisectS32(): bin %d\n", min);
    19851987    return(min);
    19861988}
     1989*/
     1990
     1991#define FUNC_MACRO_VECTOR_BIN_DISECT(TYPE) \
     1992static psS32 vectorBinDisect##TYPE(ps##TYPE *bins, \
     1993                                   psS32 numBins, \
     1994                                   ps##TYPE x) \
     1995{ \
     1996    psS32 min; \
     1997    psS32 max; \
     1998    psS32 mid; \
     1999    \
     2000    psTrace(".psLib.dataManip.psFunctions.vectorBinDisect##TYPE", 4, \
     2001            "---- Calling vectorBinDisect##TYPE(%f)\n", x); \
     2002    \
     2003    if (x < bins[0]) { \
     2004        psLogMsg(__func__, PS_LOG_WARN, \
     2005                 "vectorBinDisect##TYPE(): ordinate %f is outside vector range (%f - %f).", \
     2006                 x, bins[0], bins[numBins-1]); \
     2007        return(-2); \
     2008    } \
     2009    \
     2010    if (x > bins[numBins-1]) { \
     2011        psLogMsg(__func__, PS_LOG_WARN, \
     2012                 "vectorBinDisect##TYPE(): ordinate %f is outside vector range (%f - %f).", \
     2013                 x, bins[0], bins[numBins-1]); \
     2014        return(-1); \
     2015    } \
     2016    \
     2017    min = 0; \
     2018    max = numBins-2; \
     2019    mid = ((max+1)-min)/2; \
     2020    \
     2021    while (min != max) { \
     2022        psTrace(".psLib.dataManip.psFunctions.vectorBinDisect##TYPE", 4, \
     2023                "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n", \
     2024                min, mid, max, x, bins[mid]); \
     2025        \
     2026        if (x == bins[mid]) { \
     2027            psTrace(".psLib.dataManip.psFunctions.vectorBinDisect##TYPE", 4, \
     2028                    "---- Exiting vectorBinDisect##TYPE(): bin %d\n", mid); \
     2029            return(mid); \
     2030        } else if (x < bins[mid]) { \
     2031            max = mid-1; \
     2032        } else { \
     2033            min = mid; \
     2034        } \
     2035        mid = ((max+1)+min)/2; \
     2036    } \
     2037    \
     2038    psTrace(".psLib.dataManip.psFunctions.vectorBinDisect##TYPE", 4, \
     2039            "---- Exiting vectorBinDisect##TYPE(): bin %d\n", min); \
     2040    return(min); \
     2041} \
     2042
     2043FUNC_MACRO_VECTOR_BIN_DISECT(S8)
     2044FUNC_MACRO_VECTOR_BIN_DISECT(S16)
     2045FUNC_MACRO_VECTOR_BIN_DISECT(S32)
     2046FUNC_MACRO_VECTOR_BIN_DISECT(S64)
     2047FUNC_MACRO_VECTOR_BIN_DISECT(U8)
     2048FUNC_MACRO_VECTOR_BIN_DISECT(U16)
     2049FUNC_MACRO_VECTOR_BIN_DISECT(U32)
     2050FUNC_MACRO_VECTOR_BIN_DISECT(U64)
     2051FUNC_MACRO_VECTOR_BIN_DISECT(F32)
     2052FUNC_MACRO_VECTOR_BIN_DISECT(F64)
    19872053
    19882054/*****************************************************************************
Note: See TracChangeset for help on using the changeset viewer.