V4.0.1 of the ARM CMSIS DSP libraries. Note that arm_bitreversal2.s, arm_cfft_f32.c and arm_rfft_fast_f32.c had to be removed. arm_bitreversal2.s will not assemble with the online tools. So, the fast f32 FFT functions are not yet available. All the other FFT functions are available.

Dependents:   MPU9150_Example fir_f32 fir_f32 MPU9150_nucleo_noni2cdev ... more

Committer:
emh203
Date:
Mon Jul 28 15:03:15 2014 +0000
Revision:
0:3d9c67d97d6f
1st working commit.   Had to remove arm_bitreversal2.s     arm_cfft_f32.c and arm_rfft_fast_f32.c.    The .s will not assemble.      For now I removed these functions so we could at least have a library for the other functions.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emh203 0:3d9c67d97d6f 1 /* ----------------------------------------------------------------------
emh203 0:3d9c67d97d6f 2 * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
emh203 0:3d9c67d97d6f 3 *
emh203 0:3d9c67d97d6f 4 * $Date: 12. March 2014
emh203 0:3d9c67d97d6f 5 * $Revision: V1.4.3
emh203 0:3d9c67d97d6f 6 *
emh203 0:3d9c67d97d6f 7 * Project: CMSIS DSP Library
emh203 0:3d9c67d97d6f 8 * Title: arm_mat_inverse_f32.c
emh203 0:3d9c67d97d6f 9 *
emh203 0:3d9c67d97d6f 10 * Description: Floating-point matrix inverse.
emh203 0:3d9c67d97d6f 11 *
emh203 0:3d9c67d97d6f 12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
emh203 0:3d9c67d97d6f 13 *
emh203 0:3d9c67d97d6f 14 * Redistribution and use in source and binary forms, with or without
emh203 0:3d9c67d97d6f 15 * modification, are permitted provided that the following conditions
emh203 0:3d9c67d97d6f 16 * are met:
emh203 0:3d9c67d97d6f 17 * - Redistributions of source code must retain the above copyright
emh203 0:3d9c67d97d6f 18 * notice, this list of conditions and the following disclaimer.
emh203 0:3d9c67d97d6f 19 * - Redistributions in binary form must reproduce the above copyright
emh203 0:3d9c67d97d6f 20 * notice, this list of conditions and the following disclaimer in
emh203 0:3d9c67d97d6f 21 * the documentation and/or other materials provided with the
emh203 0:3d9c67d97d6f 22 * distribution.
emh203 0:3d9c67d97d6f 23 * - Neither the name of ARM LIMITED nor the names of its contributors
emh203 0:3d9c67d97d6f 24 * may be used to endorse or promote products derived from this
emh203 0:3d9c67d97d6f 25 * software without specific prior written permission.
emh203 0:3d9c67d97d6f 26 *
emh203 0:3d9c67d97d6f 27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
emh203 0:3d9c67d97d6f 28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
emh203 0:3d9c67d97d6f 29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
emh203 0:3d9c67d97d6f 30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
emh203 0:3d9c67d97d6f 31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
emh203 0:3d9c67d97d6f 32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
emh203 0:3d9c67d97d6f 33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
emh203 0:3d9c67d97d6f 34 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
emh203 0:3d9c67d97d6f 35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
emh203 0:3d9c67d97d6f 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
emh203 0:3d9c67d97d6f 37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
emh203 0:3d9c67d97d6f 38 * POSSIBILITY OF SUCH DAMAGE.
emh203 0:3d9c67d97d6f 39 * -------------------------------------------------------------------- */
emh203 0:3d9c67d97d6f 40
emh203 0:3d9c67d97d6f 41 #include "arm_math.h"
emh203 0:3d9c67d97d6f 42
emh203 0:3d9c67d97d6f 43 /**
emh203 0:3d9c67d97d6f 44 * @ingroup groupMatrix
emh203 0:3d9c67d97d6f 45 */
emh203 0:3d9c67d97d6f 46
emh203 0:3d9c67d97d6f 47 /**
emh203 0:3d9c67d97d6f 48 * @defgroup MatrixInv Matrix Inverse
emh203 0:3d9c67d97d6f 49 *
emh203 0:3d9c67d97d6f 50 * Computes the inverse of a matrix.
emh203 0:3d9c67d97d6f 51 *
emh203 0:3d9c67d97d6f 52 * The inverse is defined only if the input matrix is square and non-singular (the determinant
emh203 0:3d9c67d97d6f 53 * is non-zero). The function checks that the input and output matrices are square and of the
emh203 0:3d9c67d97d6f 54 * same size.
emh203 0:3d9c67d97d6f 55 *
emh203 0:3d9c67d97d6f 56 * Matrix inversion is numerically sensitive and the CMSIS DSP library only supports matrix
emh203 0:3d9c67d97d6f 57 * inversion of floating-point matrices.
emh203 0:3d9c67d97d6f 58 *
emh203 0:3d9c67d97d6f 59 * \par Algorithm
emh203 0:3d9c67d97d6f 60 * The Gauss-Jordan method is used to find the inverse.
emh203 0:3d9c67d97d6f 61 * The algorithm performs a sequence of elementary row-operations until it
emh203 0:3d9c67d97d6f 62 * reduces the input matrix to an identity matrix. Applying the same sequence
emh203 0:3d9c67d97d6f 63 * of elementary row-operations to an identity matrix yields the inverse matrix.
emh203 0:3d9c67d97d6f 64 * If the input matrix is singular, then the algorithm terminates and returns error status
emh203 0:3d9c67d97d6f 65 * <code>ARM_MATH_SINGULAR</code>.
emh203 0:3d9c67d97d6f 66 * \image html MatrixInverse.gif "Matrix Inverse of a 3 x 3 matrix using Gauss-Jordan Method"
emh203 0:3d9c67d97d6f 67 */
emh203 0:3d9c67d97d6f 68
emh203 0:3d9c67d97d6f 69 /**
emh203 0:3d9c67d97d6f 70 * @addtogroup MatrixInv
emh203 0:3d9c67d97d6f 71 * @{
emh203 0:3d9c67d97d6f 72 */
emh203 0:3d9c67d97d6f 73
emh203 0:3d9c67d97d6f 74 /**
emh203 0:3d9c67d97d6f 75 * @brief Floating-point matrix inverse.
emh203 0:3d9c67d97d6f 76 * @param[in] *pSrc points to input matrix structure
emh203 0:3d9c67d97d6f 77 * @param[out] *pDst points to output matrix structure
emh203 0:3d9c67d97d6f 78 * @return The function returns
emh203 0:3d9c67d97d6f 79 * <code>ARM_MATH_SIZE_MISMATCH</code> if the input matrix is not square or if the size
emh203 0:3d9c67d97d6f 80 * of the output matrix does not match the size of the input matrix.
emh203 0:3d9c67d97d6f 81 * If the input matrix is found to be singular (non-invertible), then the function returns
emh203 0:3d9c67d97d6f 82 * <code>ARM_MATH_SINGULAR</code>. Otherwise, the function returns <code>ARM_MATH_SUCCESS</code>.
emh203 0:3d9c67d97d6f 83 */
emh203 0:3d9c67d97d6f 84
emh203 0:3d9c67d97d6f 85 arm_status arm_mat_inverse_f32(
emh203 0:3d9c67d97d6f 86 const arm_matrix_instance_f32 * pSrc,
emh203 0:3d9c67d97d6f 87 arm_matrix_instance_f32 * pDst)
emh203 0:3d9c67d97d6f 88 {
emh203 0:3d9c67d97d6f 89 float32_t *pIn = pSrc->pData; /* input data matrix pointer */
emh203 0:3d9c67d97d6f 90 float32_t *pOut = pDst->pData; /* output data matrix pointer */
emh203 0:3d9c67d97d6f 91 float32_t *pInT1, *pInT2; /* Temporary input data matrix pointer */
emh203 0:3d9c67d97d6f 92 float32_t *pOutT1, *pOutT2; /* Temporary output data matrix pointer */
emh203 0:3d9c67d97d6f 93 float32_t *pPivotRowIn, *pPRT_in, *pPivotRowDst, *pPRT_pDst; /* Temporary input and output data matrix pointer */
emh203 0:3d9c67d97d6f 94 uint32_t numRows = pSrc->numRows; /* Number of rows in the matrix */
emh203 0:3d9c67d97d6f 95 uint32_t numCols = pSrc->numCols; /* Number of Cols in the matrix */
emh203 0:3d9c67d97d6f 96
emh203 0:3d9c67d97d6f 97 #ifndef ARM_MATH_CM0_FAMILY
emh203 0:3d9c67d97d6f 98 float32_t maxC; /* maximum value in the column */
emh203 0:3d9c67d97d6f 99
emh203 0:3d9c67d97d6f 100 /* Run the below code for Cortex-M4 and Cortex-M3 */
emh203 0:3d9c67d97d6f 101
emh203 0:3d9c67d97d6f 102 float32_t Xchg, in = 0.0f, in1; /* Temporary input values */
emh203 0:3d9c67d97d6f 103 uint32_t i, rowCnt, flag = 0u, j, loopCnt, k, l; /* loop counters */
emh203 0:3d9c67d97d6f 104 arm_status status; /* status of matrix inverse */
emh203 0:3d9c67d97d6f 105
emh203 0:3d9c67d97d6f 106 #ifdef ARM_MATH_MATRIX_CHECK
emh203 0:3d9c67d97d6f 107
emh203 0:3d9c67d97d6f 108
emh203 0:3d9c67d97d6f 109 /* Check for matrix mismatch condition */
emh203 0:3d9c67d97d6f 110 if((pSrc->numRows != pSrc->numCols) || (pDst->numRows != pDst->numCols)
emh203 0:3d9c67d97d6f 111 || (pSrc->numRows != pDst->numRows))
emh203 0:3d9c67d97d6f 112 {
emh203 0:3d9c67d97d6f 113 /* Set status as ARM_MATH_SIZE_MISMATCH */
emh203 0:3d9c67d97d6f 114 status = ARM_MATH_SIZE_MISMATCH;
emh203 0:3d9c67d97d6f 115 }
emh203 0:3d9c67d97d6f 116 else
emh203 0:3d9c67d97d6f 117 #endif /* #ifdef ARM_MATH_MATRIX_CHECK */
emh203 0:3d9c67d97d6f 118
emh203 0:3d9c67d97d6f 119 {
emh203 0:3d9c67d97d6f 120
emh203 0:3d9c67d97d6f 121 /*--------------------------------------------------------------------------------------------------------------
emh203 0:3d9c67d97d6f 122 * Matrix Inverse can be solved using elementary row operations.
emh203 0:3d9c67d97d6f 123 *
emh203 0:3d9c67d97d6f 124 * Gauss-Jordan Method:
emh203 0:3d9c67d97d6f 125 *
emh203 0:3d9c67d97d6f 126 * 1. First combine the identity matrix and the input matrix separated by a bar to form an
emh203 0:3d9c67d97d6f 127 * augmented matrix as follows:
emh203 0:3d9c67d97d6f 128 * _ _ _ _
emh203 0:3d9c67d97d6f 129 * | a11 a12 | 1 0 | | X11 X12 |
emh203 0:3d9c67d97d6f 130 * | | | = | |
emh203 0:3d9c67d97d6f 131 * |_ a21 a22 | 0 1 _| |_ X21 X21 _|
emh203 0:3d9c67d97d6f 132 *
emh203 0:3d9c67d97d6f 133 * 2. In our implementation, pDst Matrix is used as identity matrix.
emh203 0:3d9c67d97d6f 134 *
emh203 0:3d9c67d97d6f 135 * 3. Begin with the first row. Let i = 1.
emh203 0:3d9c67d97d6f 136 *
emh203 0:3d9c67d97d6f 137 * 4. Check to see if the pivot for column i is the greatest of the column.
emh203 0:3d9c67d97d6f 138 * The pivot is the element of the main diagonal that is on the current row.
emh203 0:3d9c67d97d6f 139 * For instance, if working with row i, then the pivot element is aii.
emh203 0:3d9c67d97d6f 140 * If the pivot is not the most significant of the columns, exchange that row with a row
emh203 0:3d9c67d97d6f 141 * below it that does contain the most significant value in column i. If the most
emh203 0:3d9c67d97d6f 142 * significant value of the column is zero, then an inverse to that matrix does not exist.
emh203 0:3d9c67d97d6f 143 * The most significant value of the column is the absolute maximum.
emh203 0:3d9c67d97d6f 144 *
emh203 0:3d9c67d97d6f 145 * 5. Divide every element of row i by the pivot.
emh203 0:3d9c67d97d6f 146 *
emh203 0:3d9c67d97d6f 147 * 6. For every row below and row i, replace that row with the sum of that row and
emh203 0:3d9c67d97d6f 148 * a multiple of row i so that each new element in column i below row i is zero.
emh203 0:3d9c67d97d6f 149 *
emh203 0:3d9c67d97d6f 150 * 7. Move to the next row and column and repeat steps 2 through 5 until you have zeros
emh203 0:3d9c67d97d6f 151 * for every element below and above the main diagonal.
emh203 0:3d9c67d97d6f 152 *
emh203 0:3d9c67d97d6f 153 * 8. Now an identical matrix is formed to the left of the bar(input matrix, pSrc).
emh203 0:3d9c67d97d6f 154 * Therefore, the matrix to the right of the bar is our solution(pDst matrix, pDst).
emh203 0:3d9c67d97d6f 155 *----------------------------------------------------------------------------------------------------------------*/
emh203 0:3d9c67d97d6f 156
emh203 0:3d9c67d97d6f 157 /* Working pointer for destination matrix */
emh203 0:3d9c67d97d6f 158 pOutT1 = pOut;
emh203 0:3d9c67d97d6f 159
emh203 0:3d9c67d97d6f 160 /* Loop over the number of rows */
emh203 0:3d9c67d97d6f 161 rowCnt = numRows;
emh203 0:3d9c67d97d6f 162
emh203 0:3d9c67d97d6f 163 /* Making the destination matrix as identity matrix */
emh203 0:3d9c67d97d6f 164 while(rowCnt > 0u)
emh203 0:3d9c67d97d6f 165 {
emh203 0:3d9c67d97d6f 166 /* Writing all zeroes in lower triangle of the destination matrix */
emh203 0:3d9c67d97d6f 167 j = numRows - rowCnt;
emh203 0:3d9c67d97d6f 168 while(j > 0u)
emh203 0:3d9c67d97d6f 169 {
emh203 0:3d9c67d97d6f 170 *pOutT1++ = 0.0f;
emh203 0:3d9c67d97d6f 171 j--;
emh203 0:3d9c67d97d6f 172 }
emh203 0:3d9c67d97d6f 173
emh203 0:3d9c67d97d6f 174 /* Writing all ones in the diagonal of the destination matrix */
emh203 0:3d9c67d97d6f 175 *pOutT1++ = 1.0f;
emh203 0:3d9c67d97d6f 176
emh203 0:3d9c67d97d6f 177 /* Writing all zeroes in upper triangle of the destination matrix */
emh203 0:3d9c67d97d6f 178 j = rowCnt - 1u;
emh203 0:3d9c67d97d6f 179 while(j > 0u)
emh203 0:3d9c67d97d6f 180 {
emh203 0:3d9c67d97d6f 181 *pOutT1++ = 0.0f;
emh203 0:3d9c67d97d6f 182 j--;
emh203 0:3d9c67d97d6f 183 }
emh203 0:3d9c67d97d6f 184
emh203 0:3d9c67d97d6f 185 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 186 rowCnt--;
emh203 0:3d9c67d97d6f 187 }
emh203 0:3d9c67d97d6f 188
emh203 0:3d9c67d97d6f 189 /* Loop over the number of columns of the input matrix.
emh203 0:3d9c67d97d6f 190 All the elements in each column are processed by the row operations */
emh203 0:3d9c67d97d6f 191 loopCnt = numCols;
emh203 0:3d9c67d97d6f 192
emh203 0:3d9c67d97d6f 193 /* Index modifier to navigate through the columns */
emh203 0:3d9c67d97d6f 194 l = 0u;
emh203 0:3d9c67d97d6f 195
emh203 0:3d9c67d97d6f 196 while(loopCnt > 0u)
emh203 0:3d9c67d97d6f 197 {
emh203 0:3d9c67d97d6f 198 /* Check if the pivot element is zero..
emh203 0:3d9c67d97d6f 199 * If it is zero then interchange the row with non zero row below.
emh203 0:3d9c67d97d6f 200 * If there is no non zero element to replace in the rows below,
emh203 0:3d9c67d97d6f 201 * then the matrix is Singular. */
emh203 0:3d9c67d97d6f 202
emh203 0:3d9c67d97d6f 203 /* Working pointer for the input matrix that points
emh203 0:3d9c67d97d6f 204 * to the pivot element of the particular row */
emh203 0:3d9c67d97d6f 205 pInT1 = pIn + (l * numCols);
emh203 0:3d9c67d97d6f 206
emh203 0:3d9c67d97d6f 207 /* Working pointer for the destination matrix that points
emh203 0:3d9c67d97d6f 208 * to the pivot element of the particular row */
emh203 0:3d9c67d97d6f 209 pOutT1 = pOut + (l * numCols);
emh203 0:3d9c67d97d6f 210
emh203 0:3d9c67d97d6f 211 /* Temporary variable to hold the pivot value */
emh203 0:3d9c67d97d6f 212 in = *pInT1;
emh203 0:3d9c67d97d6f 213
emh203 0:3d9c67d97d6f 214 /* Grab the most significant value from column l */
emh203 0:3d9c67d97d6f 215 maxC = 0;
emh203 0:3d9c67d97d6f 216 for (i = l; i < numRows; i++)
emh203 0:3d9c67d97d6f 217 {
emh203 0:3d9c67d97d6f 218 maxC = *pInT1 > 0 ? (*pInT1 > maxC ? *pInT1 : maxC) : (-*pInT1 > maxC ? -*pInT1 : maxC);
emh203 0:3d9c67d97d6f 219 pInT1 += numCols;
emh203 0:3d9c67d97d6f 220 }
emh203 0:3d9c67d97d6f 221
emh203 0:3d9c67d97d6f 222 /* Update the status if the matrix is singular */
emh203 0:3d9c67d97d6f 223 if(maxC == 0.0f)
emh203 0:3d9c67d97d6f 224 {
emh203 0:3d9c67d97d6f 225 return ARM_MATH_SINGULAR;
emh203 0:3d9c67d97d6f 226 }
emh203 0:3d9c67d97d6f 227
emh203 0:3d9c67d97d6f 228 /* Restore pInT1 */
emh203 0:3d9c67d97d6f 229 pInT1 = pIn;
emh203 0:3d9c67d97d6f 230
emh203 0:3d9c67d97d6f 231 /* Destination pointer modifier */
emh203 0:3d9c67d97d6f 232 k = 1u;
emh203 0:3d9c67d97d6f 233
emh203 0:3d9c67d97d6f 234 /* Check if the pivot element is the most significant of the column */
emh203 0:3d9c67d97d6f 235 if( (in > 0.0f ? in : -in) != maxC)
emh203 0:3d9c67d97d6f 236 {
emh203 0:3d9c67d97d6f 237 /* Loop over the number rows present below */
emh203 0:3d9c67d97d6f 238 i = numRows - (l + 1u);
emh203 0:3d9c67d97d6f 239
emh203 0:3d9c67d97d6f 240 while(i > 0u)
emh203 0:3d9c67d97d6f 241 {
emh203 0:3d9c67d97d6f 242 /* Update the input and destination pointers */
emh203 0:3d9c67d97d6f 243 pInT2 = pInT1 + (numCols * l);
emh203 0:3d9c67d97d6f 244 pOutT2 = pOutT1 + (numCols * k);
emh203 0:3d9c67d97d6f 245
emh203 0:3d9c67d97d6f 246 /* Look for the most significant element to
emh203 0:3d9c67d97d6f 247 * replace in the rows below */
emh203 0:3d9c67d97d6f 248 if((*pInT2 > 0.0f ? *pInT2: -*pInT2) == maxC)
emh203 0:3d9c67d97d6f 249 {
emh203 0:3d9c67d97d6f 250 /* Loop over number of columns
emh203 0:3d9c67d97d6f 251 * to the right of the pilot element */
emh203 0:3d9c67d97d6f 252 j = numCols - l;
emh203 0:3d9c67d97d6f 253
emh203 0:3d9c67d97d6f 254 while(j > 0u)
emh203 0:3d9c67d97d6f 255 {
emh203 0:3d9c67d97d6f 256 /* Exchange the row elements of the input matrix */
emh203 0:3d9c67d97d6f 257 Xchg = *pInT2;
emh203 0:3d9c67d97d6f 258 *pInT2++ = *pInT1;
emh203 0:3d9c67d97d6f 259 *pInT1++ = Xchg;
emh203 0:3d9c67d97d6f 260
emh203 0:3d9c67d97d6f 261 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 262 j--;
emh203 0:3d9c67d97d6f 263 }
emh203 0:3d9c67d97d6f 264
emh203 0:3d9c67d97d6f 265 /* Loop over number of columns of the destination matrix */
emh203 0:3d9c67d97d6f 266 j = numCols;
emh203 0:3d9c67d97d6f 267
emh203 0:3d9c67d97d6f 268 while(j > 0u)
emh203 0:3d9c67d97d6f 269 {
emh203 0:3d9c67d97d6f 270 /* Exchange the row elements of the destination matrix */
emh203 0:3d9c67d97d6f 271 Xchg = *pOutT2;
emh203 0:3d9c67d97d6f 272 *pOutT2++ = *pOutT1;
emh203 0:3d9c67d97d6f 273 *pOutT1++ = Xchg;
emh203 0:3d9c67d97d6f 274
emh203 0:3d9c67d97d6f 275 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 276 j--;
emh203 0:3d9c67d97d6f 277 }
emh203 0:3d9c67d97d6f 278
emh203 0:3d9c67d97d6f 279 /* Flag to indicate whether exchange is done or not */
emh203 0:3d9c67d97d6f 280 flag = 1u;
emh203 0:3d9c67d97d6f 281
emh203 0:3d9c67d97d6f 282 /* Break after exchange is done */
emh203 0:3d9c67d97d6f 283 break;
emh203 0:3d9c67d97d6f 284 }
emh203 0:3d9c67d97d6f 285
emh203 0:3d9c67d97d6f 286 /* Update the destination pointer modifier */
emh203 0:3d9c67d97d6f 287 k++;
emh203 0:3d9c67d97d6f 288
emh203 0:3d9c67d97d6f 289 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 290 i--;
emh203 0:3d9c67d97d6f 291 }
emh203 0:3d9c67d97d6f 292 }
emh203 0:3d9c67d97d6f 293
emh203 0:3d9c67d97d6f 294 /* Update the status if the matrix is singular */
emh203 0:3d9c67d97d6f 295 if((flag != 1u) && (in == 0.0f))
emh203 0:3d9c67d97d6f 296 {
emh203 0:3d9c67d97d6f 297 return ARM_MATH_SINGULAR;
emh203 0:3d9c67d97d6f 298 }
emh203 0:3d9c67d97d6f 299
emh203 0:3d9c67d97d6f 300 /* Points to the pivot row of input and destination matrices */
emh203 0:3d9c67d97d6f 301 pPivotRowIn = pIn + (l * numCols);
emh203 0:3d9c67d97d6f 302 pPivotRowDst = pOut + (l * numCols);
emh203 0:3d9c67d97d6f 303
emh203 0:3d9c67d97d6f 304 /* Temporary pointers to the pivot row pointers */
emh203 0:3d9c67d97d6f 305 pInT1 = pPivotRowIn;
emh203 0:3d9c67d97d6f 306 pInT2 = pPivotRowDst;
emh203 0:3d9c67d97d6f 307
emh203 0:3d9c67d97d6f 308 /* Pivot element of the row */
emh203 0:3d9c67d97d6f 309 in = *pPivotRowIn;
emh203 0:3d9c67d97d6f 310
emh203 0:3d9c67d97d6f 311 /* Loop over number of columns
emh203 0:3d9c67d97d6f 312 * to the right of the pilot element */
emh203 0:3d9c67d97d6f 313 j = (numCols - l);
emh203 0:3d9c67d97d6f 314
emh203 0:3d9c67d97d6f 315 while(j > 0u)
emh203 0:3d9c67d97d6f 316 {
emh203 0:3d9c67d97d6f 317 /* Divide each element of the row of the input matrix
emh203 0:3d9c67d97d6f 318 * by the pivot element */
emh203 0:3d9c67d97d6f 319 in1 = *pInT1;
emh203 0:3d9c67d97d6f 320 *pInT1++ = in1 / in;
emh203 0:3d9c67d97d6f 321
emh203 0:3d9c67d97d6f 322 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 323 j--;
emh203 0:3d9c67d97d6f 324 }
emh203 0:3d9c67d97d6f 325
emh203 0:3d9c67d97d6f 326 /* Loop over number of columns of the destination matrix */
emh203 0:3d9c67d97d6f 327 j = numCols;
emh203 0:3d9c67d97d6f 328
emh203 0:3d9c67d97d6f 329 while(j > 0u)
emh203 0:3d9c67d97d6f 330 {
emh203 0:3d9c67d97d6f 331 /* Divide each element of the row of the destination matrix
emh203 0:3d9c67d97d6f 332 * by the pivot element */
emh203 0:3d9c67d97d6f 333 in1 = *pInT2;
emh203 0:3d9c67d97d6f 334 *pInT2++ = in1 / in;
emh203 0:3d9c67d97d6f 335
emh203 0:3d9c67d97d6f 336 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 337 j--;
emh203 0:3d9c67d97d6f 338 }
emh203 0:3d9c67d97d6f 339
emh203 0:3d9c67d97d6f 340 /* Replace the rows with the sum of that row and a multiple of row i
emh203 0:3d9c67d97d6f 341 * so that each new element in column i above row i is zero.*/
emh203 0:3d9c67d97d6f 342
emh203 0:3d9c67d97d6f 343 /* Temporary pointers for input and destination matrices */
emh203 0:3d9c67d97d6f 344 pInT1 = pIn;
emh203 0:3d9c67d97d6f 345 pInT2 = pOut;
emh203 0:3d9c67d97d6f 346
emh203 0:3d9c67d97d6f 347 /* index used to check for pivot element */
emh203 0:3d9c67d97d6f 348 i = 0u;
emh203 0:3d9c67d97d6f 349
emh203 0:3d9c67d97d6f 350 /* Loop over number of rows */
emh203 0:3d9c67d97d6f 351 /* to be replaced by the sum of that row and a multiple of row i */
emh203 0:3d9c67d97d6f 352 k = numRows;
emh203 0:3d9c67d97d6f 353
emh203 0:3d9c67d97d6f 354 while(k > 0u)
emh203 0:3d9c67d97d6f 355 {
emh203 0:3d9c67d97d6f 356 /* Check for the pivot element */
emh203 0:3d9c67d97d6f 357 if(i == l)
emh203 0:3d9c67d97d6f 358 {
emh203 0:3d9c67d97d6f 359 /* If the processing element is the pivot element,
emh203 0:3d9c67d97d6f 360 only the columns to the right are to be processed */
emh203 0:3d9c67d97d6f 361 pInT1 += numCols - l;
emh203 0:3d9c67d97d6f 362
emh203 0:3d9c67d97d6f 363 pInT2 += numCols;
emh203 0:3d9c67d97d6f 364 }
emh203 0:3d9c67d97d6f 365 else
emh203 0:3d9c67d97d6f 366 {
emh203 0:3d9c67d97d6f 367 /* Element of the reference row */
emh203 0:3d9c67d97d6f 368 in = *pInT1;
emh203 0:3d9c67d97d6f 369
emh203 0:3d9c67d97d6f 370 /* Working pointers for input and destination pivot rows */
emh203 0:3d9c67d97d6f 371 pPRT_in = pPivotRowIn;
emh203 0:3d9c67d97d6f 372 pPRT_pDst = pPivotRowDst;
emh203 0:3d9c67d97d6f 373
emh203 0:3d9c67d97d6f 374 /* Loop over the number of columns to the right of the pivot element,
emh203 0:3d9c67d97d6f 375 to replace the elements in the input matrix */
emh203 0:3d9c67d97d6f 376 j = (numCols - l);
emh203 0:3d9c67d97d6f 377
emh203 0:3d9c67d97d6f 378 while(j > 0u)
emh203 0:3d9c67d97d6f 379 {
emh203 0:3d9c67d97d6f 380 /* Replace the element by the sum of that row
emh203 0:3d9c67d97d6f 381 and a multiple of the reference row */
emh203 0:3d9c67d97d6f 382 in1 = *pInT1;
emh203 0:3d9c67d97d6f 383 *pInT1++ = in1 - (in * *pPRT_in++);
emh203 0:3d9c67d97d6f 384
emh203 0:3d9c67d97d6f 385 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 386 j--;
emh203 0:3d9c67d97d6f 387 }
emh203 0:3d9c67d97d6f 388
emh203 0:3d9c67d97d6f 389 /* Loop over the number of columns to
emh203 0:3d9c67d97d6f 390 replace the elements in the destination matrix */
emh203 0:3d9c67d97d6f 391 j = numCols;
emh203 0:3d9c67d97d6f 392
emh203 0:3d9c67d97d6f 393 while(j > 0u)
emh203 0:3d9c67d97d6f 394 {
emh203 0:3d9c67d97d6f 395 /* Replace the element by the sum of that row
emh203 0:3d9c67d97d6f 396 and a multiple of the reference row */
emh203 0:3d9c67d97d6f 397 in1 = *pInT2;
emh203 0:3d9c67d97d6f 398 *pInT2++ = in1 - (in * *pPRT_pDst++);
emh203 0:3d9c67d97d6f 399
emh203 0:3d9c67d97d6f 400 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 401 j--;
emh203 0:3d9c67d97d6f 402 }
emh203 0:3d9c67d97d6f 403
emh203 0:3d9c67d97d6f 404 }
emh203 0:3d9c67d97d6f 405
emh203 0:3d9c67d97d6f 406 /* Increment the temporary input pointer */
emh203 0:3d9c67d97d6f 407 pInT1 = pInT1 + l;
emh203 0:3d9c67d97d6f 408
emh203 0:3d9c67d97d6f 409 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 410 k--;
emh203 0:3d9c67d97d6f 411
emh203 0:3d9c67d97d6f 412 /* Increment the pivot index */
emh203 0:3d9c67d97d6f 413 i++;
emh203 0:3d9c67d97d6f 414 }
emh203 0:3d9c67d97d6f 415
emh203 0:3d9c67d97d6f 416 /* Increment the input pointer */
emh203 0:3d9c67d97d6f 417 pIn++;
emh203 0:3d9c67d97d6f 418
emh203 0:3d9c67d97d6f 419 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 420 loopCnt--;
emh203 0:3d9c67d97d6f 421
emh203 0:3d9c67d97d6f 422 /* Increment the index modifier */
emh203 0:3d9c67d97d6f 423 l++;
emh203 0:3d9c67d97d6f 424 }
emh203 0:3d9c67d97d6f 425
emh203 0:3d9c67d97d6f 426
emh203 0:3d9c67d97d6f 427 #else
emh203 0:3d9c67d97d6f 428
emh203 0:3d9c67d97d6f 429 /* Run the below code for Cortex-M0 */
emh203 0:3d9c67d97d6f 430
emh203 0:3d9c67d97d6f 431 float32_t Xchg, in = 0.0f; /* Temporary input values */
emh203 0:3d9c67d97d6f 432 uint32_t i, rowCnt, flag = 0u, j, loopCnt, k, l; /* loop counters */
emh203 0:3d9c67d97d6f 433 arm_status status; /* status of matrix inverse */
emh203 0:3d9c67d97d6f 434
emh203 0:3d9c67d97d6f 435 #ifdef ARM_MATH_MATRIX_CHECK
emh203 0:3d9c67d97d6f 436
emh203 0:3d9c67d97d6f 437 /* Check for matrix mismatch condition */
emh203 0:3d9c67d97d6f 438 if((pSrc->numRows != pSrc->numCols) || (pDst->numRows != pDst->numCols)
emh203 0:3d9c67d97d6f 439 || (pSrc->numRows != pDst->numRows))
emh203 0:3d9c67d97d6f 440 {
emh203 0:3d9c67d97d6f 441 /* Set status as ARM_MATH_SIZE_MISMATCH */
emh203 0:3d9c67d97d6f 442 status = ARM_MATH_SIZE_MISMATCH;
emh203 0:3d9c67d97d6f 443 }
emh203 0:3d9c67d97d6f 444 else
emh203 0:3d9c67d97d6f 445 #endif /* #ifdef ARM_MATH_MATRIX_CHECK */
emh203 0:3d9c67d97d6f 446 {
emh203 0:3d9c67d97d6f 447
emh203 0:3d9c67d97d6f 448 /*--------------------------------------------------------------------------------------------------------------
emh203 0:3d9c67d97d6f 449 * Matrix Inverse can be solved using elementary row operations.
emh203 0:3d9c67d97d6f 450 *
emh203 0:3d9c67d97d6f 451 * Gauss-Jordan Method:
emh203 0:3d9c67d97d6f 452 *
emh203 0:3d9c67d97d6f 453 * 1. First combine the identity matrix and the input matrix separated by a bar to form an
emh203 0:3d9c67d97d6f 454 * augmented matrix as follows:
emh203 0:3d9c67d97d6f 455 * _ _ _ _ _ _ _ _
emh203 0:3d9c67d97d6f 456 * | | a11 a12 | | | 1 0 | | | X11 X12 |
emh203 0:3d9c67d97d6f 457 * | | | | | | | = | |
emh203 0:3d9c67d97d6f 458 * |_ |_ a21 a22 _| | |_0 1 _| _| |_ X21 X21 _|
emh203 0:3d9c67d97d6f 459 *
emh203 0:3d9c67d97d6f 460 * 2. In our implementation, pDst Matrix is used as identity matrix.
emh203 0:3d9c67d97d6f 461 *
emh203 0:3d9c67d97d6f 462 * 3. Begin with the first row. Let i = 1.
emh203 0:3d9c67d97d6f 463 *
emh203 0:3d9c67d97d6f 464 * 4. Check to see if the pivot for row i is zero.
emh203 0:3d9c67d97d6f 465 * The pivot is the element of the main diagonal that is on the current row.
emh203 0:3d9c67d97d6f 466 * For instance, if working with row i, then the pivot element is aii.
emh203 0:3d9c67d97d6f 467 * If the pivot is zero, exchange that row with a row below it that does not
emh203 0:3d9c67d97d6f 468 * contain a zero in column i. If this is not possible, then an inverse
emh203 0:3d9c67d97d6f 469 * to that matrix does not exist.
emh203 0:3d9c67d97d6f 470 *
emh203 0:3d9c67d97d6f 471 * 5. Divide every element of row i by the pivot.
emh203 0:3d9c67d97d6f 472 *
emh203 0:3d9c67d97d6f 473 * 6. For every row below and row i, replace that row with the sum of that row and
emh203 0:3d9c67d97d6f 474 * a multiple of row i so that each new element in column i below row i is zero.
emh203 0:3d9c67d97d6f 475 *
emh203 0:3d9c67d97d6f 476 * 7. Move to the next row and column and repeat steps 2 through 5 until you have zeros
emh203 0:3d9c67d97d6f 477 * for every element below and above the main diagonal.
emh203 0:3d9c67d97d6f 478 *
emh203 0:3d9c67d97d6f 479 * 8. Now an identical matrix is formed to the left of the bar(input matrix, src).
emh203 0:3d9c67d97d6f 480 * Therefore, the matrix to the right of the bar is our solution(dst matrix, dst).
emh203 0:3d9c67d97d6f 481 *----------------------------------------------------------------------------------------------------------------*/
emh203 0:3d9c67d97d6f 482
emh203 0:3d9c67d97d6f 483 /* Working pointer for destination matrix */
emh203 0:3d9c67d97d6f 484 pOutT1 = pOut;
emh203 0:3d9c67d97d6f 485
emh203 0:3d9c67d97d6f 486 /* Loop over the number of rows */
emh203 0:3d9c67d97d6f 487 rowCnt = numRows;
emh203 0:3d9c67d97d6f 488
emh203 0:3d9c67d97d6f 489 /* Making the destination matrix as identity matrix */
emh203 0:3d9c67d97d6f 490 while(rowCnt > 0u)
emh203 0:3d9c67d97d6f 491 {
emh203 0:3d9c67d97d6f 492 /* Writing all zeroes in lower triangle of the destination matrix */
emh203 0:3d9c67d97d6f 493 j = numRows - rowCnt;
emh203 0:3d9c67d97d6f 494 while(j > 0u)
emh203 0:3d9c67d97d6f 495 {
emh203 0:3d9c67d97d6f 496 *pOutT1++ = 0.0f;
emh203 0:3d9c67d97d6f 497 j--;
emh203 0:3d9c67d97d6f 498 }
emh203 0:3d9c67d97d6f 499
emh203 0:3d9c67d97d6f 500 /* Writing all ones in the diagonal of the destination matrix */
emh203 0:3d9c67d97d6f 501 *pOutT1++ = 1.0f;
emh203 0:3d9c67d97d6f 502
emh203 0:3d9c67d97d6f 503 /* Writing all zeroes in upper triangle of the destination matrix */
emh203 0:3d9c67d97d6f 504 j = rowCnt - 1u;
emh203 0:3d9c67d97d6f 505 while(j > 0u)
emh203 0:3d9c67d97d6f 506 {
emh203 0:3d9c67d97d6f 507 *pOutT1++ = 0.0f;
emh203 0:3d9c67d97d6f 508 j--;
emh203 0:3d9c67d97d6f 509 }
emh203 0:3d9c67d97d6f 510
emh203 0:3d9c67d97d6f 511 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 512 rowCnt--;
emh203 0:3d9c67d97d6f 513 }
emh203 0:3d9c67d97d6f 514
emh203 0:3d9c67d97d6f 515 /* Loop over the number of columns of the input matrix.
emh203 0:3d9c67d97d6f 516 All the elements in each column are processed by the row operations */
emh203 0:3d9c67d97d6f 517 loopCnt = numCols;
emh203 0:3d9c67d97d6f 518
emh203 0:3d9c67d97d6f 519 /* Index modifier to navigate through the columns */
emh203 0:3d9c67d97d6f 520 l = 0u;
emh203 0:3d9c67d97d6f 521 //for(loopCnt = 0u; loopCnt < numCols; loopCnt++)
emh203 0:3d9c67d97d6f 522 while(loopCnt > 0u)
emh203 0:3d9c67d97d6f 523 {
emh203 0:3d9c67d97d6f 524 /* Check if the pivot element is zero..
emh203 0:3d9c67d97d6f 525 * If it is zero then interchange the row with non zero row below.
emh203 0:3d9c67d97d6f 526 * If there is no non zero element to replace in the rows below,
emh203 0:3d9c67d97d6f 527 * then the matrix is Singular. */
emh203 0:3d9c67d97d6f 528
emh203 0:3d9c67d97d6f 529 /* Working pointer for the input matrix that points
emh203 0:3d9c67d97d6f 530 * to the pivot element of the particular row */
emh203 0:3d9c67d97d6f 531 pInT1 = pIn + (l * numCols);
emh203 0:3d9c67d97d6f 532
emh203 0:3d9c67d97d6f 533 /* Working pointer for the destination matrix that points
emh203 0:3d9c67d97d6f 534 * to the pivot element of the particular row */
emh203 0:3d9c67d97d6f 535 pOutT1 = pOut + (l * numCols);
emh203 0:3d9c67d97d6f 536
emh203 0:3d9c67d97d6f 537 /* Temporary variable to hold the pivot value */
emh203 0:3d9c67d97d6f 538 in = *pInT1;
emh203 0:3d9c67d97d6f 539
emh203 0:3d9c67d97d6f 540 /* Destination pointer modifier */
emh203 0:3d9c67d97d6f 541 k = 1u;
emh203 0:3d9c67d97d6f 542
emh203 0:3d9c67d97d6f 543 /* Check if the pivot element is zero */
emh203 0:3d9c67d97d6f 544 if(*pInT1 == 0.0f)
emh203 0:3d9c67d97d6f 545 {
emh203 0:3d9c67d97d6f 546 /* Loop over the number rows present below */
emh203 0:3d9c67d97d6f 547 for (i = (l + 1u); i < numRows; i++)
emh203 0:3d9c67d97d6f 548 {
emh203 0:3d9c67d97d6f 549 /* Update the input and destination pointers */
emh203 0:3d9c67d97d6f 550 pInT2 = pInT1 + (numCols * l);
emh203 0:3d9c67d97d6f 551 pOutT2 = pOutT1 + (numCols * k);
emh203 0:3d9c67d97d6f 552
emh203 0:3d9c67d97d6f 553 /* Check if there is a non zero pivot element to
emh203 0:3d9c67d97d6f 554 * replace in the rows below */
emh203 0:3d9c67d97d6f 555 if(*pInT2 != 0.0f)
emh203 0:3d9c67d97d6f 556 {
emh203 0:3d9c67d97d6f 557 /* Loop over number of columns
emh203 0:3d9c67d97d6f 558 * to the right of the pilot element */
emh203 0:3d9c67d97d6f 559 for (j = 0u; j < (numCols - l); j++)
emh203 0:3d9c67d97d6f 560 {
emh203 0:3d9c67d97d6f 561 /* Exchange the row elements of the input matrix */
emh203 0:3d9c67d97d6f 562 Xchg = *pInT2;
emh203 0:3d9c67d97d6f 563 *pInT2++ = *pInT1;
emh203 0:3d9c67d97d6f 564 *pInT1++ = Xchg;
emh203 0:3d9c67d97d6f 565 }
emh203 0:3d9c67d97d6f 566
emh203 0:3d9c67d97d6f 567 for (j = 0u; j < numCols; j++)
emh203 0:3d9c67d97d6f 568 {
emh203 0:3d9c67d97d6f 569 Xchg = *pOutT2;
emh203 0:3d9c67d97d6f 570 *pOutT2++ = *pOutT1;
emh203 0:3d9c67d97d6f 571 *pOutT1++ = Xchg;
emh203 0:3d9c67d97d6f 572 }
emh203 0:3d9c67d97d6f 573
emh203 0:3d9c67d97d6f 574 /* Flag to indicate whether exchange is done or not */
emh203 0:3d9c67d97d6f 575 flag = 1u;
emh203 0:3d9c67d97d6f 576
emh203 0:3d9c67d97d6f 577 /* Break after exchange is done */
emh203 0:3d9c67d97d6f 578 break;
emh203 0:3d9c67d97d6f 579 }
emh203 0:3d9c67d97d6f 580
emh203 0:3d9c67d97d6f 581 /* Update the destination pointer modifier */
emh203 0:3d9c67d97d6f 582 k++;
emh203 0:3d9c67d97d6f 583 }
emh203 0:3d9c67d97d6f 584 }
emh203 0:3d9c67d97d6f 585
emh203 0:3d9c67d97d6f 586 /* Update the status if the matrix is singular */
emh203 0:3d9c67d97d6f 587 if((flag != 1u) && (in == 0.0f))
emh203 0:3d9c67d97d6f 588 {
emh203 0:3d9c67d97d6f 589 return ARM_MATH_SINGULAR;
emh203 0:3d9c67d97d6f 590 }
emh203 0:3d9c67d97d6f 591
emh203 0:3d9c67d97d6f 592 /* Points to the pivot row of input and destination matrices */
emh203 0:3d9c67d97d6f 593 pPivotRowIn = pIn + (l * numCols);
emh203 0:3d9c67d97d6f 594 pPivotRowDst = pOut + (l * numCols);
emh203 0:3d9c67d97d6f 595
emh203 0:3d9c67d97d6f 596 /* Temporary pointers to the pivot row pointers */
emh203 0:3d9c67d97d6f 597 pInT1 = pPivotRowIn;
emh203 0:3d9c67d97d6f 598 pOutT1 = pPivotRowDst;
emh203 0:3d9c67d97d6f 599
emh203 0:3d9c67d97d6f 600 /* Pivot element of the row */
emh203 0:3d9c67d97d6f 601 in = *(pIn + (l * numCols));
emh203 0:3d9c67d97d6f 602
emh203 0:3d9c67d97d6f 603 /* Loop over number of columns
emh203 0:3d9c67d97d6f 604 * to the right of the pilot element */
emh203 0:3d9c67d97d6f 605 for (j = 0u; j < (numCols - l); j++)
emh203 0:3d9c67d97d6f 606 {
emh203 0:3d9c67d97d6f 607 /* Divide each element of the row of the input matrix
emh203 0:3d9c67d97d6f 608 * by the pivot element */
emh203 0:3d9c67d97d6f 609 *pInT1 = *pInT1 / in;
emh203 0:3d9c67d97d6f 610 pInT1++;
emh203 0:3d9c67d97d6f 611 }
emh203 0:3d9c67d97d6f 612 for (j = 0u; j < numCols; j++)
emh203 0:3d9c67d97d6f 613 {
emh203 0:3d9c67d97d6f 614 /* Divide each element of the row of the destination matrix
emh203 0:3d9c67d97d6f 615 * by the pivot element */
emh203 0:3d9c67d97d6f 616 *pOutT1 = *pOutT1 / in;
emh203 0:3d9c67d97d6f 617 pOutT1++;
emh203 0:3d9c67d97d6f 618 }
emh203 0:3d9c67d97d6f 619
emh203 0:3d9c67d97d6f 620 /* Replace the rows with the sum of that row and a multiple of row i
emh203 0:3d9c67d97d6f 621 * so that each new element in column i above row i is zero.*/
emh203 0:3d9c67d97d6f 622
emh203 0:3d9c67d97d6f 623 /* Temporary pointers for input and destination matrices */
emh203 0:3d9c67d97d6f 624 pInT1 = pIn;
emh203 0:3d9c67d97d6f 625 pOutT1 = pOut;
emh203 0:3d9c67d97d6f 626
emh203 0:3d9c67d97d6f 627 for (i = 0u; i < numRows; i++)
emh203 0:3d9c67d97d6f 628 {
emh203 0:3d9c67d97d6f 629 /* Check for the pivot element */
emh203 0:3d9c67d97d6f 630 if(i == l)
emh203 0:3d9c67d97d6f 631 {
emh203 0:3d9c67d97d6f 632 /* If the processing element is the pivot element,
emh203 0:3d9c67d97d6f 633 only the columns to the right are to be processed */
emh203 0:3d9c67d97d6f 634 pInT1 += numCols - l;
emh203 0:3d9c67d97d6f 635 pOutT1 += numCols;
emh203 0:3d9c67d97d6f 636 }
emh203 0:3d9c67d97d6f 637 else
emh203 0:3d9c67d97d6f 638 {
emh203 0:3d9c67d97d6f 639 /* Element of the reference row */
emh203 0:3d9c67d97d6f 640 in = *pInT1;
emh203 0:3d9c67d97d6f 641
emh203 0:3d9c67d97d6f 642 /* Working pointers for input and destination pivot rows */
emh203 0:3d9c67d97d6f 643 pPRT_in = pPivotRowIn;
emh203 0:3d9c67d97d6f 644 pPRT_pDst = pPivotRowDst;
emh203 0:3d9c67d97d6f 645
emh203 0:3d9c67d97d6f 646 /* Loop over the number of columns to the right of the pivot element,
emh203 0:3d9c67d97d6f 647 to replace the elements in the input matrix */
emh203 0:3d9c67d97d6f 648 for (j = 0u; j < (numCols - l); j++)
emh203 0:3d9c67d97d6f 649 {
emh203 0:3d9c67d97d6f 650 /* Replace the element by the sum of that row
emh203 0:3d9c67d97d6f 651 and a multiple of the reference row */
emh203 0:3d9c67d97d6f 652 *pInT1 = *pInT1 - (in * *pPRT_in++);
emh203 0:3d9c67d97d6f 653 pInT1++;
emh203 0:3d9c67d97d6f 654 }
emh203 0:3d9c67d97d6f 655 /* Loop over the number of columns to
emh203 0:3d9c67d97d6f 656 replace the elements in the destination matrix */
emh203 0:3d9c67d97d6f 657 for (j = 0u; j < numCols; j++)
emh203 0:3d9c67d97d6f 658 {
emh203 0:3d9c67d97d6f 659 /* Replace the element by the sum of that row
emh203 0:3d9c67d97d6f 660 and a multiple of the reference row */
emh203 0:3d9c67d97d6f 661 *pOutT1 = *pOutT1 - (in * *pPRT_pDst++);
emh203 0:3d9c67d97d6f 662 pOutT1++;
emh203 0:3d9c67d97d6f 663 }
emh203 0:3d9c67d97d6f 664
emh203 0:3d9c67d97d6f 665 }
emh203 0:3d9c67d97d6f 666 /* Increment the temporary input pointer */
emh203 0:3d9c67d97d6f 667 pInT1 = pInT1 + l;
emh203 0:3d9c67d97d6f 668 }
emh203 0:3d9c67d97d6f 669 /* Increment the input pointer */
emh203 0:3d9c67d97d6f 670 pIn++;
emh203 0:3d9c67d97d6f 671
emh203 0:3d9c67d97d6f 672 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 673 loopCnt--;
emh203 0:3d9c67d97d6f 674 /* Increment the index modifier */
emh203 0:3d9c67d97d6f 675 l++;
emh203 0:3d9c67d97d6f 676 }
emh203 0:3d9c67d97d6f 677
emh203 0:3d9c67d97d6f 678
emh203 0:3d9c67d97d6f 679 #endif /* #ifndef ARM_MATH_CM0_FAMILY */
emh203 0:3d9c67d97d6f 680
emh203 0:3d9c67d97d6f 681 /* Set status as ARM_MATH_SUCCESS */
emh203 0:3d9c67d97d6f 682 status = ARM_MATH_SUCCESS;
emh203 0:3d9c67d97d6f 683
emh203 0:3d9c67d97d6f 684 if((flag != 1u) && (in == 0.0f))
emh203 0:3d9c67d97d6f 685 {
emh203 0:3d9c67d97d6f 686 status = ARM_MATH_SINGULAR;
emh203 0:3d9c67d97d6f 687 }
emh203 0:3d9c67d97d6f 688 }
emh203 0:3d9c67d97d6f 689 /* Return to application */
emh203 0:3d9c67d97d6f 690 return (status);
emh203 0:3d9c67d97d6f 691 }
emh203 0:3d9c67d97d6f 692
emh203 0:3d9c67d97d6f 693 /**
emh203 0:3d9c67d97d6f 694 * @} end of MatrixInv group
emh203 0:3d9c67d97d6f 695 */