1 /* 2 * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 * Copyright 2016-2017 NXP 4 * All rights reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 */ 8 9 /*! \file matrix.h 10 \brief Matrix manipulation functions 11 12 Contains functions for basic manipulation of 3x3 matrices 13 */ 14 15 #ifndef MATRIX_H 16 #define MATRIX_H 17 18 // function prototypes 19 20 /// function sets the 3x3 matrix A to the identity matrix 21 void f3x3matrixAeqI( 22 float A[][3] 23 ); 24 /// function sets 3x3 matrix A to 3x3 matrix B 25 void f3x3matrixAeqB( 26 float A[][3], 27 float B[][3] 28 ); 29 /// function sets the matrix A to the identity matrix 30 void fmatrixAeqI( 31 float *A[], ///< pointer to the matrix 32 int16 rc ///< dimension of the matrix 33 ); 34 /// function sets every entry in the 3x3 matrix A to a constant scalar 35 void f3x3matrixAeqScalar( 36 float A[][3], 37 float Scalar 38 ); 39 /// function directly calculates the symmetric inverse of a symmetric 3x3 matrix 40 /// only the on and above diagonal terms in B are used and need to be specified 41 void f3x3matrixAeqInvSymB( 42 float A[][3], 43 float B[][3] 44 ); 45 /// function multiplies all elements of 3x3 matrix A by the specified scalar 46 void f3x3matrixAeqAxScalar( 47 float A[][3], 48 float Scalar 49 ); 50 /// function negates all elements of 3x3 matrix A 51 void f3x3matrixAeqMinusA( 52 float A[][3] 53 ); 54 /// function calculates the determinant of a 3x3 matrix 55 float f3x3matrixDetA( 56 float A[][3] 57 ); 58 /// function computes all eigenvalues and eigenvectors of a real symmetric matrix A[0..n-1][0..n-1] 59 /// stored in the top left of a 10x10 array A[10][10] 60 void fEigenCompute10( 61 float A[][10], ///< real symmetric matrix A[0..n-1][0..n-1] 62 float eigval[], ///< eigval[0..n-1] returns the eigenvalues of A[][]. 63 float eigvec[][10], ///< eigvec[0..n-1][0..n-1] returns the normalized eigenvectors of A[][] 64 int8 n ///< n can vary up to and including 10 but the matrices A and eigvec must have 10 columns. 65 ); 66 /// function computes all eigenvalues and eigenvectors of a real symmetric matrix A[0..n-1][0..n-1] 67 /// stored in the top left of a 4x4 array A[4][4] 68 /// A[][] is changed on output. 69 /// The eigenvectors are not sorted by value. 70 /// This function is identical to eigencompute10 except for the workaround for 4x4 matrices since C cannot 71 /// handle functions accepting matrices with variable numbers of columns. 72 void fEigenCompute4( 73 float A[][4], 74 float eigval[], ///< eigval[0..n-1] returns the eigenvalues of A[][]. 75 float eigvec[][4], ///< eigvec[0..n-1][0..n-1] returns the normalized eigenvectors of A[][] 76 int8 n ///< n can vary up to and including 4 but the matrices A and eigvec must have 4 columns. 77 ); 78 void fComputeEigSlice( 79 float fmatA[10][10], 80 float fmatB[10][10], 81 float fvecA[10], 82 int8 i, 83 int8 j, 84 int8 iMatrixSize 85 ); 86 /// function uses Gauss-Jordan elimination to compute the inverse of matrix A in situ 87 /// on exit, A is replaced with its inverse 88 void fmatrixAeqInvA( 89 float *A[], 90 int8 iColInd[], 91 int8 iRowInd[], 92 int8 iPivot[], 93 int8 isize, 94 int8* pierror 95 ); 96 /// function rotates 3x1 vector u onto 3x1 vector using 3x3 rotation matrix fR. 97 /// the rotation is applied in the inverse direction if itranpose is true 98 void fveqRu( 99 float fv[], ///< 3x1 output vector 100 float fR[][3], ///< rotation matrix 101 float fu[], ///< 3x1 input vector 102 int8 itranspose ///< true if inverse direction desired 103 ); 104 /// function multiplies the 3x1 vector V by a 3x3 matrix A 105 void fVeq3x3AxV( 106 float V[3], ///< used for both input and output 107 float A[][3] 108 ); 109 110 #endif // #ifndef MATRIX_H 111