Developer Reference

  • 2020
  • 10/21/2020
  • Public Content
Contents

Threshold

Performs the threshold operation on the elements of a vector by limiting the element values by specified value.

Syntax

IppStatus ippsThreshold_16s(const Ipp16s*
pSrc
, Ipp16s*
pDst
, int
len
, Ipp16s
level
, IppCmpOp
relOp
);
IppStatus ippsThreshold_32f(const Ipp32f*
pSrc
, Ipp32f*
pDst
, int
len
, Ipp32f
level
, IppCmpOp
relOp
);
IppStatus ippsThreshold_64f(const Ipp64f*
pSrc
, Ipp64f*
pDst
, int
len
, Ipp64f
level
, IppCmpOp
relOp
);
IppStatus ippsThreshold_32fc(const Ipp32fc*
pSrc
, Ipp32fc*
pDst
, int
len
, Ipp32f
level
, IppCmpOp
relOp
);
IppStatus ippsThreshold_64fc(const Ipp64fc*
pSrc
, Ipp64fc*
pDst
, int
len
, Ipp64f
level
, IppCmpOp
relOp
);
IppStatus ippsThreshold_16sc(const Ipp16sc*
pSrc
, Ipp16sc*
pDst
, int
len
, Ipp16s
level
, IppCmpOp
relOp
);
IppStatus ippsThreshold_16s_I(Ipp16s*
pSrcDst
, int
len
, Ipp16s
level
,IppCmpOp
relOp
);
IppStatus ippsThreshold_32f_I(Ipp32f*
pSrcDst
, int
len
, Ipp32f
level
, IppCmpOp
relOp
);
IppStatus ippsThreshold_64f_I(Ipp64f*
pSrcDst
, int
len
, Ipp64f
level
, IppCmpOp
relOp
);
IppStatus ippsThreshold_32fc_I(Ipp32fc*
pSrcDst
, int
len
, Ipp32f
level
, IppCmpOp
relOp
);
IppStatus ippsThreshold_64fc_I(Ipp64fc*
pSrcDst
, int
len
, Ipp64f
level
, IppCmpOp
relOp
);
IppStatus ippsThreshold_16sc_I(Ipp16sc*
pSrcDst
, int
len
, Ipp16s
level
, IppCmpOp
relOp
);
Include Files
ipps.h
Domain Dependencies
Headers:
ippcore.h
,
ippvm.h
Libraries:
ippcore.lib
,
ippvm.lib
Parameters
pSrc
Pointer to the source vector.
pDst
Pointer to the destination vector.
pSrcDst
Pointer to the source and destination vector for the in-place operation.
len
Number of elements in the vector.
level
Value used to limit each element of
pSrc
or
pSrcDst
.This parameter must always be real. For complex versions, it must be positive and represent magnitude.
relOp
Values of this argument specify which relational operator to use and whether
level
is an upper or lower bound for the input. The
relOp
must have one of the following values:
ippCmpLess
Specifies the “less than” operator and
level
is a lower bound.
ippCmpGreater
Specifies the “greater than” operator and
level
is an upper bound.
Description
This function performs the threshold operation on the vector
pSrc
by limiting each element by the threshold value
level
. Function operation is similar to that of the functions
ippsThreshold_LT
,
ippsThreshold_GT
but its interface contains the
relOp
parameter that specifies the type of the comparison operation to perform.
The in-place flavors of
ippsThreshold
perform the threshold operation on the vector
pSrcDst
by limiting each element by the threshold value
level
.
The
relOp
argument specifies which relational operator to use: when its value is
ippCmpGreater -
“greater than”, when
ippCmpLess
- “less than”, and determines whether
level
is an upper or lower bound for the input, respectively.
The formula for
ippsThreshold
called with the
relOp
= ippCmpLess
is:
The formula for
ippsThreshold
called with the
relOp
= ippCmpGreater
is:
For complex versions of the function
ippsThreshold
, the
level
argument is always real. The formula for complex
ippsThreshold
called with the
relOp
= ippCmpLess
is:
The formula for complex
ippsThreshold
called with the
relOp
= ippCmpGreater
is:
Application Notes
For all complex versions,
level
must be positive and represents a magnitude. The magnitude of the input is limited, but the phase remains unchanged. Zero-valued input is assumed to have zero phase.
A special rule is applied to the integer complex versions of the function
ippsThreshold
. In general, the resulting point coordinates at the complex plane are not integer. The function rounds them off to integer in such a way that the threshold operation is not performed. Thus, for the “less than” operation (with the
ippCmpLess
flag) the coordinates are rounded to the infinity (
+Inf
for positive coordinates, and
-Inf
for negative), and for the “greater than” operation (with the
ippCmpGreater
flag) the coordinates are rounded to zero.
Return Values
ippStsNoErr
Indicates no error.
ippStsNullPtrErr
Indicates an error when the
pSrc
,
pDst
, or
pSrcDst
pointer is
NULL
.
ippStsSizeErr
Indicates an error when
len
is less than or equal to 0.
ippStsBadArgErr
Indicates an error when
relOp
has an invalid value.
ippStsThreshNegLevelErr
Indicates an error when
level
for the complex version is negative (see appendix A "Handling of Special Cases" for more information).

Example



    
/******************************************************************************* * Copyright 2015-2020 Intel Corporation. * * This software and the related documents are Intel copyrighted materials, and * your use of them is governed by the express license under which they were * provided to you (License). Unless the License provides otherwise, you may not * use, modify, copy, publish, distribute, disclose or transmit this software or * the related documents without Intel's prior written permission. * * This software and the related documents are provided as is, with no express * or implied warranties, other than those that are expressly stated in the * License. *******************************************************************************/ #include <stdio.h> #include "ipp.h" /* Next two defines are created to simplify code reading and understanding */ #define EXIT_MAIN exitLine: /* Label for Exit */ #define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) Integrated Primitives (Intel(R) IPP) function returned status different from ippStsNoErr */ /* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status */ int main() { Ipp32f pVals[] = { 1, -3, 5, -7, 18, -24, 35, 48 }; Ipp32f pOutVals[8]; IppStatus status; int i; printf("\nSource vector\n"); for (i = 0; i < 8; i++) printf("%f ", pVals[i]); check_sts(status = ippsThreshold_32f(pVals, pOutVals, 8, 10, ippCmpGreater)); printf("\nResult values vector\n"); for (i = 0; i < 8; i++) printf("%f ", pOutVals[i]); EXIT_MAIN printf("\nExit status %d (%s)\n", (int)status, ippGetStatusString(status)); return (int)status; }

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804