DSPLIB User Guide
DSPLIB_cholesky_solver_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 
30 
31 template <typename dataType>
33 DSPLIB_cholesky_solver_cn(const int order, dataType *U, dataType *y, dataType *b, dataType *x, int32_t colLStride)
34 {
35  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
36 
37  short i = 0;
38  short j = 0;
39  dataType sum = 0;
40 
41  /* FORWARD SUBSTITUTION */
42  for (i = 0; i < order; i++) {
43  sum = 0.0;
44  for (j = 0; j < i; j++) {
45  sum += ((dataType) U[i + j * colLStride]) * y[j];
46  }
47  y[i] = (b[i] - sum) / ((dataType) U[i + i * colLStride]);
48  }
49 
50  /* BACKWARD SUBSTITUTION */
51  for (i = order - 1; i >= 0; i--) {
52  sum = 0.0;
53  for (j = i + 1; j < order; j++) {
54  sum += ((dataType) U[j + i * colLStride]) * x[j];
55  }
56  x[i] = (y[i] - sum) / ((dataType) U[i + i * colLStride]);
57  }
58 
59  return DSPLIB_SUCCESS;
60 }
61 template DSPLIB_STATUS
62 DSPLIB_cholesky_solver_cn<float>(const int order, float *L, float *y, float *b, float *x, int32_t colLStride);
63 template DSPLIB_STATUS
64 DSPLIB_cholesky_solver_cn<double>(const int order, double *L, double *y, double *b, double *x, int32_t colLStride);
65 
66 /*Natural C implementation*/
67 template <typename dataType>
69  void *restrict pU,
70  void *restrict pScratch,
71  void *restrict pY,
72  void *restrict pB,
73  void *restrict pX,
74  void *restrict pDiv)
75 {
76  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
77 
79  int32_t order = pKerPrivArgs->order;
80  int32_t strideL = pKerPrivArgs->strideCn;
81  int32_t colLStride = strideL / sizeof(dataType);
82 
83  dataType *pLocalU = (dataType *) pU;
84  dataType *pLocalY = (dataType *) pY;
85  dataType *pLocalB = (dataType *) pB;
86  dataType *pLocalX = (dataType *) pX;
87 
88  DSPLIB_STATUS status = DSPLIB_cholesky_solver_cn<dataType>(order, pLocalU, pLocalY, pLocalB, pLocalX, colLStride);
89 
90  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
91 
92  return status;
93 }
94 
95 // explicit instantiation for the different data type versions
97  void *restrict pU,
98  void *restrict pScratch,
99  void *restrict pY,
100  void *restrict pB,
101  void *restrict pX,
102  void *restrict pDiv);
103 
105  void *restrict pU,
106  void *restrict pScratch,
107  void *restrict pY,
108  void *restrict pB,
109  void *restrict pX,
110  void *restrict pDiv);
111 /* ======================================================================== */
112 /* End of file: DSPLIB_cholesky_solver_cn.cpp */
113 /* ======================================================================== */
template DSPLIB_STATUS DSPLIB_cholesky_solver_cn< double >(const int order, double *L, double *y, double *b, double *x, int32_t colLStride)
template DSPLIB_STATUS DSPLIB_cholesky_solver_cn< float >(const int order, float *L, float *y, float *b, float *x, int32_t colLStride)
DSPLIB_STATUS DSPLIB_cholesky_solver_exec_cn(DSPLIB_kernelHandle handle, void *restrict pU, void *restrict pScratch, void *restrict pY, void *restrict pB, void *restrict pX, void *restrict pDiv)
This function is the main execution function for the natural C implementation of the kernel....
DSPLIB_STATUS DSPLIB_cholesky_solver_cn(const int order, dataType *U, dataType *y, dataType *b, dataType *x, int32_t colLStride)
template DSPLIB_STATUS DSPLIB_cholesky_solver_exec_cn< double >(DSPLIB_kernelHandle handle, void *restrict pU, void *restrict pScratch, void *restrict pY, void *restrict pB, void *restrict pX, void *restrict pDiv)
template DSPLIB_STATUS DSPLIB_cholesky_solver_exec_cn< float >(DSPLIB_kernelHandle handle, void *restrict pU, void *restrict pScratch, void *restrict pY, void *restrict pB, void *restrict pX, void *restrict pDiv)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_cholesky_solver.
#define DSPLIB_DEBUGPRINTFN(N, fmt,...)
Definition: DSPLIB_types.h:83
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 order
Order of input buffer for different batches DSPLIB_cholesky_solver_init that will be retrieved and us...