DSPLIB User Guide
DSPLIB_negate_cn.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 **+--------------------------------------------------------------------------+**
3 **| **** |**
4 **| **** |**
5 **| ******o*** |**
6 **| ********_///_**** |**
7 **| ***** /_//_/ **** |**
8 **| ** ** (__/ **** |**
9 **| ********* |**
10 **| **** |**
11 **| *** |**
12 **| |**
13 **| Copyright (c) 2016 Texas Instruments Incorporated |**
14 **| ALL RIGHTS RESERVED |**
15 **| |**
16 **| Permission to use, copy, modify, or distribute this software, |**
17 **| whether in part or in whole, for any purpose is forbidden without |**
18 **| a signed licensing agreement and NDA from Texas Instruments |**
19 **| Incorporated (TI). |**
20 **| |**
21 **| TI makes no representation or warranties with respect to the |**
22 **| performance of this computer program, and specifically disclaims |**
23 **| any responsibility for any damages, special or consequential, |**
24 **| connected with the use of this program. |**
25 **| |**
26 **+--------------------------------------------------------------------------+**
27 *******************************************************************************/
28 
29 #include "DSPLIB_negate_priv.h"
30 #include <limits>
31 
32 template <typename dataType, int32_t dataIn>
33 DSPLIB_STATUS DSPLIB_negate_exec_cn(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
34 {
36 
37  DSPLIB_negate_PrivArgs *pKerPrivArgs = (DSPLIB_negate_PrivArgs *) handle;
38  uint32_t blockSize = pKerPrivArgs->blockSize;
39 
40 #if DSPLIB_DEBUGPRINT
41  printf("Enter DSPLIB_negate_exec_cn\n");
42 #endif
43 
44  dataType *pInLocal = (dataType *) pIn;
45  dataType *pOutLocal = (dataType *) pOut;
46 
47 #if DSPLIB_DEBUGPRINT
48  printf("Enter pInLocal %p pOut %p\n", pInLocal, pOut);
49 #endif
50 
51  dataType a;
52 
53  for (int32_t counter = 0; counter < blockSize; counter++) {
54  a = *pInLocal++;
55 #if DSPLIB_DEBUGPRINT
56  if (counter <= 8)
57  printf("counter %d a %f\n", counter, a);
58 #endif
59 
60  // if input == min, output = max
61  if (a == std::numeric_limits<dataType>::lowest()){
62  (*pOutLocal++) = std::numeric_limits<dataType>::max();
63  }
64  else{
65  (*pOutLocal++) = -a;
66  }
67  }
68 
69  return (status);
70 }
71 
72 // explicit instantiation for the different data type versions
73 template DSPLIB_STATUS
74 DSPLIB_negate_exec_cn<int32_t, DSPLIB_INT32>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
75 
76 template DSPLIB_STATUS
77 DSPLIB_negate_exec_cn<int16_t, DSPLIB_INT16>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
78 
79 template DSPLIB_STATUS
80 DSPLIB_negate_exec_cn<int8_t, DSPLIB_INT8>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
DSPLIB_STATUS DSPLIB_negate_exec_cn(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
This function is the main execution function for the natural C implementation of the kernel....
template DSPLIB_STATUS DSPLIB_negate_exec_cn< int8_t, DSPLIB_INT8 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_negate_exec_cn< int16_t, DSPLIB_INT16 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_negate_exec_cn< int32_t, DSPLIB_INT32 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_negate.
DSPLIB_STATUS_NAME
The enumeration of all status codes.
Definition: DSPLIB_types.h:151
void * DSPLIB_kernelHandle
Handle type for DSPLIB operations.
Definition: DSPLIB_types.h:172
@ DSPLIB_SUCCESS
Definition: DSPLIB_types.h:152
Structure that is reserved for internal use by the kernel.
int32_t blockSize
Size of input buffer for different batches DSPLIB_negate_init that will be retrieved and used by DSPL...