CMSIS DSP library

Dependents:   KL25Z_FFT_Demo Hat_Board_v5_1 KL25Z_FFT_Demo_tony KL25Z_FFT_Demo_tony ... more

Fork of mbed-dsp by mbed official

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers arm_mat_inverse_f32.c Source File

arm_mat_inverse_f32.c

00001 /* ----------------------------------------------------------------------    
00002 * Copyright (C) 2010-2013 ARM Limited. All rights reserved.    
00003 *    
00004 * $Date:        1. March 2013 
00005 * $Revision:    V1.4.1
00006 *    
00007 * Project:      CMSIS DSP Library    
00008 * Title:        arm_mat_inverse_f32.c    
00009 *    
00010 * Description:  Floating-point matrix inverse.    
00011 *    
00012 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
00013 *  
00014 * Redistribution and use in source and binary forms, with or without 
00015 * modification, are permitted provided that the following conditions
00016 * are met:
00017 *   - Redistributions of source code must retain the above copyright
00018 *     notice, this list of conditions and the following disclaimer.
00019 *   - Redistributions in binary form must reproduce the above copyright
00020 *     notice, this list of conditions and the following disclaimer in
00021 *     the documentation and/or other materials provided with the 
00022 *     distribution.
00023 *   - Neither the name of ARM LIMITED nor the names of its contributors
00024 *     may be used to endorse or promote products derived from this
00025 *     software without specific prior written permission.
00026 *
00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00028 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00029 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00030 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
00031 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00032 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00033 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00034 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00036 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00037 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00038 * POSSIBILITY OF SUCH DAMAGE.    
00039 * -------------------------------------------------------------------- */
00040 
00041 #include "arm_math.h"
00042 
00043 /**    
00044  * @ingroup groupMatrix    
00045  */
00046 
00047 /**    
00048  * @defgroup MatrixInv Matrix Inverse    
00049  *    
00050  * Computes the inverse of a matrix.    
00051  *    
00052  * The inverse is defined only if the input matrix is square and non-singular (the determinant    
00053  * is non-zero). The function checks that the input and output matrices are square and of the    
00054  * same size.    
00055  *    
00056  * Matrix inversion is numerically sensitive and the CMSIS DSP library only supports matrix    
00057  * inversion of floating-point matrices.    
00058  *    
00059  * \par Algorithm    
00060  * The Gauss-Jordan method is used to find the inverse.    
00061  * The algorithm performs a sequence of elementary row-operations till it    
00062  * reduces the input matrix to an identity matrix. Applying the same sequence    
00063  * of elementary row-operations to an identity matrix yields the inverse matrix.    
00064  * If the input matrix is singular, then the algorithm terminates and returns error status    
00065  * <code>ARM_MATH_SINGULAR</code>.    
00066  * \image html MatrixInverse.gif "Matrix Inverse of a 3 x 3 matrix using Gauss-Jordan Method"    
00067  */
00068 
00069 /**    
00070  * @addtogroup MatrixInv    
00071  * @{    
00072  */
00073 
00074 /**    
00075  * @brief Floating-point matrix inverse.    
00076  * @param[in]       *pSrc points to input matrix structure    
00077  * @param[out]      *pDst points to output matrix structure    
00078  * @return          The function returns    
00079  * <code>ARM_MATH_SIZE_MISMATCH</code> if the input matrix is not square or if the size    
00080  * of the output matrix does not match the size of the input matrix.    
00081  * If the input matrix is found to be singular (non-invertible), then the function returns    
00082  * <code>ARM_MATH_SINGULAR</code>.  Otherwise, the function returns <code>ARM_MATH_SUCCESS</code>.    
00083  */
00084 
00085 arm_status arm_mat_inverse_f32(
00086   const arm_matrix_instance_f32 * pSrc,
00087   arm_matrix_instance_f32 * pDst)
00088 {
00089   float32_t *pIn = pSrc->pData;                  /* input data matrix pointer */
00090   float32_t *pOut = pDst->pData;                 /* output data matrix pointer */
00091   float32_t *pInT1, *pInT2;                      /* Temporary input data matrix pointer */
00092   float32_t *pInT3, *pInT4;                      /* Temporary output data matrix pointer */
00093   float32_t *pPivotRowIn, *pPRT_in, *pPivotRowDst, *pPRT_pDst;  /* Temporary input and output data matrix pointer */
00094   uint32_t numRows = pSrc->numRows;              /* Number of rows in the matrix  */
00095   uint32_t numCols = pSrc->numCols;              /* Number of Cols in the matrix  */
00096 
00097 #ifndef ARM_MATH_CM0_FAMILY
00098   float32_t maxC;                                /* maximum value in the column */
00099 
00100   /* Run the below code for Cortex-M4 and Cortex-M3 */
00101 
00102   float32_t Xchg, in = 0.0f, in1;                /* Temporary input values  */
00103   uint32_t i, rowCnt, flag = 0u, j, loopCnt, k, l;      /* loop counters */
00104   arm_status status;                             /* status of matrix inverse */
00105 
00106 #ifdef ARM_MATH_MATRIX_CHECK
00107 
00108 
00109   /* Check for matrix mismatch condition */
00110   if((pSrc->numRows != pSrc->numCols) || (pDst->numRows != pDst->numCols)
00111      || (pSrc->numRows != pDst->numRows))
00112   {
00113     /* Set status as ARM_MATH_SIZE_MISMATCH */
00114     status = ARM_MATH_SIZE_MISMATCH;
00115   }
00116   else
00117 #endif /*    #ifdef ARM_MATH_MATRIX_CHECK    */
00118 
00119   {
00120 
00121     /*--------------------------------------------------------------------------------------------------------------    
00122      * Matrix Inverse can be solved using elementary row operations.    
00123      *    
00124      *  Gauss-Jordan Method:    
00125      *    
00126      *     1. First combine the identity matrix and the input matrix separated by a bar to form an    
00127      *        augmented matrix as follows:    
00128      *                      _                  _         _         _    
00129      *                     |  a11  a12 | 1   0  |       |  X11 X12  |    
00130      *                     |           |        |   =   |           |    
00131      *                     |_ a21  a22 | 0   1 _|       |_ X21 X21 _|    
00132      *    
00133      *      2. In our implementation, pDst Matrix is used as identity matrix.    
00134      *    
00135      *      3. Begin with the first row. Let i = 1.    
00136      *    
00137      *      4. Check to see if the pivot for column i is the greatest of the column.    
00138      *         The pivot is the element of the main diagonal that is on the current row.    
00139      *         For instance, if working with row i, then the pivot element is aii.    
00140      *         If the pivot is not the most significant of the coluimns, exchange that row with a row
00141      *         below it that does contain the most significant value in column i. If the most
00142      *         significant value of the column is zero, then an inverse to that matrix does not exist.
00143      *         The most significant value of the column is the absolut maximum.
00144      *    
00145      *      5. Divide every element of row i by the pivot.    
00146      *    
00147      *      6. For every row below and  row i, replace that row with the sum of that row and    
00148      *         a multiple of row i so that each new element in column i below row i is zero.    
00149      *    
00150      *      7. Move to the next row and column and repeat steps 2 through 5 until you have zeros    
00151      *         for every element below and above the main diagonal.    
00152      *    
00153      *      8. Now an identical matrix is formed to the left of the bar(input matrix, pSrc).    
00154      *         Therefore, the matrix to the right of the bar is our solution(pDst matrix, pDst).    
00155      *----------------------------------------------------------------------------------------------------------------*/
00156 
00157     /* Working pointer for destination matrix */
00158     pInT2 = pOut;
00159 
00160     /* Loop over the number of rows */
00161     rowCnt = numRows;
00162 
00163     /* Making the destination matrix as identity matrix */
00164     while(rowCnt > 0u)
00165     {
00166       /* Writing all zeroes in lower triangle of the destination matrix */
00167       j = numRows - rowCnt;
00168       while(j > 0u)
00169       {
00170         *pInT2++ = 0.0f;
00171         j--;
00172       }
00173 
00174       /* Writing all ones in the diagonal of the destination matrix */
00175       *pInT2++ = 1.0f;
00176 
00177       /* Writing all zeroes in upper triangle of the destination matrix */
00178       j = rowCnt - 1u;
00179       while(j > 0u)
00180       {
00181         *pInT2++ = 0.0f;
00182         j--;
00183       }
00184 
00185       /* Decrement the loop counter */
00186       rowCnt--;
00187     }
00188 
00189     /* Loop over the number of columns of the input matrix.    
00190        All the elements in each column are processed by the row operations */
00191     loopCnt = numCols;
00192 
00193     /* Index modifier to navigate through the columns */
00194     l = 0u;
00195 
00196     while(loopCnt > 0u)
00197     {
00198       /* Check if the pivot element is zero..    
00199        * If it is zero then interchange the row with non zero row below.    
00200        * If there is no non zero element to replace in the rows below,    
00201        * then the matrix is Singular. */
00202 
00203       /* Working pointer for the input matrix that points    
00204        * to the pivot element of the particular row  */
00205       pInT1 = pIn + (l * numCols);
00206 
00207       /* Working pointer for the destination matrix that points    
00208        * to the pivot element of the particular row  */
00209       pInT3 = pOut + (l * numCols);
00210 
00211       /* Temporary variable to hold the pivot value */
00212       in = *pInT1;
00213 
00214       /* Destination pointer modifier */
00215       k = 1u;
00216 
00217      /* Grab the most significant value from column l */
00218       maxC = 0;
00219       for (i = 0; i < numRows; i++)
00220       {
00221         maxC = *pInT1 > 0 ? (*pInT1 > maxC ? *pInT1 : maxC) : (-*pInT1 > maxC ? -*pInT1 : maxC);
00222         pInT1 += numCols;
00223       }
00224 
00225       /* Update the status if the matrix is singular */
00226       if(maxC == 0.0f)
00227       {
00228         status = ARM_MATH_SINGULAR;
00229         break;
00230       }
00231 
00232       /* Restore pInT1  */
00233       pInT1 -= numRows * numCols;
00234       
00235       /* Check if the pivot element is the most significant of the column */
00236       if( (in > 0.0f ? in : -in) != maxC)
00237       {
00238         /* Loop over the number rows present below */
00239         i = numRows - (l + 1u);
00240 
00241         while(i > 0u)
00242         {
00243           /* Update the input and destination pointers */
00244           pInT2 = pInT1 + (numCols * l);
00245           pInT4 = pInT3 + (numCols * k);
00246 
00247           /* Look for the most significant element to    
00248            * replace in the rows below */
00249           if((*pInT2 > 0.0f ? *pInT2: -*pInT2) == maxC)
00250           {
00251             /* Loop over number of columns    
00252              * to the right of the pilot element */
00253             j = numCols - l;
00254 
00255             while(j > 0u)
00256             {
00257               /* Exchange the row elements of the input matrix */
00258               Xchg = *pInT2;
00259               *pInT2++ = *pInT1;
00260               *pInT1++ = Xchg;
00261 
00262               /* Decrement the loop counter */
00263               j--;
00264             }
00265 
00266             /* Loop over number of columns of the destination matrix */
00267             j = numCols;
00268 
00269             while(j > 0u)
00270             {
00271               /* Exchange the row elements of the destination matrix */
00272               Xchg = *pInT4;
00273               *pInT4++ = *pInT3;
00274               *pInT3++ = Xchg;
00275 
00276               /* Decrement the loop counter */
00277               j--;
00278             }
00279 
00280             /* Flag to indicate whether exchange is done or not */
00281             flag = 1u;
00282 
00283             /* Break after exchange is done */
00284             break;
00285           }
00286 
00287           /* Update the destination pointer modifier */
00288           k++;
00289 
00290           /* Decrement the loop counter */
00291           i--;
00292         }
00293       }
00294 
00295       /* Update the status if the matrix is singular */
00296       if((flag != 1u) && (in == 0.0f))
00297       {
00298         status = ARM_MATH_SINGULAR;
00299 
00300         break;
00301       }
00302 
00303       /* Points to the pivot row of input and destination matrices */
00304       pPivotRowIn = pIn + (l * numCols);
00305       pPivotRowDst = pOut + (l * numCols);
00306 
00307       /* Temporary pointers to the pivot row pointers */
00308       pInT1 = pPivotRowIn;
00309       pInT2 = pPivotRowDst;
00310 
00311       /* Pivot element of the row */
00312       in = *pPivotRowIn;
00313 
00314       /* Loop over number of columns    
00315        * to the right of the pilot element */
00316       j = (numCols - l);
00317 
00318       while(j > 0u)
00319       {
00320         /* Divide each element of the row of the input matrix    
00321          * by the pivot element */
00322         in1 = *pInT1;
00323         *pInT1++ = in1 / in;
00324 
00325         /* Decrement the loop counter */
00326         j--;
00327       }
00328 
00329       /* Loop over number of columns of the destination matrix */
00330       j = numCols;
00331 
00332       while(j > 0u)
00333       {
00334         /* Divide each element of the row of the destination matrix    
00335          * by the pivot element */
00336         in1 = *pInT2;
00337         *pInT2++ = in1 / in;
00338 
00339         /* Decrement the loop counter */
00340         j--;
00341       }
00342 
00343       /* Replace the rows with the sum of that row and a multiple of row i    
00344        * so that each new element in column i above row i is zero.*/
00345 
00346       /* Temporary pointers for input and destination matrices */
00347       pInT1 = pIn;
00348       pInT2 = pOut;
00349 
00350       /* index used to check for pivot element */
00351       i = 0u;
00352 
00353       /* Loop over number of rows */
00354       /*  to be replaced by the sum of that row and a multiple of row i */
00355       k = numRows;
00356 
00357       while(k > 0u)
00358       {
00359         /* Check for the pivot element */
00360         if(i == l)
00361         {
00362           /* If the processing element is the pivot element,    
00363              only the columns to the right are to be processed */
00364           pInT1 += numCols - l;
00365 
00366           pInT2 += numCols;
00367         }
00368         else
00369         {
00370           /* Element of the reference row */
00371           in = *pInT1;
00372 
00373           /* Working pointers for input and destination pivot rows */
00374           pPRT_in = pPivotRowIn;
00375           pPRT_pDst = pPivotRowDst;
00376 
00377           /* Loop over the number of columns to the right of the pivot element,    
00378              to replace the elements in the input matrix */
00379           j = (numCols - l);
00380 
00381           while(j > 0u)
00382           {
00383             /* Replace the element by the sum of that row    
00384                and a multiple of the reference row  */
00385             in1 = *pInT1;
00386             *pInT1++ = in1 - (in * *pPRT_in++);
00387 
00388             /* Decrement the loop counter */
00389             j--;
00390           }
00391 
00392           /* Loop over the number of columns to    
00393              replace the elements in the destination matrix */
00394           j = numCols;
00395 
00396           while(j > 0u)
00397           {
00398             /* Replace the element by the sum of that row    
00399                and a multiple of the reference row  */
00400             in1 = *pInT2;
00401             *pInT2++ = in1 - (in * *pPRT_pDst++);
00402 
00403             /* Decrement the loop counter */
00404             j--;
00405           }
00406 
00407         }
00408 
00409         /* Increment the temporary input pointer */
00410         pInT1 = pInT1 + l;
00411 
00412         /* Decrement the loop counter */
00413         k--;
00414 
00415         /* Increment the pivot index */
00416         i++;
00417       }
00418 
00419       /* Increment the input pointer */
00420       pIn++;
00421 
00422       /* Decrement the loop counter */
00423       loopCnt--;
00424 
00425       /* Increment the index modifier */
00426       l++;
00427     }
00428 
00429 
00430 #else
00431 
00432   /* Run the below code for Cortex-M0 */
00433 
00434   float32_t Xchg, in = 0.0f;                     /* Temporary input values  */
00435   uint32_t i, rowCnt, flag = 0u, j, loopCnt, k, l;      /* loop counters */
00436   arm_status status;                             /* status of matrix inverse */
00437 
00438 #ifdef ARM_MATH_MATRIX_CHECK
00439 
00440   /* Check for matrix mismatch condition */
00441   if((pSrc->numRows != pSrc->numCols) || (pDst->numRows != pDst->numCols)
00442      || (pSrc->numRows != pDst->numRows))
00443   {
00444     /* Set status as ARM_MATH_SIZE_MISMATCH */
00445     status = ARM_MATH_SIZE_MISMATCH;
00446   }
00447   else
00448 #endif /*      #ifdef ARM_MATH_MATRIX_CHECK    */
00449   {
00450 
00451     /*--------------------------------------------------------------------------------------------------------------       
00452      * Matrix Inverse can be solved using elementary row operations.        
00453      *        
00454      *  Gauss-Jordan Method:       
00455      *             
00456      *     1. First combine the identity matrix and the input matrix separated by a bar to form an        
00457      *        augmented matrix as follows:        
00458      *                      _  _          _     _      _   _         _         _       
00459      *                     |  |  a11  a12  | | | 1   0  |   |       |  X11 X12  |         
00460      *                     |  |            | | |        |   |   =   |           |        
00461      *                     |_ |_ a21  a22 _| | |_0   1 _|  _|       |_ X21 X21 _|       
00462      *                            
00463      *      2. In our implementation, pDst Matrix is used as identity matrix.    
00464      *       
00465      *      3. Begin with the first row. Let i = 1.       
00466      *       
00467      *      4. Check to see if the pivot for row i is zero.       
00468      *         The pivot is the element of the main diagonal that is on the current row.       
00469      *         For instance, if working with row i, then the pivot element is aii.       
00470      *         If the pivot is zero, exchange that row with a row below it that does not        
00471      *         contain a zero in column i. If this is not possible, then an inverse        
00472      *         to that matrix does not exist.       
00473      *         
00474      *      5. Divide every element of row i by the pivot.       
00475      *         
00476      *      6. For every row below and  row i, replace that row with the sum of that row and        
00477      *         a multiple of row i so that each new element in column i below row i is zero.       
00478      *         
00479      *      7. Move to the next row and column and repeat steps 2 through 5 until you have zeros       
00480      *         for every element below and above the main diagonal.        
00481      *                        
00482      *      8. Now an identical matrix is formed to the left of the bar(input matrix, src).       
00483      *         Therefore, the matrix to the right of the bar is our solution(dst matrix, dst).         
00484      *----------------------------------------------------------------------------------------------------------------*/
00485 
00486     /* Working pointer for destination matrix */
00487     pInT2 = pOut;
00488 
00489     /* Loop over the number of rows */
00490     rowCnt = numRows;
00491 
00492     /* Making the destination matrix as identity matrix */
00493     while(rowCnt > 0u)
00494     {
00495       /* Writing all zeroes in lower triangle of the destination matrix */
00496       j = numRows - rowCnt;
00497       while(j > 0u)
00498       {
00499         *pInT2++ = 0.0f;
00500         j--;
00501       }
00502 
00503       /* Writing all ones in the diagonal of the destination matrix */
00504       *pInT2++ = 1.0f;
00505 
00506       /* Writing all zeroes in upper triangle of the destination matrix */
00507       j = rowCnt - 1u;
00508       while(j > 0u)
00509       {
00510         *pInT2++ = 0.0f;
00511         j--;
00512       }
00513 
00514       /* Decrement the loop counter */
00515       rowCnt--;
00516     }
00517 
00518     /* Loop over the number of columns of the input matrix.     
00519        All the elements in each column are processed by the row operations */
00520     loopCnt = numCols;
00521 
00522     /* Index modifier to navigate through the columns */
00523     l = 0u;
00524     //for(loopCnt = 0u; loopCnt < numCols; loopCnt++)   
00525     while(loopCnt > 0u)
00526     {
00527       /* Check if the pivot element is zero..    
00528        * If it is zero then interchange the row with non zero row below.   
00529        * If there is no non zero element to replace in the rows below,   
00530        * then the matrix is Singular. */
00531 
00532       /* Working pointer for the input matrix that points     
00533        * to the pivot element of the particular row  */
00534       pInT1 = pIn + (l * numCols);
00535 
00536       /* Working pointer for the destination matrix that points     
00537        * to the pivot element of the particular row  */
00538       pInT3 = pOut + (l * numCols);
00539 
00540       /* Temporary variable to hold the pivot value */
00541       in = *pInT1;
00542 
00543       /* Destination pointer modifier */
00544       k = 1u;
00545 
00546       /* Check if the pivot element is zero */
00547       if(*pInT1 == 0.0f)
00548       {
00549         /* Loop over the number rows present below */
00550         for (i = (l + 1u); i < numRows; i++)
00551         {
00552           /* Update the input and destination pointers */
00553           pInT2 = pInT1 + (numCols * l);
00554           pInT4 = pInT3 + (numCols * k);
00555 
00556           /* Check if there is a non zero pivot element to     
00557            * replace in the rows below */
00558           if(*pInT2 != 0.0f)
00559           {
00560             /* Loop over number of columns     
00561              * to the right of the pilot element */
00562             for (j = 0u; j < (numCols - l); j++)
00563             {
00564               /* Exchange the row elements of the input matrix */
00565               Xchg = *pInT2;
00566               *pInT2++ = *pInT1;
00567               *pInT1++ = Xchg;
00568             }
00569 
00570             for (j = 0u; j < numCols; j++)
00571             {
00572               Xchg = *pInT4;
00573               *pInT4++ = *pInT3;
00574               *pInT3++ = Xchg;
00575             }
00576 
00577             /* Flag to indicate whether exchange is done or not */
00578             flag = 1u;
00579 
00580             /* Break after exchange is done */
00581             break;
00582           }
00583 
00584           /* Update the destination pointer modifier */
00585           k++;
00586         }
00587       }
00588 
00589       /* Update the status if the matrix is singular */
00590       if((flag != 1u) && (in == 0.0f))
00591       {
00592         status = ARM_MATH_SINGULAR;
00593 
00594         break;
00595       }
00596 
00597       /* Points to the pivot row of input and destination matrices */
00598       pPivotRowIn = pIn + (l * numCols);
00599       pPivotRowDst = pOut + (l * numCols);
00600 
00601       /* Temporary pointers to the pivot row pointers */
00602       pInT1 = pPivotRowIn;
00603       pInT2 = pPivotRowDst;
00604 
00605       /* Pivot element of the row */
00606       in = *(pIn + (l * numCols));
00607 
00608       /* Loop over number of columns     
00609        * to the right of the pilot element */
00610       for (j = 0u; j < (numCols - l); j++)
00611       {
00612         /* Divide each element of the row of the input matrix     
00613          * by the pivot element */
00614         *pInT1 = *pInT1 / in;
00615         pInT1++;
00616       }
00617       for (j = 0u; j < numCols; j++)
00618       {
00619         /* Divide each element of the row of the destination matrix     
00620          * by the pivot element */
00621         *pInT2 = *pInT2 / in;
00622         pInT2++;
00623       }
00624 
00625       /* Replace the rows with the sum of that row and a multiple of row i     
00626        * so that each new element in column i above row i is zero.*/
00627 
00628       /* Temporary pointers for input and destination matrices */
00629       pInT1 = pIn;
00630       pInT2 = pOut;
00631 
00632       for (i = 0u; i < numRows; i++)
00633       {
00634         /* Check for the pivot element */
00635         if(i == l)
00636         {
00637           /* If the processing element is the pivot element,     
00638              only the columns to the right are to be processed */
00639           pInT1 += numCols - l;
00640           pInT2 += numCols;
00641         }
00642         else
00643         {
00644           /* Element of the reference row */
00645           in = *pInT1;
00646 
00647           /* Working pointers for input and destination pivot rows */
00648           pPRT_in = pPivotRowIn;
00649           pPRT_pDst = pPivotRowDst;
00650 
00651           /* Loop over the number of columns to the right of the pivot element,     
00652              to replace the elements in the input matrix */
00653           for (j = 0u; j < (numCols - l); j++)
00654           {
00655             /* Replace the element by the sum of that row     
00656                and a multiple of the reference row  */
00657             *pInT1 = *pInT1 - (in * *pPRT_in++);
00658             pInT1++;
00659           }
00660           /* Loop over the number of columns to     
00661              replace the elements in the destination matrix */
00662           for (j = 0u; j < numCols; j++)
00663           {
00664             /* Replace the element by the sum of that row     
00665                and a multiple of the reference row  */
00666             *pInT2 = *pInT2 - (in * *pPRT_pDst++);
00667             pInT2++;
00668           }
00669 
00670         }
00671         /* Increment the temporary input pointer */
00672         pInT1 = pInT1 + l;
00673       }
00674       /* Increment the input pointer */
00675       pIn++;
00676 
00677       /* Decrement the loop counter */
00678       loopCnt--;
00679       /* Increment the index modifier */
00680       l++;
00681     }
00682 
00683 
00684 #endif /* #ifndef ARM_MATH_CM0_FAMILY */
00685 
00686     /* Set status as ARM_MATH_SUCCESS */
00687     status = ARM_MATH_SUCCESS;
00688 
00689     if((flag != 1u) && (in == 0.0f))
00690     {
00691       status = ARM_MATH_SINGULAR;
00692     }
00693   }
00694   /* Return to application */
00695   return (status);
00696 }
00697 
00698 /**    
00699  * @} end of MatrixInv group    
00700  */