Developer Reference

  • 2020
  • 07/15/2020
  • Public Content
Contents

Sum

Computes the sum of the elements of a vector.

Syntax

IppStatus ippsSum_32f(const Ipp32f*
pSrc
, int
len
, Ipp32f*
pSum,
IppHintAlgorithm
hint
);
IppStatus ippsSum_32fc(const Ipp32fc*
pSrc
, int
len
, Ipp32fc*
pSum,
IppHintAlgorithm
hint
);
IppStatus ippsSum_64f(const Ipp64f*
pSrc
, int
len
, Ipp64f*
pSum
);
IppStatus ippsSum_64fc(const Ipp64fc*
pSrc
, int
len
, Ipp64fc*
pSum
);
IppStatus ippsSum_16s_Sfs(const Ipp16s*
pSrc
, int
len
, Ipp16s*
pSum
, int
scaleFactor
);
IppStatus ippsSum_32s_Sfs(const Ipp32s*
pSrc
, int
len
, Ipp32s*
pSum
, int
scaleFactor
);
IppStatus ippsSum_16s32s_Sfs(const Ipp16s*
pSrc
, int
len
, Ipp32s*
pSum
, int
scaleFactor
);
IppStatus ippsSum_16sc_Sfs(const Ipp16sc*
pSrc
, int
len
, Ipp16sc*
pSum
, int
scaleFactor
);
IppStatus ippsSum_16sc32sc_Sfs(const Ipp16sc*
pSrc
, int
len
, Ipp32sc*
pSum
, int
scaleFactor
);
Include Files
ipps.h
Domain Dependencies
Headers:
ippcore.h
,
ippvm.h
Libraries:
ippcore.lib
,
ippvm.lib
Parameters
pSrc
Pointer to the source vector.
pSum
Pointer to the output result.
len
Number of elements in the vector.
hint
Suggests using specific code. The possible values for the
hint
argument are described in Hint Arguments.
scaleFactor
Scale factor, refer to Integer Scaling.
Description
This function computes the sum of the elements of the vector
pSrc
and stores the result in
pSum
.
The sum of the elements of
pSrc
is defined by the formula:
The
hint
argument suggests using specific code, either faster but less accurate calculation, or more accurate but slower calculation.
When computing the sum of integer numbers, the output result can exceed the data range and become saturated. To get a precise result, use the scale factor. The scaling is performed in accordance with the
scaleFactor
value.
Return Values
ippStsNoErr
Indicates no error.
ippStsNullPtrErr
Indicates an error when the
pSum
or
pSrc
pointer is
NULL
.
ippStsSizeErr
Indicates an error when
len
is less than or equal to 0.

Example

The example below shows how to use the function
ippsSum
.
void sum(void) { Ipp16s x[4] = {-32768, 32767, 32767, 32767}, sm; ippsSum_16s_Sfs(x, 4, &sm, 1); printf_16s(“sum =”, &sm, 1, ippStsNoErr); }
Output:
sum = 32766 Matlab* Analog: >> x = [-32768, 32767, 32767, 32767]; sum(x)/2

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