FFTLIB User Guide
FFTLIB_debugPrintMatrix.cpp
Go to the documentation of this file.
1 /******************************************************************************/
5 /* Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the
17  * distribution.
18  *
19  * Neither the name of Texas Instruments Incorporated nor the names of
20  * its contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35  ******************************************************************************/
36 
37 
38 /*******************************************************************************
39  *
40  * INCLUDES
41  *
42  ******************************************************************************/
43 
44 #include "../FFTLIB_types.h"
45 #include "../FFTLIB_bufParams.h"
46 #include "../FFTLIB_utility.h"
47 
48 
49 //----------------------------------------------------------------------------------
50 
51 template <typename dataType>
52 void FFTLIB_debugPrintMatrix_helper(dataType *matrix, const FFTLIB_bufParams2D_t *params)
53 {
54  uint32_t x,y;
55  dataType* xPtr;
56  dataType* yPtr = matrix;
57 
58  // stride_y is stored in bytes, but easier to use in elements
59  uint32_t stride_y_elements = params->stride_y / FFTLIB_sizeof(params->data_type);
60 
61  for(y = 0; y < params->dim_y; y++){
62  xPtr = yPtr;
63  FFTLIB_PRINTF("%p |", xPtr);
64  for(x = 0; x < params->dim_x; x++){
65  FFTLIB_PRINTF("%3d ", *(xPtr));
66  xPtr++;
67  }
68  FFTLIB_PRINTF("%s", "|\n");
69  yPtr += stride_y_elements;
70  }
71 
72  return;
73 }
74 
75 template void FFTLIB_debugPrintMatrix_helper<int8_t> (int8_t *matrix, const FFTLIB_bufParams2D_t *params);
76 template void FFTLIB_debugPrintMatrix_helper<uint8_t> (uint8_t *matrix, const FFTLIB_bufParams2D_t *params);
77 template void FFTLIB_debugPrintMatrix_helper<int16_t> (int16_t *matrix, const FFTLIB_bufParams2D_t *params);
78 template void FFTLIB_debugPrintMatrix_helper<uint16_t>(uint16_t *matrix, const FFTLIB_bufParams2D_t *params);
79 template void FFTLIB_debugPrintMatrix_helper<int32_t> (int32_t *matrix, const FFTLIB_bufParams2D_t *params);
80 
81 /******************************************************************************/
82 
83 /******************************************************************************/
90 /******************************************************************************/
91 
92 
93 // want this function to have C-linkage in library...
94 #ifdef __cplusplus
95 extern "C" {
96 #endif /* __cplusplus */
97 
98  void FFTLIB_debugPrintMatrix(void *matrix, const FFTLIB_bufParams2D_t *params)
99  {
100  switch(params->data_type){
101  case FFTLIB_INT32 :
102  FFTLIB_debugPrintMatrix_helper<int32_t>((int32_t *)matrix, params);
103  break;
104  case FFTLIB_INT16 :
105  FFTLIB_debugPrintMatrix_helper<int16_t>((int16_t *)matrix, params);
106  break;
107  case FFTLIB_UINT16 :
108  FFTLIB_debugPrintMatrix_helper<uint16_t>((uint16_t *)matrix, params);
109  break;
110  case FFTLIB_INT8 :
111  FFTLIB_debugPrintMatrix_helper<int8_t>((int8_t *)matrix, params);
112  break;
113  case FFTLIB_UINT8 :
114  FFTLIB_debugPrintMatrix_helper<uint8_t>((uint8_t *)matrix, params);
115  break;
116  default :
117  FFTLIB_PRINTF("\nERROR: Unrecognized data type in %s.\n", __FUNCTION__);
118  }
119 
120  return;
121  }
122 #ifdef __cplusplus
123 }
124 #endif /* __cplusplus */
@ FFTLIB_INT16
@ FFTLIB_INT8
@ FFTLIB_UINT16
@ FFTLIB_UINT8
@ FFTLIB_INT32
static int32_t FFTLIB_sizeof(uint32_t type)
Inline function returns number of bytes per element given a type of _FFTLIB_data_type_e.
template void FFTLIB_debugPrintMatrix_helper< uint16_t >(uint16_t *matrix, const FFTLIB_bufParams2D_t *params)
template void FFTLIB_debugPrintMatrix_helper< int16_t >(int16_t *matrix, const FFTLIB_bufParams2D_t *params)
void FFTLIB_debugPrintMatrix_helper(dataType *matrix, const FFTLIB_bufParams2D_t *params)
void FFTLIB_debugPrintMatrix(void *matrix, const FFTLIB_bufParams2D_t *params)
template void FFTLIB_debugPrintMatrix_helper< int32_t >(int32_t *matrix, const FFTLIB_bufParams2D_t *params)
template void FFTLIB_debugPrintMatrix_helper< uint8_t >(uint8_t *matrix, const FFTLIB_bufParams2D_t *params)
template void FFTLIB_debugPrintMatrix_helper< int8_t >(int8_t *matrix, const FFTLIB_bufParams2D_t *params)
#define FFTLIB_PRINTF(fmt,...)
Definition: FFTLIB_types.h:105
A structure for a 2 dimensional buffer descriptor.
uint32_t dim_y
Height of buffer in Y dimension in elements.
uint32_t dim_x
Width of buffer in X dimension in elements.
int32_t stride_y
Stride in Y dimension in bytes.
uint32_t data_type
Values are of type FFTLIB_data_type_e.